From 768662004662d48d96b649f343f7cf8a24a5db3e Mon Sep 17 00:00:00 2001 From: Samuel Young Date: Wed, 7 Jan 2026 14:57:02 +0000 Subject: [PATCH] Revert "CLDC-4136: Remove question from BU parser" This reverts commit e4715ee976c6a4ade30a61b11f51af8bce211324. --- .../lettings/year2026/row_parser.rb | 872 +++++++++--------- 1 file changed, 438 insertions(+), 434 deletions(-) diff --git a/app/services/bulk_upload/lettings/year2026/row_parser.rb b/app/services/bulk_upload/lettings/year2026/row_parser.rb index f96856438..84f6f57d9 100644 --- a/app/services/bulk_upload/lettings/year2026/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2026/row_parser.rb @@ -31,108 +31,109 @@ class BulkUpload::Lettings::Year2026::RowParser field_24: "Part 2 of the property’s postcode", field_25: "What is the property’s local authority?", field_26: "What type of unit is the property?", - field_27: "Is the property built or adapted to wheelchair-user standards?", - field_28: "How many bedrooms does the property have?", - field_29: "What is the void date?", + field_27: "Which type of building is the property?", + field_28: "Is the property built or adapted to wheelchair-user standards?", + field_29: "How many bedrooms does the property have?", field_30: "What is the void date?", field_31: "What is the void date?", - field_32: "What date were any major repairs completed on?", + field_32: "What is the void date?", field_33: "What date were any major repairs completed on?", field_34: "What date were any major repairs completed on?", - field_35: "Is this letting sheltered accommodation?", - field_36: "Is this a joint tenancy?", - field_37: "Is this a starter tenancy?", - field_38: "What is the type of tenancy?", - field_39: "If 'Other', what is the type of tenancy?", - field_40: "What is the length of the fixed-term tenancy to the nearest year?", - field_41: "What is the lead tenant’s age?", - field_42: "Which of these best describes the lead tenant’s gender identity?", - field_43: "Which of these best describes the lead tenant’s ethnic background?", - field_44: "What is the lead tenant’s nationality?", - field_45: "Which of these best describes the lead tenant’s working situation?", - field_46: "Is person 2 the partner of the lead tenant?", - field_47: "What is person 2’s age?", - field_48: "Which of these best describes person 2’s gender identity?", - field_49: "Which of these best describes person 2’s working situation?", - field_50: "Is person 3 the partner of the lead tenant?", - field_51: "What is person 3’s age?", - field_52: "Which of these best describes person 3’s gender identity?", - field_53: "Which of these best describes person 3’s working situation?", - field_54: "Is person 4 the partner of the lead tenant?", - field_55: "What is person 4’s age?", - field_56: "Which of these best describes person 4’s gender identity?", - field_57: "Which of these best describes person 4’s working situation?", - field_58: "Is person 5 the partner of the lead tenant?", - field_59: "What is person 5’s age?", - field_60: "Which of these best describes person 5’s gender identity?", - field_61: "Which of these best describes person 5’s working situation?", - field_62: "Is person 6 the partner of the lead tenant?", - field_63: "What is person 6’s age?", - field_64: "Which of these best describes person 6’s gender identity?", - field_65: "Which of these best describes person 6’s working situation?", - field_66: "Is person 7 the partner of the lead tenant?", - field_67: "What is person 7’s age?", - field_68: "Which of these best describes person 7’s gender identity?", - field_69: "Which of these best describes person 7’s working situation?", - field_70: "Is person 8 the partner of the lead tenant?", - field_71: "What is person 8’s age?", - field_72: "Which of these best describes person 8’s gender identity?", - field_73: "Which of these best describes person 8’s working situation?", - field_74: "Does anybody in the household have links to the UK armed forces?", - field_75: "Is this person still serving in the UK armed forces?", - field_76: "Was this person seriously injured or ill as a result of serving in the UK armed forces?", - field_77: "Is anybody in the household pregnant?", - field_78: "Does anybody in the household have any disabled access needs?", + field_35: "What date were any major repairs completed on?", + field_36: "Is this letting sheltered accommodation?", + field_37: "Is this a joint tenancy?", + field_38: "Is this a starter tenancy?", + field_39: "What is the type of tenancy?", + field_40: "If 'Other', what is the type of tenancy?", + field_41: "What is the length of the fixed-term tenancy to the nearest year?", + field_42: "What is the lead tenant’s age?", + field_43: "Which of these best describes the lead tenant’s gender identity?", + field_44: "Which of these best describes the lead tenant’s ethnic background?", + field_45: "What is the lead tenant’s nationality?", + field_46: "Which of these best describes the lead tenant’s working situation?", + field_47: "Is person 2 the partner of the lead tenant?", + field_48: "What is person 2’s age?", + field_49: "Which of these best describes person 2’s gender identity?", + field_50: "Which of these best describes person 2’s working situation?", + field_51: "Is person 3 the partner of the lead tenant?", + field_52: "What is person 3’s age?", + field_53: "Which of these best describes person 3’s gender identity?", + field_54: "Which of these best describes person 3’s working situation?", + field_55: "Is person 4 the partner of the lead tenant?", + field_56: "What is person 4’s age?", + field_57: "Which of these best describes person 4’s gender identity?", + field_58: "Which of these best describes person 4’s working situation?", + field_59: "Is person 5 the partner of the lead tenant?", + field_60: "What is person 5’s age?", + field_61: "Which of these best describes person 5’s gender identity?", + field_62: "Which of these best describes person 5’s working situation?", + field_63: "Is person 6 the partner of the lead tenant?", + field_64: "What is person 6’s age?", + field_65: "Which of these best describes person 6’s gender identity?", + field_66: "Which of these best describes person 6’s working situation?", + field_67: "Is person 7 the partner of the lead tenant?", + field_68: "What is person 7’s age?", + field_69: "Which of these best describes person 7’s gender identity?", + field_70: "Which of these best describes person 7’s working situation?", + field_71: "Is person 8 the partner of the lead tenant?", + field_72: "What is person 8’s age?", + field_73: "Which of these best describes person 8’s gender identity?", + field_74: "Which of these best describes person 8’s working situation?", + field_75: "Does anybody in the household have links to the UK armed forces?", + field_76: "Is this person still serving in the UK armed forces?", + field_77: "Was this person seriously injured or ill as a result of serving in the UK armed forces?", + field_78: "Is anybody in the household pregnant?", field_79: "Does anybody in the household have any disabled access needs?", field_80: "Does anybody in the household have any disabled access needs?", field_81: "Does anybody in the household have any disabled access needs?", field_82: "Does anybody in the household have any disabled access needs?", field_83: "Does anybody in the household have any disabled access needs?", - field_84: "Does anybody in the household have a physical or mental health condition (or other illness) expected to last 12 months or more?", - field_85: "Does this person’s condition affect their dexterity?", - field_86: "Does this person’s condition affect their learning or understanding or concentrating?", - field_87: "Does this person’s condition affect their hearing?", - field_88: "Does this person’s condition affect their memory?", - field_89: "Does this person’s condition affect their mental health?", - field_90: "Does this person’s condition affect their mobility?", - field_91: "Does this person’s condition affect them socially or behaviourally?", - field_92: "Does this person’s condition affect their stamina or breathing or fatigue?", - field_93: "Does this person’s condition affect their vision?", - field_94: "Does this person’s condition affect them in another way?", - field_95: "How long has the household continuously lived in the local authority area of the new letting?", - field_96: "How long has the household been on the local authority waiting list for the new letting?", - field_97: "What is the tenant’s main reason for the household leaving their last settled home?", - field_98: "If 'Other', what was the main reason for leaving their last settled home?", - field_99: "Where was the household immediately before this letting?", - field_100: "Did the household experience homelessness immediately before this letting?", - field_101: "Do you know the postcode of the household’s last settled home?", - field_102: "What is the postcode of the household’s last settled home?", + field_84: "Does anybody in the household have any disabled access needs?", + field_85: "Does anybody in the household have a physical or mental health condition (or other illness) expected to last 12 months or more?", + field_86: "Does this person’s condition affect their dexterity?", + field_87: "Does this person’s condition affect their learning or understanding or concentrating?", + field_88: "Does this person’s condition affect their hearing?", + field_89: "Does this person’s condition affect their memory?", + field_90: "Does this person’s condition affect their mental health?", + field_91: "Does this person’s condition affect their mobility?", + field_92: "Does this person’s condition affect them socially or behaviourally?", + field_93: "Does this person’s condition affect their stamina or breathing or fatigue?", + field_94: "Does this person’s condition affect their vision?", + field_95: "Does this person’s condition affect them in another way?", + field_96: "How long has the household continuously lived in the local authority area of the new letting?", + field_97: "How long has the household been on the local authority waiting list for the new letting?", + field_98: "What is the tenant’s main reason for the household leaving their last settled home?", + field_99: "If 'Other', what was the main reason for leaving their last settled home?", + field_100: "Where was the household immediately before this letting?", + field_101: "Did the household experience homelessness immediately before this letting?", + field_102: "Do you know the postcode of the household’s last settled home?", field_103: "What is the postcode of the household’s last settled home?", - field_104: "What is the local authority of the household’s last settled home?", - field_105: "Was the household given 'reasonable preference' by the local authority?", - field_106: "Reasonable preference reason - They were homeless or about to lose their home (within 56 days)", - field_107: "Reasonable preference reason - They were living in insanitary, overcrowded or unsatisfactory housing", - field_108: "Reasonable preference reason - They needed to move on medical and welfare reasons (including disability)", - field_109: "Reasonable preference reason - They needed to move to avoid hardship to themselves or others", - field_110: "Reasonable preference reason - Don’t know", - field_111: "Was the letting made under the Choice-Based Lettings (CBL)?", - field_112: "Was the letting made under the Common Allocation Policy (CAP)?", - field_113: "Was the letting made under the Common Housing Register (CHR)?", - field_114: "Was the letting made under the Accessible Register?", - field_115: "What was the source of referral for this letting?", - field_116: "Do you know the household’s combined total income after tax?", - field_117: "How often does the household receive income?", - field_118: "How much income does the household have in total?", - field_119: "Is the tenant likely to be receiving any of these housing-related benefits?", - field_120: "How much of the household’s income is from Universal Credit, state pensions or benefits?", - field_121: "Does the household pay rent or other charges for the accommodation?", - field_122: "How often does the household pay rent and other charges?", - field_123: "What is the basic rent?", - field_124: "What is the service charge?", - field_125: "What is the personal service charge?", - field_126: "What is the support charge?", - field_127: "After the household has received any housing-related benefits, will they still need to pay for rent and charges?", - field_128: "What do you expect the outstanding amount to be?", + field_104: "What is the postcode of the household’s last settled home?", + field_105: "What is the local authority of the household’s last settled home?", + field_106: "Was the household given 'reasonable preference' by the local authority?", + field_107: "Reasonable preference reason - They were homeless or about to lose their home (within 56 days)", + field_108: "Reasonable preference reason - They were living in insanitary, overcrowded or unsatisfactory housing", + field_109: "Reasonable preference reason - They needed to move on medical and welfare reasons (including disability)", + field_110: "Reasonable preference reason - They needed to move to avoid hardship to themselves or others", + field_111: "Reasonable preference reason - Don’t know", + field_112: "Was the letting made under the Choice-Based Lettings (CBL)?", + field_113: "Was the letting made under the Common Allocation Policy (CAP)?", + field_114: "Was the letting made under the Common Housing Register (CHR)?", + field_115: "Was the letting made under the Accessible Register?", + field_116: "What was the source of referral for this letting?", + field_117: "Do you know the household’s combined total income after tax?", + field_118: "How often does the household receive income?", + field_119: "How much income does the household have in total?", + field_120: "Is the tenant likely to be receiving any of these housing-related benefits?", + field_121: "How much of the household’s income is from Universal Credit, state pensions or benefits?", + field_122: "Does the household pay rent or other charges for the accommodation?", + field_123: "How often does the household pay rent and other charges?", + field_124: "What is the basic rent?", + field_125: "What is the service charge?", + field_126: "What is the personal service charge?", + field_127: "What is the support charge?", + field_128: "After the household has received any housing-related benefits, will they still need to pay for rent and charges?", + field_129: "What do you expect the outstanding amount to be?", }.freeze RENT_TYPE_BU_MAPPING = { @@ -185,46 +186,46 @@ class BulkUpload::Lettings::Year2026::RowParser attribute :field_32, :integer attribute :field_33, :integer attribute :field_34, :integer - attribute :field_36, :integer + attribute :field_35, :integer attribute :field_37, :integer attribute :field_38, :integer - attribute :field_39, :string - attribute :field_40, :integer - attribute :field_35, :integer + attribute :field_39, :integer + attribute :field_40, :string + attribute :field_41, :integer + attribute :field_36, :integer attribute :field_15, :integer - attribute :field_41, :string attribute :field_42, :string - attribute :field_43, :integer + attribute :field_43, :string attribute :field_44, :integer attribute :field_45, :integer attribute :field_46, :integer - attribute :field_47, :string + attribute :field_47, :integer attribute :field_48, :string - attribute :field_49, :integer + attribute :field_49, :string attribute :field_50, :integer - attribute :field_51, :string + attribute :field_51, :integer attribute :field_52, :string - attribute :field_53, :integer + attribute :field_53, :string attribute :field_54, :integer - attribute :field_55, :string + attribute :field_55, :integer attribute :field_56, :string - attribute :field_57, :integer + attribute :field_57, :string attribute :field_58, :integer - attribute :field_59, :string + attribute :field_59, :integer attribute :field_60, :string - attribute :field_61, :integer + attribute :field_61, :string attribute :field_62, :integer - attribute :field_63, :string + attribute :field_63, :integer attribute :field_64, :string - attribute :field_65, :integer + attribute :field_65, :string attribute :field_66, :integer - attribute :field_67, :string + attribute :field_67, :integer attribute :field_68, :string - attribute :field_69, :integer + attribute :field_69, :string attribute :field_70, :integer - attribute :field_71, :string + attribute :field_71, :integer attribute :field_72, :string - attribute :field_73, :integer + attribute :field_73, :string attribute :field_74, :integer attribute :field_75, :integer attribute :field_76, :integer @@ -249,14 +250,14 @@ class BulkUpload::Lettings::Year2026::RowParser attribute :field_95, :integer attribute :field_96, :integer attribute :field_97, :integer - attribute :field_98, :string - attribute :field_99, :integer + attribute :field_98, :integer + attribute :field_99, :string attribute :field_100, :integer attribute :field_101, :integer - attribute :field_102, :string + attribute :field_102, :integer attribute :field_103, :string attribute :field_104, :string - attribute :field_105, :integer + attribute :field_105, :string attribute :field_106, :integer attribute :field_107, :integer attribute :field_108, :integer @@ -269,17 +270,18 @@ class BulkUpload::Lettings::Year2026::RowParser attribute :field_115, :integer attribute :field_116, :integer attribute :field_117, :integer - attribute :field_118, :decimal - attribute :field_119, :integer + attribute :field_118, :integer + attribute :field_119, :decimal attribute :field_120, :integer attribute :field_121, :integer attribute :field_122, :integer - attribute :field_123, :decimal + attribute :field_123, :integer attribute :field_124, :decimal attribute :field_125, :decimal attribute :field_126, :decimal - attribute :field_127, :integer - attribute :field_128, :decimal + attribute :field_127, :decimal + attribute :field_128, :integer + attribute :field_129, :decimal validate :validate_valid_radio_option, on: :before_log @@ -346,7 +348,7 @@ class BulkUpload::Lettings::Year2026::RowParser }, on: :after_log - validates :field_111, + validates :field_112, presence: { message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "was the letting made under the Choice-Based Lettings (CBL)?"), category: :not_answered, @@ -354,11 +356,11 @@ class BulkUpload::Lettings::Year2026::RowParser inclusion: { in: [1, 2], message: I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: "was the letting made under the Choice-Based Lettings (CBL)?"), - if: -> { field_111.present? }, + if: -> { field_112.present? }, }, on: :after_log - validates :field_112, + validates :field_113, presence: { message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "was the letting made under the Common Allocation Policy (CAP)?"), category: :not_answered, @@ -366,11 +368,11 @@ class BulkUpload::Lettings::Year2026::RowParser inclusion: { in: [1, 2], message: I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: "was the letting made under the Common Allocation Policy (CAP)?"), - if: -> { field_112.present? }, + if: -> { field_113.present? }, }, on: :after_log - validates :field_113, + validates :field_114, presence: { message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "was the letting made under the Common Housing Register (CHR)?"), category: :not_answered, @@ -378,11 +380,11 @@ class BulkUpload::Lettings::Year2026::RowParser inclusion: { in: [1, 2], message: I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: "was the letting made under the Common Housing Register (CHR)?"), - if: -> { field_113.present? }, + if: -> { field_114.present? }, }, on: :after_log - validates :field_114, + validates :field_115, presence: { message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "was the letting made under the Accessible Register?"), category: :not_answered, @@ -390,18 +392,18 @@ class BulkUpload::Lettings::Year2026::RowParser inclusion: { in: [1, 2], message: I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: "was the letting made under the Accessible Register?"), - if: -> { field_114.present? }, + if: -> { field_115.present? }, }, on: :after_log - validates :field_41, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 1) }, on: :after_log - validates :field_47, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 2) }, on: :after_log, if: proc { details_known?(2).zero? } - validates :field_51, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 3) }, on: :after_log, if: proc { details_known?(3).zero? } - validates :field_55, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 4) }, on: :after_log, if: proc { details_known?(4).zero? } - validates :field_59, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 5) }, on: :after_log, if: proc { details_known?(5).zero? } - validates :field_63, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 6) }, on: :after_log, if: proc { details_known?(6).zero? } - validates :field_67, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 7) }, on: :after_log, if: proc { details_known?(7).zero? } - validates :field_71, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 8) }, on: :after_log, if: proc { details_known?(8).zero? } + validates :field_42, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 1) }, on: :after_log + validates :field_48, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 2) }, on: :after_log, if: proc { details_known?(2).zero? } + validates :field_52, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 3) }, on: :after_log, if: proc { details_known?(3).zero? } + validates :field_56, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 4) }, on: :after_log, if: proc { details_known?(4).zero? } + validates :field_60, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 5) }, on: :after_log, if: proc { details_known?(5).zero? } + validates :field_64, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 6) }, on: :after_log, if: proc { details_known?(6).zero? } + validates :field_68, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 7) }, on: :after_log, if: proc { details_known?(7).zero? } + validates :field_72, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 8) }, on: :after_log, if: proc { details_known?(8).zero? } validate :validate_needs_type_present, on: :after_log validate :validate_data_types, on: :after_log @@ -537,12 +539,12 @@ class BulkUpload::Lettings::Year2026::RowParser !general_needs? ? :field_6.to_s : nil, # location !supported_housing? ? "field_23" : nil, # postcode !supported_housing? ? "field_24" : nil, # postcode - "field_41", # age1 - "field_42", # sex1 - "field_45", # ecstat1 + "field_42", # age1 + "field_43", # sex1 + "field_46", # ecstat1 ) - if [field_123, field_124, field_125, field_126].all?(&:present?) - hash.merge({ "tcharge" => [field_123, field_124, field_125, field_126].sum }) + if [field_124, field_125, field_126, field_127].all?(&:present?) + hash.merge({ "tcharge" => [field_124, field_125, field_126, field_127].sum }) else hash end @@ -551,7 +553,7 @@ class BulkUpload::Lettings::Year2026::RowParser def add_duplicate_found_in_spreadsheet_errors spreadsheet_duplicate_hash.each_key do |field| if field == "tcharge" - %w[field_123 field_124 field_125 field_126].each do |sub_field| + %w[field_124 field_125 field_126 field_127].each do |sub_field| errors.add(sub_field, I18n.t("#{ERROR_BASE_KEY}.spreadsheet_dupe"), category: :setup) end else @@ -660,14 +662,14 @@ private end def validate_nationality - if field_44.present? && !valid_nationality_options.include?(field_44.to_s) - errors.add(:field_44, I18n.t("#{ERROR_BASE_KEY}.nationality.invalid")) + if field_45.present? && !valid_nationality_options.include?(field_45.to_s) + errors.add(:field_45, I18n.t("#{ERROR_BASE_KEY}.nationality.invalid")) end end def validate_reasonpref_reason_values valid_reasonpref_reason_options = %w[0 1] - %w[field_106 field_107 field_108 field_109 field_110].each do |field| + %w[field_107 field_108 field_109 field_110 field_111].each do |field| next unless send(field).present? && !valid_reasonpref_reason_options.include?(send(field).to_s) question_text = QUESTIONS[field.to_sym] @@ -678,9 +680,9 @@ private def validate_prevten_value_when_renewal return unless field_7 == 1 - return if field_99.blank? || [6, 30, 31, 32, 33, 34, 35, 38].include?(field_99) + return if field_100.blank? || [6, 30, 31, 32, 33, 34, 35, 38].include?(field_100) - errors.add(:field_99, I18n.t("#{ERROR_BASE_KEY}.prevten.invalid")) + errors.add(:field_100, I18n.t("#{ERROR_BASE_KEY}.prevten.invalid")) end def duplicate_check_fields @@ -705,41 +707,41 @@ private end def validate_no_and_dont_know_disabled_needs_conjunction - if field_82 == 1 && field_83 == 1 - errors.add(:field_82, I18n.t("#{ERROR_BASE_KEY}.housingneeds.no_and_dont_know_disabled_needs_conjunction")) + if field_83 == 1 && field_84 == 1 errors.add(:field_83, I18n.t("#{ERROR_BASE_KEY}.housingneeds.no_and_dont_know_disabled_needs_conjunction")) + errors.add(:field_84, I18n.t("#{ERROR_BASE_KEY}.housingneeds.no_and_dont_know_disabled_needs_conjunction")) end end def validate_dont_know_disabled_needs_conjunction - if field_83 == 1 && [field_78, field_79, field_80, field_81].count(1).positive? - %i[field_83 field_78 field_79 field_80 field_81].each do |field| + if field_84 == 1 && [field_79, field_80, field_81, field_82].count(1).positive? + %i[field_84 field_79 field_80 field_81 field_82].each do |field| errors.add(field, I18n.t("#{ERROR_BASE_KEY}.housingneeds.dont_know_disabled_needs_conjunction")) if send(field) == 1 end end end def validate_no_disabled_needs_conjunction - if field_82 == 1 && [field_78, field_79, field_80, field_81].count(1).positive? - %i[field_82 field_78 field_79 field_80 field_81].each do |field| + if field_83 == 1 && [field_79, field_80, field_81, field_82].count(1).positive? + %i[field_83 field_79 field_80 field_81 field_82].each do |field| errors.add(field, I18n.t("#{ERROR_BASE_KEY}.housingneeds.no_disabled_needs_conjunction")) if send(field) == 1 end end end def validate_only_one_housing_needs_type - if [field_78, field_79, field_80].count(1) > 1 - %i[field_78 field_79 field_80].each do |field| + if [field_79, field_80, field_81].count(1) > 1 + %i[field_79 field_80 field_81].each do |field| errors.add(field, I18n.t("#{ERROR_BASE_KEY}.housingneeds_type.only_one_option_permitted")) if send(field) == 1 end end end def validate_no_housing_needs_questions_answered - if [field_78, field_79, field_80, field_81, field_82, field_83].all?(&:blank?) - errors.add(:field_82, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "anybody with disabled access needs.")) - errors.add(:field_81, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "other access needs.")) - %i[field_78 field_79 field_80].each do |field| + if [field_79, field_80, field_81, field_82, field_83, field_84].all?(&:blank?) + errors.add(:field_83, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "anybody with disabled access needs.")) + errors.add(:field_82, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "other access needs.")) + %i[field_79 field_80 field_81].each do |field| errors.add(field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "disabled access needs type.")) end end @@ -747,16 +749,16 @@ private def validate_reasonable_preference_dont_know if rp_dontknow_conflict? - errors.add(:field_110, I18n.t("#{ERROR_BASE_KEY}.reasonpref.conflict.dont_know")) - %i[field_106 field_107 field_108 field_109].each do |field| + errors.add(:field_111, I18n.t("#{ERROR_BASE_KEY}.reasonpref.conflict.dont_know")) + %i[field_107 field_108 field_109 field_110].each do |field| errors.add(field, I18n.t("#{ERROR_BASE_KEY}.reasonpref.conflict.other")) if send(field) == 1 end end end def validate_reasonable_preference_homeless - reason_fields = %i[field_106 field_107 field_108 field_109 field_110] - if field_105 == 1 && reason_fields.all? { |field| attributes[field.to_s].blank? } + reason_fields = %i[field_107 field_108 field_109 field_110 field_111] + if field_106 == 1 && reason_fields.all? { |field| attributes[field.to_s].blank? } reason_fields.each do |field| errors.add(field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "reason for reasonable preference.")) end @@ -764,7 +766,7 @@ private end def validate_condition_effects - illness_option_fields = %i[field_93 field_87 field_90 field_85 field_86 field_88 field_89 field_92 field_91 field_94] + illness_option_fields = %i[field_94 field_88 field_91 field_86 field_87 field_89 field_90 field_93 field_92 field_95] if household_no_illness? illness_option_fields.each do |field| if attributes[field.to_s] == 1 @@ -779,12 +781,12 @@ private end def household_no_illness? - field_84 != 1 + field_85 != 1 end def validate_leaving_reason_for_renewal - if field_7 == 1 && ![50, 51, 52, 53].include?(field_97) - errors.add(:field_97, I18n.t("#{ERROR_BASE_KEY}.reason.renewal_reason_needed")) + if field_7 == 1 && ![50, 51, 52, 53].include?(field_98) + errors.add(:field_98, I18n.t("#{ERROR_BASE_KEY}.reason.renewal_reason_needed")) end end @@ -797,14 +799,14 @@ private end def validate_cannot_be_la_referral_if_general_needs_and_la - if field_115 == 4 && general_needs? && owning_organisation && owning_organisation.la? - errors.add :field_115, I18n.t("#{ERROR_BASE_KEY}.referral.general_needs_prp_referred_by_la") + if field_116 == 4 && general_needs? && owning_organisation && owning_organisation.la? + errors.add :field_116, I18n.t("#{ERROR_BASE_KEY}.referral.general_needs_prp_referred_by_la") end end def validate_la_with_local_housing_referral - if field_115 == 3 && owning_organisation && owning_organisation.la? - errors.add(:field_115, I18n.t("#{ERROR_BASE_KEY}.referral.nominated_by_local_ha_but_la")) + if field_116 == 3 && owning_organisation && owning_organisation.la? + errors.add(:field_116, I18n.t("#{ERROR_BASE_KEY}.referral.nominated_by_local_ha_but_la")) end end @@ -933,13 +935,13 @@ private end def validate_all_charges_given - return if supported_housing? && field_123 == 1 + return if supported_housing? && field_124 == 1 blank_charge_fields, other_charge_fields = { - field_123: "basic rent", - field_124: "service charge", - field_125: "personal service charge", - field_126: "support charge", + field_124: "basic rent", + field_125: "service charge", + field_126: "personal service charge", + field_127: "support charge", }.partition { |field, _| public_send(field).blank? }.map(&:to_h) blank_charge_fields.each do |field, charge| @@ -955,7 +957,7 @@ private end def all_charges_given? - field_123.present? && field_124.present? && field_125.present? && field_126.present? + field_124.present? && field_125.present? && field_126.present? && field_127.present? end def setup_question?(question) @@ -976,14 +978,14 @@ private errors.add(:field_23, error_message) unless supported_housing? # postcode_full errors.add(:field_24, error_message) unless supported_housing? # postcode_full errors.add(:field_25, error_message) unless supported_housing? # la - errors.add(:field_41, error_message) # age1 - errors.add(:field_42, error_message) # sex1 - errors.add(:field_45, error_message) # ecstat1 - errors.add(:field_121, error_message) unless general_needs? # household_charge - errors.add(:field_123, error_message) # brent - errors.add(:field_124, error_message) # scharge - errors.add(:field_125, error_message) # pscharge - errors.add(:field_126, error_message) # chcharge + errors.add(:field_42, error_message) # age1 + errors.add(:field_43, error_message) # sex1 + errors.add(:field_46, error_message) # ecstat1 + errors.add(:field_122, error_message) unless general_needs? # household_charge + errors.add(:field_124, error_message) # brent + errors.add(:field_125, error_message) # scharge + errors.add(:field_126, error_message) # pscharge + errors.add(:field_127, error_message) # chcharge end end @@ -1008,138 +1010,139 @@ private rent_type: %i[field_11], startdate: %i[field_8 field_9 field_10], unittype_gn: %i[field_26], - wchair: %i[field_27], - beds: %i[field_28], - joint: %i[field_36], - startertenancy: %i[field_37], - tenancy: %i[field_38], - tenancyother: %i[field_39], - tenancylength: %i[field_40], + builtype: %i[field_27], + wchair: %i[field_28], + beds: %i[field_29], + joint: %i[field_37], + startertenancy: %i[field_38], + tenancy: %i[field_39], + tenancyother: %i[field_40], + tenancylength: %i[field_41], declaration: %i[field_15], - age1_known: %i[field_41], - age1: %i[field_41], - age2_known: %i[field_47], - age2: %i[field_47], - age3_known: %i[field_51], - age3: %i[field_51], - age4_known: %i[field_55], - age4: %i[field_55], - age5_known: %i[field_59], - age5: %i[field_59], - age6_known: %i[field_63], - age6: %i[field_63], - age7_known: %i[field_67], - age7: %i[field_67], - age8_known: %i[field_71], - age8: %i[field_71], - - sex1: %i[field_42], - sex2: %i[field_48], - sex3: %i[field_52], - sex4: %i[field_56], - sex5: %i[field_60], - sex6: %i[field_64], - sex7: %i[field_68], - sex8: %i[field_72], - - ethnic_group: %i[field_43], - ethnic: %i[field_43], - nationality_all: %i[field_44], - nationality_all_group: %i[field_44], - - relat2: %i[field_46], - relat3: %i[field_50], - relat4: %i[field_54], - relat5: %i[field_58], - relat6: %i[field_62], - relat7: %i[field_66], - relat8: %i[field_70], - - ecstat1: %i[field_45], - ecstat2: %i[field_49], - ecstat3: %i[field_53], - ecstat4: %i[field_57], - ecstat5: %i[field_61], - ecstat6: %i[field_65], - ecstat7: %i[field_69], - ecstat8: %i[field_73], - - armedforces: %i[field_74], - leftreg: %i[field_75], - reservist: %i[field_76], - preg_occ: %i[field_77], - housingneeds: %i[field_77], - - illness: %i[field_84], - - layear: %i[field_95], - waityear: %i[field_96], - reason: %i[field_97], - reasonother: %i[field_98], - prevten: %i[field_99], - homeless: %i[field_100], - - prevloc: %i[field_104], - previous_la_known: %i[field_104], - ppcodenk: %i[field_101], - ppostcode_full: %i[field_102 field_103], - - reasonpref: %i[field_105], - rp_homeless: %i[field_106], - rp_insan_unsat: %i[field_107], - rp_medwel: %i[field_108], - rp_hardship: %i[field_109], - rp_dontknow: %i[field_110], - - cbl: %i[field_111], - cap: %i[field_112], - chr: %i[field_113], - accessible_register: %i[field_114], - letting_allocation: %i[field_111 field_112 field_113 field_114], - - referral_type: %i[field_115], - referral: %i[field_115], - - net_income_known: %i[field_116], - incfreq: %i[field_117], - earnings: %i[field_118], - hb: %i[field_119], - benefits: %i[field_120], - - period: %i[field_122], - brent: %i[field_123], - scharge: %i[field_124], - pscharge: %i[field_125], - supcharg: %i[field_126], - tcharge: %i[field_123 field_124 field_125 field_126], - household_charge: %i[field_121], - hbrentshortfall: %i[field_127], - tshortfall: %i[field_128], + age1_known: %i[field_42], + age1: %i[field_42], + age2_known: %i[field_48], + age2: %i[field_48], + age3_known: %i[field_52], + age3: %i[field_52], + age4_known: %i[field_56], + age4: %i[field_56], + age5_known: %i[field_60], + age5: %i[field_60], + age6_known: %i[field_64], + age6: %i[field_64], + age7_known: %i[field_68], + age7: %i[field_68], + age8_known: %i[field_72], + age8: %i[field_72], + + sex1: %i[field_43], + sex2: %i[field_49], + sex3: %i[field_53], + sex4: %i[field_57], + sex5: %i[field_61], + sex6: %i[field_65], + sex7: %i[field_69], + sex8: %i[field_73], + + ethnic_group: %i[field_44], + ethnic: %i[field_44], + nationality_all: %i[field_45], + nationality_all_group: %i[field_45], + + relat2: %i[field_47], + relat3: %i[field_51], + relat4: %i[field_55], + relat5: %i[field_59], + relat6: %i[field_63], + relat7: %i[field_67], + relat8: %i[field_71], + + ecstat1: %i[field_46], + ecstat2: %i[field_50], + ecstat3: %i[field_54], + ecstat4: %i[field_58], + ecstat5: %i[field_62], + ecstat6: %i[field_66], + ecstat7: %i[field_70], + ecstat8: %i[field_74], + + armedforces: %i[field_75], + leftreg: %i[field_76], + reservist: %i[field_77], + preg_occ: %i[field_78], + housingneeds: %i[field_78], + + illness: %i[field_85], + + layear: %i[field_96], + waityear: %i[field_97], + reason: %i[field_98], + reasonother: %i[field_99], + prevten: %i[field_100], + homeless: %i[field_101], + + prevloc: %i[field_105], + previous_la_known: %i[field_105], + ppcodenk: %i[field_102], + ppostcode_full: %i[field_103 field_104], + + reasonpref: %i[field_106], + rp_homeless: %i[field_107], + rp_insan_unsat: %i[field_108], + rp_medwel: %i[field_109], + rp_hardship: %i[field_110], + rp_dontknow: %i[field_111], + + cbl: %i[field_112], + cap: %i[field_113], + chr: %i[field_114], + accessible_register: %i[field_115], + letting_allocation: %i[field_112 field_113 field_114 field_115], + + referral_type: %i[field_116], + referral: %i[field_116], + + net_income_known: %i[field_117], + incfreq: %i[field_118], + earnings: %i[field_119], + hb: %i[field_120], + benefits: %i[field_121], + + period: %i[field_123], + brent: %i[field_124], + scharge: %i[field_125], + pscharge: %i[field_126], + supcharg: %i[field_127], + tcharge: %i[field_124 field_125 field_126 field_127], + household_charge: %i[field_122], + hbrentshortfall: %i[field_128], + tshortfall: %i[field_129], unitletas: %i[field_17], rsnvac: %i[field_16], - sheltered: %i[field_35], - - illness_type_1: %i[field_93], - illness_type_2: %i[field_87], - illness_type_3: %i[field_90], - illness_type_4: %i[field_85], - illness_type_5: %i[field_86], - illness_type_6: %i[field_88], - illness_type_7: %i[field_89], - illness_type_8: %i[field_92], - illness_type_9: %i[field_91], - illness_type_10: %i[field_94], + sheltered: %i[field_36], + + illness_type_1: %i[field_94], + illness_type_2: %i[field_88], + illness_type_3: %i[field_91], + illness_type_4: %i[field_86], + illness_type_5: %i[field_87], + illness_type_6: %i[field_89], + illness_type_7: %i[field_90], + illness_type_8: %i[field_93], + illness_type_9: %i[field_92], + illness_type_10: %i[field_95], irproduct_other: %i[field_12], propcode: %i[field_14], - majorrepairs: %i[field_32 field_33 field_34], - mrcdate: %i[field_32 field_33 field_34], + majorrepairs: %i[field_33 field_34 field_35], + mrcdate: %i[field_33 field_34 field_35], - voiddate: %i[field_29 field_30 field_31], + voiddate: %i[field_30 field_31 field_32], uprn: [:field_18], address_line1: [:field_19], @@ -1174,69 +1177,70 @@ private attributes["rent_type"] = RENT_TYPE_BU_MAPPING[field_11] attributes["startdate"] = startdate attributes["unittype_gn"] = field_26 - attributes["wchair"] = field_27 - attributes["beds"] = field_26 == 2 ? 1 : field_28 - attributes["joint"] = field_36 - attributes["startertenancy"] = field_37 - attributes["tenancy"] = field_38 - attributes["tenancyother"] = field_39 - attributes["tenancylength"] = field_40 + attributes["builtype"] = field_27 + attributes["wchair"] = field_28 + attributes["beds"] = field_26 == 2 ? 1 : field_29 + attributes["joint"] = field_37 + attributes["startertenancy"] = field_38 + attributes["tenancy"] = field_39 + attributes["tenancyother"] = field_40 + attributes["tenancylength"] = field_41 attributes["declaration"] = field_15 attributes["age1_known"] = age1_known? - attributes["age1"] = field_41 if attributes["age1_known"]&.zero? && field_41&.match(/\A\d{1,3}\z|\AR\z/) + attributes["age1"] = field_42 if attributes["age1_known"]&.zero? && field_42&.match(/\A\d{1,3}\z|\AR\z/) attributes["age2_known"] = age2_known? - attributes["age2"] = field_47 if attributes["age2_known"]&.zero? && field_47&.match(/\A\d{1,3}\z|\AR\z/) + attributes["age2"] = field_48 if attributes["age2_known"]&.zero? && field_48&.match(/\A\d{1,3}\z|\AR\z/) attributes["age3_known"] = age3_known? - attributes["age3"] = field_51 if attributes["age3_known"]&.zero? && field_51&.match(/\A\d{1,3}\z|\AR\z/) + attributes["age3"] = field_52 if attributes["age3_known"]&.zero? && field_52&.match(/\A\d{1,3}\z|\AR\z/) attributes["age4_known"] = age4_known? - attributes["age4"] = field_55 if attributes["age4_known"]&.zero? && field_55&.match(/\A\d{1,3}\z|\AR\z/) + attributes["age4"] = field_56 if attributes["age4_known"]&.zero? && field_56&.match(/\A\d{1,3}\z|\AR\z/) attributes["age5_known"] = age5_known? - attributes["age5"] = field_59 if attributes["age5_known"]&.zero? && field_59&.match(/\A\d{1,3}\z|\AR\z/) + attributes["age5"] = field_60 if attributes["age5_known"]&.zero? && field_60&.match(/\A\d{1,3}\z|\AR\z/) attributes["age6_known"] = age6_known? - attributes["age6"] = field_63 if attributes["age6_known"]&.zero? && field_63&.match(/\A\d{1,3}\z|\AR\z/) + attributes["age6"] = field_64 if attributes["age6_known"]&.zero? && field_64&.match(/\A\d{1,3}\z|\AR\z/) attributes["age7_known"] = age7_known? - attributes["age7"] = field_67 if attributes["age7_known"]&.zero? && field_67&.match(/\A\d{1,3}\z|\AR\z/) + attributes["age7"] = field_68 if attributes["age7_known"]&.zero? && field_68&.match(/\A\d{1,3}\z|\AR\z/) attributes["age8_known"] = age8_known? - attributes["age8"] = field_71 if attributes["age8_known"]&.zero? && field_71&.match(/\A\d{1,3}\z|\AR\z/) + attributes["age8"] = field_72 if attributes["age8_known"]&.zero? && field_72&.match(/\A\d{1,3}\z|\AR\z/) - attributes["sex1"] = field_42 - attributes["sex2"] = field_48 - attributes["sex3"] = field_52 - attributes["sex4"] = field_56 - attributes["sex5"] = field_60 - attributes["sex6"] = field_64 - attributes["sex7"] = field_68 - attributes["sex8"] = field_72 + attributes["sex1"] = field_43 + attributes["sex2"] = field_49 + attributes["sex3"] = field_53 + attributes["sex4"] = field_57 + attributes["sex5"] = field_61 + attributes["sex6"] = field_65 + attributes["sex7"] = field_69 + attributes["sex8"] = field_73 attributes["ethnic_group"] = ethnic_group_from_ethnic - attributes["ethnic"] = field_43 - attributes["nationality_all"] = field_44 if field_44.present? && valid_nationality_options.include?(field_44.to_s) + attributes["ethnic"] = field_44 + attributes["nationality_all"] = field_45 if field_45.present? && valid_nationality_options.include?(field_45.to_s) attributes["nationality_all_group"] = nationality_group(attributes["nationality_all"]) - attributes["relat2"] = relationship_from_input_value(field_46) - attributes["relat3"] = relationship_from_input_value(field_50) - attributes["relat4"] = relationship_from_input_value(field_54) - attributes["relat5"] = relationship_from_input_value(field_58) - attributes["relat6"] = relationship_from_input_value(field_62) - attributes["relat7"] = relationship_from_input_value(field_66) - attributes["relat8"] = relationship_from_input_value(field_70) - - attributes["ecstat1"] = field_45 - attributes["ecstat2"] = field_49 - attributes["ecstat3"] = field_53 - attributes["ecstat4"] = field_57 - attributes["ecstat5"] = field_61 - attributes["ecstat6"] = field_65 - attributes["ecstat7"] = field_69 - attributes["ecstat8"] = field_73 + attributes["relat2"] = relationship_from_input_value(field_47) + attributes["relat3"] = relationship_from_input_value(field_51) + attributes["relat4"] = relationship_from_input_value(field_55) + attributes["relat5"] = relationship_from_input_value(field_59) + attributes["relat6"] = relationship_from_input_value(field_63) + attributes["relat7"] = relationship_from_input_value(field_67) + attributes["relat8"] = relationship_from_input_value(field_71) + + attributes["ecstat1"] = field_46 + attributes["ecstat2"] = field_50 + attributes["ecstat3"] = field_54 + attributes["ecstat4"] = field_58 + attributes["ecstat5"] = field_62 + attributes["ecstat6"] = field_66 + attributes["ecstat7"] = field_70 + attributes["ecstat8"] = field_74 attributes["details_known_2"] = details_known?(2) attributes["details_known_3"] = details_known?(3) @@ -1246,36 +1250,36 @@ private attributes["details_known_7"] = details_known?(7) attributes["details_known_8"] = details_known?(8) - attributes["armedforces"] = field_74 + attributes["armedforces"] = field_75 attributes["leftreg"] = leftreg - attributes["reservist"] = field_76 + attributes["reservist"] = field_77 - attributes["preg_occ"] = field_77 + attributes["preg_occ"] = field_78 attributes["housingneeds"] = housingneeds attributes["housingneeds_type"] = housingneeds_type attributes["housingneeds_other"] = housingneeds_other - attributes["illness"] = field_84 + attributes["illness"] = field_85 - attributes["layear"] = field_95 - attributes["waityear"] = field_96 - attributes["reason"] = field_97 - attributes["reasonother"] = field_98 if reason_is_other? - attributes["prevten"] = field_99 - attributes["homeless"] = field_100 + attributes["layear"] = field_96 + attributes["waityear"] = field_97 + attributes["reason"] = field_98 + attributes["reasonother"] = field_99 if reason_is_other? + attributes["prevten"] = field_100 + attributes["homeless"] = field_101 attributes["prevloc"] = prevloc attributes["previous_la_known"] = previous_la_known attributes["ppcodenk"] = ppcodenk attributes["ppostcode_full"] = ppostcode_full - attributes["reasonpref"] = field_105 - attributes["rp_homeless"] = field_106 unless rp_dontknow_conflict? - attributes["rp_insan_unsat"] = field_107 unless rp_dontknow_conflict? - attributes["rp_medwel"] = field_108 unless rp_dontknow_conflict? - attributes["rp_hardship"] = field_109 unless rp_dontknow_conflict? - attributes["rp_dontknow"] = field_110 unless rp_dontknow_conflict? + attributes["reasonpref"] = field_106 + attributes["rp_homeless"] = field_107 unless rp_dontknow_conflict? + attributes["rp_insan_unsat"] = field_108 unless rp_dontknow_conflict? + attributes["rp_medwel"] = field_109 unless rp_dontknow_conflict? + attributes["rp_hardship"] = field_110 unless rp_dontknow_conflict? + attributes["rp_dontknow"] = field_111 unless rp_dontknow_conflict? attributes["cbl"] = cbl attributes["chr"] = chr @@ -1284,40 +1288,40 @@ private attributes["letting_allocation_unknown"] = letting_allocation_unknown attributes["referral_type"] = referral_type - attributes["referral"] = field_115 + attributes["referral"] = field_116 attributes["net_income_known"] = net_income_known attributes["earnings"] = earnings - attributes["incfreq"] = field_117 - attributes["hb"] = field_119 - attributes["benefits"] = field_120 - - attributes["period"] = field_122 - attributes["brent"] = field_123 if all_charges_given? - attributes["scharge"] = field_124 if all_charges_given? - attributes["pscharge"] = field_125 if all_charges_given? - attributes["supcharg"] = field_126 if all_charges_given? - attributes["household_charge"] = supported_housing? ? field_121 : nil - attributes["hbrentshortfall"] = field_127 + attributes["incfreq"] = field_118 + attributes["hb"] = field_120 + attributes["benefits"] = field_121 + + attributes["period"] = field_123 + attributes["brent"] = field_124 if all_charges_given? + attributes["scharge"] = field_125 if all_charges_given? + attributes["pscharge"] = field_126 if all_charges_given? + attributes["supcharg"] = field_127 if all_charges_given? + attributes["household_charge"] = supported_housing? ? field_122 : nil + attributes["hbrentshortfall"] = field_128 attributes["tshortfall_known"] = tshortfall_known - attributes["tshortfall"] = field_128 + attributes["tshortfall"] = field_129 attributes["hhmemb"] = hhmemb attributes["unitletas"] = field_17 attributes["rsnvac"] = rsnvac - attributes["sheltered"] = field_35 - - attributes["illness_type_1"] = field_93 - attributes["illness_type_2"] = field_87 - attributes["illness_type_3"] = field_90 - attributes["illness_type_4"] = field_85 - attributes["illness_type_5"] = field_86 - attributes["illness_type_6"] = field_88 - attributes["illness_type_7"] = field_89 - attributes["illness_type_8"] = field_92 - attributes["illness_type_9"] = field_91 - attributes["illness_type_10"] = field_94 + attributes["sheltered"] = field_36 + + attributes["illness_type_1"] = field_94 + attributes["illness_type_2"] = field_88 + attributes["illness_type_3"] = field_91 + attributes["illness_type_4"] = field_86 + attributes["illness_type_5"] = field_87 + attributes["illness_type_6"] = field_89 + attributes["illness_type_7"] = field_90 + attributes["illness_type_8"] = field_93 + attributes["illness_type_9"] = field_92 + attributes["illness_type_10"] = field_95 attributes["irproduct_other"] = field_12 if RENT_TYPE_BU_MAPPING[field_11] == 5 @@ -1417,9 +1421,9 @@ private end def ethnic_group_from_ethnic - return nil if field_43.blank? + return nil if field_44.blank? - case field_43 + case field_44 when 1, 2, 3, 18, 20 0 when 4, 5, 6, 7 @@ -1436,19 +1440,19 @@ private end def age1_known? - return 1 if field_41 == "R" + return 1 if field_42 == "R" 0 end [ - { person: 2, field: :field_47 }, - { person: 3, field: :field_51 }, - { person: 4, field: :field_55 }, - { person: 5, field: :field_59 }, - { person: 6, field: :field_63 }, - { person: 7, field: :field_67 }, - { person: 8, field: :field_71 }, + { person: 2, field: :field_48 }, + { person: 3, field: :field_52 }, + { person: 4, field: :field_56 }, + { person: 5, field: :field_60 }, + { person: 6, field: :field_64 }, + { person: 7, field: :field_68 }, + { person: 8, field: :field_72 }, ].each do |hash| define_method("age#{hash[:person]}_known?") do return 1 if public_send(hash[:field]) == "R" @@ -1461,53 +1465,53 @@ private end def person_2_present? - field_46.present? || field_47.present? || field_48.present? + field_47.present? || field_48.present? || field_49.present? end def person_3_present? - field_50.present? || field_51.present? || field_52.present? + field_51.present? || field_52.present? || field_53.present? end def person_4_present? - field_54.present? || field_55.present? || field_56.present? + field_55.present? || field_56.present? || field_57.present? end def person_5_present? - field_58.present? || field_59.present? || field_60.present? + field_59.present? || field_60.present? || field_61.present? end def person_6_present? - field_62.present? || field_63.present? || field_64.present? + field_63.present? || field_64.present? || field_65.present? end def person_7_present? - field_66.present? || field_67.present? || field_68.present? + field_67.present? || field_68.present? || field_69.present? end def person_8_present? - field_70.present? || field_71.present? || field_72.present? + field_71.present? || field_72.present? || field_73.present? end def leftreg - field_75 + field_76 end def housingneeds - if field_82 == 1 + if field_83 == 1 2 - elsif field_83 == 1 + elsif field_84 == 1 3 - elsif field_82.blank? || field_82&.zero? + elsif field_83.blank? || field_83&.zero? 1 end end def housingneeds_type - if field_78 == 1 + if field_79 == 1 0 - elsif field_79 == 1 - 1 elsif field_80 == 1 + 1 + elsif field_81 == 1 2 else 3 @@ -1515,12 +1519,12 @@ private end def housingneeds_other - return 1 if field_81 == 1 - return 0 if [field_78, field_79, field_80].include?(1) + return 1 if field_82 == 1 + return 0 if [field_79, field_80, field_81].include?(1) end def prevloc - field_104 + field_105 end def previous_la_known @@ -1528,7 +1532,7 @@ private end def ppcodenk - case field_101 + case field_102 when 1 0 when 2 @@ -1537,11 +1541,11 @@ private end def ppostcode_full - "#{field_102} #{field_103}".strip.gsub(/\s+/, " ") + "#{field_103} #{field_104}".strip.gsub(/\s+/, " ") end def cbl - case field_111 + case field_112 when 2 0 when 1 @@ -1550,7 +1554,7 @@ private end def cap - case field_112 + case field_113 when 2 0 when 1 @@ -1559,7 +1563,7 @@ private end def chr - case field_113 + case field_114 when 2 0 when 1 @@ -1568,7 +1572,7 @@ private end def accessible_register - case field_114 + case field_115 when 2 0 when 1 @@ -1581,7 +1585,7 @@ private end def net_income_known - case field_116 + case field_117 when 1 0 when 2 @@ -1592,11 +1596,11 @@ private end def earnings - field_118.round if field_118.present? + field_119.round if field_119.present? end def tshortfall_known - field_127 == 1 ? 0 : 1 + field_128 == 1 ? 0 : 1 end def hhmemb @@ -1616,15 +1620,15 @@ private end def mrcdate - year = field_34.to_s.strip.length.between?(1, 2) ? field_34 + 2000 : field_34 - Date.new(year, field_33, field_32) if field_34.present? && field_33.present? && field_32.present? + year = field_35.to_s.strip.length.between?(1, 2) ? field_35 + 2000 : field_35 + Date.new(year, field_34, field_33) if field_35.present? && field_34.present? && field_33.present? rescue Date::Error Date.new end def voiddate - year = field_31.to_s.strip.length.between?(1, 2) ? field_31 + 2000 : field_31 - Date.new(year, field_30, field_29) if field_31.present? && field_30.present? && field_29.present? + year = field_32.to_s.strip.length.between?(1, 2) ? field_32 + 2000 : field_32 + Date.new(year, field_31, field_30) if field_32.present? && field_31.present? && field_30.present? rescue Date::Error Date.new end @@ -1651,7 +1655,7 @@ private end def reason_is_other? - field_97 == 20 + field_98 == 20 end def bulk_upload_organisation @@ -1670,10 +1674,10 @@ private end def rp_dontknow_conflict? - other_reason_fields = %i[field_106 field_107 field_108 field_109] - if field_105 == 1 + other_reason_fields = %i[field_107 field_108 field_109 field_110] + if field_106 == 1 selected_reasons = other_reason_fields.select { |field| send(field) == 1 } - dont_know_selected = field_110 == 1 + dont_know_selected = field_111 == 1 return true if selected_reasons.any? && dont_know_selected end @@ -1692,7 +1696,7 @@ private } mapping.each do |key, values| - return key if values.include?(field_115) + return key if values.include?(field_116) end 0