From 0002e799607bdfec06559db16dcd7a15c56551bc Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Wed, 11 Jan 2023 14:15:03 +0000 Subject: [PATCH] bulk upload earnings accepts pennies but rounds --- app/services/bulk_upload/lettings/row_parser.rb | 8 ++++++-- spec/services/bulk_upload/lettings/row_parser_spec.rb | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/services/bulk_upload/lettings/row_parser.rb b/app/services/bulk_upload/lettings/row_parser.rb index a5dc7a7cf..569fa945d 100644 --- a/app/services/bulk_upload/lettings/row_parser.rb +++ b/app/services/bulk_upload/lettings/row_parser.rb @@ -53,7 +53,7 @@ class BulkUpload::Lettings::RowParser attribute :field_47, :integer attribute :field_48, :integer attribute :field_49, :integer - attribute :field_50, :integer + attribute :field_50, :decimal attribute :field_51, :integer attribute :field_52, :integer attribute :field_53, :string @@ -502,7 +502,7 @@ private attributes["referral"] = field_78 attributes["net_income_known"] = net_income_known - attributes["earnings"] = field_50 + attributes["earnings"] = earnings attributes["incfreq"] = field_116 attributes["hb"] = field_48 attributes["benefits"] = field_49 @@ -535,6 +535,10 @@ private attributes end + def earnings + field_50.round if field_50.present? + end + def net_income_known case field_51 when 1 diff --git a/spec/services/bulk_upload/lettings/row_parser_spec.rb b/spec/services/bulk_upload/lettings/row_parser_spec.rb index f42a1efc0..60d28d8f5 100644 --- a/spec/services/bulk_upload/lettings/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/row_parser_spec.rb @@ -549,5 +549,13 @@ RSpec.describe BulkUpload::Lettings::RowParser do expect(parser.log.tenancylength).to eq(2) end end + + describe "#earnings" do + let(:attributes) { { bulk_upload:, field_50: "104.50" } } + + it "rounds to the nearest whole pound" do + expect(parser.log.earnings).to eq(105) + end + end end end