diff --git a/app/models/validations/sales/household_validations.rb b/app/models/validations/sales/household_validations.rb index 50c5bce36..a0202ce89 100644 --- a/app/models/validations/sales/household_validations.rb +++ b/app/models/validations/sales/household_validations.rb @@ -24,6 +24,7 @@ module Validations::Sales::HouseholdValidations return unless record.form.start_date.year >= 2023 if record.buyers_will_live_in? && record.buyer_one_will_not_live_in_property? && record.buyer_two_will_not_live_in_property? + record.errors.add :buylivein, I18n.t("validations.household.buylivein.buyers_will_live_in_property_values_inconsistent_setup") record.errors.add :buy1livein, I18n.t("validations.household.buylivein.buyers_will_live_in_property_values_inconsistent") record.errors.add :buy2livein, I18n.t("validations.household.buylivein.buyers_will_live_in_property_values_inconsistent") end diff --git a/config/locales/en.yml b/config/locales/en.yml index b2fd8ee8a..111c2a879 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -443,6 +443,7 @@ en: postcode: discounted_ownership: "Last settled accommodation and discounted ownership property postcodes must match" buylivein: + buyers_will_live_in_property_values_inconsistent_setup: "You have already told us that both buyer 1 and buyer 2 will not live in the property" buyers_will_live_in_property_values_inconsistent: "You have already told us that the buyers will live in the property. Either buyer 1 or buyer 2 must live in the property" tenancy: diff --git a/spec/models/validations/sales/household_validations_spec.rb b/spec/models/validations/sales/household_validations_spec.rb index 1737371d6..925ac1814 100644 --- a/spec/models/validations/sales/household_validations_spec.rb +++ b/spec/models/validations/sales/household_validations_spec.rb @@ -238,6 +238,7 @@ RSpec.describe Validations::Sales::HouseholdValidations do it "triggers a validation if buyer two will also not live in the property" do sales_log.buy2livein = 2 household_validator.validate_buyers_living_in_property(sales_log) + expect(sales_log.errors[:buylivein]).to include I18n.t("validations.household.buylivein.buyers_will_live_in_property_values_inconsistent_setup") expect(sales_log.errors[:buy2livein]).to include I18n.t("validations.household.buylivein.buyers_will_live_in_property_values_inconsistent") expect(sales_log.errors[:buy1livein]).to include I18n.t("validations.household.buylivein.buyers_will_live_in_property_values_inconsistent") end