Browse Source
# Conflicts: # app/controllers/logs_controller.rb # app/models/sales_log.rb # db/schema.rbpull/1169/head
157 changed files with 11588 additions and 8278 deletions
@ -0,0 +1,21 @@ |
|||||||
|
class Form::Sales::Pages::ExtraBorrowingValueCheck < Form::Page |
||||||
|
def initialize(id, hsh, subsection) |
||||||
|
super |
||||||
|
@depends_on = [ |
||||||
|
{ |
||||||
|
"extra_borrowing_expected_but_not_reported?" => true, |
||||||
|
}, |
||||||
|
] |
||||||
|
@title_text = { |
||||||
|
"translation" => "soft_validations.extra_borrowing.title", |
||||||
|
} |
||||||
|
@informative_text = { |
||||||
|
} |
||||||
|
end |
||||||
|
|
||||||
|
def questions |
||||||
|
@questions ||= [ |
||||||
|
Form::Sales::Questions::ExtraBorrowingValueCheck.new(nil, nil, self), |
||||||
|
] |
||||||
|
end |
||||||
|
end |
||||||
@ -0,0 +1,13 @@ |
|||||||
|
class Form::Sales::Pages::HandoverDateCheck < ::Form::Page |
||||||
|
def initialize(id, hsh, subsection) |
||||||
|
super |
||||||
|
@depends_on = [{ "hodate_3_years_or_more_saledate?" => true }] |
||||||
|
@informative_text = {} |
||||||
|
end |
||||||
|
|
||||||
|
def questions |
||||||
|
@questions ||= [ |
||||||
|
Form::Sales::Questions::HandoverDateCheck.new(nil, nil, self), |
||||||
|
] |
||||||
|
end |
||||||
|
end |
||||||
@ -0,0 +1,43 @@ |
|||||||
|
class Form::Sales::Pages::RetirementValueCheck < Form::Sales::Pages::Person |
||||||
|
def initialize(id, hsh, subsection, person_index:) |
||||||
|
super |
||||||
|
@depends_on = [ |
||||||
|
{ |
||||||
|
"person_#{person_index}_retired_under_soft_min_age?" => true, |
||||||
|
"jointpur" => joint_purchase? ? 1 : 2, |
||||||
|
}, |
||||||
|
] |
||||||
|
@person_index = person_index |
||||||
|
@title_text = { |
||||||
|
"translation" => "soft_validations.retirement.min.title", |
||||||
|
"arguments" => [ |
||||||
|
{ |
||||||
|
"key" => "retirement_age_for_person_#{person_index}", |
||||||
|
"label" => false, |
||||||
|
"i18n_template" => "age", |
||||||
|
}, |
||||||
|
], |
||||||
|
} |
||||||
|
@informative_text = { |
||||||
|
"translation" => "soft_validations.retirement.min.hint_text", |
||||||
|
"arguments" => [ |
||||||
|
{ |
||||||
|
"key" => "plural_gender_for_person_#{person_index}", |
||||||
|
"label" => false, |
||||||
|
"i18n_template" => "gender", |
||||||
|
}, |
||||||
|
{ |
||||||
|
"key" => "retirement_age_for_person_#{person_index}", |
||||||
|
"label" => false, |
||||||
|
"i18n_template" => "age", |
||||||
|
}, |
||||||
|
], |
||||||
|
} |
||||||
|
end |
||||||
|
|
||||||
|
def questions |
||||||
|
@questions ||= [ |
||||||
|
Form::Sales::Questions::RetirementValueCheck.new(nil, nil, self, person_index: @person_index), |
||||||
|
] |
||||||
|
end |
||||||
|
end |
||||||
@ -0,0 +1,23 @@ |
|||||||
|
class Form::Sales::Questions::ExtraBorrowingValueCheck < ::Form::Question |
||||||
|
def initialize(id, hsh, page) |
||||||
|
super(id, hsh, page) |
||||||
|
@id = "extrabor_value_check" |
||||||
|
@check_answer_label = "Extra borrowing confirmation" |
||||||
|
@type = "interruption_screen" |
||||||
|
@answer_options = { |
||||||
|
"0" => { "value" => "Yes" }, |
||||||
|
"1" => { "value" => "No" }, |
||||||
|
} |
||||||
|
@hidden_in_check_answers = { |
||||||
|
"depends_on" => [ |
||||||
|
{ |
||||||
|
"extrabor_value_check" => 0, |
||||||
|
}, |
||||||
|
{ |
||||||
|
"extrabor_value_check" => 1, |
||||||
|
}, |
||||||
|
], |
||||||
|
} |
||||||
|
@header = "Are you sure there is no extra borrowing?" |
||||||
|
end |
||||||
|
end |
||||||
@ -0,0 +1,23 @@ |
|||||||
|
class Form::Sales::Questions::HandoverDateCheck < ::Form::Question |
||||||
|
def initialize(id, hsh, page) |
||||||
|
super |
||||||
|
@id = "hodate_check" |
||||||
|
@check_answer_label = "Practical completion or handover date check" |
||||||
|
@header = "Are you sure practical completion or handover date is more than 3 years before exchange date?" |
||||||
|
@type = "interruption_screen" |
||||||
|
@answer_options = { |
||||||
|
"0" => { "value" => "Yes" }, |
||||||
|
"1" => { "value" => "No" }, |
||||||
|
} |
||||||
|
@hidden_in_check_answers = { |
||||||
|
"depends_on" => [ |
||||||
|
{ |
||||||
|
"hodate_check" => 0, |
||||||
|
}, |
||||||
|
{ |
||||||
|
"hodate_check" => 1, |
||||||
|
}, |
||||||
|
], |
||||||
|
} |
||||||
|
end |
||||||
|
end |
||||||
@ -0,0 +1,24 @@ |
|||||||
|
class Form::Sales::Questions::RetirementValueCheck < ::Form::Question |
||||||
|
def initialize(id, hsh, page, person_index:) |
||||||
|
super(id, hsh, page) |
||||||
|
@id = "retirement_value_check" |
||||||
|
@check_answer_label = "Retirement confirmation" |
||||||
|
@type = "interruption_screen" |
||||||
|
@answer_options = { |
||||||
|
"0" => { "value" => "Yes" }, |
||||||
|
"1" => { "value" => "No" }, |
||||||
|
} |
||||||
|
@hidden_in_check_answers = { |
||||||
|
"depends_on" => [ |
||||||
|
{ |
||||||
|
"retirement_value_check" => 0, |
||||||
|
}, |
||||||
|
{ |
||||||
|
"retirement_value_check" => 1, |
||||||
|
}, |
||||||
|
], |
||||||
|
} |
||||||
|
@check_answers_card_number = person_index |
||||||
|
@header = "Are you sure this person is retired?" |
||||||
|
end |
||||||
|
end |
||||||
@ -0,0 +1,10 @@ |
|||||||
|
module Validations::Sales::PropertyValidations |
||||||
|
def validate_postcodes_match_if_discounted_ownership(record) |
||||||
|
return unless record.ppostcode_full.present? && record.postcode_full.present? |
||||||
|
|
||||||
|
if record.discounted_ownership_sale? && record.ppostcode_full != record.postcode_full |
||||||
|
record.errors.add :postcode_full, I18n.t("validations.property.postcode.must_match_previous") |
||||||
|
record.errors.add :ppostcode_full, I18n.t("validations.property.postcode.must_match_previous") |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
@ -0,0 +1,41 @@ |
|||||||
|
module Validations::Sales::SaleInformationValidations |
||||||
|
def validate_practical_completion_date_before_saledate(record) |
||||||
|
return if record.saledate.blank? || record.hodate.blank? |
||||||
|
|
||||||
|
unless record.saledate > record.hodate |
||||||
|
record.errors.add :hodate, "Practical completion or handover date must be before exchange date" |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
def validate_years_living_in_property_before_purchase(record) |
||||||
|
return unless record.proplen && record.proplen.nonzero? |
||||||
|
|
||||||
|
case record.type |
||||||
|
when 18 |
||||||
|
record.errors.add :type, I18n.t("validations.sale_information.proplen.social_homebuy") |
||||||
|
record.errors.add :proplen, I18n.t("validations.sale_information.proplen.social_homebuy") |
||||||
|
when 28, 29 |
||||||
|
record.errors.add :type, I18n.t("validations.sale_information.proplen.rent_to_buy") |
||||||
|
record.errors.add :proplen, I18n.t("validations.sale_information.proplen.rent_to_buy") |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
def validate_exchange_date(record) |
||||||
|
return unless record.exdate && record.saledate |
||||||
|
|
||||||
|
record.errors.add(:exdate, I18n.t("validations.sale_information.exdate.must_be_before_saledate")) if record.exdate > record.saledate |
||||||
|
|
||||||
|
return if (record.saledate.to_date - record.exdate.to_date).to_i / 365 < 1 |
||||||
|
|
||||||
|
record.errors.add(:exdate, I18n.t("validations.sale_information.exdate.must_be_less_than_1_year_from_saledate")) |
||||||
|
end |
||||||
|
|
||||||
|
def validate_previous_property_unit_type(record) |
||||||
|
return unless record.fromprop && record.frombeds |
||||||
|
|
||||||
|
if record.frombeds != 1 && record.fromprop == 2 |
||||||
|
record.errors.add :frombeds, I18n.t("validations.sale_information.previous_property_beds.property_type_bedsit") |
||||||
|
record.errors.add :fromprop, I18n.t("validations.sale_information.previous_property_type.property_type_bedsit") |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
@ -0,0 +1,58 @@ |
|||||||
|
require "csv" |
||||||
|
|
||||||
|
class BulkUpload::Lettings::CsvParser |
||||||
|
attr_reader :path |
||||||
|
|
||||||
|
def initialize(path:) |
||||||
|
@path = path |
||||||
|
end |
||||||
|
|
||||||
|
def row_offset |
||||||
|
with_headers? ? 5 : 0 |
||||||
|
end |
||||||
|
|
||||||
|
def col_offset |
||||||
|
with_headers? ? 1 : 0 |
||||||
|
end |
||||||
|
|
||||||
|
def cols |
||||||
|
@cols ||= ("A".."EE").to_a |
||||||
|
end |
||||||
|
|
||||||
|
def row_parsers |
||||||
|
@row_parsers ||= body_rows.map do |row| |
||||||
|
stripped_row = row[col_offset..] |
||||||
|
headers = ("field_1".."field_134").to_a |
||||||
|
hash = Hash[headers.zip(stripped_row)] |
||||||
|
|
||||||
|
BulkUpload::Lettings::RowParser.new(hash) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
def body_rows |
||||||
|
rows[row_offset..] |
||||||
|
end |
||||||
|
|
||||||
|
def rows |
||||||
|
@rows ||= CSV.parse(normalised_string, row_sep:) |
||||||
|
end |
||||||
|
|
||||||
|
private |
||||||
|
|
||||||
|
def with_headers? |
||||||
|
rows[0][0]&.match?(/\D+/) |
||||||
|
end |
||||||
|
|
||||||
|
def row_sep |
||||||
|
"\n" |
||||||
|
end |
||||||
|
|
||||||
|
def normalised_string |
||||||
|
return @normalised_string if @normalised_string |
||||||
|
|
||||||
|
@normalised_string = File.read(path, encoding: "bom|utf-8") |
||||||
|
@normalised_string.gsub!("\r\n", "\n") |
||||||
|
|
||||||
|
@normalised_string |
||||||
|
end |
||||||
|
end |
||||||
@ -0,0 +1,57 @@ |
|||||||
|
class BulkUpload::Lettings::LogCreator |
||||||
|
attr_reader :bulk_upload, :path |
||||||
|
|
||||||
|
def initialize(bulk_upload:, path:) |
||||||
|
@bulk_upload = bulk_upload |
||||||
|
@path = path |
||||||
|
end |
||||||
|
|
||||||
|
def call |
||||||
|
row_parsers.each do |row_parser| |
||||||
|
row_parser.valid? |
||||||
|
|
||||||
|
row_parser.log.blank_invalid_non_setup_fields! |
||||||
|
row_parser.log.bulk_upload = bulk_upload |
||||||
|
|
||||||
|
begin |
||||||
|
row_parser.log.save! |
||||||
|
rescue StandardError => e |
||||||
|
Sentry.capture_exception(e) |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
private |
||||||
|
|
||||||
|
def csv_parser |
||||||
|
@csv_parser ||= BulkUpload::Lettings::CsvParser.new(path:) |
||||||
|
end |
||||||
|
|
||||||
|
def row_offset |
||||||
|
csv_parser.row_offset |
||||||
|
end |
||||||
|
|
||||||
|
def col_offset |
||||||
|
csv_parser.col_offset |
||||||
|
end |
||||||
|
|
||||||
|
def row_parsers |
||||||
|
return @row_parsers if @row_parsers |
||||||
|
|
||||||
|
@row_parsers = csv_parser.row_parsers |
||||||
|
|
||||||
|
@row_parsers.each do |row_parser| |
||||||
|
row_parser.bulk_upload = bulk_upload |
||||||
|
end |
||||||
|
|
||||||
|
@row_parsers |
||||||
|
end |
||||||
|
|
||||||
|
def body_rows |
||||||
|
csv_parser.body_rows |
||||||
|
end |
||||||
|
|
||||||
|
def rows |
||||||
|
csv_parser.rows |
||||||
|
end |
||||||
|
end |
||||||
@ -1,17 +0,0 @@ |
|||||||
<%= govuk_details(summary_text: "What counts as income?") do %> |
|
||||||
<p class="govuk-body">You should include any income from:</p> |
|
||||||
<ul class="govuk-list govuk-list--bullet"> |
|
||||||
<li>employment</li> |
|
||||||
<li>pensions</li> |
|
||||||
<li>investments</li> |
|
||||||
<li>Universal Credit</li> |
|
||||||
</ul> |
|
||||||
|
|
||||||
<p class="govuk-body">Don’t include:</p> |
|
||||||
<ul class="govuk-list govuk-list--bullet"> |
|
||||||
<li>National Insurance (NI) contributions and tax</li> |
|
||||||
<li>housing benefit</li> |
|
||||||
<li>child benefit</li> |
|
||||||
<li>council tax support</li> |
|
||||||
</ul> |
|
||||||
<% end %> |
|
||||||
@ -1,16 +1,22 @@ |
|||||||
<div class="app-card"> |
<div class="app-card"> |
||||||
<h2 class="govuk-heading-s">Collection resources</h2> |
<p class="govuk-body-l govuk-!-margin-bottom-3">Collection resources</p> |
||||||
|
<p class="govuk-body govuk-!-margin-bottom-6">For lettings starting during 1 April 2023 - 31 March 2024 and sales completing during the same period, use the 23/24 forms.</p> |
||||||
|
|
||||||
|
<h2 class="govuk-body-l govuk-!-margin-bottom-3">Lettings 23/24</h2> |
||||||
|
<%= render DocumentListComponent.new(items: [ |
||||||
|
{ |
||||||
|
name: "Lettings log for tenants (2023/24)", |
||||||
|
href: "https://core.communities.gov.uk/public/download/guides-and-manuals/2023-24%20Lettings%20paper%20form.pdf?download-format=pdf", |
||||||
|
metadata: "PDF, 281 KB, 8 pages", |
||||||
|
}, |
||||||
|
]) %> |
||||||
|
|
||||||
|
<h2 class="govuk-body-l govuk-!-margin-bottom-3">Lettings 22/23</h2> |
||||||
<%= render DocumentListComponent.new(items: [ |
<%= render DocumentListComponent.new(items: [ |
||||||
{ |
{ |
||||||
name: "Lettings log for tenants (2022/23)", |
name: "Lettings log for tenants (2022/23)", |
||||||
href: "https://core.communities.gov.uk/public/download/guides-and-manuals/2022-23%20Lettings%20paper%20form.pdf?download-format=pdf", |
href: "https://core.communities.gov.uk/public/download/guides-and-manuals/2022-23%20Lettings%20paper%20form.pdf?download-format=pdf", |
||||||
metadata: "PDF, 654 KB, 4 pages", |
metadata: "PDF, 654 KB, 4 pages", |
||||||
}, |
}, |
||||||
{ |
|
||||||
name: "Lettings log for tenants (2021/22)", |
|
||||||
href: "https://core.communities.gov.uk/public/download/guides-and-manuals/2021_22%20Lettings%20Log.pdf?download-format=pdf", |
|
||||||
metadata: "PDF, 302 KB, 3 pages", |
|
||||||
}, |
|
||||||
]) %> |
]) %> |
||||||
</div> |
</div> |
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,6 @@ |
|||||||
|
class AddBulkUploadToLogs < ActiveRecord::Migration[7.0] |
||||||
|
def change |
||||||
|
add_reference :lettings_logs, :bulk_upload |
||||||
|
add_reference :sales_logs, :bulk_upload |
||||||
|
end |
||||||
|
end |
||||||
@ -0,0 +1,7 @@ |
|||||||
|
class AddRetirementValueCheckToSales < ActiveRecord::Migration[7.0] |
||||||
|
def change |
||||||
|
change_table :sales_logs, bulk: true do |t| |
||||||
|
t.column :retirement_value_check, :integer |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
@ -0,0 +1,7 @@ |
|||||||
|
class AddHoDateCheck < ActiveRecord::Migration[7.0] |
||||||
|
def change |
||||||
|
change_table :sales_logs, bulk: true do |t| |
||||||
|
t.column :hodate_check, :integer |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
@ -0,0 +1,7 @@ |
|||||||
|
class AddExtraBorrowingValueCheckToSales < ActiveRecord::Migration[7.0] |
||||||
|
def change |
||||||
|
change_table :sales_logs, bulk: true do |t| |
||||||
|
t.column :extrabor_value_check, :integer |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
Can't render this file because it has a wrong number of fields in line 72.
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue