Browse Source

CLDC-4168: Enforce mortlen is not R if buyer not interviewed in BU

pull/3195/head
samyou-softwire 3 weeks ago
parent
commit
c62efa3174
  1. 33
      app/services/bulk_upload/sales/year2026/row_parser.rb
  2. 1
      config/locales/validations/sales/2026/bulk_upload.en.yml

33
app/services/bulk_upload/sales/year2026/row_parser.rb

@ -454,6 +454,7 @@ class BulkUpload::Sales::Year2026::RowParser
validate :validate_nationality, on: :after_log validate :validate_nationality, on: :after_log
validate :validate_buyer_2_nationality, on: :after_log validate :validate_buyer_2_nationality, on: :after_log
validate :validate_mortlen_field_if_buyer_not_interviewed, on: :after_log
validate :validate_nulls, on: :after_log validate :validate_nulls, on: :after_log
@ -948,7 +949,7 @@ private
attributes["hb"] = field_74 attributes["hb"] = field_74
attributes["mortlen"] = mortlen attributes["mortlen"] = mortlen != "R" ? mortlen : nil
attributes["mortgage_length_known"] = mortgage_length_known attributes["mortgage_length_known"] = mortgage_length_known
attributes["proplen"] = proplen if proplen&.positive? attributes["proplen"] = proplen if proplen&.positive?
@ -1169,25 +1170,15 @@ private
end end
def mortlen def mortlen
value = if shared_ownership? return field_90 if shared_ownership?
field_90
elsif discounted_ownership?
field_118
end
return nil if value == "R" field_118 if discounted_ownership?
value
end end
def mortgage_length_known def mortgage_length_known
value = if shared_ownership? return nil if field_14 == 1
field_90
elsif discounted_ownership?
field_118
end
if value == "R" if mortlen == "R"
1 1
else else
0 0
@ -1561,14 +1552,10 @@ private
%w[0] + GlobalConstants::COUNTRIES_ANSWER_OPTIONS.keys # 0 is "Prefers not to say" %w[0] + GlobalConstants::COUNTRIES_ANSWER_OPTIONS.keys # 0 is "Prefers not to say"
end end
def validate_relat_fields def validate_mortlen_field_if_buyer_not_interviewed
%i[field_34 field_42 field_46 field_50 field_54].each do |field| if field_14 == 1 && mortlen == "R"
value = send(field) errors.add(:field_90, I18n.t("#{ERROR_BASE_KEY}.mortlen.invalid_for_not_interviewed")) if shared_ownership?
next if value.blank? errors.add(:field_118, I18n.t("#{ERROR_BASE_KEY}.mortlen.invalid_for_not_interviewed")) if discounted_ownership?
unless (1..3).cover?(value)
errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: format_ending(QUESTIONS[field])))
end
end end
end end

1
config/locales/validations/sales/2026/bulk_upload.en.yml

@ -46,3 +46,4 @@ en:
invalid: "Select a valid nationality." invalid: "Select a valid nationality."
mortlen: mortlen:
invalid: "Mortgage length must be a number or the letter R" invalid: "Mortgage length must be a number or the letter R"
invalid_for_not_interviewed: "You indicated that the buyer was interviewed, but selected “Don’t know” for mortgage length. Please provide the mortgage length or update your response."

Loading…
Cancel
Save