From 2f986fe11154b9ba1ab126224fb8fa0f18a7c200 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Wed, 13 Sep 2023 17:54:30 +0100 Subject: [PATCH] CLDC-2795 Update charges validations (#1912) * Update charges hard maximums * Add charges value check fields * Add 2023 charges value check pages and questions * add scharge_over_soft_max method * add LA cases * Add pscharge_over_soft_max method * Add supcharg_over_soft_max method * Add pages to subsections (2023) and update content * Confirm soft validations when importing * csv tests * Fix copy for 2022 --- .../lettings/pages/pscharge_value_check.rb | 24 + .../lettings/pages/scharge_value_check.rb | 24 + .../lettings/pages/supcharg_value_check.rb | 24 + .../questions/pscharge_value_check.rb | 15 + .../lettings/questions/scharge_value_check.rb | 15 + .../questions/supcharg_value_check.rb | 15 + .../subsections/income_and_benefits.rb | 3 + .../validations/financial_validations.rb | 24 +- app/models/validations/soft_validations.rb | 36 + .../imports/lettings_logs_import_service.rb | 5 +- config/forms/2022_2023.json | 135 ++++ config/locales/en.yml | 34 +- ...20230913093443_add_charges_value_checks.rb | 9 + db/schema.rb | 5 +- .../files/lettings_log_csv_export_codes.csv | 4 +- .../files/lettings_log_csv_export_labels.csv | 4 +- ...tings_log_csv_export_non_support_codes.csv | 4 +- ...ings_log_csv_export_non_support_labels.csv | 4 +- .../subsections/income_and_benefits_spec.rb | 3 + .../validations/financial_validations_spec.rb | 144 ++-- .../validations/soft_validations_spec.rb | 642 ++++++++++++++++++ .../lettings_logs_import_service_spec.rb | 41 +- 22 files changed, 1105 insertions(+), 109 deletions(-) create mode 100644 app/models/form/lettings/pages/pscharge_value_check.rb create mode 100644 app/models/form/lettings/pages/scharge_value_check.rb create mode 100644 app/models/form/lettings/pages/supcharg_value_check.rb create mode 100644 app/models/form/lettings/questions/pscharge_value_check.rb create mode 100644 app/models/form/lettings/questions/scharge_value_check.rb create mode 100644 app/models/form/lettings/questions/supcharg_value_check.rb create mode 100644 db/migrate/20230913093443_add_charges_value_checks.rb diff --git a/app/models/form/lettings/pages/pscharge_value_check.rb b/app/models/form/lettings/pages/pscharge_value_check.rb new file mode 100644 index 000000000..89cca160e --- /dev/null +++ b/app/models/form/lettings/pages/pscharge_value_check.rb @@ -0,0 +1,24 @@ +class Form::Lettings::Pages::PschargeValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "pscharge_value_check" + @depends_on = [{ "pscharge_over_soft_max?" => true }] + @title_text = { + "translation" => "soft_validations.pscharge.over_soft_max_title", + "arguments" => [{ + "key" => "pscharge", + "label" => true, + "i18n_template" => "pscharge", + }], + } + @informative_text = I18n.t("soft_validations.charges.informative_text") + end + + def questions + @questions ||= [Form::Lettings::Questions::PschargeValueCheck.new(nil, nil, self)] + end + + def interruption_screen_question_ids + %w[period needstype pscharge] + end +end diff --git a/app/models/form/lettings/pages/scharge_value_check.rb b/app/models/form/lettings/pages/scharge_value_check.rb new file mode 100644 index 000000000..72ad8039e --- /dev/null +++ b/app/models/form/lettings/pages/scharge_value_check.rb @@ -0,0 +1,24 @@ +class Form::Lettings::Pages::SchargeValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "scharge_value_check" + @depends_on = [{ "scharge_over_soft_max?" => true }] + @title_text = { + "translation" => "soft_validations.scharge.over_soft_max_title", + "arguments" => [{ + "key" => "scharge", + "label" => true, + "i18n_template" => "scharge", + }], + } + @informative_text = I18n.t("soft_validations.charges.informative_text") + end + + def questions + @questions ||= [Form::Lettings::Questions::SchargeValueCheck.new(nil, nil, self)] + end + + def interruption_screen_question_ids + %w[period needstype scharge] + end +end diff --git a/app/models/form/lettings/pages/supcharg_value_check.rb b/app/models/form/lettings/pages/supcharg_value_check.rb new file mode 100644 index 000000000..8155a28bb --- /dev/null +++ b/app/models/form/lettings/pages/supcharg_value_check.rb @@ -0,0 +1,24 @@ +class Form::Lettings::Pages::SupchargValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "supcharg_value_check" + @depends_on = [{ "supcharg_over_soft_max?" => true }] + @title_text = { + "translation" => "soft_validations.supcharg.over_soft_max_title", + "arguments" => [{ + "key" => "supcharg", + "label" => true, + "i18n_template" => "supcharg", + }], + } + @informative_text = I18n.t("soft_validations.charges.informative_text") + end + + def questions + @questions ||= [Form::Lettings::Questions::SupchargValueCheck.new(nil, nil, self)] + end + + def interruption_screen_question_ids + %w[period needstype supcharg] + end +end diff --git a/app/models/form/lettings/questions/pscharge_value_check.rb b/app/models/form/lettings/questions/pscharge_value_check.rb new file mode 100644 index 000000000..b44979ae1 --- /dev/null +++ b/app/models/form/lettings/questions/pscharge_value_check.rb @@ -0,0 +1,15 @@ +class Form::Lettings::Questions::PschargeValueCheck < ::Form::Question + def initialize(id, hsh, page) + super + @id = "pscharge_value_check" + @check_answer_label = "Personal service charge confirmation" + @header = "Are you sure?" + @type = "interruption_screen" + @check_answers_card_number = 0 + @answer_options = ANSWER_OPTIONS + @hidden_in_check_answers = { "depends_on" => [{ "pscharge_value_check" => 0 }, { "pscharge_value_check" => 1 }] } + @hint_text = I18n.t("soft_validations.charges.hint_text") + end + + ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/questions/scharge_value_check.rb b/app/models/form/lettings/questions/scharge_value_check.rb new file mode 100644 index 000000000..1946d603f --- /dev/null +++ b/app/models/form/lettings/questions/scharge_value_check.rb @@ -0,0 +1,15 @@ +class Form::Lettings::Questions::SchargeValueCheck < ::Form::Question + def initialize(id, hsh, page) + super + @id = "scharge_value_check" + @check_answer_label = "Service charge confirmation" + @header = "Are you sure?" + @type = "interruption_screen" + @check_answers_card_number = 0 + @answer_options = ANSWER_OPTIONS + @hidden_in_check_answers = { "depends_on" => [{ "scharge_value_check" => 0 }, { "scharge_value_check" => 1 }] } + @hint_text = I18n.t("soft_validations.charges.hint_text") + end + + ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/questions/supcharg_value_check.rb b/app/models/form/lettings/questions/supcharg_value_check.rb new file mode 100644 index 000000000..978c5e3ef --- /dev/null +++ b/app/models/form/lettings/questions/supcharg_value_check.rb @@ -0,0 +1,15 @@ +class Form::Lettings::Questions::SupchargValueCheck < ::Form::Question + def initialize(id, hsh, page) + super + @id = "supcharg_value_check" + @check_answer_label = "Support charge confirmation" + @header = "Are you sure?" + @type = "interruption_screen" + @check_answers_card_number = 0 + @answer_options = ANSWER_OPTIONS + @hidden_in_check_answers = { "depends_on" => [{ "supcharg_value_check" => 0 }, { "supcharg_value_check" => 1 }] } + @hint_text = I18n.t("soft_validations.charges.hint_text") + end + + ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/subsections/income_and_benefits.rb b/app/models/form/lettings/subsections/income_and_benefits.rb index 25f5d0ce4..1404ebf04 100644 --- a/app/models/form/lettings/subsections/income_and_benefits.rb +++ b/app/models/form/lettings/subsections/income_and_benefits.rb @@ -26,6 +26,9 @@ class Form::Lettings::Subsections::IncomeAndBenefits < ::Form::Subsection Form::Lettings::Pages::RentMonthly.new(nil, nil, self), Form::Lettings::Pages::MinRentValueCheck.new("brent_min_rent_value_check", nil, self, check_answers_card_number: 0), Form::Lettings::Pages::MaxRentValueCheck.new("brent_max_rent_value_check", nil, self, check_answers_card_number: 0), + Form::Lettings::Pages::SchargeValueCheck.new(nil, nil, self), + Form::Lettings::Pages::PschargeValueCheck.new(nil, nil, self), + Form::Lettings::Pages::SupchargValueCheck.new(nil, nil, self), Form::Lettings::Pages::Outstanding.new(nil, nil, self), Form::Lettings::Pages::OutstandingAmount.new(nil, nil, self), ].compact diff --git a/app/models/validations/financial_validations.rb b/app/models/validations/financial_validations.rb index 5a1775db4..29c22eb62 100644 --- a/app/models/validations/financial_validations.rb +++ b/app/models/validations/financial_validations.rb @@ -149,32 +149,32 @@ private CHARGE_MAXIMUMS = { scharge: { private_registered_provider: { - general_needs: 155, - supported_housing: 480, + general_needs: 800, + supported_housing: 800, }, local_authority: { - general_needs: 155, - supported_housing: 365, + general_needs: 500, + supported_housing: 500, }, }, pscharge: { private_registered_provider: { - general_needs: 30, - supported_housing: 200, + general_needs: 700, + supported_housing: 700, }, local_authority: { - general_needs: 35, - supported_housing: 75, + general_needs: 200, + supported_housing: 200, }, }, supcharg: { private_registered_provider: { - general_needs: 40, - supported_housing: 465, + general_needs: 800, + supported_housing: 800, }, local_authority: { - general_needs: 60, - supported_housing: 120, + general_needs: 200, + supported_housing: 200, }, }, }.freeze diff --git a/app/models/validations/soft_validations.rb b/app/models/validations/soft_validations.rb index 303f525cd..5720c0f0d 100644 --- a/app/models/validations/soft_validations.rb +++ b/app/models/validations/soft_validations.rb @@ -97,6 +97,42 @@ module Validations::SoftValidations net_income_in_soft_max_range? ? "higher" : "lower" end + def scharge_over_soft_max? + return unless scharge && period && needstype + return if weekly_value(scharge).blank? + + max = if needstype == 1 + owning_organisation.provider_type == "LA" ? 25 : 35 + else + owning_organisation.provider_type == "LA" ? 100 : 200 + end + weekly_value(scharge) > max + end + + def pscharge_over_soft_max? + return unless pscharge && period && needstype + return if weekly_value(pscharge).blank? + + max = if needstype == 1 + owning_organisation.provider_type == "LA" ? 25 : 35 + else + owning_organisation.provider_type == "LA" ? 75 : 100 + end + weekly_value(pscharge) > max + end + + def supcharg_over_soft_max? + return unless supcharg && period && needstype + return if weekly_value(supcharg).blank? + + max = if needstype == 1 + owning_organisation.provider_type == "LA" ? 25 : 35 + else + owning_organisation.provider_type == "LA" ? 75 : 85 + end + weekly_value(supcharg) > max + end + private def details_known_or_lead_tenant?(tenant_number) diff --git a/app/services/imports/lettings_logs_import_service.rb b/app/services/imports/lettings_logs_import_service.rb index 865f8417f..e8ed9a058 100644 --- a/app/services/imports/lettings_logs_import_service.rb +++ b/app/services/imports/lettings_logs_import_service.rb @@ -243,6 +243,9 @@ module Imports attributes["net_income_value_check"] = 0 attributes["carehome_charges_value_check"] = 0 attributes["referral_value_check"] = 0 + attributes["scharge_value_check"] = 0 + attributes["pscharge_value_check"] = 0 + attributes["supcharg_value_check"] = 0 # Sets the log creator owner_id = meta_field_value(xml_doc, "owner-user-id").strip @@ -402,7 +405,7 @@ module Imports end def fields_not_present_in_softwire_data - %w[majorrepairs illness_type_0 tshortfall_known pregnancy_value_check retirement_value_check rent_value_check net_income_value_check major_repairs_date_value_check void_date_value_check carehome_charges_value_check referral_value_check housingneeds_type housingneeds_other created_by uprn_known uprn_confirmed] + %w[majorrepairs illness_type_0 tshortfall_known pregnancy_value_check retirement_value_check rent_value_check net_income_value_check major_repairs_date_value_check void_date_value_check carehome_charges_value_check referral_value_check scharge_value_check pscharge_value_check supcharg_value_check housingneeds_type housingneeds_other created_by uprn_known uprn_confirmed] end def check_status_completed(lettings_log, previous_status) diff --git a/config/forms/2022_2023.json b/config/forms/2022_2023.json index 0fea72f3b..ac2da385d 100644 --- a/config/forms/2022_2023.json +++ b/config/forms/2022_2023.json @@ -8364,6 +8364,141 @@ }, "interruption_screen_question_ids": ["brent", "startdate", "la", "beds", "rent_type", "needstype"] }, + "scharge_value_check": { + "depends_on": [ + { + "scharge_over_soft_max?": true + } + ], + "title_text": { + "translation": "soft_validations.scharge.over_soft_max_title", + "arguments": [ + { + "key": "scharge", + "label": true, + "i18n_template": "scharge" + } + ] + }, + "informative_text": {}, + "questions": { + "scharge_value_check": { + "check_answer_label": "Service charge confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "scharge_value_check": 0 + }, + { + "scharge_value_check": 1 + } + ] + }, + "header": "Are you sure?", + "hint_text": "This is higher than we would expect. Check:", + "type": "interruption_screen", + "answer_options": { + "0": { + "value": "Yes" + }, + "1": { + "value": "No" + } + } + } + }, + "interruption_screen_question_ids": ["period", "needstype", "scharge"] + }, + "pscharge_value_check": { + "depends_on": [ + { + "pscharge_over_soft_max?": true + } + ], + "title_text": { + "translation": "soft_validations.pscharge.over_soft_max_title", + "arguments": [ + { + "key": "pscharge", + "label": true, + "i18n_template": "pscharge" + } + ] + }, + "informative_text": {}, + "questions": { + "pscharge_value_check": { + "check_answer_label": "Personal service charge confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "pscharge_value_check": 0 + }, + { + "pscharge_value_check": 1 + } + ] + }, + "header": "Are you sure?", + "hint_text": "This is higher than we would expect. Check:", + "type": "interruption_screen", + "answer_options": { + "0": { + "value": "Yes" + }, + "1": { + "value": "No" + } + } + } + }, + "interruption_screen_question_ids": ["period", "needstype", "pscharge"] + }, + "supcharg_value_check": { + "depends_on": [ + { + "supcharg_over_soft_max?": true + } + ], + "title_text": { + "translation": "soft_validations.supcharg.over_soft_max_title", + "arguments": [ + { + "key": "supcharg", + "label": true, + "i18n_template": "supcharg" + } + ] + }, + "informative_text": {}, + "questions": { + "supcharg_value_check": { + "check_answer_label": "Personal service charge confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "supcharg_value_check": 0 + }, + { + "supcharg_value_check": 1 + } + ] + }, + "header": "Are you sure?", + "hint_text": "This is higher than we would expect. Check:", + "type": "interruption_screen", + "answer_options": { + "0": { + "value": "Yes" + }, + "1": { + "value": "No" + } + } + } + }, + "interruption_screen_question_ids": ["period", "needstype", "supcharg"] + }, "outstanding": { "header": "", "description": "", diff --git a/config/locales/en.yml b/config/locales/en.yml index 8f53b4590..c982f9592 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -369,25 +369,25 @@ en: less_than_shortfall: "Enter an amount that is more than the shortfall in basic rent" scharge: private_registered_provider: - general_needs: "Enter a value for the service charge between £0 and £155 per week if the landlord is a private registered provider and it is a general needs letting" - supported_housing: "Enter a value for the service charge between £0 and £480 per week if the landlord is a private registered provider and it is a supported housing letting" + general_needs: "Enter a value for the service charge between £0 and £800 per week if the landlord is a private registered provider and it is a general needs letting" + supported_housing: "Enter a value for the service charge between £0 and £800 per week if the landlord is a private registered provider and it is a supported housing letting" local_authority: - general_needs: "Enter a value for the service charge between £0 and £155 per week if the landlord is a local authority and it is a general needs letting" - supported_housing: "Enter a value for the service charge between £0 and £365 per week if the landlord is a local authority and it is a supported housing letting" + general_needs: "Enter a value for the service charge between £0 and £500 per week if the landlord is a local authority and it is a general needs letting" + supported_housing: "Enter a value for the service charge between £0 and £500 per week if the landlord is a local authority and it is a supported housing letting" pscharge: private_registered_provider: - general_needs: "Enter a value for the personal service charge between £0 and £30 per week if the landlord is a private registered provider and it is a general needs letting" - supported_housing: "Enter a value for the personal service charge between £0 and £200 per week if the landlord is a private registered provider and it is a supported housing letting" + general_needs: "Enter a value for the personal service charge between £0 and £700 per week if the landlord is a private registered provider and it is a general needs letting" + supported_housing: "Enter a value for the personal service charge between £0 and £700 per week if the landlord is a private registered provider and it is a supported housing letting" local_authority: - general_needs: "Enter a value for the personal service charge between £0 and £35 per week if the landlord is a local authority and it is a general needs letting" - supported_housing: "Enter a value for the personal service charge between £0 and £75 per week if the landlord is a local authority and it is a supported housing letting" + general_needs: "Enter a value for the personal service charge between £0 and £200 per week if the landlord is a local authority and it is a general needs letting" + supported_housing: "Enter a value for the personal service charge between £0 and £200 per week if the landlord is a local authority and it is a supported housing letting" supcharg: private_registered_provider: - general_needs: "Enter a value for the support charge between £0 and £40 per week if the landlord is a private registered provider and it is a general needs letting" - supported_housing: "Enter a value for the support charge between £0 and £465 per week if the landlord is a private registered provider and it is a supported housing letting" + general_needs: "Enter a value for the support charge between £0 and £800 per week if the landlord is a private registered provider and it is a general needs letting" + supported_housing: "Enter a value for the support charge between £0 and £800 per week if the landlord is a private registered provider and it is a supported housing letting" local_authority: - general_needs: "Enter a value for the support charge between £0 and £60 per week if the landlord is a local authority and it is a general needs letting" - supported_housing: "Enter a value for the support charge between £0 and £120 per week if the landlord is a local authority and it is a supported housing letting" + general_needs: "Enter a value for the support charge between £0 and £200 per week if the landlord is a local authority and it is a general needs letting" + supported_housing: "Enter a value for the support charge between £0 and £200 per week if the landlord is a local authority and it is a supported housing letting" ecstat: over_hard_max: "Net income of %{hard_max} per week is too high given the tenant’s working situation" brent: @@ -709,6 +709,16 @@ Make sure these answers are correct." referral: title_text: "Are you sure?" hint_text: "This is a general needs log, and this referral type is for supported housing." + scharge: + over_soft_max_title: "You told us the service charge is %{scharge}" + pscharge: + over_soft_max_title: "You told us the personal service charge is %{pscharge}" + supcharg: + over_soft_max_title: "You told us the support charge is %{supcharg}" + charges: + informative_text: "This is higher than we would expect." + hint_text: "Check the following:" + devise: email: diff --git a/db/migrate/20230913093443_add_charges_value_checks.rb b/db/migrate/20230913093443_add_charges_value_checks.rb new file mode 100644 index 000000000..c220b0998 --- /dev/null +++ b/db/migrate/20230913093443_add_charges_value_checks.rb @@ -0,0 +1,9 @@ +class AddChargesValueChecks < ActiveRecord::Migration[7.0] + def change + change_table :lettings_logs, bulk: true do |t| + t.column :supcharg_value_check, :integer + t.column :scharge_value_check, :integer + t.column :pscharge_value_check, :integer + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 26aef31ac..e353ff9c7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_09_12_115233) do +ActiveRecord::Schema[7.0].define(version: 2023_09_13_093443) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -299,6 +299,9 @@ ActiveRecord::Schema[7.0].define(version: 2023_09_12_115233) do t.integer "creation_method", default: 1 t.datetime "values_updated_at" t.integer "referral_value_check" + t.integer "supcharg_value_check" + t.integer "scharge_value_check" + t.integer "pscharge_value_check" t.index ["bulk_upload_id"], name: "index_lettings_logs_on_bulk_upload_id" t.index ["created_by_id"], name: "index_lettings_logs_on_created_by_id" t.index ["location_id"], name: "index_lettings_logs_on_location_id" diff --git a/spec/fixtures/files/lettings_log_csv_export_codes.csv b/spec/fixtures/files/lettings_log_csv_export_codes.csv index 6076d253b..41e8cadde 100644 --- a/spec/fixtures/files/lettings_log_csv_export_codes.csv +++ b/spec/fixtures/files/lettings_log_csv_export_codes.csv @@ -1,2 +1,2 @@ -id,status,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,rent_type_detail,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,uprn_confirmed,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,pregnancy_value_check,age1_known,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,national,ecstat1,details_known_2,relat2,age2_known,age2,sex2,ecstat2,details_known_3,relat3,age3_known,age3,sex3,ecstat3,details_known_4,relat4,age4_known,age4,sex4,ecstat4,details_known_5,relat5,age5_known,age5,sex5,ecstat5,details_known_6,relat6,age6_known,age6,sex6,ecstat6,details_known_7,relat7,age7_known,age7,sex7,ecstat7,details_known_8,relat8,age8_known,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,new_old,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_unknown,referral,referral_value_check,net_income_known,incref,earnings,incfreq,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_admin_district,location_startdate -,completed,s.port@jeemayle.com,false,2023-06-26T00:00:00+01:00,,2023-06-26T00:00:00+01:00,1,,,2023,DLUHC,DLUHC,1,7,0,2023-06-26T00:00:00+01:00,2,1,,,,HIJKLMN,ABCDEFG,0,,,fake address,,London,,NW9 5LL,false,Barnet,E09000003,0,2,6,2,2,7,1,1,3,2023-06-24T00:00:00+01:00,,,1,2023-06-25T00:00:00+01:00,,3,1,4,,2,,1,2,,0,0,4,0,0,2,35,,F,0,2,13,0,0,P,0,32,M,6,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,6,2,1,0,TN23 6LZ,1,false,Ashford,E07000105,1,0,1,0,0,0,0,0,1,,2,,0,0,68,1,,6,1,1,,0,2,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,1,0,12.0,6.0,,,,,,,,,,,,,,,,,,,, +id,status,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,rent_type_detail,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,uprn_confirmed,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,pregnancy_value_check,age1_known,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,national,ecstat1,details_known_2,relat2,age2_known,age2,sex2,ecstat2,details_known_3,relat3,age3_known,age3,sex3,ecstat3,details_known_4,relat4,age4_known,age4,sex4,ecstat4,details_known_5,relat5,age5_known,age5,sex5,ecstat5,details_known_6,relat6,age6_known,age6,sex6,ecstat6,details_known_7,relat7,age7_known,age7,sex7,ecstat7,details_known_8,relat8,age8_known,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,new_old,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_unknown,referral,referral_value_check,net_income_known,incref,earnings,incfreq,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_admin_district,location_startdate +,completed,s.port@jeemayle.com,false,2023-06-26T00:00:00+01:00,,2023-06-26T00:00:00+01:00,1,,,2023,DLUHC,DLUHC,1,7,0,2023-06-26T00:00:00+01:00,2,1,,,,HIJKLMN,ABCDEFG,0,,,fake address,,London,,NW9 5LL,false,Barnet,E09000003,0,2,6,2,2,7,1,1,3,2023-06-24T00:00:00+01:00,,,1,2023-06-25T00:00:00+01:00,,3,1,4,,2,,1,2,,0,0,4,0,0,2,35,,F,0,2,13,0,0,P,0,32,M,6,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,6,2,1,0,TN23 6LZ,1,false,Ashford,E07000105,1,0,1,0,0,0,0,0,1,,2,,0,0,68,1,,6,1,1,,0,2,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,1,0,12.0,6.0,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/lettings_log_csv_export_labels.csv b/spec/fixtures/files/lettings_log_csv_export_labels.csv index e553083c1..729f1a63d 100644 --- a/spec/fixtures/files/lettings_log_csv_export_labels.csv +++ b/spec/fixtures/files/lettings_log_csv_export_labels.csv @@ -1,2 +1,2 @@ -id,status,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,rent_type_detail,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,uprn_confirmed,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,pregnancy_value_check,age1_known,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,national,ecstat1,details_known_2,relat2,age2_known,age2,sex2,ecstat2,details_known_3,relat3,age3_known,age3,sex3,ecstat3,details_known_4,relat4,age4_known,age4,sex4,ecstat4,details_known_5,relat5,age5_known,age5,sex5,ecstat5,details_known_6,relat6,age6_known,age6,sex6,ecstat6,details_known_7,relat7,age7_known,age7,sex7,ecstat7,details_known_8,relat8,age8_known,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,new_old,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_unknown,referral,referral_value_check,net_income_known,incref,earnings,incfreq,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_admin_district,location_startdate -,completed,s.port@jeemayle.com,false,2023-06-26T00:00:00+01:00,,2023-06-26T00:00:00+01:00,single log,,,2023,DLUHC,DLUHC,General needs,7,No,2023-06-26T00:00:00+01:00,2,Affordable Rent,,,,HIJKLMN,ABCDEFG,No,,,fake address,,London,,NW9 5LL,No,Barnet,E09000003,No,Affordable rent basis,Tenant abandoned property,2,2,House,Purpose built,Yes,3,2023-06-24T00:00:00+01:00,,,Yes,2023-06-25T00:00:00+01:00,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,1,2,,Yes,0,4,0,0,2,35,,Female,White,Irish,Tenant prefers not to say,Other,Yes,Partner,Yes,32,Male,Not seeking work,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,1,0,0,0,0,0,No,Yes,0,0,1,0,0,0,0,0,0,0,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,Other supported housing,2,No,Yes,TN23 6LZ,Yes,No,Ashford,E07000105,Yes,0,1,0,0,0,0,0,1,,Tenant applied directly (no referral or nomination),,Yes,0,68,Weekly,,Universal Credit housing element,1,All,,0,Every 2 weeks,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,Yes,Yes,12.0,6.0,,,,,,,,,,,,,,,,,,,, +id,status,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,rent_type_detail,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,uprn_confirmed,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,pregnancy_value_check,age1_known,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,national,ecstat1,details_known_2,relat2,age2_known,age2,sex2,ecstat2,details_known_3,relat3,age3_known,age3,sex3,ecstat3,details_known_4,relat4,age4_known,age4,sex4,ecstat4,details_known_5,relat5,age5_known,age5,sex5,ecstat5,details_known_6,relat6,age6_known,age6,sex6,ecstat6,details_known_7,relat7,age7_known,age7,sex7,ecstat7,details_known_8,relat8,age8_known,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,new_old,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_unknown,referral,referral_value_check,net_income_known,incref,earnings,incfreq,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_admin_district,location_startdate +,completed,s.port@jeemayle.com,false,2023-06-26T00:00:00+01:00,,2023-06-26T00:00:00+01:00,single log,,,2023,DLUHC,DLUHC,General needs,7,No,2023-06-26T00:00:00+01:00,2,Affordable Rent,,,,HIJKLMN,ABCDEFG,No,,,fake address,,London,,NW9 5LL,No,Barnet,E09000003,No,Affordable rent basis,Tenant abandoned property,2,2,House,Purpose built,Yes,3,2023-06-24T00:00:00+01:00,,,Yes,2023-06-25T00:00:00+01:00,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,1,2,,Yes,0,4,0,0,2,35,,Female,White,Irish,Tenant prefers not to say,Other,Yes,Partner,Yes,32,Male,Not seeking work,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,1,0,0,0,0,0,No,Yes,0,0,1,0,0,0,0,0,0,0,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,Other supported housing,2,No,Yes,TN23 6LZ,Yes,No,Ashford,E07000105,Yes,0,1,0,0,0,0,0,1,,Tenant applied directly (no referral or nomination),,Yes,0,68,Weekly,,Universal Credit housing element,1,All,,0,Every 2 weeks,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,Yes,Yes,12.0,6.0,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/lettings_log_csv_export_non_support_codes.csv b/spec/fixtures/files/lettings_log_csv_export_non_support_codes.csv index 6908e829b..46d68db05 100644 --- a/spec/fixtures/files/lettings_log_csv_export_non_support_codes.csv +++ b/spec/fixtures/files/lettings_log_csv_export_non_support_codes.csv @@ -1,2 +1,2 @@ -id,status,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,lettype,renewal,startdate,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,refused,age1,sex1,ethnic_group,ethnic,national,ecstat1,relat2,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,referral,referral_value_check,incref,earnings,incfreq,hb,has_benefits,benefits,household_charge,nocharge,period,chcharge,wchchrg,carehome_charges_value_check,brent,scharge,pscharge,supcharg,tcharge,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_admin_district,location_startdate -,completed,choreographer@owtluk.com,false,2023-06-26T00:00:00+01:00,,2023-06-26T00:00:00+01:00,1,2023,DLUHC,DLUHC,7,0,2023-06-26T00:00:00+01:00,,,,HIJKLMN,ABCDEFG,0,,fake address,,London,,NW9 5LL,Barnet,2,6,2,2,7,1,1,3,2023-06-24T00:00:00+01:00,,1,2023-06-25T00:00:00+01:00,,3,1,4,,2,,1,0,35,F,0,2,13,0,P,32,M,6,,,,,,,,,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,6,1,0,TN23 6LZ,Ashford,1,0,1,0,0,0,0,0,1,2,,0,68,1,6,1,1,,0,2,,,,200.0,50.0,40.0,35.0,325.0,1,12.0,,,,,,,,,,,,,,,,,,,, +id,status,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,lettype,renewal,startdate,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,refused,age1,sex1,ethnic_group,ethnic,national,ecstat1,relat2,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,referral,referral_value_check,incref,earnings,incfreq,hb,has_benefits,benefits,household_charge,nocharge,period,chcharge,wchchrg,carehome_charges_value_check,brent,scharge,pscharge,supcharg,tcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_admin_district,location_startdate +,completed,choreographer@owtluk.com,false,2023-06-26T00:00:00+01:00,,2023-06-26T00:00:00+01:00,1,2023,DLUHC,DLUHC,7,0,2023-06-26T00:00:00+01:00,,,,HIJKLMN,ABCDEFG,0,,fake address,,London,,NW9 5LL,Barnet,2,6,2,2,7,1,1,3,2023-06-24T00:00:00+01:00,,1,2023-06-25T00:00:00+01:00,,3,1,4,,2,,1,0,35,F,0,2,13,0,P,32,M,6,,,,,,,,,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,6,1,0,TN23 6LZ,Ashford,1,0,1,0,0,0,0,0,1,2,,0,68,1,6,1,1,,0,2,,,,200.0,50.0,40.0,35.0,325.0,,,,1,12.0,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/lettings_log_csv_export_non_support_labels.csv b/spec/fixtures/files/lettings_log_csv_export_non_support_labels.csv index fd70049dc..0b475c037 100644 --- a/spec/fixtures/files/lettings_log_csv_export_non_support_labels.csv +++ b/spec/fixtures/files/lettings_log_csv_export_non_support_labels.csv @@ -1,2 +1,2 @@ -id,status,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,lettype,renewal,startdate,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,refused,age1,sex1,ethnic_group,ethnic,national,ecstat1,relat2,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,referral,referral_value_check,incref,earnings,incfreq,hb,has_benefits,benefits,household_charge,nocharge,period,chcharge,wchchrg,carehome_charges_value_check,brent,scharge,pscharge,supcharg,tcharge,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_admin_district,location_startdate -,completed,choreographer@owtluk.com,false,2023-06-26T00:00:00+01:00,,2023-06-26T00:00:00+01:00,single log,2023,DLUHC,DLUHC,7,No,2023-06-26T00:00:00+01:00,,,,HIJKLMN,ABCDEFG,No,,fake address,,London,,NW9 5LL,Barnet,Affordable rent basis,Tenant abandoned property,2,2,House,Purpose built,Yes,3,2023-06-24T00:00:00+01:00,,Yes,2023-06-25T00:00:00+01:00,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,1,0,35,Female,White,Irish,Tenant prefers not to say,Other,Partner,32,Male,Not seeking work,,,,,,,,,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,1,0,0,0,0,0,No,Yes,0,0,1,0,0,0,0,0,0,0,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,Other supported housing,No,Yes,TN23 6LZ,Ashford,Yes,0,1,0,0,0,0,0,1,Tenant applied directly (no referral or nomination),,0,68,Weekly,Universal Credit housing element,1,All,,0,Every 2 weeks,,,,200.0,50.0,40.0,35.0,325.0,Yes,12.0,,,,,,,,,,,,,,,,,,,, +id,status,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,lettype,renewal,startdate,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,refused,age1,sex1,ethnic_group,ethnic,national,ecstat1,relat2,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,referral,referral_value_check,incref,earnings,incfreq,hb,has_benefits,benefits,household_charge,nocharge,period,chcharge,wchchrg,carehome_charges_value_check,brent,scharge,pscharge,supcharg,tcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_admin_district,location_startdate +,completed,choreographer@owtluk.com,false,2023-06-26T00:00:00+01:00,,2023-06-26T00:00:00+01:00,single log,2023,DLUHC,DLUHC,7,No,2023-06-26T00:00:00+01:00,,,,HIJKLMN,ABCDEFG,No,,fake address,,London,,NW9 5LL,Barnet,Affordable rent basis,Tenant abandoned property,2,2,House,Purpose built,Yes,3,2023-06-24T00:00:00+01:00,,Yes,2023-06-25T00:00:00+01:00,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,1,0,35,Female,White,Irish,Tenant prefers not to say,Other,Partner,32,Male,Not seeking work,,,,,,,,,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,1,0,0,0,0,0,No,Yes,0,0,1,0,0,0,0,0,0,0,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,Other supported housing,No,Yes,TN23 6LZ,Ashford,Yes,0,1,0,0,0,0,0,1,Tenant applied directly (no referral or nomination),,0,68,Weekly,Universal Credit housing element,1,All,,0,Every 2 weeks,,,,200.0,50.0,40.0,35.0,325.0,,,,Yes,12.0,,,,,,,,,,,,,,,,,,,, diff --git a/spec/models/form/lettings/subsections/income_and_benefits_spec.rb b/spec/models/form/lettings/subsections/income_and_benefits_spec.rb index e914ccc6a..c260ff56d 100644 --- a/spec/models/form/lettings/subsections/income_and_benefits_spec.rb +++ b/spec/models/form/lettings/subsections/income_and_benefits_spec.rb @@ -32,6 +32,9 @@ RSpec.describe Form::Lettings::Subsections::IncomeAndBenefits, type: :model do rent_monthly brent_min_rent_value_check brent_max_rent_value_check + scharge_value_check + pscharge_value_check + supcharg_value_check outstanding outstanding_amount ], diff --git a/spec/models/validations/financial_validations_spec.rb b/spec/models/validations/financial_validations_spec.rb index ab3924d90..3e645f164 100644 --- a/spec/models/validations/financial_validations_spec.rb +++ b/spec/models/validations/financial_validations_spec.rb @@ -263,39 +263,39 @@ RSpec.describe Validations::FinancialValidations do [{ period: { label: "weekly", value: 1 }, - charge: { field: "scharge", value: 156 }, + charge: { field: "scharge", value: 801 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "scharge", value: 672 }, + charge: { field: "scharge", value: 3471 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "scharge", value: 311 }, + charge: { field: "scharge", value: 1601 }, }, { period: { label: "weekly", value: 1 }, - charge: { field: "pscharge", value: 31 }, + charge: { field: "pscharge", value: 701 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "pscharge", value: 150 }, + charge: { field: "pscharge", value: 3200 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "pscharge", value: 61 }, + charge: { field: "pscharge", value: 1401 }, }, { period: { label: "weekly", value: 1 }, - charge: { field: "supcharg", value: 41 }, + charge: { field: "supcharg", value: 801 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "supcharg", value: 200 }, + charge: { field: "supcharg", value: 3471 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "supcharg", value: 81 }, + charge: { field: "supcharg", value: 1601 }, }].each do |test_case| it "does not allow charges outside the range when period is #{test_case[:period][:label]}" do record.period = test_case[:period][:value] @@ -308,39 +308,39 @@ RSpec.describe Validations::FinancialValidations do [{ period: { label: "weekly", value: 1 }, - charge: { field: "scharge", value: 154 }, + charge: { field: "scharge", value: 799 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "scharge", value: 670 }, + charge: { field: "scharge", value: 3400 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "scharge", value: 309 }, + charge: { field: "scharge", value: 1599 }, }, { period: { label: "weekly", value: 1 }, - charge: { field: "pscharge", value: 30 }, + charge: { field: "pscharge", value: 699 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "pscharge", value: 120 }, + charge: { field: "pscharge", value: 2500 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "pscharge", value: 59 }, + charge: { field: "pscharge", value: 1399 }, }, { period: { label: "weekly", value: 1 }, - charge: { field: "supcharg", value: 39 }, + charge: { field: "supcharg", value: 799 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "supcharg", value: 120 }, + charge: { field: "supcharg", value: 3000 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "supcharg", value: 79 }, + charge: { field: "supcharg", value: 1599 }, }].each do |test_case| it "does allow charges inside the range when period is #{test_case[:period][:label]}" do record.period = test_case[:period][:value] @@ -357,39 +357,39 @@ RSpec.describe Validations::FinancialValidations do [{ period: { label: "weekly", value: 1 }, - charge: { field: "scharge", value: 481 }, + charge: { field: "scharge", value: 801 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "scharge", value: 2081 }, + charge: { field: "scharge", value: 3471 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "scharge", value: 961 }, + charge: { field: "scharge", value: 1601 }, }, { period: { label: "weekly", value: 1 }, - charge: { field: "pscharge", value: 201 }, + charge: { field: "pscharge", value: 701 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "pscharge", value: 1000 }, + charge: { field: "pscharge", value: 3200 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "pscharge", value: 400.80 }, + charge: { field: "pscharge", value: 1401 }, }, { period: { label: "weekly", value: 1 }, - charge: { field: "supcharg", value: 466 }, + charge: { field: "supcharg", value: 801 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "supcharg", value: 3100 }, + charge: { field: "supcharg", value: 3471 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "supcharg", value: 990 }, + charge: { field: "supcharg", value: 1601 }, }].each do |test_case| it "does not allow charges outside the range when period is #{test_case[:period][:label]}" do record.period = test_case[:period][:value] @@ -402,39 +402,39 @@ RSpec.describe Validations::FinancialValidations do [{ period: { label: "weekly", value: 1 }, - charge: { field: "scharge", value: 366 }, + charge: { field: "scharge", value: 799 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "scharge", value: 1582 }, + charge: { field: "scharge", value: 3400 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "scharge", value: 731 }, + charge: { field: "scharge", value: 1599 }, }, { period: { label: "weekly", value: 1 }, - charge: { field: "pscharge", value: 199.99 }, + charge: { field: "pscharge", value: 699 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "pscharge", value: 800 }, + charge: { field: "pscharge", value: 2500 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "pscharge", value: 400 }, + charge: { field: "pscharge", value: 1399 }, }, { period: { label: "weekly", value: 1 }, - charge: { field: "supcharg", value: 464 }, + charge: { field: "supcharg", value: 799 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "supcharg", value: 2000 }, + charge: { field: "supcharg", value: 3400 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "supcharg", value: 880 }, + charge: { field: "supcharg", value: 1599 }, }].each do |test_case| it "does allow charges inside the range when period is #{test_case[:period][:label]}" do record.period = test_case[:period][:value] @@ -455,39 +455,39 @@ RSpec.describe Validations::FinancialValidations do [{ period: { label: "weekly", value: 1 }, - charge: { field: "scharge", value: 156 }, + charge: { field: "scharge", value: 501 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "scharge", value: 672 }, + charge: { field: "scharge", value: 2300 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "scharge", value: 311 }, + charge: { field: "scharge", value: 1001 }, }, { period: { label: "weekly", value: 1 }, - charge: { field: "pscharge", value: 36 }, + charge: { field: "pscharge", value: 201 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "pscharge", value: 190 }, + charge: { field: "pscharge", value: 1000 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "pscharge", value: 71 }, + charge: { field: "pscharge", value: 401 }, }, { period: { label: "weekly", value: 1 }, - charge: { field: "supcharg", value: 61 }, + charge: { field: "supcharg", value: 201 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "supcharg", value: 300 }, + charge: { field: "supcharg", value: 1000 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "supcharg", value: 122 }, + charge: { field: "supcharg", value: 401 }, }].each do |test_case| it "does not allow charges outside the range when period is #{test_case[:period][:label]}" do record.period = test_case[:period][:value] @@ -500,39 +500,39 @@ RSpec.describe Validations::FinancialValidations do [{ period: { label: "weekly", value: 1 }, - charge: { field: "scharge", value: 44 }, + charge: { field: "scharge", value: 499 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "scharge", value: 160 }, + charge: { field: "scharge", value: 2000 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "scharge", value: 89 }, + charge: { field: "scharge", value: 999 }, }, { period: { label: "weekly", value: 1 }, - charge: { field: "pscharge", value: 34 }, + charge: { field: "pscharge", value: 199 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "pscharge", value: 140 }, + charge: { field: "pscharge", value: 800 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "pscharge", value: 69 }, + charge: { field: "pscharge", value: 399 }, }, { period: { label: "weekly", value: 1 }, - charge: { field: "supcharg", value: 59.99 }, + charge: { field: "supcharg", value: 199.99 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "supcharg", value: 240 }, + charge: { field: "supcharg", value: 800 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "supcharg", value: 119 }, + charge: { field: "supcharg", value: 399 }, }].each do |test_case| it "does allow charges inside the range when period is #{test_case[:period][:label]}" do record.period = test_case[:period][:value] @@ -549,39 +549,39 @@ RSpec.describe Validations::FinancialValidations do [{ period: { label: "weekly", value: 1 }, - charge: { field: "scharge", value: 365.90 }, + charge: { field: "scharge", value: 501 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "scharge", value: 2081 }, + charge: { field: "scharge", value: 2300 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "scharge", value: 961 }, + charge: { field: "scharge", value: 1001 }, }, { period: { label: "weekly", value: 1 }, - charge: { field: "pscharge", value: 76 }, + charge: { field: "pscharge", value: 201 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "pscharge", value: 400 }, + charge: { field: "pscharge", value: 1000 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "pscharge", value: 151 }, + charge: { field: "pscharge", value: 401 }, }, { period: { label: "weekly", value: 1 }, - charge: { field: "supcharg", value: 121 }, + charge: { field: "supcharg", value: 201 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "supcharg", value: 620 }, + charge: { field: "supcharg", value: 1000 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "supcharg", value: 241 }, + charge: { field: "supcharg", value: 401 }, }].each do |test_case| it "does not allow charges outside the range when period is #{test_case[:period][:label]}" do record.period = test_case[:period][:value] @@ -617,39 +617,39 @@ RSpec.describe Validations::FinancialValidations do [{ period: { label: "weekly", value: 1 }, - charge: { field: "scharge", value: 364.88 }, + charge: { field: "scharge", value: 499 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "scharge", value: 1200 }, + charge: { field: "scharge", value: 2000 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "scharge", value: 700.99 }, + charge: { field: "scharge", value: 999 }, }, { period: { label: "weekly", value: 1 }, - charge: { field: "pscharge", value: 74 }, + charge: { field: "pscharge", value: 199 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "pscharge", value: 210 }, + charge: { field: "pscharge", value: 800 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "pscharge", value: 149 }, + charge: { field: "pscharge", value: 399 }, }, { period: { label: "weekly", value: 1 }, - charge: { field: "supcharg", value: 119 }, + charge: { field: "supcharg", value: 199.99 }, }, { period: { label: "monthly", value: 4 }, - charge: { field: "supcharg", value: 480 }, + charge: { field: "supcharg", value: 800 }, }, { period: { label: "every 2 weeks", value: 2 }, - charge: { field: "supcharg", value: 239 }, + charge: { field: "supcharg", value: 399 }, }].each do |test_case| it "does allow charges inside the range when period is #{test_case[:period][:label]}" do record.period = test_case[:period][:value] diff --git a/spec/models/validations/soft_validations_spec.rb b/spec/models/validations/soft_validations_spec.rb index 0a267b9e9..8f00799ff 100644 --- a/spec/models/validations/soft_validations_spec.rb +++ b/spec/models/validations/soft_validations_spec.rb @@ -375,4 +375,646 @@ RSpec.describe Validations::SoftValidations do expect(record).to be_la_referral_for_general_needs end end + + describe "scharge_over_soft_max?" do + context "and organisation is PRP" do + before do + record.owning_organisation.update(provider_type: "PRP") + end + + it "returns false if scharge is not given" do + record.scharge = nil + record.needstype = 1 + record.period = 1 + + expect(record).not_to be_scharge_over_soft_max + end + + it "returns false if period is not given" do + record.scharge = 201 + record.needstype = 1 + record.period = nil + + expect(record).not_to be_scharge_over_soft_max + end + + [{ + period: { label: "weekly", value: 1 }, + scharge: 34, + }, + { + period: { label: "monthly", value: 4 }, + scharge: 100, + }, + { + period: { label: "every 2 weeks", value: 2 }, + scharge: 69, + }].each do |test_case| + it "returns false if scharge is under soft max for general needs #{test_case[:period][:label]}(35)" do + record.scharge = test_case[:scharge] + record.needstype = 1 + record.period = test_case[:period][:value] + + expect(record).not_to be_scharge_over_soft_max + end + end + + [{ + period: { label: "weekly", value: 1 }, + scharge: 199, + }, + { + period: { label: "monthly", value: 4 }, + scharge: 400, + }, + { + period: { label: "every 2 weeks", value: 2 }, + scharge: 399, + }].each do |test_case| + it "returns false if scharge is under soft max for supported housing #{test_case[:period][:label]} (200)" do + record.scharge = test_case[:scharge] + record.needstype = 2 + record.period = test_case[:period][:value] + + expect(record).not_to be_scharge_over_soft_max + end + end + + [{ + period: { label: "weekly", value: 1 }, + scharge: 36, + }, + { + period: { label: "monthly", value: 4 }, + scharge: 180, + }, + { + period: { label: "every 2 weeks", value: 2 }, + scharge: 71, + }].each do |test_case| + it "returns true if scharge is over soft max for general needs #{test_case[:period][:label]} (35)" do + record.scharge = test_case[:scharge] + record.needstype = 1 + record.period = test_case[:period][:value] + + expect(record).to be_scharge_over_soft_max + end + end + + [{ + period: { label: "weekly", value: 1 }, + scharge: 201, + }, + { + period: { label: "monthly", value: 4 }, + scharge: 1000, + }, + { + period: { label: "every 2 weeks", value: 2 }, + scharge: 401, + }].each do |test_case| + it "returns true if scharge is over soft max for supported housing #{test_case[:period][:label]} (200)" do + record.scharge = test_case[:scharge] + record.needstype = 2 + record.period = test_case[:period][:value] + + expect(record).to be_scharge_over_soft_max + end + end + end + + context "and organisation is LA" do + before do + record.owning_organisation.update(provider_type: "LA") + end + + it "returns false if scharge is not given" do + record.scharge = nil + record.needstype = 1 + record.period = 1 + + expect(record).not_to be_scharge_over_soft_max + end + + it "returns false if period is not given" do + record.scharge = 201 + record.needstype = 1 + record.period = nil + + expect(record).not_to be_scharge_over_soft_max + end + + [{ + period: { label: "weekly", value: 1 }, + scharge: 24, + }, + { + period: { label: "monthly", value: 4 }, + scharge: 88, + }, + { + period: { label: "every 2 weeks", value: 2 }, + scharge: 49, + }].each do |test_case| + it "returns false if scharge is under soft max for general needs #{test_case[:period][:label]}(25)" do + record.scharge = test_case[:scharge] + record.needstype = 1 + record.period = test_case[:period][:value] + + expect(record).not_to be_scharge_over_soft_max + end + end + + [{ + period: { label: "weekly", value: 1 }, + scharge: 99, + }, + { + period: { label: "monthly", value: 4 }, + scharge: 400, + }, + { + period: { label: "every 2 weeks", value: 2 }, + scharge: 199, + }].each do |test_case| + it "returns false if scharge is under soft max for supported housing #{test_case[:period][:label]} (100)" do + record.scharge = test_case[:scharge] + record.needstype = 2 + record.period = test_case[:period][:value] + + expect(record).not_to be_scharge_over_soft_max + end + end + + [{ + period: { label: "weekly", value: 1 }, + scharge: 26, + }, + { + period: { label: "monthly", value: 4 }, + scharge: 120, + }, + { + period: { label: "every 2 weeks", value: 2 }, + scharge: 51, + }].each do |test_case| + it "returns true if scharge is over soft max for general needs #{test_case[:period][:label]} (25)" do + record.scharge = test_case[:scharge] + record.needstype = 1 + record.period = test_case[:period][:value] + + expect(record).to be_scharge_over_soft_max + end + end + + [{ + period: { label: "weekly", value: 1 }, + scharge: 101, + }, + { + period: { label: "monthly", value: 4 }, + scharge: 450, + }, + { + period: { label: "every 2 weeks", value: 2 }, + scharge: 201, + }].each do |test_case| + it "returns true if scharge is over soft max for supported housing #{test_case[:period][:label]} (100)" do + record.scharge = test_case[:scharge] + record.needstype = 2 + record.period = test_case[:period][:value] + + expect(record).to be_scharge_over_soft_max + end + end + end + end + + describe "pscharge_over_soft_max?" do + context "and organisation is PRP" do + before do + record.owning_organisation.update(provider_type: "PRP") + end + + it "returns false if pscharge is not given" do + record.pscharge = nil + record.needstype = 1 + record.period = 1 + + expect(record).not_to be_pscharge_over_soft_max + end + + it "returns false if period is not given" do + record.pscharge = 201 + record.needstype = 1 + record.period = nil + + expect(record).not_to be_pscharge_over_soft_max + end + + [{ + period: { label: "weekly", value: 1 }, + pscharge: 34, + }, + { + period: { label: "monthly", value: 4 }, + pscharge: 100, + }, + { + period: { label: "every 2 weeks", value: 2 }, + pscharge: 69, + }].each do |test_case| + it "returns false if pscharge is under soft max for general needs #{test_case[:period][:label]}(35)" do + record.pscharge = test_case[:pscharge] + record.needstype = 1 + record.period = test_case[:period][:value] + + expect(record).not_to be_pscharge_over_soft_max + end + end + + [{ + period: { label: "weekly", value: 1 }, + pscharge: 99, + }, + { + period: { label: "monthly", value: 4 }, + pscharge: 400, + }, + { + period: { label: "every 2 weeks", value: 2 }, + pscharge: 199, + }].each do |test_case| + it "returns false if pscharge is under soft max for supported housing #{test_case[:period][:label]} (100)" do + record.pscharge = test_case[:pscharge] + record.needstype = 2 + record.period = test_case[:period][:value] + + expect(record).not_to be_pscharge_over_soft_max + end + end + + [{ + period: { label: "weekly", value: 1 }, + pscharge: 36, + }, + { + period: { label: "monthly", value: 4 }, + pscharge: 180, + }, + { + period: { label: "every 2 weeks", value: 2 }, + pscharge: 71, + }].each do |test_case| + it "returns true if pscharge is over soft max for general needs #{test_case[:period][:label]} (35)" do + record.pscharge = test_case[:pscharge] + record.needstype = 1 + record.period = test_case[:period][:value] + + expect(record).to be_pscharge_over_soft_max + end + end + + [{ + period: { label: "weekly", value: 1 }, + pscharge: 101, + }, + { + period: { label: "monthly", value: 4 }, + pscharge: 450, + }, + { + period: { label: "every 2 weeks", value: 2 }, + pscharge: 201, + }].each do |test_case| + it "returns true if pscharge is over soft max for supported housing #{test_case[:period][:label]} (100)" do + record.pscharge = test_case[:pscharge] + record.needstype = 2 + record.period = test_case[:period][:value] + + expect(record).to be_pscharge_over_soft_max + end + end + end + + context "and organisation is LA" do + before do + record.owning_organisation.update(provider_type: "LA") + end + + it "returns false if pscharge is not given" do + record.pscharge = nil + record.needstype = 1 + record.period = 1 + + expect(record).not_to be_pscharge_over_soft_max + end + + it "returns false if period is not given" do + record.pscharge = 201 + record.needstype = 1 + record.period = nil + + expect(record).not_to be_pscharge_over_soft_max + end + + [{ + period: { label: "weekly", value: 1 }, + pscharge: 24, + }, + { + period: { label: "monthly", value: 4 }, + pscharge: 88, + }, + { + period: { label: "every 2 weeks", value: 2 }, + pscharge: 49, + }].each do |test_case| + it "returns false if pscharge is under soft max for general needs #{test_case[:period][:label]}(25)" do + record.pscharge = test_case[:pscharge] + record.needstype = 1 + record.period = test_case[:period][:value] + + expect(record).not_to be_pscharge_over_soft_max + end + end + + [{ + period: { label: "weekly", value: 1 }, + pscharge: 74, + }, + { + period: { label: "monthly", value: 4 }, + pscharge: 250, + }, + { + period: { label: "every 2 weeks", value: 2 }, + pscharge: 149, + }].each do |test_case| + it "returns false if pscharge is under soft max for supported housing #{test_case[:period][:label]} (75)" do + record.pscharge = test_case[:pscharge] + record.needstype = 2 + record.period = test_case[:period][:value] + + expect(record).not_to be_pscharge_over_soft_max + end + end + + [{ + period: { label: "weekly", value: 1 }, + pscharge: 26, + }, + { + period: { label: "monthly", value: 4 }, + pscharge: 120, + }, + { + period: { label: "every 2 weeks", value: 2 }, + pscharge: 51, + }].each do |test_case| + it "returns true if pscharge is over soft max for general needs #{test_case[:period][:label]} (25)" do + record.pscharge = test_case[:pscharge] + record.needstype = 1 + record.period = test_case[:period][:value] + + expect(record).to be_pscharge_over_soft_max + end + end + + [{ + period: { label: "weekly", value: 1 }, + pscharge: 76, + }, + { + period: { label: "monthly", value: 4 }, + pscharge: 350, + }, + { + period: { label: "every 2 weeks", value: 2 }, + pscharge: 151, + }].each do |test_case| + it "returns true if pscharge is over soft max for supported housing #{test_case[:period][:label]} (75)" do + record.pscharge = test_case[:pscharge] + record.needstype = 2 + record.period = test_case[:period][:value] + + expect(record).to be_pscharge_over_soft_max + end + end + end + end + + describe "supcharg_over_soft_max?" do + context "and organisation is PRP" do + before do + record.owning_organisation.update(provider_type: "PRP") + end + + it "returns false if supcharg is not given" do + record.supcharg = nil + record.needstype = 1 + record.period = 1 + + expect(record).not_to be_supcharg_over_soft_max + end + + it "returns false if period is not given" do + record.supcharg = 201 + record.needstype = 1 + record.period = nil + + expect(record).not_to be_supcharg_over_soft_max + end + + [{ + period: { label: "weekly", value: 1 }, + supcharg: 34, + }, + { + period: { label: "monthly", value: 4 }, + supcharg: 100, + }, + { + period: { label: "every 2 weeks", value: 2 }, + supcharg: 69, + }].each do |test_case| + it "returns false if supcharg is under soft max for general needs #{test_case[:period][:label]}(35)" do + record.supcharg = test_case[:supcharg] + record.needstype = 1 + record.period = test_case[:period][:value] + + expect(record).not_to be_supcharg_over_soft_max + end + end + + [{ + period: { label: "weekly", value: 1 }, + supcharg: 84, + }, + { + period: { label: "monthly", value: 4 }, + supcharg: 320, + }, + { + period: { label: "every 2 weeks", value: 2 }, + supcharg: 169, + }].each do |test_case| + it "returns false if supcharg is under soft max for supported housing #{test_case[:period][:label]} (85)" do + record.supcharg = test_case[:supcharg] + record.needstype = 2 + record.period = test_case[:period][:value] + + expect(record).not_to be_supcharg_over_soft_max + end + end + + [{ + period: { label: "weekly", value: 1 }, + supcharg: 36, + }, + { + period: { label: "monthly", value: 4 }, + supcharg: 180, + }, + { + period: { label: "every 2 weeks", value: 2 }, + supcharg: 71, + }].each do |test_case| + it "returns true if supcharg is over soft max for general needs #{test_case[:period][:label]} (35)" do + record.supcharg = test_case[:supcharg] + record.needstype = 1 + record.period = test_case[:period][:value] + + expect(record).to be_supcharg_over_soft_max + end + end + + [{ + period: { label: "weekly", value: 1 }, + supcharg: 86, + }, + { + period: { label: "monthly", value: 4 }, + supcharg: 400, + }, + { + period: { label: "every 2 weeks", value: 2 }, + supcharg: 171, + }].each do |test_case| + it "returns true if supcharg is over soft max for supported housing #{test_case[:period][:label]} (85)" do + record.supcharg = test_case[:supcharg] + record.needstype = 2 + record.period = test_case[:period][:value] + + expect(record).to be_supcharg_over_soft_max + end + end + end + + context "and organisation is LA" do + before do + record.owning_organisation.update(provider_type: "LA") + end + + it "returns false if supcharg is not given" do + record.supcharg = nil + record.needstype = 1 + record.period = 1 + + expect(record).not_to be_supcharg_over_soft_max + end + + it "returns false if period is not given" do + record.supcharg = 201 + record.needstype = 1 + record.period = nil + + expect(record).not_to be_supcharg_over_soft_max + end + + [{ + period: { label: "weekly", value: 1 }, + supcharg: 24, + }, + { + period: { label: "monthly", value: 4 }, + supcharg: 88, + }, + { + period: { label: "every 2 weeks", value: 2 }, + supcharg: 49, + }].each do |test_case| + it "returns false if supcharg is under soft max for general needs #{test_case[:period][:label]}(25)" do + record.supcharg = test_case[:supcharg] + record.needstype = 1 + record.period = test_case[:period][:value] + + expect(record).not_to be_supcharg_over_soft_max + end + end + + [{ + period: { label: "weekly", value: 1 }, + supcharg: 74, + }, + { + period: { label: "monthly", value: 4 }, + supcharg: 250, + }, + { + period: { label: "every 2 weeks", value: 2 }, + supcharg: 149, + }].each do |test_case| + it "returns false if supcharg is under soft max for supported housing #{test_case[:period][:label]} (75)" do + record.supcharg = test_case[:supcharg] + record.needstype = 2 + record.period = test_case[:period][:value] + + expect(record).not_to be_supcharg_over_soft_max + end + end + + [{ + period: { label: "weekly", value: 1 }, + supcharg: 26, + }, + { + period: { label: "monthly", value: 4 }, + supcharg: 120, + }, + { + period: { label: "every 2 weeks", value: 2 }, + supcharg: 51, + }].each do |test_case| + it "returns true if supcharg is over soft max for general needs #{test_case[:period][:label]} (25)" do + record.supcharg = test_case[:supcharg] + record.needstype = 1 + record.period = test_case[:period][:value] + + expect(record).to be_supcharg_over_soft_max + end + end + + [{ + period: { label: "weekly", value: 1 }, + supcharg: 76, + }, + { + period: { label: "monthly", value: 4 }, + supcharg: 350, + }, + { + period: { label: "every 2 weeks", value: 2 }, + supcharg: 151, + }].each do |test_case| + it "returns true if supcharg is over soft max for supported housing #{test_case[:period][:label]} (75)" do + record.supcharg = test_case[:supcharg] + record.needstype = 2 + record.period = test_case[:period][:value] + + expect(record).to be_supcharg_over_soft_max + end + end + end + end end diff --git a/spec/services/imports/lettings_logs_import_service_spec.rb b/spec/services/imports/lettings_logs_import_service_spec.rb index a9b0b9260..1138fd203 100644 --- a/spec/services/imports/lettings_logs_import_service_spec.rb +++ b/spec/services/imports/lettings_logs_import_service_spec.rb @@ -891,7 +891,7 @@ RSpec.describe Imports::LettingsLogsImportService do context "and pscharge is out of range" do before do lettings_log_xml.at_xpath("//xmlns:Q17").content = "1" - lettings_log_xml.at_xpath("//xmlns:Q18aiii").content = "36" + lettings_log_xml.at_xpath("//xmlns:Q18aiii").content = "701" end it "intercepts the relevant validation error" do @@ -914,7 +914,7 @@ RSpec.describe Imports::LettingsLogsImportService do context "and supcharg is out of range" do before do lettings_log_xml.at_xpath("//xmlns:Q17").content = "1" - lettings_log_xml.at_xpath("//xmlns:Q18aiv").content = "46" + lettings_log_xml.at_xpath("//xmlns:Q18aiv").content = "801" end it "intercepts the relevant validation error" do @@ -937,7 +937,7 @@ RSpec.describe Imports::LettingsLogsImportService do context "and scharge is out of range" do before do lettings_log_xml.at_xpath("//xmlns:Q17").content = "1" - lettings_log_xml.at_xpath("//xmlns:Q18aii").content = "156" + lettings_log_xml.at_xpath("//xmlns:Q18aii").content = "801" end it "intercepts the relevant validation error" do @@ -2068,5 +2068,40 @@ RSpec.describe Imports::LettingsLogsImportService do expect(lettings_log.status).to eq("completed") end end + + context "and the scharge/pscharge/supcharg soft validations are triggered" do + let(:lettings_log_id) { "00d2343e-d5fa-4c89-8400-ec3854b0f2b4" } + let(:lettings_log_file) { open_file(fixture_directory, lettings_log_id) } + let(:lettings_log_xml) { Nokogiri::XML(lettings_log_file) } + + around do |example| + Timecop.freeze(Time.zone.local(2023, 4, 1)) do + Singleton.__init__(FormHandler) + example.run + end + Timecop.return + Singleton.__init__(FormHandler) + end + + before do + lettings_log_xml.at_xpath("//xmlns:AddressLine1").content = "address 1" + lettings_log_xml.at_xpath("//xmlns:TownCity").content = "towncity" + lettings_log_xml.at_xpath("//xmlns:DAY").content = "10" + lettings_log_xml.at_xpath("//xmlns:MONTH").content = "4" + lettings_log_xml.at_xpath("//xmlns:YEAR").content = "2023" + lettings_log_xml.at_xpath("//xmlns:P1Nat").content = "18" + + lettings_log_xml.at_xpath("//xmlns:Q17").content = "1" + lettings_log_xml.at_xpath("//xmlns:Q18aii").content = "800" + lettings_log_xml.at_xpath("//xmlns:Q18aiii").content = "300" + lettings_log_xml.at_xpath("//xmlns:Q18aiv").content = "300" + end + + it "completes the log" do + lettings_log_service.send(:create_log, lettings_log_xml) + lettings_log = LettingsLog.find_by(old_id: lettings_log_id) + expect(lettings_log.status).to eq("completed") + end + end end end