240 changed files with 3414 additions and 1442 deletions
@ -0,0 +1,27 @@ |
|||||||
|
class CsvDownloadsController < ApplicationController |
||||||
|
before_action :authenticate_user! |
||||||
|
|
||||||
|
def show |
||||||
|
@csv_download = CsvDownload.find(params[:id]) |
||||||
|
authorize @csv_download |
||||||
|
|
||||||
|
return render "errors/download_link_expired" if @csv_download.expired? |
||||||
|
end |
||||||
|
|
||||||
|
def download |
||||||
|
csv_download = CsvDownload.find(params[:id]) |
||||||
|
authorize csv_download |
||||||
|
|
||||||
|
return render "errors/download_link_expired" if csv_download.expired? |
||||||
|
|
||||||
|
downloader = Csv::Downloader.new(csv_download:) |
||||||
|
|
||||||
|
if Rails.env.development? |
||||||
|
downloader.call |
||||||
|
send_file downloader.path, filename: csv_download.filename, type: "text/csv" |
||||||
|
else |
||||||
|
presigned_url = downloader.presigned_url |
||||||
|
redirect_to presigned_url, allow_other_host: true |
||||||
|
end |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,10 @@ |
|||||||
|
class CsvDownload < ApplicationRecord |
||||||
|
enum download_type: { lettings: "lettings", sales: "sales", schemes: "schemes", locations: "locations", combined: "combined" } |
||||||
|
|
||||||
|
belongs_to :user |
||||||
|
belongs_to :organisation |
||||||
|
|
||||||
|
def expired? |
||||||
|
created_at < expiration_time.seconds.ago |
||||||
|
end |
||||||
|
end |
@ -1,12 +1,12 @@ |
|||||||
class Form::Sales::Pages::Buyer1IncomeMaxValueCheck < ::Form::Page |
class Form::Sales::Pages::Buyer1IncomeDiscountedMaxValueCheck < ::Form::Page |
||||||
def initialize(id, hsh, subsection, check_answers_card_number:) |
def initialize(id, hsh, subsection, check_answers_card_number:) |
||||||
super(id, hsh, subsection) |
super(id, hsh, subsection) |
||||||
@depends_on = [ |
@depends_on = [ |
||||||
{ |
{ |
||||||
"income1_over_soft_max?" => true, |
"income1_over_soft_max_for_discounted_ownership?" => true, |
||||||
}, |
}, |
||||||
] |
] |
||||||
@copy_key = "sales.soft_validations.income1_value_check.max" |
@copy_key = "sales.soft_validations.income1_value_check.discounted" |
||||||
@title_text = { |
@title_text = { |
||||||
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", |
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", |
||||||
"arguments" => [ |
"arguments" => [ |
@ -1,12 +1,12 @@ |
|||||||
class Form::Sales::Pages::Buyer2IncomeMaxValueCheck < ::Form::Page |
class Form::Sales::Pages::Buyer2IncomeDiscountedMaxValueCheck < ::Form::Page |
||||||
def initialize(id, hsh, subsection, check_answers_card_number:) |
def initialize(id, hsh, subsection, check_answers_card_number:) |
||||||
super(id, hsh, subsection) |
super(id, hsh, subsection) |
||||||
@depends_on = [ |
@depends_on = [ |
||||||
{ |
{ |
||||||
"income2_over_soft_max?" => true, |
"income2_over_soft_max_for_discounted_ownership?" => true, |
||||||
}, |
}, |
||||||
] |
] |
||||||
@copy_key = "sales.soft_validations.income2_value_check.max" |
@copy_key = "sales.soft_validations.income2_value_check.discounted" |
||||||
@title_text = { |
@title_text = { |
||||||
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", |
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", |
||||||
"arguments" => [ |
"arguments" => [ |
@ -0,0 +1,13 @@ |
|||||||
|
class Form::Sales::Pages::EstateManagementFee < ::Form::Page |
||||||
|
def initialize(id, hsh, subsection) |
||||||
|
super |
||||||
|
@copy_key = "sales.sale_information.management_fee" |
||||||
|
end |
||||||
|
|
||||||
|
def questions |
||||||
|
@questions ||= [ |
||||||
|
Form::Sales::Questions::HasManagementFee.new(nil, nil, self), |
||||||
|
Form::Sales::Questions::ManagementFee.new(nil, nil, self), |
||||||
|
] |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,17 @@ |
|||||||
|
class Form::Sales::Pages::MonthlyRentStaircasing < ::Form::Page |
||||||
|
def initialize(id, hsh, subsection) |
||||||
|
super |
||||||
|
@id = "monthly_rent_staircasing" |
||||||
|
@copy_key = "sales.sale_information.mrent_staircasing" |
||||||
|
@depends_on = [{ |
||||||
|
"stairowned_100?" => false, |
||||||
|
}] |
||||||
|
end |
||||||
|
|
||||||
|
def questions |
||||||
|
@questions ||= [ |
||||||
|
Form::Sales::Questions::MonthlyRentBeforeStaircasing.new(nil, nil, self), |
||||||
|
Form::Sales::Questions::MonthlyRentAfterStaircasing.new(nil, nil, self), |
||||||
|
] |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,17 @@ |
|||||||
|
class Form::Sales::Pages::MonthlyRentStaircasingOwned < ::Form::Page |
||||||
|
def initialize(id, hsh, subsection) |
||||||
|
super |
||||||
|
@id = "monthly_rent_staircasing_owned" |
||||||
|
@copy_key = "sales.sale_information.mrent_staircasing" |
||||||
|
@header = "" |
||||||
|
@depends_on = [{ |
||||||
|
"stairowned_100?" => true, |
||||||
|
}] |
||||||
|
end |
||||||
|
|
||||||
|
def questions |
||||||
|
@questions ||= [ |
||||||
|
Form::Sales::Questions::MonthlyRentBeforeStaircasing.new(nil, nil, self), |
||||||
|
] |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,15 @@ |
|||||||
|
class Form::Sales::Pages::StaircaseFirstTime < ::Form::Page |
||||||
|
def initialize(id, hsh, subsection) |
||||||
|
super(id, hsh, subsection) |
||||||
|
@id = "staircase_first_time" |
||||||
|
@depends_on = [{ |
||||||
|
"staircase" => 1, |
||||||
|
}] |
||||||
|
end |
||||||
|
|
||||||
|
def questions |
||||||
|
@questions ||= [ |
||||||
|
Form::Sales::Questions::StaircaseFirstTime.new(nil, nil, self), |
||||||
|
] |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,16 @@ |
|||||||
|
class Form::Sales::Pages::StaircaseInitialDate < ::Form::Page |
||||||
|
def initialize(id, hsh, subsection) |
||||||
|
super(id, hsh, subsection) |
||||||
|
@id = "staircase_initial_date" |
||||||
|
@header = "" |
||||||
|
@depends_on = [{ |
||||||
|
"is_firststair?" => true, |
||||||
|
}] |
||||||
|
end |
||||||
|
|
||||||
|
def questions |
||||||
|
@questions ||= [ |
||||||
|
Form::Sales::Questions::StaircaseInitialDate.new(nil, nil, self), |
||||||
|
] |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,18 @@ |
|||||||
|
class Form::Sales::Pages::StaircasePrevious < ::Form::Page |
||||||
|
def initialize(id, hsh, subsection) |
||||||
|
super(id, hsh, subsection) |
||||||
|
@id = "staircase_previous" |
||||||
|
@copy_key = "sales.sale_information.stairprevious" |
||||||
|
@depends_on = [{ |
||||||
|
"is_firststair?" => false, |
||||||
|
}] |
||||||
|
end |
||||||
|
|
||||||
|
def questions |
||||||
|
@questions ||= [ |
||||||
|
Form::Sales::Questions::StaircaseCount.new(nil, nil, self), |
||||||
|
Form::Sales::Questions::StaircaseLastDate.new(nil, nil, self), |
||||||
|
Form::Sales::Questions::StaircaseInitialDate.new(nil, nil, self), |
||||||
|
] |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,17 @@ |
|||||||
|
class Form::Sales::Pages::StaircaseSale < ::Form::Page |
||||||
|
def initialize(id, hsh, subsection) |
||||||
|
super(id, hsh, subsection) |
||||||
|
@id = "staircase_sale" |
||||||
|
@copy_key = form.start_year_2025_or_later? ? "sales.sale_information.staircasesale" : "sales.sale_information.about_staircasing.staircasesale" |
||||||
|
@depends_on = [{ |
||||||
|
"staircase" => 1, |
||||||
|
"stairowned" => 100, |
||||||
|
}] |
||||||
|
end |
||||||
|
|
||||||
|
def questions |
||||||
|
@questions ||= [ |
||||||
|
Form::Sales::Questions::StaircaseSale.new(nil, nil, self), |
||||||
|
] |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,24 @@ |
|||||||
|
class Form::Sales::Questions::HasManagementFee < ::Form::Question |
||||||
|
def initialize(id, hsh, subsection) |
||||||
|
super |
||||||
|
@id = "has_management_fee" |
||||||
|
@copy_key = "sales.sale_information.management_fee.has_management_fee" |
||||||
|
@type = "radio" |
||||||
|
@answer_options = ANSWER_OPTIONS |
||||||
|
@conditional_for = { |
||||||
|
"management_fee" => [1], |
||||||
|
} |
||||||
|
@hidden_in_check_answers = { |
||||||
|
"depends_on" => [ |
||||||
|
{ |
||||||
|
"has_management_fee" => 1, |
||||||
|
}, |
||||||
|
], |
||||||
|
} |
||||||
|
end |
||||||
|
|
||||||
|
ANSWER_OPTIONS = { |
||||||
|
"1" => { "value" => "Yes" }, |
||||||
|
"0" => { "value" => "No" }, |
||||||
|
}.freeze |
||||||
|
end |
@ -0,0 +1,12 @@ |
|||||||
|
class Form::Sales::Questions::ManagementFee < ::Form::Question |
||||||
|
def initialize(id, hsh, subsection) |
||||||
|
super |
||||||
|
@id = "management_fee" |
||||||
|
@copy_key = "sales.sale_information.management_fee.management_fee" |
||||||
|
@type = "numeric" |
||||||
|
@min = 1 |
||||||
|
@step = 0.01 |
||||||
|
@width = 5 |
||||||
|
@prefix = "£" |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,15 @@ |
|||||||
|
class Form::Sales::Questions::MonthlyRentAfterStaircasing < ::Form::Question |
||||||
|
def initialize(id, hsh, page) |
||||||
|
super |
||||||
|
@id = "mrent" |
||||||
|
@copy_key = "sales.sale_information.mrent_staircasing.poststaircasing" |
||||||
|
@type = "numeric" |
||||||
|
@min = 0 |
||||||
|
@step = 0.01 |
||||||
|
@width = 5 |
||||||
|
@prefix = "£" |
||||||
|
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] |
||||||
|
end |
||||||
|
|
||||||
|
QUESTION_NUMBER_FROM_YEAR = { 2025 => 99 }.freeze |
||||||
|
end |
@ -0,0 +1,15 @@ |
|||||||
|
class Form::Sales::Questions::MonthlyRentBeforeStaircasing < ::Form::Question |
||||||
|
def initialize(id, hsh, page) |
||||||
|
super |
||||||
|
@id = "mrentprestaircasing" |
||||||
|
@copy_key = "sales.sale_information.mrent_staircasing.prestaircasing" |
||||||
|
@type = "numeric" |
||||||
|
@min = 0 |
||||||
|
@step = 0.01 |
||||||
|
@width = 5 |
||||||
|
@prefix = "£" |
||||||
|
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] |
||||||
|
end |
||||||
|
|
||||||
|
QUESTION_NUMBER_FROM_YEAR = { 2025 => 98 }.freeze |
||||||
|
end |
@ -0,0 +1,15 @@ |
|||||||
|
class Form::Sales::Questions::StaircaseCount < ::Form::Question |
||||||
|
def initialize(id, hsh, page) |
||||||
|
super |
||||||
|
@id = "numstair" |
||||||
|
@copy_key = "sales.sale_information.stairprevious.numstair" |
||||||
|
@type = "numeric" |
||||||
|
@width = 2 |
||||||
|
@min = 2 |
||||||
|
@max = 10 |
||||||
|
@step = 1 |
||||||
|
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] |
||||||
|
end |
||||||
|
|
||||||
|
QUESTION_NUMBER_FROM_YEAR = { 2025 => 82 }.freeze |
||||||
|
end |
@ -0,0 +1,16 @@ |
|||||||
|
class Form::Sales::Questions::StaircaseFirstTime < ::Form::Question |
||||||
|
def initialize(id, hsh, page) |
||||||
|
super |
||||||
|
@id = "firststair" |
||||||
|
@type = "radio" |
||||||
|
@answer_options = ANSWER_OPTIONS |
||||||
|
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] |
||||||
|
end |
||||||
|
|
||||||
|
ANSWER_OPTIONS = { |
||||||
|
"1" => { "value" => "Yes" }, |
||||||
|
"2" => { "value" => "No" }, |
||||||
|
}.freeze |
||||||
|
|
||||||
|
QUESTION_NUMBER_FROM_YEAR = { 2025 => 81 }.freeze |
||||||
|
end |
@ -0,0 +1,11 @@ |
|||||||
|
class Form::Sales::Questions::StaircaseInitialDate < ::Form::Question |
||||||
|
def initialize(id, hsh, page) |
||||||
|
super |
||||||
|
@id = "initialpurchase" |
||||||
|
@copy_key = "sales.sale_information.stairprevious.initialpurchase" |
||||||
|
@type = "date" |
||||||
|
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] |
||||||
|
end |
||||||
|
|
||||||
|
QUESTION_NUMBER_FROM_YEAR = { 2025 => 83 }.freeze |
||||||
|
end |
@ -0,0 +1,11 @@ |
|||||||
|
class Form::Sales::Questions::StaircaseLastDate < ::Form::Question |
||||||
|
def initialize(id, hsh, page) |
||||||
|
super |
||||||
|
@id = "lasttransaction" |
||||||
|
@copy_key = "sales.sale_information.stairprevious.lasttransaction" |
||||||
|
@type = "date" |
||||||
|
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] |
||||||
|
end |
||||||
|
|
||||||
|
QUESTION_NUMBER_FROM_YEAR = { 2025 => 83 }.freeze |
||||||
|
end |
@ -0,0 +1,49 @@ |
|||||||
|
class Form::Sales::Subsections::SharedOwnershipInitialPurchase < ::Form::Subsection |
||||||
|
def initialize(id, hsh, section) |
||||||
|
super |
||||||
|
@id = "shared_ownership_initial_purchase" |
||||||
|
@label = "Shared ownership - initial purchase" |
||||||
|
@depends_on = [{ "ownershipsch" => 1, "setup_completed?" => true, "staircase" => 2 }] |
||||||
|
@copy_key = "sale_information" |
||||||
|
end |
||||||
|
|
||||||
|
def pages |
||||||
|
@pages ||= [ |
||||||
|
Form::Sales::Pages::Resale.new(nil, nil, self), |
||||||
|
Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_shared_ownership_joint_purchase", nil, self, ownershipsch: 1, joint_purchase: true), |
||||||
|
Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_shared_ownership", nil, self, ownershipsch: 1, joint_purchase: false), |
||||||
|
Form::Sales::Pages::HandoverDate.new(nil, nil, self), |
||||||
|
Form::Sales::Pages::HandoverDateCheck.new(nil, nil, self), |
||||||
|
Form::Sales::Pages::BuyerPrevious.new("buyer_previous_joint_purchase", nil, self, joint_purchase: true), |
||||||
|
Form::Sales::Pages::BuyerPrevious.new("buyer_previous_not_joint_purchase", nil, self, joint_purchase: false), |
||||||
|
Form::Sales::Pages::PreviousBedrooms.new(nil, nil, self), |
||||||
|
Form::Sales::Pages::PreviousPropertyType.new(nil, nil, self), |
||||||
|
Form::Sales::Pages::PreviousTenure.new(nil, nil, self), |
||||||
|
Form::Sales::Pages::ValueSharedOwnership.new("value_shared_ownership", nil, self), |
||||||
|
Form::Sales::Pages::AboutPriceValueCheck.new("about_price_shared_ownership_value_check", nil, self), |
||||||
|
Form::Sales::Pages::Equity.new("initial_equity", 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, 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, 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::MortgageLength.new("mortgage_length_shared_ownership", nil, self, ownershipsch: 1), |
||||||
|
Form::Sales::Pages::Deposit.new("deposit_shared_ownership", nil, self, ownershipsch: 1, optional: false), |
||||||
|
Form::Sales::Pages::Deposit.new("deposit_shared_ownership_optional", nil, self, ownershipsch: 1, optional: true), |
||||||
|
Form::Sales::Pages::DepositValueCheck.new("deposit_joint_purchase_value_check", nil, self, joint_purchase: true), |
||||||
|
Form::Sales::Pages::DepositValueCheck.new("deposit_value_check", nil, self, joint_purchase: false), |
||||||
|
Form::Sales::Pages::DepositDiscount.new("deposit_discount", nil, self, optional: false), |
||||||
|
Form::Sales::Pages::DepositDiscount.new("deposit_discount_optional", nil, self, optional: true), |
||||||
|
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, ownershipsch: 1), |
||||||
|
Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_shared_ownership_value_check", nil, self), |
||||||
|
Form::Sales::Pages::EstateManagementFee.new("estate_management_fee", nil, self), |
||||||
|
].compact |
||||||
|
end |
||||||
|
|
||||||
|
def displayed_in_tasklist?(log) |
||||||
|
log.staircase == 2 && (log.ownershipsch.nil? || log.ownershipsch == 1) |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,35 @@ |
|||||||
|
class Form::Sales::Subsections::SharedOwnershipStaircasingTransaction < ::Form::Subsection |
||||||
|
def initialize(id, hsh, section) |
||||||
|
super |
||||||
|
@id = "shared_ownership_staircasing_transaction" |
||||||
|
@label = "Shared ownership - staircasing transaction" |
||||||
|
@depends_on = [{ "ownershipsch" => 1, "setup_completed?" => true, "staircase" => 1 }] |
||||||
|
@copy_key = "sale_information" |
||||||
|
end |
||||||
|
|
||||||
|
def pages |
||||||
|
@pages ||= [ |
||||||
|
Form::Sales::Pages::AboutStaircase.new("about_staircasing_joint_purchase", nil, self, joint_purchase: true), |
||||||
|
Form::Sales::Pages::AboutStaircase.new("about_staircasing_not_joint_purchase", nil, self, joint_purchase: false), |
||||||
|
Form::Sales::Pages::StaircaseSale.new(nil, nil, self), |
||||||
|
Form::Sales::Pages::StaircaseBoughtValueCheck.new(nil, nil, self), |
||||||
|
Form::Sales::Pages::StaircaseOwnedValueCheck.new("staircase_owned_value_check_joint_purchase", nil, self, joint_purchase: true), |
||||||
|
Form::Sales::Pages::StaircaseOwnedValueCheck.new("staircase_owned_value_check_not_joint_purchase", nil, self, joint_purchase: false), |
||||||
|
Form::Sales::Pages::StaircaseFirstTime.new(nil, nil, self), |
||||||
|
Form::Sales::Pages::StaircasePrevious.new(nil, nil, self), |
||||||
|
Form::Sales::Pages::StaircaseInitialDate.new(nil, nil, self), |
||||||
|
Form::Sales::Pages::ValueSharedOwnership.new("value_shared_ownership_staircase", nil, self), |
||||||
|
Form::Sales::Pages::AboutPriceValueCheck.new("about_price_shared_ownership_value_check", nil, self), |
||||||
|
Form::Sales::Pages::Equity.new("staircase_equity", nil, self), |
||||||
|
Form::Sales::Pages::SharedOwnershipDepositValueCheck.new("shared_ownership_equity_value_check", nil, self), |
||||||
|
Form::Sales::Pages::Mortgageused.new("staircase_mortgage_used_shared_ownership", nil, self, ownershipsch: 1), |
||||||
|
Form::Sales::Pages::MonthlyRentStaircasingOwned.new(nil, nil, self), |
||||||
|
Form::Sales::Pages::MonthlyRentStaircasing.new(nil, nil, self), |
||||||
|
Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_shared_ownership_value_check", nil, self), |
||||||
|
].compact |
||||||
|
end |
||||||
|
|
||||||
|
def displayed_in_tasklist?(log) |
||||||
|
log.staircase == 1 && (log.ownershipsch.nil? || log.ownershipsch == 1) |
||||||
|
end |
||||||
|
end |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue