From 554201d0bf98c42db48b5c132d4d6d620bf93f06 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Tue, 23 May 2023 16:12:42 +0100 Subject: [PATCH] feat: update mapping to indicate privacy notice can be null in template if buyer not interviewed --- app/services/bulk_upload/sales/year2022/row_parser.rb | 2 +- app/services/bulk_upload/sales/year2023/row_parser.rb | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/services/bulk_upload/sales/year2022/row_parser.rb b/app/services/bulk_upload/sales/year2022/row_parser.rb index 7eafd7e06..902b5ad71 100644 --- a/app/services/bulk_upload/sales/year2022/row_parser.rb +++ b/app/services/bulk_upload/sales/year2022/row_parser.rb @@ -414,7 +414,7 @@ class BulkUpload::Sales::Year2022::RowParser private def validate_data_protection_answered - unless field_112 == 1 + unless field_112 == 1 || buyer_not_interviewed? errors.add(:field_112, I18n.t("validations.not_answered", question: QUESTIONS[:field_112].downcase), category: :setup) end end diff --git a/app/services/bulk_upload/sales/year2023/row_parser.rb b/app/services/bulk_upload/sales/year2023/row_parser.rb index f2c3e6d8b..ed42e1b5c 100644 --- a/app/services/bulk_upload/sales/year2023/row_parser.rb +++ b/app/services/bulk_upload/sales/year2023/row_parser.rb @@ -536,11 +536,15 @@ class BulkUpload::Sales::Year2023::RowParser private def validate_data_protection_answered - unless field_29 == 1 + unless field_29 == 1 || buyer_not_interviewed? errors.add(:field_29, I18n.t("validations.not_answered", question: QUESTIONS[:field_29].downcase), category: :setup) end end + def buyer_not_interviewed? + field_28 == 1 + end + def prevtenbuy2 case field_72 when "R" @@ -753,7 +757,7 @@ private attributes["purchid"] = purchaser_code attributes["saledate"] = saledate - attributes["noint"] = 2 if field_28 == 1 + attributes["noint"] = 2 if buyer_not_interviewed? attributes["age1_known"] = age1_known? attributes["age1"] = field_30 if attributes["age1_known"].zero? && field_30&.match(/\A\d{1,3}\z|\AR\z/)