From d2a1bc6c49182b4e5b3f4080463c41a3f4b6b5ab Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 4 Apr 2023 12:37:49 +0100 Subject: [PATCH] Correclty save carehome charges (#1511) --- .../lettings/year2022/row_parser.rb | 1 + .../lettings/year2022/row_parser_spec.rb | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/app/services/bulk_upload/lettings/year2022/row_parser.rb b/app/services/bulk_upload/lettings/year2022/row_parser.rb index 289dea7ca..cdd47f99f 100644 --- a/app/services/bulk_upload/lettings/year2022/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2022/row_parser.rb @@ -1016,6 +1016,7 @@ private attributes["supcharg"] = field_83 attributes["tcharge"] = field_84 attributes["chcharge"] = field_85 + attributes["is_carehome"] = field_85.present? ? 1 : 0 attributes["household_charge"] = field_86 attributes["hbrentshortfall"] = field_87 attributes["tshortfall_known"] = tshortfall_known diff --git a/spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb index fef0a88fa..afd68644e 100644 --- a/spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb @@ -599,6 +599,28 @@ RSpec.describe BulkUpload::Lettings::Year2022::RowParser do end end + describe "#field_85" do + let(:bulk_upload) { create(:bulk_upload, :lettings, user:, needstype: "2") } + + context "when care home charge is given" do + let(:attributes) { valid_attributes.merge(field_85: "100") } + + it "sets is carehome to yes and saves the charge" do + expect(parser.log.is_carehome).to eq(1) + expect(parser.log.chcharge).to eq(100) + end + end + + context "when care home charge is not given" do + let(:attributes) { valid_attributes.merge(field_85: nil) } + + it "sets is carehome to no and does not save the charge" do + expect(parser.log.is_carehome).to eq(0) + expect(parser.log.chcharge).to be_nil + end + end + end + describe "fields 96, 97, 98 => startdate" do context "when all of these fields are blank" do let(:attributes) { { bulk_upload:, field_1: "1", field_96: nil, field_97: nil, field_98: nil } }