diff --git a/app/models/form/sales/pages/grant_value_check.rb b/app/models/form/sales/pages/grant_value_check.rb new file mode 100644 index 000000000..a739a1654 --- /dev/null +++ b/app/models/form/sales/pages/grant_value_check.rb @@ -0,0 +1,18 @@ +class Form::Sales::Pages::GrantValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "grant_value_check" + @depends_on = [ + { + "grant_outside_common_range?" => true, + }, + ] + @informative_text = {} + end + + def questions + @questions ||= [ + Form::Sales::Questions::GrantValueCheck.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/questions/grant_value_check.rb b/app/models/form/sales/questions/grant_value_check.rb new file mode 100644 index 000000000..a7efdbaee --- /dev/null +++ b/app/models/form/sales/questions/grant_value_check.rb @@ -0,0 +1,23 @@ +class Form::Sales::Questions::GrantValueCheck < ::Form::Question + def initialize(id, hsh, page) + super + @id = "grant_value_check" + @check_answer_label = "Grant value confirmation" + @header = "Are you sure? Grants are usually £9,000 - £16,000" + @type = "interruption_screen" + @answer_options = { + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + } + @hidden_in_check_answers = { + "depends_on" => [ + { + "grant_value_check" => 0, + }, + { + "grant_value_check" => 1, + }, + ], + } + end +end diff --git a/app/models/form/sales/subsections/discounted_ownership_scheme.rb b/app/models/form/sales/subsections/discounted_ownership_scheme.rb index b527cd7d4..24fc96d38 100644 --- a/app/models/form/sales/subsections/discounted_ownership_scheme.rb +++ b/app/models/form/sales/subsections/discounted_ownership_scheme.rb @@ -11,6 +11,7 @@ class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_discounted_ownership", nil, self), Form::Sales::Pages::AboutPriceRtb.new(nil, nil, self), Form::Sales::Pages::AboutPriceNotRtb.new(nil, nil, self), + Form::Sales::Pages::GrantValueCheck.new(nil, nil, self), Form::Sales::Pages::PurchasePrice.new("purchase_price_discounted_ownership", nil, self), Form::Sales::Pages::Mortgageused.new("mortgage_used_discounted_ownership", nil, self), Form::Sales::Pages::MortgageAmount.new("mortgage_amount_discounted_ownership", nil, self), diff --git a/app/models/validations/sales/soft_validations.rb b/app/models/validations/sales/soft_validations.rb index 19c2a13ec..e8589866c 100644 --- a/app/models/validations/sales/soft_validations.rb +++ b/app/models/validations/sales/soft_validations.rb @@ -42,4 +42,10 @@ module Validations::Sales::SoftValidations ((saledate.to_date - hodate.to_date).to_i / 365) >= 3 end + + def grant_outside_common_range? + return unless grant + + !(9_000..16_000).cover? grant + end end