Browse Source

More updates

pull/2272/head
Kat 2 years ago
parent
commit
bea9e1f808
  1. 10
      app/models/form/sales/questions/privacy_notice.rb
  2. 2
      app/models/validations/sales/financial_validations.rb
  3. 8
      app/models/validations/sales/property_validations.rb
  4. 1
      app/views/form/guidance/_privacy_notice_buyer_2024_joint_purchase.erb
  5. 1
      app/views/form/guidance/_privacy_notice_buyer_joint_purchase.erb
  6. 2
      config/locales/en.yml
  7. 2
      spec/models/validations/sales/financial_validations_spec.rb
  8. 12
      spec/models/validations/sales/property_validations_spec.rb

10
app/models/form/sales/questions/privacy_notice.rb

@ -5,9 +5,9 @@ class Form::Sales::Questions::PrivacyNotice < ::Form::Question
@check_answer_label = "#{joint_purchase ? 'Buyers have' : 'Buyer has'} seen the privacy notice?" @check_answer_label = "#{joint_purchase ? 'Buyers have' : 'Buyer has'} seen the privacy notice?"
@header = "Declaration" @header = "Declaration"
@type = "checkbox" @type = "checkbox"
@top_guidance_partial = form.start_year_after_2024? ? "privacy_notice_buyer_2024" : "privacy_notice_buyer"
@question_number = 19 @question_number = 19
@joint_purchase = joint_purchase @joint_purchase = joint_purchase
@top_guidance_partial = guidance
end end
def answer_options def answer_options
@ -19,4 +19,12 @@ class Form::Sales::Questions::PrivacyNotice < ::Form::Question
{ "privacynotice" => { "value" => declaration_text } }.freeze { "privacynotice" => { "value" => declaration_text } }.freeze
end end
def guidance
if form.start_year_after_2024?
@joint_purchase ? "privacy_notice_buyer_2024_joint_purchase" : "privacy_notice_buyer_2024"
else
@joint_purchase ? "privacy_notice_buyer_joint_purchase" : "privacy_notice_buyer"
end
end
end end

2
app/models/validations/sales/financial_validations.rb

@ -48,7 +48,7 @@ module Validations::Sales::FinancialValidations
return unless record.stairbought && record.stairowned return unless record.stairbought && record.stairowned
if record.stairbought > record.stairowned if record.stairbought > record.stairowned
record.errors.add :stairowned, I18n.t("validations.financial.staircasing.percentage_bought_must_be_greater_than_percentage_owned", buyer_possessive: record.joint_purchase? ? "buyers" : "buyer") record.errors.add :stairowned, I18n.t("validations.financial.staircasing.percentage_bought_must_be_greater_than_percentage_owned", buyer_now_owns: record.joint_purchase? ? "buyers now own" : "buyer now owns")
end end
end end

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

@ -4,10 +4,10 @@ module Validations::Sales::PropertyValidations
return unless record.ppostcode_full.present? && record.postcode_full.present? return unless record.ppostcode_full.present? && record.postcode_full.present?
if record.discounted_ownership_sale? && record.ppostcode_full != record.postcode_full if record.discounted_ownership_sale? && record.ppostcode_full != record.postcode_full
record.errors.add :postcode_full, I18n.t("validations.property.postcode.must_match_previous", buyer_possessive: record.joint_purchase? ? "Buyers" : "Buyers") record.errors.add :postcode_full, I18n.t("validations.property.postcode.must_match_previous", buyer_possessive: record.joint_purchase? ? "Buyers" : "Buyers")
record.errors.add :ppostcode_full, I18n.t("validations.property.postcode.must_match_previous", buyer_possessive: record.joint_purchase? ? "Buyers" : "Buyers") record.errors.add :ppostcode_full, I18n.t("validations.property.postcode.must_match_previous", buyer_possessive: record.joint_purchase? ? "Buyers" : "Buyers")
record.errors.add :ownershipsch, I18n.t("validations.property.postcode.must_match_previous", buyer_possessive: record.joint_purchase? ? "Buyers" : "Buyers") record.errors.add :ownershipsch, I18n.t("validations.property.postcode.must_match_previous", buyer_possessive: record.joint_purchase? ? "Buyers" : "Buyers")
record.errors.add :uprn, I18n.t("validations.property.postcode.must_match_previous", buyer_possessive: record.joint_purchase? ? "Buyers" : "Buyers") record.errors.add :uprn, I18n.t("validations.property.postcode.must_match_previous", buyer_possessive: record.joint_purchase? ? "Buyers" : "Buyers")
end end
end end

1
app/views/form/guidance/_privacy_notice_buyer_2024_joint_purchase.erb

@ -0,0 +1 @@
<p class="govuk-body">Make sure the buyers have seen or been given access to <%= govuk_link_to "the Department for Levelling Up, Housing & Communities (DLUHC) privacy notice", privacy_notice_path, target: :_blank %> before completing this log. This is a legal requirement under data protection legislation.</p>

