Browse Source

CLDC-4177: update sales log export service

pull/3156/head
Nat Dean-Lewis 2 weeks ago
parent
commit
d861e6feb9
  1. 14
      app/services/exports/sales_log_export_constants.rb
  2. 12
      app/services/exports/sales_log_export_service.rb

14
app/services/exports/sales_log_export_constants.rb

@ -7,7 +7,7 @@ module Exports::SalesLogExportConstants
csv: 2, csv: 2,
}.freeze }.freeze
EXPORT_FIELDS = Set["ID", ALL_YEAR_EXPORT_FIELDS = Set["ID",
"STATUS", "STATUS",
"DAY", "DAY",
"MONTH", "MONTH",
@ -135,18 +135,18 @@ module Exports::SalesLogExportConstants
"SERVICECHARGES",] "SERVICECHARGES",]
(1..6).each do |index| (1..6).each do |index|
EXPORT_FIELDS << "AGE#{index}" ALL_YEAR_EXPORT_FIELDS << "AGE#{index}"
EXPORT_FIELDS << "ECSTAT#{index}" ALL_YEAR_EXPORT_FIELDS << "ECSTAT#{index}"
EXPORT_FIELDS << "SEX#{index}" ALL_YEAR_EXPORT_FIELDS << "SEX#{index}"
end end
(2..6).each do |index| (2..6).each do |index|
EXPORT_FIELDS << "RELAT#{index}" ALL_YEAR_EXPORT_FIELDS << "RELAT#{index}"
end end
POST_2026_EXPORT_FIELDS = Set[] YEAR_2026_EXPORT_FIELDS = Set[]
(1..6).each do |index| (1..6).each do |index|
POST_2026_EXPORT_FIELDS << "SEXRAB#{index}" YEAR_2026_EXPORT_FIELDS << "SEXRAB#{index}"
end end
end end

12
app/services/exports/sales_log_export_service.rb

@ -156,12 +156,16 @@ module Exports
def get_included_fields(sales_log) def get_included_fields(sales_log)
included_fields = Set[] included_fields = Set[]
included_fields.merge(EXPORT_FIELDS) included_fields.merge(ALL_YEAR_EXPORT_FIELDS)
if sales_log.form.start_year_2026_or_later? year_fields = case sales_log.collection_start_year
included_fields.merge(POST_2026_EXPORT_FIELDS) when 2026
end YEAR_2026_EXPORT_FIELDS
else
Set[]
end
included_fields.merge(year_fields)
included_fields included_fields
end end

Loading…
Cancel
Save