From eb7c30d0de07d8390695ff743f38638344f25787 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Mon, 6 Mar 2023 15:18:12 +0000 Subject: [PATCH] feat: shared, discount and outright numbering --- .../pages/about_deposit_with_discount.rb | 2 +- .../pages/about_deposit_without_discount.rb | 7 ++++--- .../form/sales/pages/about_price_not_rtb.rb | 2 +- .../form/sales/pages/about_price_rtb.rb | 2 +- .../form/sales/pages/extra_borrowing.rb | 7 ++++--- .../form/sales/pages/leasehold_charges.rb | 9 +++++++-- .../sales/pages/living_before_purchase.rb | 8 ++++++-- .../form/sales/pages/mortgage_amount.rb | 7 ++++--- .../form/sales/pages/mortgage_lender.rb | 7 ++++--- .../form/sales/pages/mortgage_lender_other.rb | 7 ++++--- .../form/sales/pages/mortgage_length.rb | 7 ++++--- app/models/form/sales/pages/mortgageused.rb | 7 ++++++- .../purchase_price_outright_ownership.rb | 7 ++++--- .../form/sales/questions/deposit_amount.rb | 18 ++++++++++++++--- app/models/form/sales/questions/discount.rb | 1 + .../form/sales/questions/extra_borrowing.rb | 18 ++++++++++++++--- app/models/form/sales/questions/grant.rb | 1 + .../form/sales/questions/leasehold_charges.rb | 18 ++++++++++++++--- .../questions/leasehold_charges_known.rb | 18 ++++++++++++++--- .../sales/questions/living_before_purchase.rb | 16 ++++++++++++--- .../questions/living_before_purchase_years.rb | 16 ++++++++++++--- .../form/sales/questions/mortgage_amount.rb | 19 +++++++++++++++--- .../form/sales/questions/mortgage_lender.rb | 18 ++++++++++++++--- .../sales/questions/mortgage_lender_other.rb | 18 ++++++++++++++--- .../form/sales/questions/mortgage_length.rb | 18 ++++++++++++++--- .../form/sales/questions/mortgageused.rb | 18 ++++++++++++++--- .../form/sales/questions/purchase_price.rb | 15 ++++++++++++-- .../purchase_price_outright_ownership.rb | 12 ----------- .../discounted_ownership_scheme.rb | 20 +++++++++---------- .../form/sales/subsections/outright_sale.rb | 18 ++++++++--------- .../subsections/shared_ownership_scheme.rb | 18 ++++++++--------- 31 files changed, 255 insertions(+), 104 deletions(-) delete mode 100644 app/models/form/sales/questions/purchase_price_outright_ownership.rb diff --git a/app/models/form/sales/pages/about_deposit_with_discount.rb b/app/models/form/sales/pages/about_deposit_with_discount.rb index 6a4a54071..1c684b0bc 100644 --- a/app/models/form/sales/pages/about_deposit_with_discount.rb +++ b/app/models/form/sales/pages/about_deposit_with_discount.rb @@ -8,7 +8,7 @@ class Form::Sales::Pages::AboutDepositWithDiscount < ::Form::Page def questions @questions ||= [ - Form::Sales::Questions::DepositAmount.new(nil, nil, self), + Form::Sales::Questions::DepositAmount.new(nil, nil, self, ownershipsch: 1), Form::Sales::Questions::DepositDiscount.new(nil, nil, self), ] end diff --git a/app/models/form/sales/pages/about_deposit_without_discount.rb b/app/models/form/sales/pages/about_deposit_without_discount.rb index e8e387eba..1114b8f84 100644 --- a/app/models/form/sales/pages/about_deposit_without_discount.rb +++ b/app/models/form/sales/pages/about_deposit_without_discount.rb @@ -1,15 +1,16 @@ class Form::Sales::Pages::AboutDepositWithoutDiscount < ::Form::Page - def initialize(id, hsh, subsection) - super + def initialize(id, hsh, subsection, ownershipsch:) + super(id, hsh, subsection) @header = "About the deposit" @depends_on = [{ "is_type_discount?" => false, "ownershipsch" => 1 }, { "ownershipsch" => 2 }, { "ownershipsch" => 3, "mortgageused" => 1 }] + @ownershipsch = ownershipsch end def questions @questions ||= [ - Form::Sales::Questions::DepositAmount.new(nil, nil, self), + Form::Sales::Questions::DepositAmount.new(nil, nil, self, ownershipsch: @ownershipsch), ] end end diff --git a/app/models/form/sales/pages/about_price_not_rtb.rb b/app/models/form/sales/pages/about_price_not_rtb.rb index c69b9a890..2f30548c7 100644 --- a/app/models/form/sales/pages/about_price_not_rtb.rb +++ b/app/models/form/sales/pages/about_price_not_rtb.rb @@ -11,7 +11,7 @@ class Form::Sales::Pages::AboutPriceNotRtb < ::Form::Page def questions @questions ||= [ - Form::Sales::Questions::PurchasePrice.new(nil, nil, self), + Form::Sales::Questions::PurchasePrice.new(nil, nil, self, ownershipsch: 2), Form::Sales::Questions::Grant.new(nil, nil, self), ] end diff --git a/app/models/form/sales/pages/about_price_rtb.rb b/app/models/form/sales/pages/about_price_rtb.rb index 35696e966..d8d20398f 100644 --- a/app/models/form/sales/pages/about_price_rtb.rb +++ b/app/models/form/sales/pages/about_price_rtb.rb @@ -10,7 +10,7 @@ class Form::Sales::Pages::AboutPriceRtb < ::Form::Page def questions @questions ||= [ - Form::Sales::Questions::PurchasePrice.new(nil, nil, self), + Form::Sales::Questions::PurchasePrice.new(nil, nil, self, ownershipsch: 2), Form::Sales::Questions::Discount.new(nil, nil, self), ] end diff --git a/app/models/form/sales/pages/extra_borrowing.rb b/app/models/form/sales/pages/extra_borrowing.rb index 7fb8b08a4..4bb8d0530 100644 --- a/app/models/form/sales/pages/extra_borrowing.rb +++ b/app/models/form/sales/pages/extra_borrowing.rb @@ -1,6 +1,7 @@ class Form::Sales::Pages::ExtraBorrowing < ::Form::Page - def initialize(id, hsh, subsection) - super + def initialize(id, hsh, subsection, ownershipsch:) + super(id, hsh, subsection) + @ownershipsch = ownershipsch @header = "" @description = "" @subsection = subsection @@ -11,7 +12,7 @@ class Form::Sales::Pages::ExtraBorrowing < ::Form::Page def questions @questions ||= [ - Form::Sales::Questions::ExtraBorrowing.new(nil, nil, self), + Form::Sales::Questions::ExtraBorrowing.new(nil, nil, self, ownershipsch: @ownershipsch), ] end end diff --git a/app/models/form/sales/pages/leasehold_charges.rb b/app/models/form/sales/pages/leasehold_charges.rb index 93382cf18..a27c25e1d 100644 --- a/app/models/form/sales/pages/leasehold_charges.rb +++ b/app/models/form/sales/pages/leasehold_charges.rb @@ -1,8 +1,13 @@ class Form::Sales::Pages::LeaseholdCharges < ::Form::Page + def initialize(id, hsh, subsection, ownershipsch:) + super(id, hsh, subsection) + @ownershipsch = ownershipsch + end + def questions @questions ||= [ - Form::Sales::Questions::LeaseholdChargesKnown.new(nil, nil, self), - Form::Sales::Questions::LeaseholdCharges.new(nil, nil, self), + Form::Sales::Questions::LeaseholdChargesKnown.new(nil, nil, self, ownershipsch: @ownershipsch), + Form::Sales::Questions::LeaseholdCharges.new(nil, nil, self, ownershipsch: @ownershipsch), ] end end diff --git a/app/models/form/sales/pages/living_before_purchase.rb b/app/models/form/sales/pages/living_before_purchase.rb index ac61ab1de..abd681258 100644 --- a/app/models/form/sales/pages/living_before_purchase.rb +++ b/app/models/form/sales/pages/living_before_purchase.rb @@ -1,14 +1,18 @@ class Form::Sales::Pages::LivingBeforePurchase < ::Form::Page + def initialize(id, hsh, subsection, ownershipsch:) + super(id, hsh, subsection) + @ownershipsch = ownershipsch + end def questions @questions ||= [ living_before_purchase, - Form::Sales::Questions::LivingBeforePurchaseYears.new(nil, nil, self), + Form::Sales::Questions::LivingBeforePurchaseYears.new(nil, nil, self, ownershipsch: @ownershipsch), ].compact end def living_before_purchase if form.start_date.year >= 2023 - Form::Sales::Questions::LivingBeforePurchase.new(nil, nil, self) + Form::Sales::Questions::LivingBeforePurchase.new(nil, nil, self, ownershipsch: @ownershipsch) end end end diff --git a/app/models/form/sales/pages/mortgage_amount.rb b/app/models/form/sales/pages/mortgage_amount.rb index 153c3bbe6..793570b46 100644 --- a/app/models/form/sales/pages/mortgage_amount.rb +++ b/app/models/form/sales/pages/mortgage_amount.rb @@ -1,6 +1,7 @@ class Form::Sales::Pages::MortgageAmount < ::Form::Page - def initialize(id, hsh, subsection) - super + def initialize(id, hsh, subsection, ownershipsch:) + super(id, hsh, subsection) + @ownershipsch = ownershipsch @header = "Mortgage Amount" @depends_on = [{ "mortgageused" => 1, @@ -9,7 +10,7 @@ class Form::Sales::Pages::MortgageAmount < ::Form::Page def questions @questions ||= [ - Form::Sales::Questions::MortgageAmount.new(nil, nil, self), + Form::Sales::Questions::MortgageAmount.new(nil, nil, self, ownershipsch: @ownershipsch), ] end end diff --git a/app/models/form/sales/pages/mortgage_lender.rb b/app/models/form/sales/pages/mortgage_lender.rb index 552d7abf8..f187815b1 100644 --- a/app/models/form/sales/pages/mortgage_lender.rb +++ b/app/models/form/sales/pages/mortgage_lender.rb @@ -1,6 +1,7 @@ class Form::Sales::Pages::MortgageLender < ::Form::Page - def initialize(id, hsh, subsection) - super + def initialize(id, hsh, subsection, ownershipsch:) + super(id, hsh, subsection) + @ownershipsch = ownershipsch @header = "" @description = "" @subsection = subsection @@ -11,7 +12,7 @@ class Form::Sales::Pages::MortgageLender < ::Form::Page def questions @questions ||= [ - Form::Sales::Questions::MortgageLender.new(nil, nil, self), + Form::Sales::Questions::MortgageLender.new(nil, nil, self, ownershipsch: @ownershipsch), ] end end diff --git a/app/models/form/sales/pages/mortgage_lender_other.rb b/app/models/form/sales/pages/mortgage_lender_other.rb index a4f6aaf90..903a7dba8 100644 --- a/app/models/form/sales/pages/mortgage_lender_other.rb +++ b/app/models/form/sales/pages/mortgage_lender_other.rb @@ -1,6 +1,7 @@ class Form::Sales::Pages::MortgageLenderOther < ::Form::Page - def initialize(id, hsh, subsection) - super + def initialize(id, hsh, subsection, ownershipsch:) + super(id, hsh, subsection) + @ownershipsch = ownershipsch @header = "" @description = "" @subsection = subsection @@ -11,7 +12,7 @@ class Form::Sales::Pages::MortgageLenderOther < ::Form::Page def questions @questions ||= [ - Form::Sales::Questions::MortgageLenderOther.new(nil, nil, self), + Form::Sales::Questions::MortgageLenderOther.new(nil, nil, self, ownershipsch: @ownershipsch), ] end end diff --git a/app/models/form/sales/pages/mortgage_length.rb b/app/models/form/sales/pages/mortgage_length.rb index 979369bdd..dbc01a695 100644 --- a/app/models/form/sales/pages/mortgage_length.rb +++ b/app/models/form/sales/pages/mortgage_length.rb @@ -1,6 +1,7 @@ class Form::Sales::Pages::MortgageLength < ::Form::Page - def initialize(id, hsh, subsection) - super + def initialize(id, hsh, subsection, ownershipsch:) + super(id, hsh, subsection) + @ownershipsch = ownershipsch @depends_on = [{ "mortgageused" => 1, }] @@ -8,7 +9,7 @@ class Form::Sales::Pages::MortgageLength < ::Form::Page def questions @questions ||= [ - Form::Sales::Questions::MortgageLength.new(nil, nil, self), + Form::Sales::Questions::MortgageLength.new(nil, nil, self, ownershipsch: @ownershipsch), ] end end diff --git a/app/models/form/sales/pages/mortgageused.rb b/app/models/form/sales/pages/mortgageused.rb index 4a22c480e..f9d8eae2e 100644 --- a/app/models/form/sales/pages/mortgageused.rb +++ b/app/models/form/sales/pages/mortgageused.rb @@ -1,7 +1,12 @@ class Form::Sales::Pages::Mortgageused < ::Form::Page + def initialize(id, hsh, subsection, ownershipsch:) + super(id, hsh, subsection) + @ownershipsch = ownershipsch + end + def questions @questions ||= [ - Form::Sales::Questions::Mortgageused.new(nil, nil, self), + Form::Sales::Questions::Mortgageused.new(nil, nil, self, ownershipsch: @ownershipsch), ] end end diff --git a/app/models/form/sales/pages/purchase_price_outright_ownership.rb b/app/models/form/sales/pages/purchase_price_outright_ownership.rb index 6bf044d01..a5e995ed6 100644 --- a/app/models/form/sales/pages/purchase_price_outright_ownership.rb +++ b/app/models/form/sales/pages/purchase_price_outright_ownership.rb @@ -1,14 +1,15 @@ class Form::Sales::Pages::PurchasePriceOutrightOwnership < ::Form::Page - def initialize(id, hsh, subsection) - super + def initialize(id, hsh, subsection, ownershipsch:) + super(id, hsh, subsection) @depends_on = [ { "outright_sale_or_discounted_with_full_ownership?" => true }, ] + @ownershipsch = ownershipsch end def questions @questions ||= [ - Form::Sales::Questions::PurchasePriceOutrightOwnership.new(nil, nil, self), + Form::Sales::Questions::PurchasePrice.new(nil, nil, self, ownershipsch: @ownershipsch), ] end end diff --git a/app/models/form/sales/questions/deposit_amount.rb b/app/models/form/sales/questions/deposit_amount.rb index db2e630c5..fb6c0e563 100644 --- a/app/models/form/sales/questions/deposit_amount.rb +++ b/app/models/form/sales/questions/deposit_amount.rb @@ -1,6 +1,6 @@ class Form::Sales::Questions::DepositAmount < ::Form::Question - def initialize(id, hsh, page) - super + def initialize(id, hsh, subsection, ownershipsch:) + super(id, hsh, subsection) @id = "deposit" @check_answer_label = "Cash deposit" @header = "How much cash deposit was paid on the property?" @@ -11,10 +11,22 @@ class Form::Sales::Questions::DepositAmount < ::Form::Question @prefix = "£" @hint_text = "Enter the total cash sum paid by the buyer towards the property that was not funded by the mortgage" @derived = true - @question_number = 95 + @ownershipsch = ownershipsch + @question_number = question_number end def selected_answer_option_is_derived?(_log) true end + + def question_number + case @ownershipsch + when 1 + 95 + when 2 + 108 + when 3 + 116 + end + end end diff --git a/app/models/form/sales/questions/discount.rb b/app/models/form/sales/questions/discount.rb index 01ae38fd5..8c5cf7132 100644 --- a/app/models/form/sales/questions/discount.rb +++ b/app/models/form/sales/questions/discount.rb @@ -12,5 +12,6 @@ class Form::Sales::Questions::Discount < ::Form::Question @hint_text = "For Right to Buy (RTB), Preserved Right to Buy (PRTB), and Voluntary Right to Buy (VRTB)

If discount capped, enter capped %

If the property is being sold to an existing tenant under the RTB, PRTB, or VRTB schemes, enter the % discount from the full market value that is being given." + @question_number = 102 end end diff --git a/app/models/form/sales/questions/extra_borrowing.rb b/app/models/form/sales/questions/extra_borrowing.rb index eaa050516..f63413bba 100644 --- a/app/models/form/sales/questions/extra_borrowing.rb +++ b/app/models/form/sales/questions/extra_borrowing.rb @@ -1,6 +1,6 @@ class Form::Sales::Questions::ExtraBorrowing < ::Form::Question - def initialize(id, hsh, page) - super + def initialize(id, hsh, subsection, ownershipsch:) + super(id, hsh, subsection) @id = "extrabor" @check_answer_label = "Any other borrowing?" @header = "Does this include any extra borrowing?" @@ -8,7 +8,8 @@ class Form::Sales::Questions::ExtraBorrowing < ::Form::Question @answer_options = ANSWER_OPTIONS @page = page @hint_text = "" - @question_number = 94 + @ownershipsch = ownershipsch + @question_number = question_number end ANSWER_OPTIONS = { @@ -16,4 +17,15 @@ class Form::Sales::Questions::ExtraBorrowing < ::Form::Question "2" => { "value" => "No" }, "3" => { "value" => "Don't know" }, }.freeze + + def question_number + case @ownershipsch + when 1 + 94 + when 2 + 107 + when 3 + 115 + end + end end diff --git a/app/models/form/sales/questions/grant.rb b/app/models/form/sales/questions/grant.rb index beef93c58..7a2f5442f 100644 --- a/app/models/form/sales/questions/grant.rb +++ b/app/models/form/sales/questions/grant.rb @@ -10,5 +10,6 @@ class Form::Sales::Questions::Grant < ::Form::Question @width = 5 @prefix = "£" @hint_text = "For all schemes except Right to Buy (RTB), Preserved Right to Buy (PRTB), Voluntary Right to Buy (VRTB)" + @question_number = 101 end end diff --git a/app/models/form/sales/questions/leasehold_charges.rb b/app/models/form/sales/questions/leasehold_charges.rb index 46ce2ea79..697a91b26 100644 --- a/app/models/form/sales/questions/leasehold_charges.rb +++ b/app/models/form/sales/questions/leasehold_charges.rb @@ -1,6 +1,6 @@ class Form::Sales::Questions::LeaseholdCharges < ::Form::Question - def initialize(id, hsh, page) - super + def initialize(id, hsh, subsection, ownershipsch:) + super(id, hsh, subsection) @id = "mscharge" @check_answer_label = "Monthly leasehold charges" @header = "Enter the total monthly charge" @@ -8,6 +8,18 @@ class Form::Sales::Questions::LeaseholdCharges < ::Form::Question @min = 0 @width = 5 @prefix = "£" - @question_number = 98 + @ownershipsch = ownershipsch + @question_number = question_number + end + + def question_number + case @ownershipsch + when 1 + 98 + when 2 + 109 + when 3 + 117 + end end end diff --git a/app/models/form/sales/questions/leasehold_charges_known.rb b/app/models/form/sales/questions/leasehold_charges_known.rb index 99484b69f..a800690e4 100644 --- a/app/models/form/sales/questions/leasehold_charges_known.rb +++ b/app/models/form/sales/questions/leasehold_charges_known.rb @@ -1,6 +1,6 @@ class Form::Sales::Questions::LeaseholdChargesKnown < ::Form::Question - def initialize(id, hsh, page) - super + def initialize(id, hsh, subsection, ownershipsch:) + super(id, hsh, subsection) @id = "mscharge_known" @check_answer_label = "Monthly leasehold charges known?" @header = "Does the property have any monthly leasehold charges?" @@ -17,11 +17,23 @@ class Form::Sales::Questions::LeaseholdChargesKnown < ::Form::Question }, ], } - @question_number = 98 + @ownershipsch = ownershipsch + @question_number = question_number end ANSWER_OPTIONS = { "1" => { "value" => "Yes" }, "0" => { "value" => "No" }, }.freeze + + def question_number + case @ownershipsch + when 1 + 98 + when 2 + 109 + when 3 + 117 + end + end end diff --git a/app/models/form/sales/questions/living_before_purchase.rb b/app/models/form/sales/questions/living_before_purchase.rb index f28d5e86b..4080e34b6 100644 --- a/app/models/form/sales/questions/living_before_purchase.rb +++ b/app/models/form/sales/questions/living_before_purchase.rb @@ -1,6 +1,6 @@ class Form::Sales::Questions::LivingBeforePurchase < ::Form::Question - def initialize(id, hsh, page) - super + def initialize(id, hsh, page, ownershipsch:) + super(id, hsh, page) @id = "proplen_asked" @check_answer_label = "Buyer lived in the property before purchasing" @header = "Did the buyer live in the property before purchasing it?" @@ -17,11 +17,21 @@ class Form::Sales::Questions::LivingBeforePurchase < ::Form::Question }, ], } - @question_number = 75 + @ownershipsch = ownershipsch + @question_number = question_number end ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" }, }.freeze + + def question_number + case @ownershipsch + when 1 + 75 + when 2 + 99 + end + end end diff --git a/app/models/form/sales/questions/living_before_purchase_years.rb b/app/models/form/sales/questions/living_before_purchase_years.rb index 6fcdea62d..ec9cd9d52 100644 --- a/app/models/form/sales/questions/living_before_purchase_years.rb +++ b/app/models/form/sales/questions/living_before_purchase_years.rb @@ -1,6 +1,6 @@ class Form::Sales::Questions::LivingBeforePurchaseYears < ::Form::Question - def initialize(id, hsh, page) - super + def initialize(id, hsh, page, ownershipsch:) + super(id, hsh, page) @id = "proplen" @check_answer_label = "Number of years living in the property before purchase" @header = header_text @@ -11,7 +11,8 @@ class Form::Sales::Questions::LivingBeforePurchaseYears < ::Form::Question @step = 1 @width = 5 @suffix = " years" - @question_number = 75 + @ownershipsch = ownershipsch + @question_number = question_number end def header_text @@ -29,4 +30,13 @@ class Form::Sales::Questions::LivingBeforePurchaseYears < ::Form::Question "You should round this up to the nearest year. If the buyers haven't been living in the property, enter '0'" end end + + def question_number + case @ownershipsch + when 1 + 75 + when 2 + 99 + end + end end diff --git a/app/models/form/sales/questions/mortgage_amount.rb b/app/models/form/sales/questions/mortgage_amount.rb index 8a26681f3..06050a6e2 100644 --- a/app/models/form/sales/questions/mortgage_amount.rb +++ b/app/models/form/sales/questions/mortgage_amount.rb @@ -1,6 +1,6 @@ class Form::Sales::Questions::MortgageAmount < ::Form::Question - def initialize(id, hsh, page) - super + def initialize(id, hsh, subsection, ownershipsch:) + super(id, hsh, subsection) @id = "mortgage" @check_answer_label = "Mortgage amount" @header = "What is the mortgage amount?" @@ -9,6 +9,19 @@ class Form::Sales::Questions::MortgageAmount < ::Form::Question @width = 5 @prefix = "£" @hint_text = "Enter the amount of mortgage agreed with the mortgage lender. Exclude any deposits or cash payments. Numeric in pounds. Rounded to the nearest pound." - @question_number = 91 + @ownershipsch = ownershipsch + @question_number = question_number + end + + def question_number + case @ownershipsch + when 1 + 91 + when 2 + 104 + when 3 + 112 + end end end + diff --git a/app/models/form/sales/questions/mortgage_lender.rb b/app/models/form/sales/questions/mortgage_lender.rb index af463ec8a..1fee10b8b 100644 --- a/app/models/form/sales/questions/mortgage_lender.rb +++ b/app/models/form/sales/questions/mortgage_lender.rb @@ -1,6 +1,6 @@ class Form::Sales::Questions::MortgageLender < ::Form::Question - def initialize(id, hsh, page) - super + def initialize(id, hsh, subsection, ownershipsch:) + super(id, hsh, subsection) @id = "mortgagelender" @check_answer_label = "Mortgage Lender" @header = "What is the name of the mortgage lender?" @@ -10,7 +10,8 @@ class Form::Sales::Questions::MortgageLender < ::Form::Question @answer_options = ANSWER_OPTIONS @guidance_position = GuidancePosition::BOTTOM @guidance_partial = "mortgage_lender" - @question_number = 92 + @ownershipsch = ownershipsch + @question_number = question_number end ANSWER_OPTIONS = { @@ -56,4 +57,15 @@ class Form::Sales::Questions::MortgageLender < ::Form::Question "39" => "Yorkshire Building Society", "40" => "Other", }.freeze + + def question_number + case @ownershipsch + when 1 + 92 + when 2 + 105 + when 3 + 113 + end + end end diff --git a/app/models/form/sales/questions/mortgage_lender_other.rb b/app/models/form/sales/questions/mortgage_lender_other.rb index a51fd10b5..677b1c117 100644 --- a/app/models/form/sales/questions/mortgage_lender_other.rb +++ b/app/models/form/sales/questions/mortgage_lender_other.rb @@ -1,11 +1,23 @@ class Form::Sales::Questions::MortgageLenderOther < ::Form::Question - def initialize(id, hsh, page) - super + def initialize(id, hsh, subsection, ownershipsch:) + super(id, hsh, subsection) @id = "mortgagelenderother" @check_answer_label = "Other Mortgage Lender" @header = "What is the other mortgage lender?" @type = "text" @page = page - @question_number = 92 + @ownershipsch = ownershipsch + @question_number = question_number + end + + def question_number + case @ownershipsch + when 1 + 92 + when 2 + 105 + when 3 + 113 + end end end diff --git a/app/models/form/sales/questions/mortgage_length.rb b/app/models/form/sales/questions/mortgage_length.rb index 9e8091b1e..adaa94d01 100644 --- a/app/models/form/sales/questions/mortgage_length.rb +++ b/app/models/form/sales/questions/mortgage_length.rb @@ -1,6 +1,6 @@ class Form::Sales::Questions::MortgageLength < ::Form::Question - def initialize(id, hsh, page) - super + def initialize(id, hsh, subsection, ownershipsch:) + super(id, hsh, subsection) @id = "mortlen" @check_answer_label = "Length of mortgage" @header = "What is the length of the mortgage?" @@ -10,6 +10,18 @@ class Form::Sales::Questions::MortgageLength < ::Form::Question @width = 5 @suffix = " years" @hint_text = "You should round up to the nearest year. Value should not exceed 60 years." - @question_number = 93 + @ownershipsch = ownershipsch + @question_number = question_number + end + + def question_number + case @ownershipsch + when 1 + 93 + when 2 + 106 + when 3 + 114 + end end end diff --git a/app/models/form/sales/questions/mortgageused.rb b/app/models/form/sales/questions/mortgageused.rb index 175f069ef..7f87b9230 100644 --- a/app/models/form/sales/questions/mortgageused.rb +++ b/app/models/form/sales/questions/mortgageused.rb @@ -1,12 +1,13 @@ class Form::Sales::Questions::Mortgageused < ::Form::Question - def initialize(id, hsh, page) - super + def initialize(id, hsh, subsection, ownershipsch:) + super(id, hsh, subsection) @id = "mortgageused" @check_answer_label = "Mortgage used" @header = "Was a mortgage used for the purchase of this property?" @type = "radio" @answer_options = ANSWER_OPTIONS - @question_number = 90 + @ownershipsch = ownershipsch + @question_number = question_number end ANSWER_OPTIONS = { @@ -21,4 +22,15 @@ class Form::Sales::Questions::Mortgageused < ::Form::Question "2" => { "value" => "No" }, } end + + def question_number + case @ownershipsch + when 1 + 90 + when 2 + 103 + when 3 + 111 + end + end end diff --git a/app/models/form/sales/questions/purchase_price.rb b/app/models/form/sales/questions/purchase_price.rb index 6242e45e8..c98a39ef3 100644 --- a/app/models/form/sales/questions/purchase_price.rb +++ b/app/models/form/sales/questions/purchase_price.rb @@ -1,6 +1,6 @@ class Form::Sales::Questions::PurchasePrice < ::Form::Question - def initialize(id, hsh, page) - super + def initialize(id, hsh, page, ownershipsch:) + super(id, hsh, page) @id = "value" @check_answer_label = "Purchase price" @header = "What is the full purchase price?" @@ -9,5 +9,16 @@ class Form::Sales::Questions::PurchasePrice < ::Form::Question @width = 5 @prefix = "£" @hint_text = "For all schemes, including Right to Acquire (RTA), Right to Buy (RTB), Voluntary Right to Buy (VRTB) or Preserved Right to Buy (PRTB) sales, enter the full price of the property without any discount" + @ownership_sch = ownershipsch + @question_number = question_number + end + + def question_number + case @ownership_sch + when 2 + 100 + when 3 + 110 + end end end diff --git a/app/models/form/sales/questions/purchase_price_outright_ownership.rb b/app/models/form/sales/questions/purchase_price_outright_ownership.rb deleted file mode 100644 index 9824a4629..000000000 --- a/app/models/form/sales/questions/purchase_price_outright_ownership.rb +++ /dev/null @@ -1,12 +0,0 @@ -class Form::Sales::Questions::PurchasePriceOutrightOwnership < ::Form::Question - def initialize(id, hsh, page) - super - @id = "value" - @check_answer_label = "Purchase price" - @header = "What is the full purchase price?" - @type = "numeric" - @min = 0 - @width = 5 - @prefix = "£" - 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 a44f10ee9..f9292b6d6 100644 --- a/app/models/form/sales/subsections/discounted_ownership_scheme.rb +++ b/app/models/form/sales/subsections/discounted_ownership_scheme.rb @@ -8,30 +8,30 @@ class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection def pages @pages ||= [ - Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_discounted_ownership", nil, self), + Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_discounted_ownership", nil, self, ownershipsch: 2), Form::Sales::Pages::AboutPriceRtb.new(nil, nil, self), Form::Sales::Pages::ExtraBorrowingValueCheck.new("extra_borrowing_price_value_check", nil, self), Form::Sales::Pages::AboutPriceNotRtb.new(nil, nil, self), Form::Sales::Pages::GrantValueCheck.new(nil, nil, self), - Form::Sales::Pages::PurchasePriceOutrightOwnership.new("purchase_price_outright_ownership", nil, self), + Form::Sales::Pages::PurchasePriceOutrightOwnership.new("purchase_price_discounted_ownership", nil, self, ownershipsch: 2), Form::Sales::Pages::AboutPriceValueCheck.new("about_price_discounted_ownership_value_check", nil, self), Form::Sales::Pages::DepositAndMortgageValueCheck.new("discounted_ownership_deposit_and_mortgage_value_check_after_value_and_discount", nil, self), - Form::Sales::Pages::Mortgageused.new("mortgage_used_discounted_ownership", nil, self), + Form::Sales::Pages::Mortgageused.new("mortgage_used_discounted_ownership", nil, self, ownershipsch: 2), Form::Sales::Pages::MortgageValueCheck.new("discounted_ownership_mortgage_used_mortgage_value_check", nil, self), - Form::Sales::Pages::MortgageAmount.new("mortgage_amount_discounted_ownership", nil, self), + Form::Sales::Pages::MortgageAmount.new("mortgage_amount_discounted_ownership", nil, self, ownershipsch: 2), Form::Sales::Pages::MortgageValueCheck.new("discounted_ownership_mortgage_amount_mortgage_value_check", nil, self), Form::Sales::Pages::ExtraBorrowingValueCheck.new("extra_borrowing_mortgage_value_check", nil, self), Form::Sales::Pages::DepositAndMortgageValueCheck.new("discounted_ownership_deposit_and_mortgage_value_check_after_mortgage", nil, self), - Form::Sales::Pages::MortgageLender.new("mortgage_lender_discounted_ownership", nil, self), - Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_discounted_ownership", nil, self), - Form::Sales::Pages::MortgageLength.new("mortgage_length_discounted_ownership", nil, self), - Form::Sales::Pages::ExtraBorrowing.new("extra_borrowing_discounted_ownership", nil, self), + Form::Sales::Pages::MortgageLender.new("mortgage_lender_discounted_ownership", nil, self, ownershipsch: 2), + Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_discounted_ownership", nil, self, ownershipsch: 2), + Form::Sales::Pages::MortgageLength.new("mortgage_length_discounted_ownership", nil, self, ownershipsch: 2), + Form::Sales::Pages::ExtraBorrowing.new("extra_borrowing_discounted_ownership", nil, self, ownershipsch: 2), Form::Sales::Pages::ExtraBorrowingValueCheck.new("extra_borrowing_value_check", nil, self), - Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_discounted_ownership", nil, self), + Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_discounted_ownership", nil, self, ownershipsch: 2), Form::Sales::Pages::ExtraBorrowingValueCheck.new("extra_borrowing_deposit_value_check", nil, self), Form::Sales::Pages::DepositValueCheck.new("discounted_ownership_deposit_value_check", nil, self), Form::Sales::Pages::DepositAndMortgageValueCheck.new("discounted_ownership_deposit_and_mortgage_value_check_after_deposit", nil, self), - Form::Sales::Pages::LeaseholdCharges.new("leasehold_charges_discounted_ownership", nil, self), + Form::Sales::Pages::LeaseholdCharges.new("leasehold_charges_discounted_ownership", nil, self, ownershipsch: 2), Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_discounted_ownership_value_check", nil, self), ] end diff --git a/app/models/form/sales/subsections/outright_sale.rb b/app/models/form/sales/subsections/outright_sale.rb index 100c8fa64..d29dc5759 100644 --- a/app/models/form/sales/subsections/outright_sale.rb +++ b/app/models/form/sales/subsections/outright_sale.rb @@ -8,17 +8,17 @@ class Form::Sales::Subsections::OutrightSale < ::Form::Subsection def pages @pages ||= [ - Form::Sales::Pages::PurchasePriceOutrightOwnership.new("purchase_price_outright_sale", nil, self), + Form::Sales::Pages::PurchasePriceOutrightOwnership.new("purchase_price_outright_sale", nil, self, ownershipsch: 3), Form::Sales::Pages::AboutPriceValueCheck.new("about_price_outright_sale_value_check", nil, self), - Form::Sales::Pages::Mortgageused.new("mortgage_used_outright_sale", nil, self), + Form::Sales::Pages::Mortgageused.new("mortgage_used_outright_sale", nil, self, ownershipsch: 3), Form::Sales::Pages::MortgageValueCheck.new("outright_sale_mortgage_used_mortgage_value_check", nil, self), - Form::Sales::Pages::MortgageAmount.new("mortgage_amount_outright_sale", nil, self), + Form::Sales::Pages::MortgageAmount.new("mortgage_amount_outright_sale", nil, self, ownershipsch: 3), Form::Sales::Pages::MortgageValueCheck.new("outright_sale_mortgage_amount_mortgage_value_check", nil, self), - Form::Sales::Pages::MortgageLender.new("mortgage_lender_outright_sale", nil, self), - Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_outright_sale", nil, self), - Form::Sales::Pages::MortgageLength.new("mortgage_length_outright_sale", nil, self), - Form::Sales::Pages::ExtraBorrowing.new("extra_borrowing_outright_sale", nil, self), - Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_outright_sale", nil, self), + Form::Sales::Pages::MortgageLender.new("mortgage_lender_outright_sale", nil, self, ownershipsch: 3), + Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_outright_sale", nil, self, ownershipsch: 3), + Form::Sales::Pages::MortgageLength.new("mortgage_length_outright_sale", nil, self, ownershipsch: 3), + Form::Sales::Pages::ExtraBorrowing.new("extra_borrowing_outright_sale", nil, self, ownershipsch: 3), + Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_outright_sale", nil, self, ownershipsch: 3), Form::Sales::Pages::DepositValueCheck.new("outright_sale_deposit_value_check", nil, self), leasehold_charge_pages, Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_outright_sale_value_check", nil, self), @@ -31,7 +31,7 @@ class Form::Sales::Subsections::OutrightSale < ::Form::Subsection def leasehold_charge_pages if form.start_date.year >= 2023 - Form::Sales::Pages::LeaseholdCharges.new("leasehold_charges_outright_sale", nil, self) + Form::Sales::Pages::LeaseholdCharges.new("leasehold_charges_outright_sale", nil, self, ownershipsch: 3) end end end diff --git a/app/models/form/sales/subsections/shared_ownership_scheme.rb b/app/models/form/sales/subsections/shared_ownership_scheme.rb index 1f0cd6450..9b981279d 100644 --- a/app/models/form/sales/subsections/shared_ownership_scheme.rb +++ b/app/models/form/sales/subsections/shared_ownership_scheme.rb @@ -8,7 +8,7 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection def pages @pages ||= [ - Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_shared_ownership", nil, self), + Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::Staircase.new(nil, nil, self), Form::Sales::Pages::AboutStaircase.new(nil, nil, self), Form::Sales::Pages::StaircaseBoughtValueCheck.new(nil, nil, self), @@ -24,21 +24,21 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection Form::Sales::Pages::AboutPriceSharedOwnership.new(nil, nil, self), Form::Sales::Pages::AboutPriceValueCheck.new("about_price_shared_ownership_value_check", nil, self), Form::Sales::Pages::SharedOwnershipDepositValueCheck.new("shared_ownership_equity_value_check", nil, self), - Form::Sales::Pages::Mortgageused.new("mortgage_used_shared_ownership", nil, self), + Form::Sales::Pages::Mortgageused.new("mortgage_used_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::MortgageValueCheck.new("mortgage_used_mortgage_value_check", nil, self), - Form::Sales::Pages::MortgageAmount.new("mortgage_amount_shared_ownership", nil, self), + Form::Sales::Pages::MortgageAmount.new("mortgage_amount_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::SharedOwnershipDepositValueCheck.new("shared_ownership_mortgage_amount_value_check", nil, self), Form::Sales::Pages::MortgageValueCheck.new("mortgage_amount_mortgage_value_check", nil, self), - Form::Sales::Pages::MortgageLender.new("mortgage_lender_shared_ownership", nil, self), - Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_shared_ownership", nil, self), - Form::Sales::Pages::MortgageLength.new("mortgage_length_shared_ownership", nil, self), - Form::Sales::Pages::ExtraBorrowing.new("extra_borrowing_shared_ownership", nil, self), + Form::Sales::Pages::MortgageLender.new("mortgage_lender_shared_ownership", nil, self, ownershipsch: 1), + Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_shared_ownership", nil, self, ownershipsch: 1), + Form::Sales::Pages::MortgageLength.new("mortgage_length_shared_ownership", nil, self, ownershipsch: 1), + Form::Sales::Pages::ExtraBorrowing.new("extra_borrowing_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::AboutDepositWithDiscount.new(nil, nil, self), - Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_shared_ownership", nil, self), + Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::DepositValueCheck.new("deposit_value_check", nil, self), Form::Sales::Pages::SharedOwnershipDepositValueCheck.new("shared_ownership_deposit_value_check", nil, self), Form::Sales::Pages::MonthlyRent.new(nil, nil, self), - Form::Sales::Pages::LeaseholdCharges.new("leasehold_charges_shared_ownership", nil, self), + Form::Sales::Pages::LeaseholdCharges.new("leasehold_charges_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_shared_ownership_value_check", nil, self), ] end