From a0fe89c16de4f0f42898b5992529b898b3071a7a Mon Sep 17 00:00:00 2001 From: Kat Date: Wed, 5 Apr 2023 15:55:23 +0100 Subject: [PATCH] Add error messageand update import --- .../form/sales/pages/buyer_live_in_value_check.rb | 3 ++- app/models/sales_log.rb | 13 ++++++++++++- app/services/imports/sales_logs_import_service.rb | 4 +++- config/locales/en.yml | 2 ++ .../sales/pages/buyer_live_in_value_check_spec.rb | 4 ++-- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/models/form/sales/pages/buyer_live_in_value_check.rb b/app/models/form/sales/pages/buyer_live_in_value_check.rb index 8b105fb9a..7d5a2e48f 100644 --- a/app/models/form/sales/pages/buyer_live_in_value_check.rb +++ b/app/models/form/sales/pages/buyer_live_in_value_check.rb @@ -8,8 +8,9 @@ class Form::Sales::Pages::BuyerLiveInValueCheck < Form::Sales::Pages::Person ] @title_text = { "translation" => "soft_validations.buyer#{person_index}_not_livein.title_text", - "arguments" => [{ "key" => "owhership_scheme", "label" => false, "i18n_template" => "owhership_scheme" }], + "arguments" => [{ "key" => "ownership_scheme", "label" => false, "i18n_template" => "ownership_scheme" }], } + @informative_text = {} end def questions diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index 38beb850f..0f2a82104 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -43,7 +43,7 @@ class SalesLog < Log } scope :filter_by_organisation, ->(org, _user = nil) { where(owning_organisation: org) } - OPTIONAL_FIELDS = %w[saledate_check purchid monthly_charges_value_check old_persons_shared_ownership_value_check othtype discounted_sale_value_check].freeze + OPTIONAL_FIELDS = %w[saledate_check purchid monthly_charges_value_check old_persons_shared_ownership_value_check othtype discounted_sale_value_check buyer_livein_value_check].freeze RETIREMENT_AGES = { "M" => 65, "F" => 60, "X" => 65 }.freeze def lettings? @@ -350,4 +350,15 @@ class SalesLog < Log def beds_for_la_sale_range beds.nil? ? nil : [beds, LaSaleRange::MAX_BEDS].min end + + def ownership_scheme + case ownershipsch + when 1 + "Shared owhership" + when 2 + "Discounted owhership" + when 3 + "Outright sale" + end + end end diff --git a/app/services/imports/sales_logs_import_service.rb b/app/services/imports/sales_logs_import_service.rb index 2fb619619..e02d7d23c 100644 --- a/app/services/imports/sales_logs_import_service.rb +++ b/app/services/imports/sales_logs_import_service.rb @@ -155,6 +155,7 @@ module Imports attributes["monthly_charges_value_check"] = 0 attributes["student_not_child_value_check"] = 0 attributes["discounted_sale_value_check"] = 0 + attributes["buyer_livein_value_check"] = 0 # Sets the log creator owner_id = meta_field_value(xml_doc, "owner-user-id").strip @@ -278,7 +279,8 @@ module Imports hodate_check saledate_check student_not_child_value_check - discounted_sale_value_check] + discounted_sale_value_check + buyer_livein_value_check] end def check_status_completed(sales_log, previous_status) diff --git a/config/locales/en.yml b/config/locales/en.yml index e223c7fc9..6cee63112 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -551,6 +551,8 @@ en: informative_text: "Your given mortgage, deposit and grant total is £%{mortgage_deposit_and_grant_total}" care_home_charges: title_text: "Care home charges should be provided if this is a care home accommodation" + buyer1_not_livein: + title_text: "You told us that buyer 1 will not live in the property. For %{ownership_scheme} types, the buyer usually lives in the property." devise: two_factor_authentication: diff --git a/spec/models/form/sales/pages/buyer_live_in_value_check_spec.rb b/spec/models/form/sales/pages/buyer_live_in_value_check_spec.rb index 1fa84575b..d92186c89 100644 --- a/spec/models/form/sales/pages/buyer_live_in_value_check_spec.rb +++ b/spec/models/form/sales/pages/buyer_live_in_value_check_spec.rb @@ -39,7 +39,7 @@ RSpec.describe Form::Sales::Pages::BuyerLiveInValueCheck, type: :model do it "has the correct title_text" do expect(page.title_text).to eq({ "translation" => "soft_validations.buyer1_not_livein.title_text", - "arguments" => [{ "key" => "owhership_scheme", "label" => false, "i18n_template" => "owhership_scheme" }], + "arguments" => [{ "key" => "ownership_scheme", "label" => false, "i18n_template" => "ownership_scheme" }], }) end @@ -57,7 +57,7 @@ RSpec.describe Form::Sales::Pages::BuyerLiveInValueCheck, type: :model do it "has the correct title_text" do expect(page.title_text).to eq({ "translation" => "soft_validations.buyer2_not_livein.title_text", - "arguments" => [{ "key" => "owhership_scheme", "label" => false, "i18n_template" => "owhership_scheme" }], + "arguments" => [{ "key" => "ownership_scheme", "label" => false, "i18n_template" => "ownership_scheme" }], }) end end