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

12
app/services/exports/sales_log_export_service.rb

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

Loading…
Cancel
Save