Browse Source

Refactor possesive variable from errors

pull/2700/head
Kat 2 years ago
parent
commit
ac318708e0
  1. 9
      app/models/validations/sales/property_validations.rb
  2. 16
      config/locales/validations/sales/property_information.en.yml

9
app/models/validations/sales/property_validations.rb

@ -4,10 +4,11 @@ module Validations::Sales::PropertyValidations
return unless record.ppostcode_full.present? && record.postcode_full.present?
if record.discounted_ownership_sale? && record.ppostcode_full != record.postcode_full
record.errors.add :postcode_full, I18n.t("validations.sales.property_information.postcode_full.postcode_must_match_previous", buyer_possessive: record.joint_purchase? ? "Buyers’" : "Buyer’s")
record.errors.add :ppostcode_full, I18n.t("validations.sales.property_information.ppostcode_full.postcode_must_match_previous", buyer_possessive: record.joint_purchase? ? "Buyers’" : "Buyer’s")
record.errors.add :ownershipsch, I18n.t("validations.sales.property_information.ownershipsch.postcode_must_match_previous", buyer_possessive: record.joint_purchase? ? "Buyers’" : "Buyer’s")
record.errors.add :uprn, I18n.t("validations.sales.property_information.uprn.postcode_must_match_previous", buyer_possessive: record.joint_purchase? ? "Buyers’" : "Buyer’s")
joint_purchase_id = record.joint_purchase? ? "joint_purchase" : "not_joint_purchase"
record.errors.add :postcode_full, I18n.t("validations.sales.property_information.postcode_full.postcode_must_match_previous.#{joint_purchase_id}")
record.errors.add :ppostcode_full, I18n.t("validations.sales.property_information.ppostcode_full.postcode_must_match_previous.#{joint_purchase_id}")
record.errors.add :ownershipsch, I18n.t("validations.sales.property_information.ownershipsch.postcode_must_match_previous.#{joint_purchase_id}")
record.errors.add :uprn, I18n.t("validations.sales.property_information.uprn.postcode_must_match_previous.#{joint_purchase_id}")
end
end

16
config/locales/validations/sales/property_information.en.yml

@ -3,13 +3,21 @@ en:
sales:
property_information:
postcode_full:
postcode_must_match_previous: "%{buyer_possessive} last accommodation and discounted ownership postcodes must match."
postcode_must_match_previous:
joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match."
not_joint_purchase: "Buyer’s last accommodation and discounted ownership postcodes must match."
ppostcode_full:
postcode_must_match_previous: "%{buyer_possessive} last accommodation and discounted ownership postcodes must match."
postcode_must_match_previous:
joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match."
not_joint_purchase: "Buyer’s last accommodation and discounted ownership postcodes must match."
ownershipsch:
postcode_must_match_previous: "%{buyer_possessive} last accommodation and discounted ownership postcodes must match."
postcode_must_match_previous:
joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match."
not_joint_purchase: "Buyer’s last accommodation and discounted ownership postcodes must match."
uprn:
postcode_must_match_previous: "%{buyer_possessive} last accommodation and discounted ownership postcodes must match."
postcode_must_match_previous:
joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match."
not_joint_purchase: "Buyer’s last accommodation and discounted ownership postcodes must match."
invalid: "UPRN must be 12 digits or less."
beds:
bedsits_have_max_one_bedroom: "Number of bedrooms must be 1 if the property is a bedsit."

Loading…
Cancel
Save