diff --git a/app/models/derived_variables/sales_log_variables.rb b/app/models/derived_variables/sales_log_variables.rb index 2b3542813..88bad228f 100644 --- a/app/models/derived_variables/sales_log_variables.rb +++ b/app/models/derived_variables/sales_log_variables.rb @@ -1,5 +1,10 @@ module DerivedVariables::SalesLogVariables def set_derived_fields! self.ethnic = 17 if ethnic_refused? + if exdate.present? + self.exday = exdate.day + self.exmonth = exdate.month + self.exyear = exdate.year + end end end diff --git a/app/models/form/sales/pages/about_deposit_with_discount.rb b/app/models/form/sales/pages/about_deposit_with_discount.rb new file mode 100644 index 000000000..1de5365aa --- /dev/null +++ b/app/models/form/sales/pages/about_deposit_with_discount.rb @@ -0,0 +1,17 @@ +class Form::Sales::Pages::AboutDepositWithDiscount < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "about_deposit_with_discount" + @header = "About the deposit" + @description = "" + @subsection = subsection + @depends_on = [{ "is_type_discount?" => true }] + end + + def questions + @questions ||= [ + Form::Sales::Questions::DepositAmount.new(nil, nil, self), + Form::Sales::Questions::DepositDiscount.new(nil, nil, self), + ] + end +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 new file mode 100644 index 000000000..00f306208 --- /dev/null +++ b/app/models/form/sales/pages/about_deposit_without_discount.rb @@ -0,0 +1,15 @@ +class Form::Sales::Pages::AboutDepositWithoutDiscount < ::Form::Page + def initialize(id, hsh, subsection) + super + @header = "About the deposit" + @description = "" + @subsection = subsection + @depends_on = [{ "is_type_discount?" => false }] + end + + def questions + @questions ||= [ + Form::Sales::Questions::DepositAmount.new(nil, nil, self), + ] + 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 new file mode 100644 index 000000000..795ed9226 --- /dev/null +++ b/app/models/form/sales/pages/about_price_not_rtb.rb @@ -0,0 +1,19 @@ +class Form::Sales::Pages::AboutPriceNotRtb < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "about_price_not_rtb" + @header = "About the price of the property" + @description = "" + @subsection = subsection + @depends_on = [{ + "right_to_buy?" => false, + }] + end + + def questions + @questions ||= [ + Form::Sales::Questions::Value.new(nil, nil, self), + Form::Sales::Questions::Grant.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/about_price_rtb.rb b/app/models/form/sales/pages/about_price_rtb.rb new file mode 100644 index 000000000..ec90afa01 --- /dev/null +++ b/app/models/form/sales/pages/about_price_rtb.rb @@ -0,0 +1,19 @@ +class Form::Sales::Pages::AboutPriceRtb < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "about_price_rtb" + @header = "About the price of the property" + @description = "" + @subsection = subsection + @depends_on = [{ + "right_to_buy?" => true, + }] + end + + def questions + @questions ||= [ + Form::Sales::Questions::Value.new(nil, nil, self), + Form::Sales::Questions::Discount.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/about_price_shared_ownership.rb b/app/models/form/sales/pages/about_price_shared_ownership.rb new file mode 100644 index 000000000..b3f34c121 --- /dev/null +++ b/app/models/form/sales/pages/about_price_shared_ownership.rb @@ -0,0 +1,16 @@ +class Form::Sales::Pages::AboutPriceSharedOwnership < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "about_price_shared_ownership" + @header = "About the price of the property" + @description = "" + @subsection = subsection + end + + def questions + @questions ||= [ + Form::Sales::Questions::Value.new(nil, nil, self), + Form::Sales::Questions::Equity.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/about_staircase.rb b/app/models/form/sales/pages/about_staircase.rb new file mode 100644 index 000000000..03ea570f7 --- /dev/null +++ b/app/models/form/sales/pages/about_staircase.rb @@ -0,0 +1,19 @@ +class Form::Sales::Pages::AboutStaircase < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "about_staircasing" + @header = "About the staircasing transaction" + @description = "" + @subsection = subsection + @depends_on = [{ + "staircase" => 1, + }] + end + + def questions + @questions ||= [ + Form::Sales::Questions::StaircaseBought.new(nil, nil, self), + Form::Sales::Questions::StaircaseOwned.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/buyer_previous.rb b/app/models/form/sales/pages/buyer_previous.rb new file mode 100644 index 000000000..5a75787c8 --- /dev/null +++ b/app/models/form/sales/pages/buyer_previous.rb @@ -0,0 +1,15 @@ +class Form::Sales::Pages::BuyerPrevious < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "buyer_previous" + @header = "" + @description = "" + @subsection = subsection + end + + def questions + @questions ||= [ + Form::Sales::Questions::BuyerPrevious.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/exchange_date.rb b/app/models/form/sales/pages/exchange_date.rb new file mode 100644 index 000000000..59e23ab01 --- /dev/null +++ b/app/models/form/sales/pages/exchange_date.rb @@ -0,0 +1,18 @@ +class Form::Sales::Pages::ExchangeDate < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "exchange_contracts" + @header = "" + @description = "" + @subsection = subsection + @depends_on = [{ + "resale" => 2, + }] + end + + def questions + @questions ||= [ + Form::Sales::Questions::ExchangeDate.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/la_nominations.rb b/app/models/form/sales/pages/la_nominations.rb new file mode 100644 index 000000000..c5c775e9f --- /dev/null +++ b/app/models/form/sales/pages/la_nominations.rb @@ -0,0 +1,15 @@ +class Form::Sales::Pages::LaNominations < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "la_nominations" + @header = "" + @description = "" + @subsection = subsection + end + + def questions + @questions ||= [ + Form::Sales::Questions::LaNominations.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/living_before_purchase.rb b/app/models/form/sales/pages/living_before_purchase.rb new file mode 100644 index 000000000..e76b8fd63 --- /dev/null +++ b/app/models/form/sales/pages/living_before_purchase.rb @@ -0,0 +1,14 @@ +class Form::Sales::Pages::LivingBeforePurchase < ::Form::Page + def initialize(id, hsh, subsection) + super + @header = "" + @description = "" + @subsection = subsection + end + + def questions + @questions ||= [ + Form::Sales::Questions::LivingBeforePurchase.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/monthly_rent.rb b/app/models/form/sales/pages/monthly_rent.rb new file mode 100644 index 000000000..826314edf --- /dev/null +++ b/app/models/form/sales/pages/monthly_rent.rb @@ -0,0 +1,15 @@ +class Form::Sales::Pages::MonthlyRent < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "monthly_rent" + @header = "" + @description = "" + @subsection = subsection + end + + def questions + @questions ||= [ + Form::Sales::Questions::MonthlyRent.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/mortgage_amount.rb b/app/models/form/sales/pages/mortgage_amount.rb new file mode 100644 index 000000000..1c80b2f52 --- /dev/null +++ b/app/models/form/sales/pages/mortgage_amount.rb @@ -0,0 +1,14 @@ +class Form::Sales::Pages::MortgageAmount < ::Form::Page + def initialize(id, hsh, subsection) + super + @header = "Mortgage Amount" + @description = "" + @subsection = subsection + end + + def questions + @questions ||= [ + Form::Sales::Questions::MortgageAmount.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/previous_bedrooms.rb b/app/models/form/sales/pages/previous_bedrooms.rb new file mode 100644 index 000000000..3c6eb26b1 --- /dev/null +++ b/app/models/form/sales/pages/previous_bedrooms.rb @@ -0,0 +1,18 @@ +class Form::Sales::Pages::PreviousBedrooms < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "previous_bedrooms" + @header = "About the buyers’ previous property" + @description = "" + @subsection = subsection + @depends_on = [{ + "soctenant" => 1, + }] + end + + def questions + @questions ||= [ + Form::Sales::Questions::PreviousBedrooms.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/purchase_price.rb b/app/models/form/sales/pages/purchase_price.rb new file mode 100644 index 000000000..5eeb84138 --- /dev/null +++ b/app/models/form/sales/pages/purchase_price.rb @@ -0,0 +1,15 @@ +class Form::Sales::Pages::PurchasePrice < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "purchase_price" + @header = "" + @description = "" + @subsection = subsection + end + + def questions + @questions ||= [ + Form::Sales::Questions::PurchasePrice.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/resale.rb b/app/models/form/sales/pages/resale.rb new file mode 100644 index 000000000..031efd3d6 --- /dev/null +++ b/app/models/form/sales/pages/resale.rb @@ -0,0 +1,23 @@ +class Form::Sales::Pages::Resale < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "resale" + @header = "" + @description = "" + @subsection = subsection + @depends_on = [ + { + "staircase" => 2, + }, + { + "staircase" => 3, + }, + ] + end + + def questions + @questions ||= [ + Form::Sales::Questions::Resale.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/staircase.rb b/app/models/form/sales/pages/staircase.rb new file mode 100644 index 000000000..139bd7e40 --- /dev/null +++ b/app/models/form/sales/pages/staircase.rb @@ -0,0 +1,15 @@ +class Form::Sales::Pages::Staircase < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "staircasing" + @header = "" + @description = "" + @subsection = subsection + end + + def questions + @questions ||= [ + Form::Sales::Questions::Staircase.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/questions/buyer_previous.rb b/app/models/form/sales/questions/buyer_previous.rb new file mode 100644 index 000000000..ae9ac22ea --- /dev/null +++ b/app/models/form/sales/questions/buyer_previous.rb @@ -0,0 +1,16 @@ +class Form::Sales::Questions::BuyerPrevious < ::Form::Question + def initialize(id, hsh, page) + super + @id = "soctenant" + @check_answer_label = "Buyer was a registered provider, housing association or local authority tenant immediately before this sale?" + @header = "Was the buyer a private registered provider, housing association or local authority tenant immediately before this sale?" + @type = "radio" + @answer_options = ANSWER_OPTIONS + @page = page + end + + ANSWER_OPTIONS = { + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + }.freeze +end diff --git a/app/models/form/sales/questions/deposit_amount.rb b/app/models/form/sales/questions/deposit_amount.rb new file mode 100644 index 000000000..8252ad8d7 --- /dev/null +++ b/app/models/form/sales/questions/deposit_amount.rb @@ -0,0 +1,14 @@ +class Form::Sales::Questions::DepositAmount < ::Form::Question + def initialize(id, hsh, page) + super + @id = "deposit" + @check_answer_label = "Cash deposit" + @header = "How much cash deposit was paid on the property?" + @type = "numeric" + @page = page + @min = 0 + @width = 5 + @prefix = "£" + @hint_text = "Enter the total cash sum paid by the buyer towards the property that was not funded by the mortgage" + end +end diff --git a/app/models/form/sales/questions/deposit_discount.rb b/app/models/form/sales/questions/deposit_discount.rb new file mode 100644 index 000000000..9496f90fd --- /dev/null +++ b/app/models/form/sales/questions/deposit_discount.rb @@ -0,0 +1,14 @@ +class Form::Sales::Questions::DepositDiscount < ::Form::Question + def initialize(id, hsh, page) + super + @id = "cashdis" + @check_answer_label = "Cash discount through SocialHomeBuy" + @header = "How much cash discount was given through Social HomeBuy?" + @type = "numeric" + @page = page + @min = 0 + @width = 5 + @prefix = "£" + @hint_text = "Enter the total cash discount given on the property being purchased through the Social HomeBuy scheme" + end +end diff --git a/app/models/form/sales/questions/discount.rb b/app/models/form/sales/questions/discount.rb new file mode 100644 index 000000000..d7b9fa33b --- /dev/null +++ b/app/models/form/sales/questions/discount.rb @@ -0,0 +1,17 @@ +class Form::Sales::Questions::Discount < ::Form::Question + def initialize(id, hsh, page) + super + @id = "discount" + @check_answer_label = "Percentage discount" + @header = "What was the percentage discount?" + @type = "numeric" + @page = page + @min = 0 + @max = 100 + @width = 5 + @suffix = "%" + @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." + end +end diff --git a/app/models/form/sales/questions/equity.rb b/app/models/form/sales/questions/equity.rb new file mode 100644 index 000000000..585a14c36 --- /dev/null +++ b/app/models/form/sales/questions/equity.rb @@ -0,0 +1,15 @@ +class Form::Sales::Questions::Equity < ::Form::Question + def initialize(id, hsh, page) + super + @id = "equity" + @check_answer_label = "Initial percentage equity stake" + @header = "What was the initial percentage equity stake purchased?" + @type = "numeric" + @page = page + @min = 0 + @max = 100 + @width = 5 + @suffix = "%" + @hint_text = "Enter the amount of initial equity held by the purchaser (for example, 25% or 50%)" + end +end diff --git a/app/models/form/sales/questions/exchange_date.rb b/app/models/form/sales/questions/exchange_date.rb new file mode 100644 index 000000000..2c726e441 --- /dev/null +++ b/app/models/form/sales/questions/exchange_date.rb @@ -0,0 +1,10 @@ +class Form::Sales::Questions::ExchangeDate < ::Form::Question + def initialize(id, hsh, page) + super + @id = "exdate" + @check_answer_label = "Exchange of contracts date" + @header = "What is the exchange of contracts date?" + @type = "date" + @page = page + end +end diff --git a/app/models/form/sales/questions/grant.rb b/app/models/form/sales/questions/grant.rb new file mode 100644 index 000000000..edab388ac --- /dev/null +++ b/app/models/form/sales/questions/grant.rb @@ -0,0 +1,14 @@ +class Form::Sales::Questions::Grant < ::Form::Question + def initialize(id, hsh, page) + super + @id = "grant" + @check_answer_label = "Amount of any loan, grant or subsidy" + @header = "What was the amount of any loan, grant, discount or subsidy given?" + @type = "numeric" + @page = page + @min = 0 + @width = 5 + @prefix = "£" + @hint_text = "For all schemes except Right to Buy (RTB), Preserved Right to Buy (PRTB), Voluntary Right to Buy (VRTB)" + end +end diff --git a/app/models/form/sales/questions/la_nominations.rb b/app/models/form/sales/questions/la_nominations.rb new file mode 100644 index 000000000..5db0178b6 --- /dev/null +++ b/app/models/form/sales/questions/la_nominations.rb @@ -0,0 +1,18 @@ +class Form::Sales::Questions::LaNominations < ::Form::Question + def initialize(id, hsh, page) + super + @id = "lanomagr" + @check_answer_label = "Household rehoused under a local authority nominations agreement?" + @header = "Was the household rehoused under a 'local authority nominations agreement'?" + @type = "radio" + @answer_options = ANSWER_OPTIONS + @page = page + @hint_text = "A local authority nominations agreement is a written agreement between a local authority and private registered provider (PRP) that some or all of its sales vacancies are offered to local authorities for rehousing" + end + + ANSWER_OPTIONS = { + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + "3" => { "value" => "Don’t know" }, + }.freeze +end diff --git a/app/models/form/sales/questions/living_before_purchase.rb b/app/models/form/sales/questions/living_before_purchase.rb new file mode 100644 index 000000000..0486fa4d7 --- /dev/null +++ b/app/models/form/sales/questions/living_before_purchase.rb @@ -0,0 +1,16 @@ +class Form::Sales::Questions::LivingBeforePurchase < ::Form::Question + def initialize(id, hsh, page) + super + @id = "proplen" + @check_answer_label = "Number of years living in the property before purchase" + @header = "How long did the buyer(s) live in the property before purchase?" + @hint_text = "You should round this up to the nearest year. If the buyers haven't been living in the property, enter '0'" + @type = "numeric" + @page = page + @min = 0 + @max = 80 + @step = 1 + @width = 5 + @suffix = " years" + end +end diff --git a/app/models/form/sales/questions/monthly_rent.rb b/app/models/form/sales/questions/monthly_rent.rb new file mode 100644 index 000000000..4195b1238 --- /dev/null +++ b/app/models/form/sales/questions/monthly_rent.rb @@ -0,0 +1,14 @@ +class Form::Sales::Questions::MonthlyRent < ::Form::Question + def initialize(id, hsh, page) + super + @id = "mrent" + @check_answer_label = "Monthly rent" + @header = "What is the basic monthly rent?" + @type = "numeric" + @page = page + @min = 0 + @width = 5 + @prefix = "£" + @hint_text = "Amount paid before any charges" + end +end diff --git a/app/models/form/sales/questions/mortgage_amount.rb b/app/models/form/sales/questions/mortgage_amount.rb new file mode 100644 index 000000000..c385563c5 --- /dev/null +++ b/app/models/form/sales/questions/mortgage_amount.rb @@ -0,0 +1,14 @@ +class Form::Sales::Questions::MortgageAmount < ::Form::Question + def initialize(id, hsh, page) + super + @id = "mortgage" + @check_answer_label = "Mortgage amount" + @header = "What is the mortgage amount?" + @type = "numeric" + @page = page + @min = 0 + @width = 5 + @prefix = "£" + @hint_text = "" + end +end diff --git a/app/models/form/sales/questions/previous_bedrooms.rb b/app/models/form/sales/questions/previous_bedrooms.rb new file mode 100644 index 000000000..60f361499 --- /dev/null +++ b/app/models/form/sales/questions/previous_bedrooms.rb @@ -0,0 +1,13 @@ +class Form::Sales::Questions::PreviousBedrooms < ::Form::Question + def initialize(id, hsh, page) + super + @id = "frombeds" + @check_answer_label = "Number of bedrooms in previous property" + @header = "How many bedrooms did the property have?" + @type = "numeric" + @page = page + @width = 5 + @min = 0 + @hint_text = "For bedsits enter 1" + end +end diff --git a/app/models/form/sales/questions/purchase_price.rb b/app/models/form/sales/questions/purchase_price.rb new file mode 100644 index 000000000..da714d9df --- /dev/null +++ b/app/models/form/sales/questions/purchase_price.rb @@ -0,0 +1,14 @@ +class Form::Sales::Questions::PurchasePrice < ::Form::Question + def initialize(id, hsh, page) + super + @id = "value" + @check_answer_label = "Purchase price" + @header = "What is the full purchase price?" + @type = "numeric" + @page = page + @min = 0 + @width = 5 + @prefix = "£" + @hint_text = "" + end +end diff --git a/app/models/form/sales/questions/resale.rb b/app/models/form/sales/questions/resale.rb new file mode 100644 index 000000000..8da7d8abd --- /dev/null +++ b/app/models/form/sales/questions/resale.rb @@ -0,0 +1,17 @@ +class Form::Sales::Questions::Resale < ::Form::Question + def initialize(id, hsh, page) + super + @id = "resale" + @check_answer_label = "Is this a resale?" + @header = "Is this a resale?" + @type = "radio" + @answer_options = ANSWER_OPTIONS + @page = page + @hint_text = "If the social landlord has previously sold the property to another buyer and is now reselling the property, select 'yes'. If this is the first time the property has been sold, select 'no'." + end + + ANSWER_OPTIONS = { + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + }.freeze +end diff --git a/app/models/form/sales/questions/staircase.rb b/app/models/form/sales/questions/staircase.rb new file mode 100644 index 000000000..e204414b9 --- /dev/null +++ b/app/models/form/sales/questions/staircase.rb @@ -0,0 +1,18 @@ +class Form::Sales::Questions::Staircase < ::Form::Question + def initialize(id, hsh, page) + super + @id = "staircase" + @check_answer_label = "Staircasing transaction" + @header = "Is this a staircasing transaction?" + @type = "radio" + @answer_options = ANSWER_OPTIONS + @page = page + @hint_text = "A staircasing transaction is when the household purchases more shares in their property, increasing the proportion they own and decreasing the proportion the housing association owns. Once the household purchases 100% of the shares, they own the property" + end + + ANSWER_OPTIONS = { + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + "3" => { "value" => "Don’t know" }, + }.freeze +end diff --git a/app/models/form/sales/questions/staircase_bought.rb b/app/models/form/sales/questions/staircase_bought.rb new file mode 100644 index 000000000..5afca794d --- /dev/null +++ b/app/models/form/sales/questions/staircase_bought.rb @@ -0,0 +1,14 @@ +class Form::Sales::Questions::StaircaseBought < ::Form::Question + def initialize(id, hsh, page) + super + @id = "stairbought" + @check_answer_label = "Percentage bought in this staircasing transaction" + @header = "What percentage of the property has been bought in this staircasing transaction?" + @type = "numeric" + @page = page + @width = 5 + @min = 0 + @max = 100 + @suffix = " percent" + end +end diff --git a/app/models/form/sales/questions/staircase_owned.rb b/app/models/form/sales/questions/staircase_owned.rb new file mode 100644 index 000000000..0fa37ec7a --- /dev/null +++ b/app/models/form/sales/questions/staircase_owned.rb @@ -0,0 +1,14 @@ +class Form::Sales::Questions::StaircaseOwned < ::Form::Question + def initialize(id, hsh, page) + super + @id = "stairowned" + @check_answer_label = "Percentage the buyer now owns in total" + @header = "What percentage of the property does the buyer now own in total?" + @type = "numeric" + @page = page + @width = 5 + @min = 0 + @max = 100 + @suffix = " percent" + end +end diff --git a/app/models/form/sales/questions/value.rb b/app/models/form/sales/questions/value.rb new file mode 100644 index 000000000..0686d6610 --- /dev/null +++ b/app/models/form/sales/questions/value.rb @@ -0,0 +1,14 @@ +class Form::Sales::Questions::Value < ::Form::Question + def initialize(id, hsh, page) + super + @id = "value" + @check_answer_label = "Full purchase price" + @header = "What was the full purchase price?" + @type = "numeric" + @page = page + @min = 0 + @width = 5 + @prefix = "£" + @hint_text = "Enter the full purchase price of the property before any discounts are applied. For shared ownership, enter the full purchase price paid for 100% equity (this is equal to the value of the share owned by the PRP plus the value bought by the purchaser)" + end +end diff --git a/app/models/form/sales/sections/sale_information.rb b/app/models/form/sales/sections/sale_information.rb new file mode 100644 index 000000000..941abad3a --- /dev/null +++ b/app/models/form/sales/sections/sale_information.rb @@ -0,0 +1,14 @@ +class Form::Sales::Sections::SaleInformation < ::Form::Section + def initialize(id, hsh, form) + super + @id = "sale_information" + @label = "Sale information" + @description = "" + @form = form + @subsections = [ + Form::Sales::Subsections::SharedOwnershipScheme.new(nil, nil, self), + Form::Sales::Subsections::DiscountedOwnershipScheme.new(nil, nil, self), + Form::Sales::Subsections::OutrightSale.new(nil, nil, self), + ] || [] + end +end diff --git a/app/models/form/sales/subsections/discounted_ownership_scheme.rb b/app/models/form/sales/subsections/discounted_ownership_scheme.rb new file mode 100644 index 000000000..4e317618e --- /dev/null +++ b/app/models/form/sales/subsections/discounted_ownership_scheme.rb @@ -0,0 +1,23 @@ +class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection + def initialize(id, hsh, section) + super + @id = "discounted_ownership_scheme" + @label = "Discounted ownership scheme" + @section = section + @depends_on = [{ "ownershipsch" => 2, "setup_completed?" => true }] + end + + def pages + @pages ||= [ + 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::MortgageAmount.new("mortgage_amount_discounted_ownership", nil, self), + Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_discounted_ownership", nil, self), + ] + end + + def displayed_in_tasklist?(log) + log.ownershipsch == 2 + end +end diff --git a/app/models/form/sales/subsections/outright_sale.rb b/app/models/form/sales/subsections/outright_sale.rb new file mode 100644 index 000000000..c9c6bbf85 --- /dev/null +++ b/app/models/form/sales/subsections/outright_sale.rb @@ -0,0 +1,21 @@ +class Form::Sales::Subsections::OutrightSale < ::Form::Subsection + def initialize(id, hsh, section) + super + @id = "outright_sale" + @label = "Outright sale" + @section = section + @depends_on = [{ "ownershipsch" => 3, "setup_completed?" => true }] + end + + def pages + @pages ||= [ + Form::Sales::Pages::PurchasePrice.new(nil, nil, self), + Form::Sales::Pages::MortgageAmount.new("mortgage_amount_outright_sale", nil, self), + Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_outright_sale", nil, self), + ] + end + + def displayed_in_tasklist?(log) + log.ownershipsch == 3 + end +end diff --git a/app/models/form/sales/subsections/shared_ownership_scheme.rb b/app/models/form/sales/subsections/shared_ownership_scheme.rb new file mode 100644 index 000000000..89a438487 --- /dev/null +++ b/app/models/form/sales/subsections/shared_ownership_scheme.rb @@ -0,0 +1,31 @@ +class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection + def initialize(id, hsh, section) + super + @id = "shared_ownership_scheme" + @label = "Shared ownership scheme" + @section = section + @depends_on = [{ "ownershipsch" => 1, "setup_completed?" => true }] + end + + def pages + @pages ||= [ + Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_shared_ownership", nil, self), + Form::Sales::Pages::Staircase.new(nil, nil, self), + Form::Sales::Pages::AboutStaircase.new(nil, nil, self), + Form::Sales::Pages::Resale.new(nil, nil, self), + Form::Sales::Pages::ExchangeDate.new(nil, nil, self), + Form::Sales::Pages::LaNominations.new(nil, nil, self), + Form::Sales::Pages::BuyerPrevious.new(nil, nil, self), + Form::Sales::Pages::PreviousBedrooms.new(nil, nil, self), + Form::Sales::Pages::AboutPriceSharedOwnership.new(nil, nil, self), + Form::Sales::Pages::MortgageAmount.new("mortgage_amount_shared_ownership", nil, self), + Form::Sales::Pages::AboutDepositWithDiscount.new(nil, nil, self), + Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_shared_ownership", nil, self), + Form::Sales::Pages::MonthlyRent.new(nil, nil, self), + ] + end + + def displayed_in_tasklist?(log) + log.ownershipsch == 1 + end +end diff --git a/app/models/form/subsection.rb b/app/models/form/subsection.rb index 07e7fe65c..0266fc448 100644 --- a/app/models/form/subsection.rb +++ b/app/models/form/subsection.rb @@ -24,9 +24,7 @@ class Form::Subsection end def status(log) - unless enabled?(log) - return :cannot_start_yet - end + return :cannot_start_yet unless enabled?(log) qs = applicable_questions(log) qs_optional_removed = qs.reject { |q| log.optional_fields.include?(q.id) } @@ -49,4 +47,8 @@ class Form::Subsection (q.displayed_to_user?(log) && !q.derived?) || q.has_inferred_check_answers_value?(log) end end + + def displayed_in_tasklist?(_log) + true + end end diff --git a/app/models/form_handler.rb b/app/models/form_handler.rb index 69b05859e..1afa1d15f 100644 --- a/app/models/form_handler.rb +++ b/app/models/form_handler.rb @@ -23,6 +23,7 @@ class FormHandler Form::Sales::Sections::PropertyInformation, Form::Sales::Sections::Household, Form::Sales::Sections::Finances, + Form::Sales::Sections::SaleInformation, ] current_form = Form.new(nil, current_collection_start_year, sales_sections, "sales") previous_form = Form.new(nil, current_collection_start_year - 1, sales_sections, "sales") diff --git a/app/models/log.rb b/app/models/log.rb index c09cdd46a..e9dc9c69a 100644 --- a/app/models/log.rb +++ b/app/models/log.rb @@ -63,7 +63,7 @@ private end def all_fields_completed? - subsection_statuses = form.subsections.map { |subsection| subsection.status(self) }.uniq + subsection_statuses = form.subsections.map { |subsection| subsection.status(self) if subsection.displayed_in_tasklist?(self) }.uniq.compact subsection_statuses == [:completed] end diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index d3066974f..65175a802 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -111,4 +111,12 @@ class SalesLog < Log def income2_used_for_mortgage? inc2mort == 1 end + + def right_to_buy? + [9, 14, 27].include?(type) + end + + def is_type_discount? + type == 18 + end end diff --git a/app/views/logs/_tasklist.html.erb b/app/views/logs/_tasklist.html.erb index 6c82eb377..df8a3afad 100644 --- a/app/views/logs/_tasklist.html.erb +++ b/app/views/logs/_tasklist.html.erb @@ -9,7 +9,7 @@ <% end %>