Browse Source

CLDC-3328 Make bulk upload errors consistent between lettings and sales (#2341)

* feat: add validate_address_fields to lettings for 2024

* CLDC-3338: Add tolerance to discounted sale calculations (#2333)

* Rename method

* Update staircase/non staircase validations

* Add errors to type

* Remove validate_shared_ownership_deposit

* Don't add setup BU errors, deduplicate different sale type errors

* Add tolerance

* Reuse method

* Rename methods

* Skip type error completely in BU

* Update validation messages

* Update over tolerance method

* C:DC-3338: Add tolerance to grant calculations

---------

Co-authored-by: Kat <katrina@kosiak.co.uk>

* feat: add validate_address_fields to lettings for 2024

* feat: update tests

* Revert "CLDC-3338: Add tolerance to discounted sale calculations (#2333)"

This reverts commit cdecdfebfe.

---------

Co-authored-by: Robert Sullivan <Robert.Sullivan@Softwire.com>
Co-authored-by: Kat <katrina@kosiak.co.uk>
pull/2338/head
natdeanlewissoftwire 2 years ago committed by GitHub
parent
commit
03ffc2ea8f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 13
      app/services/bulk_upload/lettings/year2024/row_parser.rb
  2. 6
      spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

13
app/services/bulk_upload/lettings/year2024/row_parser.rb

@ -412,6 +412,7 @@ class BulkUpload::Lettings::Year2024::RowParser
validate :validate_address_option_found, on: :after_log
validate :validate_uprn_exists_if_any_key_address_fields_are_blank, on: :after_log, unless: -> { supported_housing? }
validate :validate_address_fields, on: :after_log
validate :validate_incomplete_soft_validations, on: :after_log
validate :validate_nationality, on: :after_log
@ -581,6 +582,18 @@ private
end
end
def validate_address_fields
if field_16.blank? || log.errors.attribute_names.include?(:uprn)
if field_17.blank?
errors.add(:field_17, I18n.t("validations.not_answered", question: "address line 1"))
end
if field_19.blank?
errors.add(:field_19, I18n.t("validations.not_answered", question: "town or city"))
end
end
end
def validate_incomplete_soft_validations
routed_to_soft_validation_questions = log.form.questions.filter { |q| q.type == "interruption_screen" && q.page.routed_to?(log, nil) }.compact
routed_to_soft_validation_questions.each do |question|

6
spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

@ -1495,10 +1495,10 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
field_1: "1" }
end
it "does not add UPRN errors" do
it "does not add UPRN errors (but still adds missing address errors)" do
expect(parser.errors[:field_16]).to be_empty
expect(parser.errors[:field_17]).to be_empty
expect(parser.errors[:field_19]).to be_empty
expect(parser.errors[:field_17]).to eql(["You must answer address line 1"])
expect(parser.errors[:field_19]).to eql(["You must answer town or city"])
end
end

Loading…
Cancel
Save