Browse Source

Add error messageand update import

pull/1521/head
Kat 3 years ago
parent
commit
a0fe89c16d
  1. 3
      app/models/form/sales/pages/buyer_live_in_value_check.rb
  2. 13
      app/models/sales_log.rb
  3. 4
      app/services/imports/sales_logs_import_service.rb
  4. 2
      config/locales/en.yml
  5. 4
      spec/models/form/sales/pages/buyer_live_in_value_check_spec.rb

3
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 = { @title_text = {
"translation" => "soft_validations.buyer#{person_index}_not_livein.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 end
def questions def questions

13
app/models/sales_log.rb

@ -43,7 +43,7 @@ class SalesLog < Log
} }
scope :filter_by_organisation, ->(org, _user = nil) { where(owning_organisation: org) } 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 RETIREMENT_AGES = { "M" => 65, "F" => 60, "X" => 65 }.freeze
def lettings? def lettings?
@ -350,4 +350,15 @@ class SalesLog < Log
def beds_for_la_sale_range def beds_for_la_sale_range
beds.nil? ? nil : [beds, LaSaleRange::MAX_BEDS].min beds.nil? ? nil : [beds, LaSaleRange::MAX_BEDS].min
end end
def ownership_scheme
case ownershipsch
when 1
"Shared owhership"
when 2
"Discounted owhership"
when 3
"Outright sale"
end
end
end end

4
app/services/imports/sales_logs_import_service.rb

@ -155,6 +155,7 @@ module Imports
attributes["monthly_charges_value_check"] = 0 attributes["monthly_charges_value_check"] = 0
attributes["student_not_child_value_check"] = 0 attributes["student_not_child_value_check"] = 0
attributes["discounted_sale_value_check"] = 0 attributes["discounted_sale_value_check"] = 0
attributes["buyer_livein_value_check"] = 0
# Sets the log creator # Sets the log creator
owner_id = meta_field_value(xml_doc, "owner-user-id").strip owner_id = meta_field_value(xml_doc, "owner-user-id").strip
@ -278,7 +279,8 @@ module Imports
hodate_check hodate_check
saledate_check saledate_check
student_not_child_value_check student_not_child_value_check
discounted_sale_value_check] discounted_sale_value_check
buyer_livein_value_check]
end end
def check_status_completed(sales_log, previous_status) def check_status_completed(sales_log, previous_status)

2
config/locales/en.yml

@ -551,6 +551,8 @@ en:
informative_text: "Your given mortgage, deposit and grant total is £%{mortgage_deposit_and_grant_total}" informative_text: "Your given mortgage, deposit and grant total is £%{mortgage_deposit_and_grant_total}"
care_home_charges: care_home_charges:
title_text: "Care home charges should be provided if this is a care home accommodation" 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: devise:
two_factor_authentication: two_factor_authentication:

4
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 it "has the correct title_text" do
expect(page.title_text).to eq({ expect(page.title_text).to eq({
"translation" => "soft_validations.buyer1_not_livein.title_text", "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 end
@ -57,7 +57,7 @@ RSpec.describe Form::Sales::Pages::BuyerLiveInValueCheck, type: :model do
it "has the correct title_text" do it "has the correct title_text" do
expect(page.title_text).to eq({ expect(page.title_text).to eq({
"translation" => "soft_validations.buyer2_not_livein.title_text", "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
end end

Loading…
Cancel
Save