Browse Source

Update mortgage known question options

pull/1356/head
Kat 3 years ago
parent
commit
752cd70120
  1. 2
      app/models/form/sales/questions/mortgage_length.rb
  2. 8
      app/models/form/sales/questions/mortgage_length_known.rb
  3. 4
      app/services/imports/sales_logs_import_service.rb
  4. 2
      spec/factories/sales_log.rb
  5. 10
      spec/models/form/sales/questions/mortgage_length_known_spec.rb
  6. 2
      spec/models/form/sales/questions/mortgage_length_spec.rb

2
app/models/form/sales/questions/mortgage_length.rb

@ -11,7 +11,7 @@ class Form::Sales::Questions::MortgageLength < ::Form::Question
@suffix = " years" @suffix = " years"
@hint_text = "You should round up to the nearest year. Value should not exceed 60 years." @hint_text = "You should round up to the nearest year. Value should not exceed 60 years."
@inferred_check_answers_value = [{ @inferred_check_answers_value = [{
"condition" => { "mortlen_known" => 1 }, "condition" => { "mortlen_known" => 2 },
"value" => "Not known", "value" => "Not known",
}] }]
end end

8
app/models/form/sales/questions/mortgage_length_known.rb

@ -12,17 +12,17 @@ class Form::Sales::Questions::MortgageLengthKnown < ::Form::Question
@hidden_in_check_answers = { @hidden_in_check_answers = {
"depends_on" => [ "depends_on" => [
{ {
"mortlen_known" => 0, "mortlen_known" => 1,
}, },
{ {
"mortlen_known" => 1, "mortlen_known" => 2,
}, },
], ],
} }
end end
ANSWER_OPTIONS = { ANSWER_OPTIONS = {
"0" => { "value" => "Yes" }, "1" => { "value" => "Yes" },
"1" => { "value" => "No" }, "2" => { "value" => "No" },
}.freeze }.freeze
end end

4
app/services/imports/sales_logs_import_service.rb

@ -118,7 +118,7 @@ module Imports
attributes["mortgagelender"] = mortgage_lender(xml_doc, attributes) attributes["mortgagelender"] = mortgage_lender(xml_doc, attributes)
attributes["mortgagelenderother"] = mortgage_lender_other(xml_doc, attributes) attributes["mortgagelenderother"] = mortgage_lender_other(xml_doc, attributes)
attributes["mortlen"] = mortgage_length(xml_doc, attributes) attributes["mortlen"] = mortgage_length(xml_doc, attributes)
attributes["mortlen_known"] = 0 if attributes["mortlen"].present? attributes["mortlen_known"] = 1 if attributes["mortlen"].present?
attributes["extrabor"] = borrowing(xml_doc, attributes) attributes["extrabor"] = borrowing(xml_doc, attributes)
attributes["totadult"] = safe_string_as_integer(xml_doc, "TOTADULT") # would get overridden attributes["totadult"] = safe_string_as_integer(xml_doc, "TOTADULT") # would get overridden
attributes["totchild"] = safe_string_as_integer(xml_doc, "TOTCHILD") # would get overridden attributes["totchild"] = safe_string_as_integer(xml_doc, "TOTCHILD") # would get overridden
@ -405,7 +405,7 @@ module Imports
attributes["hb"] ||= 4 attributes["hb"] ||= 4
attributes["prevown"] ||= 3 attributes["prevown"] ||= 3
attributes["savingsnk"] ||= attributes["savings"].present? ? 0 : 1 attributes["savingsnk"] ||= attributes["savings"].present? ? 0 : 1
attributes["mortlen_known"] ||= 1 if attributes["mortgage"].blank? attributes["mortlen_known"] ||= 2 if attributes["mortgage"].blank?
# attributes["noint"] = 1 # not interviewed # attributes["noint"] = 1 # not interviewed
# buyer 1 characteristics # buyer 1 characteristics

2
spec/factories/sales_log.rb

@ -95,7 +95,7 @@ FactoryBot.define do
armedforcesspouse { 5 } armedforcesspouse { 5 }
mscharge_known { 1 } mscharge_known { 1 }
mscharge { 100 } mscharge { 100 }
mortlen_known { 0 } mortlen_known { 1 }
mortlen { 10 } mortlen { 10 }
pcodenk { 1 } pcodenk { 1 }
is_la_inferred { false } is_la_inferred { false }

10
spec/models/form/sales/questions/mortgage_length_known_spec.rb

@ -33,8 +33,8 @@ RSpec.describe Form::Sales::Questions::MortgageLengthKnown, type: :model do
it "has the correct answer_options" do it "has the correct answer_options" do
expect(question.answer_options).to eq({ expect(question.answer_options).to eq({
"0" => { "value" => "Yes" }, "1" => { "value" => "Yes" },
"1" => { "value" => "No" }, "2" => { "value" => "No" },
}) })
end end
@ -47,9 +47,11 @@ RSpec.describe Form::Sales::Questions::MortgageLengthKnown, type: :model do
it "has correct hidden in check answers" do it "has correct hidden in check answers" do
expect(question.hidden_in_check_answers).to eq({ expect(question.hidden_in_check_answers).to eq({
"depends_on" => [{ "depends_on" => [{
"mortlen_known" => 0, "mortlen_known" => 1,
}, },
{ "mortlen_known" => 1 }], {
"mortlen_known" => 2,
}],
}) })
end end
end end

2
spec/models/form/sales/questions/mortgage_length_spec.rb

@ -56,7 +56,7 @@ RSpec.describe Form::Sales::Questions::MortgageLength, type: :model do
it "has correct inferred check answers value" do it "has correct inferred check answers value" do
expect(question.inferred_check_answers_value).to eq([ expect(question.inferred_check_answers_value).to eq([
{ {
"condition" => { "mortlen_known" => 1 }, "condition" => { "mortlen_known" => 2 },
"value" => "Not known", "value" => "Not known",
}, },
]) ])

Loading…
Cancel
Save