Browse Source

Correclty save carehome charges (#1511)

pull/1455/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
d2a1bc6c49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      app/services/bulk_upload/lettings/year2022/row_parser.rb
  2. 22
      spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb

1
app/services/bulk_upload/lettings/year2022/row_parser.rb

@ -1016,6 +1016,7 @@ private
attributes["supcharg"] = field_83 attributes["supcharg"] = field_83
attributes["tcharge"] = field_84 attributes["tcharge"] = field_84
attributes["chcharge"] = field_85 attributes["chcharge"] = field_85
attributes["is_carehome"] = field_85.present? ? 1 : 0
attributes["household_charge"] = field_86 attributes["household_charge"] = field_86
attributes["hbrentshortfall"] = field_87 attributes["hbrentshortfall"] = field_87
attributes["tshortfall_known"] = tshortfall_known attributes["tshortfall_known"] = tshortfall_known

22
spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb

@ -599,6 +599,28 @@ RSpec.describe BulkUpload::Lettings::Year2022::RowParser do
end end
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 describe "fields 96, 97, 98 => startdate" do
context "when all of these fields are blank" 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 } } let(:attributes) { { bulk_upload:, field_1: "1", field_96: nil, field_97: nil, field_98: nil } }

Loading…
Cancel
Save