Browse Source

Infer has mscharge as no if it's 0 for 23/24

pull/1629/head
Kat 3 years ago
parent
commit
747f013ba8
  1. 4
      app/services/bulk_upload/sales/year2023/row_parser.rb
  2. 30
      spec/services/bulk_upload/sales/year2023/row_parser_spec.rb

4
app/services/bulk_upload/sales/year2023/row_parser.rb

@ -786,8 +786,8 @@ private
attributes["cashdis"] = field_112
attributes["mrent"] = field_113
attributes["has_mscharge"] = mscharge.present? ? 1 : 0
attributes["mscharge"] = mscharge
attributes["mscharge"] = mscharge if mscharge&.positive?
attributes["has_mscharge"] = attributes["mscharge"].present? ? 1 : 0
attributes["grant"] = field_117
attributes["discount"] = field_118

30
spec/services/bulk_upload/sales/year2023/row_parser_spec.rb

@ -825,5 +825,35 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
expect(parser.log.proplen).to be_nil
end
end
context "when mscharge is given, but is set to 0 for shared ownership" do
let(:attributes) { valid_attributes.merge(field_114: "0") }
it "does not override variables correctly" do
log = parser.log
expect(log["has_mscharge"]).to eq(0) # no
expect(log["mscharge"]).to be_nil
end
end
context "when mscharge is given, but is set to 0 for discounted ownership" do
let(:attributes) { valid_attributes.merge(field_7: "2", field_126: "0") }
it "does not override variables correctly" do
log = parser.log
expect(log["has_mscharge"]).to eq(0) # no
expect(log["mscharge"]).to be_nil
end
end
context "when mscharge is given, but is set to 0 for outright sale" do
let(:attributes) { valid_attributes.merge(field_7: "3", field_135: "0") }
it "does not override variables correctly" do
log = parser.log
expect(log["has_mscharge"]).to eq(0) # no
expect(log["mscharge"]).to be_nil
end
end
end
end

Loading…
Cancel
Save