diff --git a/app/models/form/sales/questions/mortgageused.rb b/app/models/form/sales/questions/mortgageused.rb index 2d0bc2dde..aac846662 100644 --- a/app/models/form/sales/questions/mortgageused.rb +++ b/app/models/form/sales/questions/mortgageused.rb @@ -16,15 +16,15 @@ class Form::Sales::Questions::Mortgageused < ::Form::Question "3" => { "value" => "Don’t know" }, }.freeze - def displayed_answer_options(_log, _user = nil) - { - "1" => { "value" => "Yes" }, - "2" => { "value" => "No" }, - } - end - - def answer_options(_log, _user = null) - log.stairowned == 100 + def displayed_answer_options(log, _user = nil) + if log.stairowned == 100 && + ANSWER_OPTIONS + else + { + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + } + end end def question_number diff --git a/app/models/validations/sales/soft_validations.rb b/app/models/validations/sales/soft_validations.rb index 35f463f63..32ffffd81 100644 --- a/app/models/validations/sales/soft_validations.rb +++ b/app/models/validations/sales/soft_validations.rb @@ -135,7 +135,7 @@ module Validations::Sales::SoftValidations def discounted_ownership_value_invalid? return unless saledate && collection_start_year <= 2023 return unless value && deposit && ownershipsch - return unless mortgage || mortgageused == 2 + return unless mortgage || mortgageused == 2 || mortgageused == 3 return unless discount || grant || type == 29 mortgage_deposit_and_grant_total != value_with_discount && discounted_ownership_sale? diff --git a/spec/models/form/sales/questions/mortgageused_spec.rb b/spec/models/form/sales/questions/mortgageused_spec.rb index 32fdfde72..12f46643b 100644 --- a/spec/models/form/sales/questions/mortgageused_spec.rb +++ b/spec/models/form/sales/questions/mortgageused_spec.rb @@ -48,10 +48,24 @@ RSpec.describe Form::Sales::Questions::Mortgageused, type: :model do expect(question.hint_text).to be_nil end - it "has the correct displayed_answer_options" do - expect(question.displayed_answer_options(log)).to eq({ - "1" => { "value" => "Yes" }, - "2" => { "value" => "No" }, - }) + context "staircase owned percentage is 100%" do + let(:log) { build(:sales_log, stairowned: 100) } + it "show's the don't know option" do + expect(question.displayed_answer_options(log)).to eq({ + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + "3" => { "value" => "Don’t know" } + }) + end + end + + context "staircase owned percentage is less than 100%" do + let(:log) { build(:sales_log, stairowned: 99) } + it "show's the don't know option" do + expect(question.displayed_answer_options(log)).to eq({ + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + }) + end end end