Browse Source

Fix copy multiple matches for for this address (#2914)

* Copy update

* Update copy

* Check address options returned is more than 1

* Update test

* Update and add test

* Update error messaging for single and multiple returns

* lint

* Fix lint
pull/2924/merge
Manny Dinssa 3 days ago committed by GitHub
parent
commit
455afced6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      app/services/bulk_upload/lettings/year2024/row_parser.rb
  2. 6
      app/services/bulk_upload/sales/year2024/row_parser.rb
  3. 10
      config/locales/validations/lettings/2024/bulk_upload.en.yml
  4. 6
      config/locales/validations/sales/2024/bulk_upload.en.yml
  5. 19
      spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb
  6. 28
      spec/services/bulk_upload/sales/year2024/row_parser_spec.rb

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

@ -616,8 +616,10 @@ private
def validate_address_option_found
if log.uprn.nil? && field_16.blank? && key_address_fields_provided?
error_message = if log.address_options_present?
I18n.t("#{ERROR_BASE_KEY}.address.not_determined")
error_message = if log.address_options_present? && log.address_options.size > 1
I18n.t("#{ERROR_BASE_KEY}.address.not_determined.multiple")
elsif log.address_options_present?
I18n.t("#{ERROR_BASE_KEY}.address.not_determined.one")
else
I18n.t("#{ERROR_BASE_KEY}.address.not_found")
end

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

@ -614,8 +614,10 @@ private
def validate_address_option_found
if log.uprn.nil? && field_22.blank? && key_address_fields_provided?
error_message = if log.address_options_present?
I18n.t("#{ERROR_BASE_KEY}.address.not_determined")
error_message = if log.address_options_present? && log.address_options.size > 1
I18n.t("#{ERROR_BASE_KEY}.address.not_determined.multiple")
elsif log.address_options_present?
I18n.t("#{ERROR_BASE_KEY}.address.not_determined.one")
else
I18n.t("#{ERROR_BASE_KEY}.address.not_found")
end

10
config/locales/validations/lettings/2024/bulk_upload.en.yml

@ -17,7 +17,7 @@ en:
owning_organisation:
not_found: "The owning organisation code is incorrect."
not_stock_owner: "The owning organisation code provided is for an organisation that does not own stock."
not_permitted:
not_permitted:
not_support: "You do not have permission to add logs for this owning organisation."
support: "This owning organisation is not affiliated with %{org_name}."
managing_organisation:
@ -49,10 +49,12 @@ en:
age:
invalid: "Age of person %{person_num} must be a number or the letter R"
address:
not_found: "We could not find this address. Check the address data in your CSV file is correct and complete, or select the correct address using the CORE site."
not_determined: "There are multiple matches for this address. Either select the correct address manually or correct the UPRN in the CSV file."
not_found: "We could not find this address. Check the address data in your CSV file is correct and complete, or find the correct address in the service."
not_determined:
one: "There is a possible match for this address which doesn't look right. Check the address data in your CSV file is correct and complete, or confirm the address in the service."
multiple: "There are multiple matches for this address. Check the address data in your CSV file is correct and complete, or select the correct address in the service."
not_answered: "Enter either the UPRN or the full address."
nationality:
invalid: "Select a valid nationality."
charges:
missing_charges: "Please enter the %{sentence_fragment}. If there is no %{sentence_fragment}, please enter '0'."
missing_charges: "Please enter the %{sentence_fragment}. If there is no %{sentence_fragment}, please enter '0'."

6
config/locales/validations/sales/2024/bulk_upload.en.yml

@ -39,8 +39,10 @@ en:
age2:
buyer_cannot_be_over_16_and_child: "Buyer 2's age cannot be 16 or over if their working situation is child under 16."
address:
not_found: "We could not find this address. Check the address data in your CSV file is correct and complete, or select the correct address using the CORE site."
not_determined: "There are multiple matches for this address. Either select the correct address manually or correct the UPRN in the CSV file."
not_found: "We could not find this address. Check the address data in your CSV file is correct and complete, or find the correct address in the service."
not_determined:
one: "There is a possible match for this address which doesn't look right. Check the address data in your CSV file is correct and complete, or confirm the address in the service."
multiple: "There are multiple matches for this address. Check the address data in your CSV file is correct and complete, or select the correct address in the service."
not_answered: "Enter either the UPRN or the full address."
nationality:
invalid: "Select a valid nationality."

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

@ -1710,7 +1710,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end
end
context "when no address has a high enough match rating" do
context "when a single address with not a high enough match rating is returned" do
before do
stub_request(:get, /api\.os\.uk\/search\/places\/v1\/find/)
.to_return(status: 200, body: { results: [{ DPA: { MATCH: 0.6, BUILDING_NAME: "", POST_TOWN: "", POSTCODE: "AA1 1AA", UPRN: "1" } }] }.to_json, headers: {})
@ -1720,7 +1720,22 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
parser.valid?
expect(parser.errors[:field_16]).to be_empty
%i[field_17 field_18 field_19 field_20 field_21 field_22].each do |field|
expect(parser.errors[field]).to eql([I18n.t("validations.lettings.2024.bulk_upload.address.not_determined")])
expect(parser.errors[field]).to eql([I18n.t("validations.lettings.2024.bulk_upload.address.not_determined.one")])
end
end
end
context "when no addresses have a high enough match rating" do
before do
stub_request(:get, /api\.os\.uk\/search\/places\/v1\/find/)
.to_return(status: 200, body: { results: [{ DPA: { MATCH: 0.6, BUILDING_NAME: "", POST_TOWN: "", POSTCODE: "AA1 1AA", UPRN: "1" } }, { DPA: { MATCH: 0.8, BUILDING_NAME: "", POST_TOWN: "", POSTCODE: "BB2 2BB", UPRN: "2" } }] }.to_json, headers: {})
end
it "adds address not found errors to address fields only" do
parser.valid?
expect(parser.errors[:field_16]).to be_empty
%i[field_17 field_18 field_19 field_20 field_21 field_22].each do |field|
expect(parser.errors[field]).to eql([I18n.t("validations.lettings.2024.bulk_upload.address.not_determined.multiple")])
end
end
end

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

@ -1094,7 +1094,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
end
end
context "when no address has a high enough match rating" do
context "when a single address with not a high enough match rating is returned" do
before do
stub_request(:get, /api\.os\.uk\/search\/places\/v1\/find/)
.to_return(status: 200, body: { results: [{ DPA: { MATCH: 0.6, BUILDING_NAME: "", POST_TOWN: "", POSTCODE: "AA1 1AA", UPRN: "1" } }] }.to_json, headers: {})
@ -1104,7 +1104,31 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
parser.valid?
expect(parser.errors[:field_22]).to be_empty
%i[field_23 field_24 field_25 field_26 field_27 field_28].each do |field|
expect(parser.errors[field]).to eql([I18n.t("validations.sales.2024.bulk_upload.address.not_determined")])
expect(parser.errors[field]).to eql([I18n.t("validations.sales.2024.bulk_upload.address.not_determined.one")])
end
end
end
context "when no addresses have a high enough match rating" do
before do
stub_request(:get, /api\.os\.uk\/search\/places\/v1\/find/)
.to_return(
status: 200,
body: {
results: [
{ DPA: { MATCH: 0.6, BUILDING_NAME: "", POST_TOWN: "", POSTCODE: "AA1 1AA", UPRN: "1" } },
{ DPA: { MATCH: 0.8, BUILDING_NAME: "", POST_TOWN: "", POSTCODE: "BB2 2BB", UPRN: "2" } },
],
}.to_json,
headers: {},
)
end
it "adds address not found errors to address fields only" do
parser.valid?
expect(parser.errors[:field_22]).to be_empty
%i[field_23 field_24 field_25 field_26 field_27 field_28].each do |field|
expect(parser.errors[field]).to eql([I18n.t("validations.sales.2024.bulk_upload.address.not_determined.multiple")])
end
end
end

Loading…
Cancel
Save