diff --git a/app/services/bulk_upload/sales/year2024/row_parser.rb b/app/services/bulk_upload/sales/year2024/row_parser.rb index f5697135b..48f451843 100644 --- a/app/services/bulk_upload/sales/year2024/row_parser.rb +++ b/app/services/bulk_upload/sales/year2024/row_parser.rb @@ -344,7 +344,7 @@ class BulkUpload::Sales::Year2024::RowParser validates :field_103, inclusion: { in: [1, 2], - if: proc { field_88 != 100 }, + if: proc { field_88.present? && field_88 != 100 && shared_ownership? }, question: QUESTIONS[:field_103], }, on: :before_log diff --git a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb index b45dfe10d..58d6b2849 100644 --- a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb +++ b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb @@ -1005,6 +1005,22 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do end end + context "when value is 3 and stairowned is not answered" do + let(:attributes) { setup_section_params.merge(field_103: "3", field_86: "1", field_87: "50", field_88: nil, field_109: nil) } + + it "does not add errors" do + expect(parser.errors[:field_103]).not_to include("Enter a valid value for Was a mortgage used for the purchase of this property? - Shared ownership") + end + end + + context "when it's not shared ownership" do + let(:attributes) { setup_section_params.merge(field_8: "2", field_103: "3", field_86: "1", field_87: "50", field_88: "99", field_109: nil) } + + it "does not add errors" do + expect(parser.errors[:field_103]).not_to include("Enter a valid value for Was a mortgage used for the purchase of this property? - Shared ownership") + end + end + context "when value is 3 and stairowned is 100" do let(:attributes) { setup_section_params.merge(field_103: "3", field_86: "1", field_87: "50", field_88: "100", field_109: nil) }