diff --git a/app/services/bulk_upload/sales/year2023/row_parser.rb b/app/services/bulk_upload/sales/year2023/row_parser.rb index 7ab51ef12..efe100680 100644 --- a/app/services/bulk_upload/sales/year2023/row_parser.rb +++ b/app/services/bulk_upload/sales/year2023/row_parser.rb @@ -407,6 +407,15 @@ class BulkUpload::Sales::Year2023::RowParser private + def prevtenbuy2 + case field_72 + when "R" + 0 + else + field_72 + end + end + def infer_buyer2_ethnic_group_from_ethnic case field_40 when 1, 2, 3, 18 @@ -757,6 +766,7 @@ private attributes["nationalbuy2"] = field_41 attributes["buy2living"] = field_71 + attributes["prevtenbuy2"] = prevtenbuy2 attributes end diff --git a/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb b/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb index a90fc07e8..d1fc40e48 100644 --- a/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb +++ b/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb @@ -659,5 +659,13 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do expect(parser.log.buy2living).to be(1) end end + + describe "#prevtenbuy2" do + let(:attributes) { setup_section_params.merge({ field_72: "R" }) } + + it "is correctly set" do + expect(parser.log.prevtenbuy2).to be(0) + end + end end end