106 changed files with 10333 additions and 511 deletions
@ -0,0 +1,11 @@
|
||||
class Form::Lettings::Pages::ReferralDirect < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "referral_direct" |
||||
@depends_on = [{ "referral_type" => 1 }] |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [Form::Lettings::Questions::ReferralDirect.new(nil, nil, self)] |
||||
end |
||||
end |
@ -0,0 +1,12 @@
|
||||
class Form::Lettings::Pages::ReferralGeneralNeedsPrp < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "referral_prp" |
||||
@copy_key = "lettings.household_situation.referral.general_needs.prp" |
||||
@depends_on = [{ "owning_organisation_provider_type" => "PRP", "needstype" => 1, "renewal" => 0 }] |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [Form::Lettings::Questions::ReferralGeneralNeedsPrp.new(nil, nil, self)] |
||||
end |
||||
end |
@ -0,0 +1,11 @@
|
||||
class Form::Lettings::Pages::ReferralHsc < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "referral_hsc" |
||||
@depends_on = [{ "referral_type" => 4 }] |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [Form::Lettings::Questions::ReferralHsc.new(nil, nil, self)] |
||||
end |
||||
end |
@ -0,0 +1,11 @@
|
||||
class Form::Lettings::Pages::ReferralJustice < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "referral_justice" |
||||
@depends_on = [{ "referral_type" => 5 }] |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [Form::Lettings::Questions::ReferralJustice.new(nil, nil, self)] |
||||
end |
||||
end |
@ -0,0 +1,11 @@
|
||||
class Form::Lettings::Pages::ReferralLa < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "referral_la" |
||||
@depends_on = [{ "referral_type" => 2 }] |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [Form::Lettings::Questions::ReferralLa.new(nil, nil, self)] |
||||
end |
||||
end |
@ -0,0 +1,10 @@
|
||||
class Form::Lettings::Pages::ReferralType < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "referral_type" |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [Form::Lettings::Questions::ReferralType.new(nil, nil, self)] |
||||
end |
||||
end |
@ -0,0 +1,26 @@
|
||||
class Form::Lettings::Questions::ReferralDirect < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "referral" |
||||
@copy_key = "lettings.household_situation.referral.direct" |
||||
@type = "radio" |
||||
@check_answers_card_number = 0 |
||||
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] |
||||
end |
||||
|
||||
def answer_options |
||||
{ |
||||
"20" => { |
||||
"value" => "Homeless households owed a duty and not on a housing register or waiting list", |
||||
}, |
||||
"2" => { |
||||
"value" => "Tenant applied directly for an available property", |
||||
}, |
||||
"8" => { |
||||
"value" => "Relocated through official housing mobility scheme", |
||||
}, |
||||
}.freeze |
||||
end |
||||
|
||||
QUESTION_NUMBER_FROM_YEAR = { 2025 => 84 }.freeze |
||||
end |
@ -1,4 +1,4 @@
|
||||
class Form::Lettings::Questions::Referral < ::Form::Question |
||||
class Form::Lettings::Questions::ReferralGeneralNeeds < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "referral" |
@ -0,0 +1,105 @@
|
||||
class Form::Lettings::Questions::ReferralGeneralNeedsPrp < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "referral" |
||||
@copy_key = "lettings.household_situation.referral.general_needs.prp" |
||||
@type = "radio" |
||||
@check_answers_card_number = 0 |
||||
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] |
||||
end |
||||
|
||||
def answer_options |
||||
if form.start_year_2024_or_later? |
||||
{ |
||||
"1" => { |
||||
"value" => "Internal transfer", |
||||
"hint" => "Where the tenant has moved to another social property owned by the same landlord.", |
||||
}, |
||||
"2" => { |
||||
"value" => "Tenant applied directly (no referral or nomination)", |
||||
}, |
||||
"3" => { |
||||
"value" => "Nominated by a local housing authority", |
||||
}, |
||||
"8" => { |
||||
"value" => "Re-located through official housing mobility scheme", |
||||
}, |
||||
"10" => { |
||||
"value" => "Other social landlord", |
||||
}, |
||||
"9" => { |
||||
"value" => "Community learning disability team", |
||||
}, |
||||
"14" => { |
||||
"value" => "Community mental health team", |
||||
}, |
||||
"15" => { |
||||
"value" => "Health service", |
||||
}, |
||||
"18" => { |
||||
"value" => "Police, probation, prison or youth offending team – tenant had custodial sentence", |
||||
}, |
||||
"19" => { |
||||
"value" => "Police, probation, prison or youth offending team – no custodial sentence", |
||||
}, |
||||
"7" => { |
||||
"value" => "Voluntary agency", |
||||
}, |
||||
"17" => { |
||||
"value" => "Children’s Social Care", |
||||
}, |
||||
"16" => { |
||||
"value" => "Other", |
||||
}, |
||||
}.freeze |
||||
else |
||||
{ |
||||
"1" => { |
||||
"value" => "Internal transfer", |
||||
"hint" => "Where the tenant has moved to another social property owned by the same landlord.", |
||||
}, |
||||
"2" => { |
||||
"value" => "Tenant applied directly (no referral or nomination)", |
||||
}, |
||||
"3" => { |
||||
"value" => "Nominated by a local housing authority", |
||||
}, |
||||
"4" => { |
||||
"value" => "Referred by local authority housing department", |
||||
}, |
||||
"8" => { |
||||
"value" => "Re-located through official housing mobility scheme", |
||||
}, |
||||
"10" => { |
||||
"value" => "Other social landlord", |
||||
}, |
||||
"9" => { |
||||
"value" => "Community learning disability team", |
||||
}, |
||||
"14" => { |
||||
"value" => "Community mental health team", |
||||
}, |
||||
"15" => { |
||||
"value" => "Health service", |
||||
}, |
||||
"12" => { |
||||
"value" => "Police, probation or prison", |
||||
}, |
||||
"7" => { |
||||
"value" => "Voluntary agency", |
||||
}, |
||||
"13" => { |
||||
"value" => "Youth offending team", |
||||
}, |
||||
"17" => { |
||||
"value" => "Children’s Social Care", |
||||
}, |
||||
"16" => { |
||||
"value" => "Other", |
||||
}, |
||||
}.freeze |
||||
end |
||||
end |
||||
|
||||
QUESTION_NUMBER_FROM_YEAR = { 2023 => 85, 2024 => 84 }.freeze |
||||
end |
@ -0,0 +1,32 @@
|
||||
class Form::Lettings::Questions::ReferralHsc < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "referral" |
||||
@copy_key = "lettings.household_situation.referral.hsc" |
||||
@type = "radio" |
||||
@check_answers_card_number = 0 |
||||
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] |
||||
end |
||||
|
||||
def answer_options |
||||
{ |
||||
"15" => { |
||||
"value" => "Health service", |
||||
}, |
||||
"9" => { |
||||
"value" => "Community learning disability team", |
||||
}, |
||||
"14" => { |
||||
"value" => "Community mental health team", |
||||
}, |
||||
"24" => { |
||||
"value" => "Adult social services", |
||||
}, |
||||
"17" => { |
||||
"value" => "Children's social care", |
||||
}, |
||||
}.freeze |
||||
end |
||||
|
||||
QUESTION_NUMBER_FROM_YEAR = { 2025 => 84 }.freeze |
||||
end |
@ -0,0 +1,23 @@
|
||||
class Form::Lettings::Questions::ReferralJustice < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "referral" |
||||
@copy_key = "lettings.household_situation.referral.justice" |
||||
@type = "radio" |
||||
@check_answers_card_number = 0 |
||||
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] |
||||
end |
||||
|
||||
def answer_options |
||||
{ |
||||
"18" => { |
||||
"value" => "With a custodial sentence", |
||||
}, |
||||
"19" => { |
||||
"value" => "No custodial sentence", |
||||
}, |
||||
}.freeze |
||||
end |
||||
|
||||
QUESTION_NUMBER_FROM_YEAR = { 2025 => 84 }.freeze |
||||
end |
@ -0,0 +1,29 @@
|
||||
class Form::Lettings::Questions::ReferralLa < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "referral" |
||||
@copy_key = "lettings.household_situation.referral.la" |
||||
@type = "radio" |
||||
@check_answers_card_number = 0 |
||||
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] |
||||
end |
||||
|
||||
def answer_options |
||||
{ |
||||
"21" => { |
||||
"value" => "Local authority lettings", |
||||
}, |
||||
"3" => { |
||||
"value" => "PRP lettings nominated by a local authority", |
||||
}, |
||||
"4" => { |
||||
"value" => "PRP support lettings referred by a local authority", |
||||
}, |
||||
"22" => { |
||||
"value" => "Other", |
||||
}, |
||||
}.freeze |
||||
end |
||||
|
||||
QUESTION_NUMBER_FROM_YEAR = { 2025 => 84 }.freeze |
||||
end |
@ -0,0 +1,38 @@
|
||||
class Form::Lettings::Questions::ReferralType < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "referral_type" |
||||
@copy_key = "lettings.household_situation.referral.type" |
||||
@type = "radio" |
||||
@check_answers_card_number = 0 |
||||
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] |
||||
end |
||||
|
||||
def answer_options |
||||
{ |
||||
"1" => { |
||||
"value" => "Direct", |
||||
}, |
||||
"2" => { |
||||
"value" => "From a local authority housing register or waiting list", |
||||
}, |
||||
"3" => { |
||||
"value" => "From a PRP-only housing register or waiting list (no local authority involvement)", |
||||
}, |
||||
"4" => { |
||||
"value" => "Health and social care services", |
||||
}, |
||||
"5" => { |
||||
"value" => "Police, probation, prison or youth offending team", |
||||
}, |
||||
"6" => { |
||||
"value" => "Voluntary agency", |
||||
}, |
||||
"7" => { |
||||
"value" => "Other", |
||||
}, |
||||
}.freeze |
||||
end |
||||
|
||||
QUESTION_NUMBER_FROM_YEAR = { 2025 => 84 }.freeze |
||||
end |
@ -0,0 +1,122 @@
|
||||
require "csv" |
||||
|
||||
class BulkUpload::Lettings::Year2025::CsvParser |
||||
include CollectionTimeHelper |
||||
|
||||
FIELDS = 129 |
||||
MAX_COLUMNS = 130 |
||||
FORM_YEAR = 2025 |
||||
|
||||
attr_reader :path |
||||
|
||||
def initialize(path:) |
||||
@path = path |
||||
end |
||||
|
||||
def row_offset |
||||
if with_headers? |
||||
rows.find_index { |row| row[0].present? && row[0].match(/field number/i) } + 1 |
||||
else |
||||
0 |
||||
end |
||||
end |
||||
|
||||
def col_offset |
||||
with_headers? ? 1 : 0 |
||||
end |
||||
|
||||
def cols |
||||
@cols ||= ("A".."DZ").to_a |
||||
end |
||||
|
||||
def row_parsers |
||||
@row_parsers ||= body_rows.map { |row| |
||||
next if row.empty? |
||||
|
||||
stripped_row = row[col_offset..] |
||||
|
||||
hash = Hash[field_numbers.zip(stripped_row)] |
||||
|
||||
BulkUpload::Lettings::Year2025::RowParser.new(hash) |
||||
}.compact |
||||
end |
||||
|
||||
def body_rows |
||||
rows[row_offset..] |
||||
end |
||||
|
||||
def rows |
||||
@rows ||= CSV.parse(normalised_string, row_sep:) |
||||
end |
||||
|
||||
def column_for_field(field) |
||||
cols[field_numbers.find_index(field) + col_offset] |
||||
end |
||||
|
||||
def correct_field_count? |
||||
valid_field_numbers_count = field_numbers.count { |f| f != "field_blank" } |
||||
|
||||
valid_field_numbers_count == FIELDS |
||||
end |
||||
|
||||
def too_many_columns? |
||||
return if with_headers? |
||||
|
||||
max_columns_count = body_rows.map(&:size).max - col_offset |
||||
|
||||
max_columns_count > MAX_COLUMNS |
||||
end |
||||
|
||||
def wrong_template_for_year? |
||||
collection_start_year_for_date(first_record_start_date) != FORM_YEAR |
||||
rescue Date::Error |
||||
false |
||||
end |
||||
|
||||
def missing_required_headers? |
||||
!with_headers? |
||||
end |
||||
|
||||
private |
||||
|
||||
def default_field_numbers |
||||
(1..FIELDS).map { |h| h.present? && h.to_s.match?(/^[0-9]+$/) ? "field_#{h}" : "field_blank" } |
||||
end |
||||
|
||||
def field_numbers |
||||
@field_numbers ||= if with_headers? |
||||
rows[row_offset - 1][col_offset..].map { |h| h.present? && h.match?(/^[0-9]+$/) ? "field_#{h}" : "field_blank" } |
||||
else |
||||
default_field_numbers |
||||
end |
||||
end |
||||
|
||||
def with_headers? |
||||
rows.map { |r| r[0] }.any? { |cell| cell&.match?(/field number/i) } |
||||
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.scrub!("") |
||||
@normalised_string.tr!("\r", "\n") |
||||
|
||||
@normalised_string |
||||
end |
||||
|
||||
def first_record_start_date |
||||
if with_headers? |
||||
year = row_parsers.first.field_10.to_s.strip.length.between?(1, 2) ? row_parsers.first.field_10.to_i + 2000 : row_parsers.first.field_10.to_i |
||||
Date.new(year, row_parsers.first.field_9.to_i, row_parsers.first.field_8.to_i) |
||||
else |
||||
year = rows.first[9].to_s.strip.length.between?(1, 2) ? rows.first[9].to_i + 2000 : rows.first[9].to_i |
||||
Date.new(year, rows.first[8].to_i, rows.first[7].to_i) |
||||
end |
||||
end |
||||
end |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,124 @@
|
||||
require "csv" |
||||
|
||||
class BulkUpload::Sales::Year2025::CsvParser |
||||
include CollectionTimeHelper |
||||
|
||||
FIELDS = 121 |
||||
MAX_COLUMNS = 142 |
||||
FORM_YEAR = 2025 |
||||
|
||||
attr_reader :path |
||||
|
||||
def initialize(path:) |
||||
@path = path |
||||
end |
||||
|
||||
def row_offset |
||||
if with_headers? |
||||
rows.find_index { |row| row[0].present? && row[0].match(/field number/i) } + 1 |
||||
else |
||||
0 |
||||
end |
||||
end |
||||
|
||||
def col_offset |
||||
with_headers? ? 1 : 0 |
||||
end |
||||
|
||||
def cols |
||||
@cols ||= ("A".."DR").to_a |
||||
end |
||||
|
||||
def row_parsers |
||||
@row_parsers ||= body_rows.map { |row| |
||||
next if row.empty? |
||||
|
||||
stripped_row = row[col_offset..] |
||||
hash = Hash[field_numbers.zip(stripped_row)] |
||||
|
||||
BulkUpload::Sales::Year2025::RowParser.new(hash) |
||||
}.compact |
||||
end |
||||
|
||||
def body_rows |
||||
rows[row_offset..] |
||||
end |
||||
|
||||
def rows |
||||
@rows ||= CSV.parse(normalised_string, row_sep:) |
||||
end |
||||
|
||||
def column_for_field(field) |
||||
cols[field_numbers.find_index(field) + col_offset] |
||||
end |
||||
|
||||
def wrong_template_for_year? |
||||
collection_start_year_for_date(first_record_start_date) != FORM_YEAR |
||||
rescue Date::Error |
||||
false |
||||
end |
||||
|
||||
def missing_required_headers? |
||||
!with_headers? |
||||
end |
||||
|
||||
def correct_field_count? |
||||
valid_field_numbers_count = field_numbers.count { |f| f != "field_blank" } |
||||
|
||||
valid_field_numbers_count == FIELDS |
||||
end |
||||
|
||||
private |
||||
|
||||
def default_field_numbers |
||||
(1..FIELDS).map do |number| |
||||
if number.to_s.match?(/^[0-9]+$/) |
||||
"field_#{number}" |
||||
else |
||||
"field_blank" |
||||
end |
||||
end |
||||
end |
||||
|
||||
def field_numbers |
||||
@field_numbers ||= if with_headers? |
||||
rows[row_offset - 1][col_offset..].map { |number| number.to_s.match?(/^[0-9]+$/) ? "field_#{number}" : "field_blank" } |
||||
else |
||||
default_field_numbers |
||||
end |
||||
end |
||||
|
||||
def headers |
||||
@headers ||= ("field_1".."field_#{FIELDS}").to_a |
||||
end |
||||
|
||||
def with_headers? |
||||
# we will eventually want to validate that headers exist for this year |
||||
rows.map { |r| r[0] }.any? { |cell| cell&.match?(/field number/i) } |
||||
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.scrub!("") |
||||
@normalised_string.tr!("\r", "\n") |
||||
|
||||
@normalised_string |
||||
end |
||||
|
||||
def first_record_start_date |
||||
if with_headers? |
||||
year = row_parsers.first.field_3.to_s.strip.length.between?(1, 2) ? row_parsers.first.field_3.to_i + 2000 : row_parsers.first.field_3.to_i |
||||
Date.new(year, row_parsers.first.field_2.to_i, row_parsers.first.field_1.to_i) |
||||
else |
||||
year = rows.first[2].to_s.strip.length.between?(1, 2) ? rows.first[2].to_i + 2000 : rows.first[2].to_i |
||||
Date.new(year, rows.first[1].to_i, rows.first[0].to_i) |
||||
end |
||||
end |
||||
end |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,64 @@
|
||||
en: |
||||
validations: |
||||
lettings: |
||||
2025: |
||||
bulk_upload: |
||||
not_answered: "You must answer %{question}" |
||||
invalid_option: "Enter a valid value for %{question}" |
||||
invalid_number: "Enter a number for %{question}" |
||||
spreadsheet_dupe: "This is a duplicate of a log in your file." |
||||
duplicate: "This is a duplicate log." |
||||
blank_file: "Template is blank - The template must be filled in for us to create the logs and check if data is correct." |
||||
wrong_template: |
||||
wrong_template: "Incorrect start dates, please ensure you have used the correct template." |
||||
no_headers: "Your file does not contain the required header rows. Add or check the header rows and upload your file again. [Read more about using the template headers](%{guidance_link})." |
||||
wrong_field_numbers_count: "Incorrect number of fields, please ensure you have used the correct template." |
||||
over_max_column_count: "Too many columns, please ensure you have used the correct template." |
||||
owning_organisation: |
||||
not_found: "The owning organisation code is incorrect." |
||||
not_stock_owner: "The owning organisation code provided is for an organisation that does not own stock." |
||||
not_permitted: |
||||
not_support: "You do not have permission to add logs for this owning organisation." |
||||
support: "This owning organisation is not affiliated with %{org_name}." |
||||
managing_organisation: |
||||
no_relationship: "This managing organisation does not have a relationship with the owning organisation." |
||||
not_found: "The managing organisation code is incorrect." |
||||
assigned_to: |
||||
not_found: "User with the specified email could not be found." |
||||
organisation_not_related: "User must be related to owning organisation or managing organisation." |
||||
startdate: |
||||
outside_collection_window: "Enter a date within the %{year_combo} collection year, which is between 1st April %{start_year} and 31st March %{end_year}." |
||||
year_not_two_or_four_digits: "Tenancy start year must be 2 or 4 digits." |
||||
housingneeds: |
||||
no_and_dont_know_disabled_needs_conjunction: "No disabled access needs and don’t know disabled access needs cannot be selected together." |
||||
dont_know_disabled_needs_conjunction: "Don’t know disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs." |
||||
no_disabled_needs_conjunction: "No disabled access needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs." |
||||
housingneeds_type: |
||||
only_one_option_permitted: "Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected." |
||||
condition_effects: |
||||
no_choices: "You cannot answer this question as you told us nobody in the household has a physical or mental health condition (or other illness) expected to last 12 months or more." |
||||
reason: |
||||
renewal_reason_needed: "The reason for leaving must be \"End of social or private sector tenancy - no fault\", \"End of social or private sector tenancy - evicted due to anti-social behaviour (ASB)\", \"End of social or private sector tenancy - evicted due to rent arrears\" or \"End of social or private sector tenancy - evicted for any other reason\"." |
||||
referral: |
||||
general_needs_prp_referred_by_la: "The source of the referral cannot be referred by local authority housing department for a general needs log." |
||||
nominated_by_local_ha_but_la: "The source of the referral cannot be Nominated by local housing authority as your organisation is a local authority." |
||||
scheme: |
||||
must_relate_to_org: "This scheme code does not belong to the owning organisation or managing organisation." |
||||
location: |
||||
must_relate_to_org: "Location code must relate to a location that is owned by the owning organisation or managing organisation." |
||||
age: |
||||
invalid: "Age of person %{person_num} must be a number or the letter R" |
||||
address: |
||||
not_found: "We could not find this address. Check the address data in your CSV file is correct and complete, or find the correct address in the service." |
||||
not_determined: |
||||
one: "There is a possible match for this address which doesn't look right. Check the address data in your CSV file is correct and complete, or confirm the address in the service." |
||||
multiple: "There are multiple matches for this address. Check the address data in your CSV file is correct and complete, or select the correct address in the service." |
||||
not_answered: "Enter either the UPRN or the full address." |
||||
nationality: |
||||
invalid: "Select a valid nationality." |
||||
charges: |
||||
missing_charges: "Please enter the %{sentence_fragment}. If there is no %{sentence_fragment}, please enter '0'." |
||||
reasonpref: |
||||
conflict: |
||||
dont_know: "You cannot select 'Don't know' if any of the other reasonable preference reasons are also selected." |
||||
other: "You cannot select this reasonable preference reason as you've also selected 'Don't know' as a reason." |
@ -0,0 +1,46 @@
|
||||
en: |
||||
validations: |
||||
sales: |
||||
2025: |
||||
bulk_upload: |
||||
not_answered: "You must answer %{question}" |
||||
invalid_option: "Enter a valid value for %{question}" |
||||
spreadsheet_dupe: "This is a duplicate of a log in your file." |
||||
duplicate: "This is a duplicate log." |
||||
blank_file: "Template is blank - The template must be filled in for us to create the logs and check if data is correct." |
||||
wrong_template: |
||||
over_max_column_count: "Too many columns, please ensure you have used the correct template." |
||||
no_headers: "Your file does not contain the required header rows. Add or check the header rows and upload your file again. [Read more about using the template headers](%{guidance_link})." |
||||
wrong_field_numbers_count: "Incorrect number of fields, please ensure you have used the correct template." |
||||
wrong_template: "Incorrect sale dates, please ensure you have used the correct template." |
||||
numeric: |
||||
within_range: "%{field} must be between %{min} and %{max}." |
||||
owning_organisation: |
||||
not_found: "The owning organisation code is incorrect." |
||||
not_stock_owner: "The owning organisation code provided is for an organisation that does not own stock." |
||||
not_permitted: |
||||
support: "This owning organisation is not affiliated with %{name}." |
||||
not_support: "You do not have permission to add logs for this owning organisation." |
||||
assigned_to: |
||||
not_found: "User with the specified email could not be found." |
||||
organisation_not_related: "User must be related to owning organisation or managing organisation." |
||||
managing_organisation_not_related: "This organisation does not have a relationship with the owning organisation." |
||||
saledate: |
||||
outside_collection_window: "Enter a date within the %{year_combo} collection year, which is between 1st April %{start_year} and 31st March %{end_year}." |
||||
year_not_two_or_four_digits: "Sale completion year must be 2 or 4 digits." |
||||
ecstat1: |
||||
buyer_cannot_be_over_16_and_child: "Buyer 1's age cannot be 16 or over if their working situation is child under 16." |
||||
buyer_cannot_be_child: "Buyer 1 cannot have a working situation of child under 16." |
||||
age1: |
||||
buyer_cannot_be_over_16_and_child: "Buyer 1's age cannot be 16 or over if their working situation is child under 16." |
||||
ecstat2: |
||||
buyer_cannot_be_over_16_and_child: "Buyer 2's age cannot be 16 or over if their working situation is child under 16." |
||||
buyer_cannot_be_child: "Buyer 2 cannot have a working situation of child under 16." |
||||
age2: |
||||
buyer_cannot_be_over_16_and_child: "Buyer 2's age cannot be 16 or over if their working situation is child under 16." |
||||
address: |
||||
not_found: "We could not find this address. Check the address data in your CSV file is correct and complete, or select the correct address using the CORE site." |
||||
not_determined: "There are multiple matches for this address. Either select the correct address manually or correct the UPRN in the CSV file." |
||||
not_answered: "Enter either the UPRN or the full address." |
||||
nationality: |
||||
invalid: "Select a valid nationality." |
@ -0,0 +1,5 @@
|
||||
class AddReferralTypeToLettingsLogs < ActiveRecord::Migration[7.2] |
||||
def change |
||||
add_column :lettings_logs, :referral_type, :integer |
||||
end |
||||
end |
@ -0,0 +1,15 @@
|
||||
desc "Correct invalid BU reasonable preference values" |
||||
task correct_reasonpref_values: :environment do |
||||
%w[rp_homeless rp_hardship rp_medwel rp_insan_unsat rp_dontknow].each do |field| |
||||
field_invalid = "#{field} != 1 AND #{field} != 0 AND #{field} is NOT NULL" |
||||
|
||||
LettingsLog.filter_by_year(2024).where(field_invalid).find_each do |lettings_log| |
||||
lettings_log[field] = 0 |
||||
unless lettings_log.save |
||||
Rails.logger.info("Failed to save reasonpref for LettingsLog with id #{lettings_log.id}: #{lettings_log.errors.full_messages}") |
||||
end |
||||
end |
||||
|
||||
LettingsLog.filter_by_year(2023).where(field_invalid).update_all("#{field}": 0) |
||||
end |
||||
end |
@ -0,0 +1,12 @@
|
||||
desc "Bulk update logs with invalid rp_dontknow values" |
||||
task recalculate_invalid_rpdontknow: :environment do |
||||
validation_trigger_condition = "rp_dontknow = 1 AND (rp_homeless = 1 OR rp_insan_unsat = 1 OR rp_medwel = 1 OR rp_hardship = 1)" |
||||
|
||||
LettingsLog.filter_by_year(2024).where(validation_trigger_condition).find_each do |log| |
||||
log.rp_dontknow = 0 |
||||
|
||||
unless log.save |
||||
Rails.logger.info "Could not save changes to lettings log #{log.id}" |
||||
end |
||||
end |
||||
end |
Binary file not shown.
@ -0,0 +1,111 @@
|
||||
require "rails_helper" |
||||
require "rake" |
||||
|
||||
RSpec.describe "correct_reasonpref_values" do |
||||
describe ":correct_reasonpref_values", type: :task do |
||||
subject(:task) { Rake::Task["correct_reasonpref_values"] } |
||||
|
||||
let(:organisation) { create(:organisation, rent_periods: [2]) } |
||||
let(:user) { create(:user, organisation:) } |
||||
|
||||
before do |
||||
Rake.application.rake_require("tasks/correct_reasonpref_values") |
||||
Rake::Task.define_task(:environment) |
||||
task.reenable |
||||
end |
||||
|
||||
context "when the rake task is run" do |
||||
context "and any of the reasonable_preference_reason options are not 1, 0 or nil" do |
||||
let(:bulk_upload) { create(:bulk_upload, :lettings, year: 2024, rent_type_fix_status: BulkUpload.rent_type_fix_statuses[:not_applied]) } |
||||
|
||||
it "sets the options to 0" do |
||||
log = build(:lettings_log, :completed, reasonpref: 1, rp_homeless: -2, rp_hardship: 2, rp_medwel: 3, rp_insan_unsat: 4, rp_dontknow: 1, |
||||
bulk_upload:, assigned_to: user) |
||||
log.save!(validate: false) |
||||
initial_updated_at = log.updated_at |
||||
|
||||
task.invoke |
||||
log.reload |
||||
|
||||
expect(log.updated_at).not_to eq(initial_updated_at) |
||||
expect(log.status).to eq("completed") |
||||
expect(log.rp_homeless).to be(0) |
||||
expect(log.rp_hardship).to be(0) |
||||
expect(log.rp_medwel).to be(0) |
||||
expect(log.rp_insan_unsat).to be(0) |
||||
expect(log.rp_dontknow).to be(1) |
||||
end |
||||
|
||||
it "updates the reasonable preference reason values on a pending log" do |
||||
log = build(:lettings_log, :completed, status: "pending", reasonpref: 1, rp_homeless: -2, rp_hardship: 1, rp_medwel: 3, rp_insan_unsat: 4, rp_dontknow: 2, bulk_upload:, assigned_to: user) |
||||
log.save!(validate: false) |
||||
initial_updated_at = log.updated_at |
||||
expect(log.status).to eq("pending") |
||||
|
||||
task.invoke |
||||
log.reload |
||||
expect(log.rp_homeless).to be(0) |
||||
expect(log.rp_hardship).to be(1) |
||||
expect(log.rp_medwel).to be(0) |
||||
expect(log.rp_insan_unsat).to be(0) |
||||
expect(log.rp_dontknow).to be(0) |
||||
expect(log.status).to eq("pending") |
||||
expect(log.updated_at).not_to eq(initial_updated_at) |
||||
end |
||||
|
||||
it "does not update logs with valid values" do |
||||
log = build(:lettings_log, :completed, reasonpref: 1, rp_homeless: 0, rp_hardship: 1, rp_medwel: 0, rp_insan_unsat: 0, rp_dontknow: 0, bulk_upload:, assigned_to: user) |
||||
log.save!(validate: false) |
||||
initial_updated_at = log.updated_at |
||||
expect(log.status).to eq("completed") |
||||
|
||||
task.invoke |
||||
log.reload |
||||
|
||||
expect(log.status).to eq("completed") |
||||
expect(log.updated_at).to eq(initial_updated_at) |
||||
end |
||||
|
||||
it "updates the reasonable preference reason values if some of the checkbox values are valid" do |
||||
log = build(:lettings_log, :completed, status: "pending", reasonpref: 1, rp_homeless: 0, rp_hardship: 2, rp_medwel: 1, rp_insan_unsat: 0, rp_dontknow: 0, bulk_upload:, assigned_to: user) |
||||
log.save!(validate: false) |
||||
initial_updated_at = log.updated_at |
||||
expect(log.status).to eq("pending") |
||||
|
||||
task.invoke |
||||
log.reload |
||||
expect(log.rp_homeless).to be(0) |
||||
expect(log.rp_hardship).to be(0) |
||||
expect(log.rp_medwel).to be(1) |
||||
expect(log.rp_insan_unsat).to be(0) |
||||
expect(log.rp_dontknow).to be(0) |
||||
expect(log.status).to eq("pending") |
||||
expect(log.updated_at).not_to eq(initial_updated_at) |
||||
end |
||||
|
||||
it "updates the reasonable preference reason values on a 2023 log" do |
||||
log = build(:lettings_log, :completed, startdate: Time.zone.local(2023, 6, 6), reasonpref: 1, rp_homeless: 0, rp_hardship: 2, rp_medwel: 1, rp_insan_unsat: 0, rp_dontknow: 0, bulk_upload:, assigned_to: user) |
||||
log.save!(validate: false) |
||||
initial_updated_at = log.updated_at |
||||
|
||||
task.invoke |
||||
log.reload |
||||
|
||||
expect(log.updated_at).to eq(initial_updated_at) |
||||
expect(log.rp_hardship).to eq(0) |
||||
end |
||||
|
||||
it "does not update and logs error if a validation triggers" do |
||||
log = build(:lettings_log, :completed, postcode_full: "0", reasonpref: 1, rp_homeless: 0, rp_hardship: 2, rp_medwel: 1, rp_insan_unsat: 0, rp_dontknow: 0, bulk_upload:, assigned_to: user) |
||||
log.save!(validate: false) |
||||
initial_updated_at = log.updated_at |
||||
|
||||
task.invoke |
||||
log.reload |
||||
|
||||
expect(log.updated_at).to eq(initial_updated_at) |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,70 @@
|
||||
require "rails_helper" |
||||
require "rake" |
||||
|
||||
RSpec.describe "recalculate_invalid_reasonpref_dontknow" do |
||||
subject(:task) { Rake::Task["recalculate_invalid_rpdontknow"] } |
||||
|
||||
before do |
||||
Rake.application.rake_require("tasks/recalculate_invalid_reasonpref_dontknow") |
||||
Rake::Task.define_task(:environment) |
||||
task.reenable |
||||
end |
||||
|
||||
let(:invalid_logs) { create_list(:lettings_log, 5, :completed, reasonpref: 1, rp_dontknow: 1, rp_homeless: 1, rp_insan_unsat: rand(2), rp_medwel: rand(2), rp_hardship: rand(2), updated_at: Time.zone.local(2024, 4, 2, 12, 0, 0)) } |
||||
let(:pre_2024_invalid_logs) do |
||||
create_list(:lettings_log, 5, :completed, reasonpref: 1, rp_dontknow: 1, rp_homeless: 1, rp_insan_unsat: rand(2), rp_medwel: rand(2), rp_hardship: rand(2)).each do |log| |
||||
log.startdate = Time.zone.local(rand(2021..2023), 4, 1) |
||||
log.save!(validate: false) |
||||
end |
||||
end |
||||
let(:valid_logs) { create_list(:lettings_log, 3, :completed, reasonpref: 1, rp_dontknow: 0, rp_homeless: 1, rp_insan_unsat: 1, rp_medwel: rand(2), rp_hardship: rand(2), updated_at: Time.zone.local(2024, 4, 2, 12, 0, 0)) } |
||||
|
||||
it "updates the logs from 2024/25 with invalid rp_dontknow values" do |
||||
invalid_logs.each do |log| |
||||
expect(log.reasonpref).to eq(1) |
||||
expect(log.rp_dontknow).to eq(1) |
||||
expect(log.rp_homeless).to eq(1) |
||||
end |
||||
task.invoke |
||||
invalid_logs.each do |log| |
||||
log.reload |
||||
expect(log.reasonpref).to eq(1) |
||||
expect(log.rp_dontknow).to eq(0) |
||||
expect(log.rp_homeless).to eq(1) |
||||
expect(log.updated_at).not_to eq(Time.zone.local(2024, 4, 2, 12, 0, 0)) |
||||
end |
||||
end |
||||
|
||||
it "does not update the logs pre 2024 with invalid rp_dontknow values" do |
||||
pre_2024_invalid_logs.each do |log| |
||||
expect(log.reasonpref).to eq(1) |
||||
expect(log.rp_dontknow).to eq(1) |
||||
expect(log.rp_homeless).to eq(1) |
||||
end |
||||
task.invoke |
||||
pre_2024_invalid_logs.each do |log| |
||||
log.reload |
||||
expect(log.reasonpref).to eq(1) |
||||
expect(log.rp_dontknow).to eq(1) |
||||
expect(log.rp_homeless).to eq(1) |
||||
end |
||||
end |
||||
|
||||
it "does not update the logs with valid rp_dontknow values" do |
||||
valid_logs.each do |log| |
||||
expect(log.reasonpref).to eq(1) |
||||
expect(log.rp_dontknow).to eq(0) |
||||
expect(log.rp_homeless).to eq(1) |
||||
expect(log.rp_insan_unsat).to eq(1) |
||||
end |
||||
task.invoke |
||||
valid_logs.each do |log| |
||||
log.reload |
||||
expect(log.reasonpref).to eq(1) |
||||
expect(log.rp_dontknow).to eq(0) |
||||
expect(log.rp_homeless).to eq(1) |
||||
expect(log.rp_insan_unsat).to eq(1) |
||||
expect(log.updated_at).to eq(Time.zone.local(2024, 4, 2, 12, 0, 0)) |
||||
end |
||||
end |
||||
end |
@ -1,6 +1,6 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Lettings::Questions::ReferralPrp, type: :model do |
||||
RSpec.describe Form::Lettings::Questions::ReferralGeneralNeedsPrp, type: :model do |
||||
subject(:question) { described_class.new(question_id, question_definition, page) } |
||||
|
||||
let(:question_id) { nil } |
@ -1,6 +1,6 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Lettings::Questions::Referral, type: :model do |
||||
RSpec.describe Form::Lettings::Questions::ReferralGeneralNeeds, type: :model do |
||||
subject(:question) { described_class.new(question_id, question_definition, page) } |
||||
|
||||
let(:question_id) { nil } |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue