Browse Source

CLDC-3302 Make mortgageused bulk upload errors only display on relevant field (#2311)

* feat: only add mortgageuesd error to relevant mortgageused field

* feat: add test

* feat: test

* feat: test 2023
pull/2321/head
natdeanlewissoftwire 9 months ago committed by GitHub
parent
commit
29980b1f7b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      app/services/bulk_upload/sales/year2023/row_parser.rb
  2. 8
      app/services/bulk_upload/sales/year2024/row_parser.rb
  3. 12
      spec/services/bulk_upload/sales/year2023/row_parser_spec.rb
  4. 12
      spec/services/bulk_upload/sales/year2024/row_parser_spec.rb

8
app/services/bulk_upload/sales/year2023/row_parser.rb

@ -754,7 +754,7 @@ private
stairbought: %i[field_88], stairbought: %i[field_88],
stairowned: %i[field_89], stairowned: %i[field_89],
socprevten: %i[field_102], socprevten: %i[field_102],
mortgageused: %i[field_105 field_119 field_128], mortgageused: [mortgageused_field],
soctenant: %i[field_99], soctenant: %i[field_99],
uprn: %i[field_19], uprn: %i[field_19],
@ -1103,6 +1103,12 @@ private
return field_128 if outright_sale? return field_128 if outright_sale?
end end
def mortgageused_field
return :field_105 if shared_ownership?
return :field_119 if discounted_ownership?
return :field_128 if outright_sale?
end
def owning_organisation def owning_organisation
@owning_organisation ||= Organisation.find_by_id_on_multiple_fields(field_1) @owning_organisation ||= Organisation.find_by_id_on_multiple_fields(field_1)
end end

8
app/services/bulk_upload/sales/year2024/row_parser.rb

@ -760,7 +760,7 @@ private
stairbought: %i[field_87], stairbought: %i[field_87],
stairowned: %i[field_88], stairowned: %i[field_88],
socprevten: %i[field_100], socprevten: %i[field_100],
mortgageused: %i[field_103 field_117 field_126], mortgageused: [mortgageused_field],
uprn: %i[field_22], uprn: %i[field_22],
address_line1: %i[field_23], address_line1: %i[field_23],
@ -1116,6 +1116,12 @@ private
return field_126 if outright_sale? return field_126 if outright_sale?
end end
def mortgageused_field
return :field_103 if shared_ownership?
return :field_117 if discounted_ownership?
return :field_126 if outright_sale?
end
def owning_organisation def owning_organisation
@owning_organisation ||= Organisation.find_by_id_on_multiple_fields(field_1) @owning_organisation ||= Organisation.find_by_id_on_multiple_fields(field_1)
end end

12
spec/services/bulk_upload/sales/year2023/row_parser_spec.rb

@ -981,6 +981,18 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
end end
end end
describe "#field_119" do
context "when validate_discounted_ownership_value is triggered" do
let(:attributes) { setup_section_params.merge(field_116: 100, field_125: 100, field_7: 2, field_9: 9, field_119: 2, field_118: 10) }
it "only adds errors to the discounted ownership field" do
expect(parser.errors[:field_105]).to be_empty
expect(parser.errors[:field_119]).to include("Mortgage, deposit, and grant total must equal £90.00. Your given mortgage, deposit and grant total is £100.00")
expect(parser.errors[:field_128]).to be_empty
end
end
end
describe "soft validations" do describe "soft validations" do
context "when soft validation is triggered" do context "when soft validation is triggered" do
let(:attributes) { valid_attributes.merge({ field_30: 22, field_35: 5 }) } let(:attributes) { valid_attributes.merge({ field_30: 22, field_35: 5 }) }

12
spec/services/bulk_upload/sales/year2024/row_parser_spec.rb

@ -1038,6 +1038,18 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
end end
end end
describe "#field_117" do
context "when validate_discounted_ownership_value is triggered" do
let(:attributes) { setup_section_params.merge(field_114: 100, field_123: 100, field_8: 2, field_10: 9, field_117: 2, field_116: 10) }
it "only adds errors to the discounted ownership field" do
expect(parser.errors[:field_103]).to be_empty
expect(parser.errors[:field_117]).to include("The mortgage, deposit, and grant when added together is £100.00, and the purchase purchase price times by the discount is £90.00. These figures should be the same")
expect(parser.errors[:field_126]).to be_empty
end
end
end
describe "soft validations" do describe "soft validations" do
context "when soft validation is triggered" do context "when soft validation is triggered" do
let(:attributes) { valid_attributes.merge({ field_31: 22, field_35: 5 }) } let(:attributes) { valid_attributes.merge({ field_31: 22, field_35: 5 }) }

Loading…
Cancel
Save