diff --git a/app/services/exports/sales_log_export_constants.rb b/app/services/exports/sales_log_export_constants.rb index cf6a6e079..a8ff44a2f 100644 --- a/app/services/exports/sales_log_export_constants.rb +++ b/app/services/exports/sales_log_export_constants.rb @@ -139,13 +139,24 @@ module Exports::SalesLogExportConstants (1..6).each do |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| ALL_YEAR_EXPORT_FIELDS << "RELAT#{index}" end + YEAR_2024_EXPORT_FIELDS = Set[] + + (1..6).each do |index| + YEAR_2024_EXPORT_FIELDS << "SEX#{index}" + end + + YEAR_2025_EXPORT_FIELDS = Set[] + + (1..6).each do |index| + YEAR_2025_EXPORT_FIELDS << "SEX#{index}" + end + YEAR_2026_EXPORT_FIELDS = Set["BUILDHEIGHTCLASS"] (1..6).each do |index| diff --git a/app/services/exports/sales_log_export_service.rb b/app/services/exports/sales_log_export_service.rb index 5b3f719e8..d64fe7f6c 100644 --- a/app/services/exports/sales_log_export_service.rb +++ b/app/services/exports/sales_log_export_service.rb @@ -159,6 +159,10 @@ module Exports included_fields.merge(ALL_YEAR_EXPORT_FIELDS) year_fields = case sales_log.collection_start_year + when 2024 + YEAR_2024_EXPORT_FIELDS + when 2025 + YEAR_2025_EXPORT_FIELDS when 2026 YEAR_2026_EXPORT_FIELDS else diff --git a/spec/factories/sales_log.rb b/spec/factories/sales_log.rb index 81d679ab6..2cdc688be 100644 --- a/spec/factories/sales_log.rb +++ b/spec/factories/sales_log.rb @@ -300,7 +300,7 @@ FactoryBot.define do builtype { 1 } ethnic { 3 } ethnic_group { 17 } - sexrab2 { "X" } + sexrab2 { "R" } sex2 { "X" } buy2livein { "1" } ecstat1 { "1" } @@ -335,11 +335,11 @@ FactoryBot.define do prevshared { 2 } sexrab3 { "F" } sex3 { "F" } - sexrab4 { "X" } + sexrab4 { "R" } sex4 { "X" } sexrab5 { "M" } sex5 { "M" } - sexrab6 { "X" } + sexrab6 { "R" } sex6 { "X" } mortgage { 20_000 } ecstat3 { 9 } diff --git a/spec/fixtures/exports/sales_log_26_27.xml b/spec/fixtures/exports/sales_log_26_27.xml index 71278bbda..88bca393f 100644 --- a/spec/fixtures/exports/sales_log_26_27.xml +++ b/spec/fixtures/exports/sales_log_26_27.xml @@ -8,13 +8,13 @@ 1 2 27 - F + F 17 1 1 33 P - X + R 2 1 1 @@ -32,7 +32,7 @@ 1 1 - F + F 20000.0 1 9 @@ -44,9 +44,9 @@ R R 4 - X - M - X + R + M + R @@ -88,12 +88,6 @@ - F - - F - - M - 2 1 4 diff --git a/spec/services/exports/sales_log_export_service_spec.rb b/spec/services/exports/sales_log_export_service_spec.rb index 14e138449..25709fdb8 100644 --- a/spec/services/exports/sales_log_export_service_spec.rb +++ b/spec/services/exports/sales_log_export_service_spec.rb @@ -333,7 +333,7 @@ RSpec.describe Exports::SalesLogExportService do end end - context "when exporting only 24/25 collection period" do + context "when exporting only 24/25 collection period", metadata: { year: 24 } do let(:start_time) { Time.zone.local(2024, 4, 3) } before do @@ -365,8 +365,8 @@ RSpec.describe Exports::SalesLogExportService do end end - context "when exporting only 25/26 collection period" do - let(:start_time) { Time.zone.local(2025, 4, 1) } + context "when exporting only 25/26 collection period", metadata: { year: 25 } do + let(:start_time) { collection_start_date_for_year(2025) } before do Timecop.freeze(start_time) @@ -397,8 +397,8 @@ RSpec.describe Exports::SalesLogExportService do end end - context "when exporting only 26/27 collection period" do - let(:start_time) { Time.zone.local(2026, 4, 1) } + context "when exporting only 26/27 collection period", metadata: { year: 26 } do + let(:start_time) { collection_start_date_for_year(2026) } before do Timecop.freeze(start_time)