1
app/views/form/guidance/_privacy_notice_buyer_joint_purchase.erb

@ -0,0 +1 @@
<p class="govuk-body">Make sure the buyers have seen <%= govuk_link_to "the Department for Levelling Up, Housing & Communities (DLUHC) privacy notice", privacy_notice_path, target: :_blank %> before completing this log.</p>

2
config/locales/en.yml

@ -428,7 +428,7 @@ en:
not_provided: "Enter how much rent and other charges the household pays %{period}" not_provided: "Enter how much rent and other charges the household pays %{period}"
cash_discount_invalid: "Cash discount must be £0 - £999,999" cash_discount_invalid: "Cash discount must be £0 - £999,999"
staircasing: staircasing:
percentage_bought_must_be_greater_than_percentage_owned: "Total percentage %{buyer_possessive} now owns must be more than percentage bought in this transaction" percentage_bought_must_be_greater_than_percentage_owned: "Total percentage %{buyer_now_owns} must be more than percentage bought in this transaction"
percentage_bought_must_be_at_least_threshold: "The minimum increase in equity while staircasing is %{threshold}%" percentage_bought_must_be_at_least_threshold: "The minimum increase in equity while staircasing is %{threshold}%"
percentage_bought_equal_percentage_owned: "The percentage bought is %{stairbought}% and the percentage owned in total is %{stairowned}%. These figures cannot be the same." percentage_bought_equal_percentage_owned: "The percentage bought is %{stairbought}% and the percentage owned in total is %{stairowned}%. These figures cannot be the same."
monthly_leasehold_charges: monthly_leasehold_charges:

2
spec/models/validations/sales/financial_validations_spec.rb

@ -153,7 +153,7 @@ RSpec.describe Validations::Sales::FinancialValidations do
record.stairowned = 40 record.stairowned = 40
record.jointpur = 1 record.jointpur = 1
financial_validator.validate_percentage_bought_not_greater_than_percentage_owned(record) financial_validator.validate_percentage_bought_not_greater_than_percentage_owned(record)
expect(record.errors["stairowned"]).to include("Total percentage buyers now owns must be more than percentage bought in this transaction") expect(record.errors["stairowned"]).to include("Total percentage buyers now own must be more than percentage bought in this transaction")
end end
it "adds an error to stairowned and not stairbought if the percentage bought is more than the percentage owned for non joint purchase" do it "adds an error to stairowned and not stairbought if the percentage bought is more than the percentage owned for non joint purchase" do

12
spec/models/validations/sales/property_validations_spec.rb

@ -51,9 +51,9 @@ RSpec.describe Validations::Sales::PropertyValidations do
record.ppostcode_full = "SW1A 0AA" record.ppostcode_full = "SW1A 0AA"
record.jointpur = 1 record.jointpur = 1
property_validator.validate_postcodes_match_if_discounted_ownership(record) property_validator.validate_postcodes_match_if_discounted_ownership(record)
expect(record.errors["postcode_full"]).to include("Buyers last accommodation and discounted ownership postcodes must match") expect(record.errors["postcode_full"]).to include("Buyers last accommodation and discounted ownership postcodes must match")
expect(record.errors["ppostcode_full"]).to include("Buyers last accommodation and discounted ownership postcodes must match") expect(record.errors["ppostcode_full"]).to include("Buyers last accommodation and discounted ownership postcodes must match")
expect(record.errors["ownershipsch"]).to include("Buyers last accommodation and discounted ownership postcodes must match") expect(record.errors["ownershipsch"]).to include("Buyers last accommodation and discounted ownership postcodes must match")
end end
it "when postcodes do not match an error is added for non joint purchase" do it "when postcodes do not match an error is added for non joint purchase" do
@ -61,9 +61,9 @@ RSpec.describe Validations::Sales::PropertyValidations do
record.ppostcode_full = "SW1A 0AA" record.ppostcode_full = "SW1A 0AA"
record.jointpur = 2 record.jointpur = 2
property_validator.validate_postcodes_match_if_discounted_ownership(record) property_validator.validate_postcodes_match_if_discounted_ownership(record)
expect(record.errors["postcode_full"]).to include("Buyers last accommodation and discounted ownership postcodes must match") expect(record.errors["postcode_full"]).to include("Buyers last accommodation and discounted ownership postcodes must match")
expect(record.errors["ppostcode_full"]).to include("Buyers last accommodation and discounted ownership postcodes must match") expect(record.errors["ppostcode_full"]).to include("Buyers last accommodation and discounted ownership postcodes must match")
expect(record.errors["ownershipsch"]).to include("Buyers last accommodation and discounted ownership postcodes must match") expect(record.errors["ownershipsch"]).to include("Buyers last accommodation and discounted ownership postcodes must match")
end end
it "does not add error for 2024 log" do it "does not add error for 2024 log" do

Loading…
Cancel
Save