diff --git a/app/models/validations/sales/sale_information_validations.rb b/app/models/validations/sales/sale_information_validations.rb index 129db57bd..c2036227a 100644 --- a/app/models/validations/sales/sale_information_validations.rb +++ b/app/models/validations/sales/sale_information_validations.rb @@ -89,11 +89,11 @@ module Validations::Sales::SaleInformationValidations return unless record.discount && record.value && record.la if record.london_property? && record.discount_value > 136_400 - %i[discount value la postcode uprn].each do |field| + %i[discount value la postcode_full uprn].each do |field| record.errors.add field, I18n.t("validations.sale_information.value.over_discounted_london_max", discount_value: record.field_formatted_as_currency("discount_value")) end elsif record.property_not_in_london? && record.discount_value > 102_400 - %i[discount value la postcode uprn].each do |field| + %i[discount value la postcode_full uprn].each do |field| record.errors.add field, I18n.t("validations.sale_information.value.over_discounted_max", discount_value: record.field_formatted_as_currency("discount_value")) end end diff --git a/spec/models/validations/sales/sale_information_validations_spec.rb b/spec/models/validations/sales/sale_information_validations_spec.rb index 6508ffbbb..24f2e22ee 100644 --- a/spec/models/validations/sales/sale_information_validations_spec.rb +++ b/spec/models/validations/sales/sale_information_validations_spec.rb @@ -632,7 +632,7 @@ RSpec.describe Validations::Sales::SaleInformationValidations do expect(record.errors["value"]).to include("The percentage discount multiplied by the purchase price is £160,000.00. This figure should not be more than £136,400 for properties in London.") expect(record.errors["discount"]).to include("The percentage discount multiplied by the purchase price is £160,000.00. This figure should not be more than £136,400 for properties in London.") expect(record.errors["la"]).to include("The percentage discount multiplied by the purchase price is £160,000.00. This figure should not be more than £136,400 for properties in London.") - expect(record.errors["postcode"]).to include("The percentage discount multiplied by the purchase price is £160,000.00. This figure should not be more than £136,400 for properties in London.") + expect(record.errors["postcode_full"]).to include("The percentage discount multiplied by the purchase price is £160,000.00. This figure should not be more than £136,400 for properties in London.") expect(record.errors["uprn"]).to include("The percentage discount multiplied by the purchase price is £160,000.00. This figure should not be more than £136,400 for properties in London.") end @@ -641,7 +641,7 @@ RSpec.describe Validations::Sales::SaleInformationValidations do expect(record.errors["value"]).to be_empty expect(record.errors["discount"]).to be_empty expect(record.errors["la"]).to be_empty - expect(record.errors["postcode"]).to be_empty + expect(record.errors["postcode_full"]).to be_empty expect(record.errors["uprn"]).to be_empty end end @@ -657,7 +657,7 @@ RSpec.describe Validations::Sales::SaleInformationValidations do expect(record.errors["value"]).to include("The percentage discount multiplied by the purchase price is £104,000.00. This figure should not be more than £102,400 for properties outside of London.") expect(record.errors["discount"]).to include("The percentage discount multiplied by the purchase price is £104,000.00. This figure should not be more than £102,400 for properties outside of London.") expect(record.errors["la"]).to include("The percentage discount multiplied by the purchase price is £104,000.00. This figure should not be more than £102,400 for properties outside of London.") - expect(record.errors["postcode"]).to include("The percentage discount multiplied by the purchase price is £104,000.00. This figure should not be more than £102,400 for properties outside of London.") + expect(record.errors["postcode_full"]).to include("The percentage discount multiplied by the purchase price is £104,000.00. This figure should not be more than £102,400 for properties outside of London.") expect(record.errors["uprn"]).to include("The percentage discount multiplied by the purchase price is £104,000.00. This figure should not be more than £102,400 for properties outside of London.") end @@ -666,7 +666,7 @@ RSpec.describe Validations::Sales::SaleInformationValidations do expect(record.errors["value"]).to be_empty expect(record.errors["discount"]).to be_empty expect(record.errors["la"]).to be_empty - expect(record.errors["postcode"]).to be_empty + expect(record.errors["postcode_full"]).to be_empty expect(record.errors["uprn"]).to be_empty end end @@ -680,7 +680,7 @@ RSpec.describe Validations::Sales::SaleInformationValidations do expect(record.errors["value"]).to be_empty expect(record.errors["discount"]).to be_empty expect(record.errors["la"]).to be_empty - expect(record.errors["postcode"]).to be_empty + expect(record.errors["postcode_full"]).to be_empty expect(record.errors["uprn"]).to be_empty end end