Browse Source

feat: add as entered fields to xml export for 2024 only (#2324)

pull/2322/head^2
natdeanlewissoftwire 2 years ago committed by GitHub
parent
commit
16bb90bf1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 16
      app/services/exports/lettings_log_export_constants.rb
  2. 4
      app/services/exports/lettings_log_export_service.rb
  3. 6
      spec/fixtures/exports/general_needs_log_24_25.xml
  4. 2
      spec/services/exports/lettings_log_export_service_spec.rb

16
app/services/exports/lettings_log_export_constants.rb

@ -140,7 +140,13 @@ module Exports::LettingsLogExportConstants
"amended_by", "amended_by",
"duplicate_set_id", "duplicate_set_id",
"accessible_register", "accessible_register",
"nationality_all" "nationality_all",
"address_line1_as_entered",
"address_line2_as_entered",
"town_or_city_as_entered",
"county_as_entered",
"postcode_full_as_entered",
"la_as_entered",
] ]
(1..8).each do |index| (1..8).each do |index|
@ -160,7 +166,13 @@ module Exports::LettingsLogExportConstants
POST_2024_EXPORT_FIELDS = Set[ POST_2024_EXPORT_FIELDS = Set[
"accessible_register", "accessible_register",
"nationality_all" "nationality_all",
"address_line1_as_entered",
"address_line2_as_entered",
"town_or_city_as_entered",
"county_as_entered",
"postcode_full_as_entered",
"la_as_entered",
] ]
PRE_2024_EXPORT_FIELDS = Set[ PRE_2024_EXPORT_FIELDS = Set[

4
app/services/exports/lettings_log_export_service.rb

@ -255,10 +255,6 @@ module Exports
attribute_hash["location_status"] = location.status_at(attribute_hash["startdate"]) attribute_hash["location_status"] = location.status_at(attribute_hash["startdate"])
end end
def filter_keys!(attributes)
attributes.reject! { |attribute| is_omitted_field?(attribute) }
end
def is_omitted_field?(field_name, lettings_log) def is_omitted_field?(field_name, lettings_log)
pattern_age = /age\d_known/ pattern_age = /age\d_known/
details_known_prefix = "details_known_" details_known_prefix = "details_known_"

6
spec/fixtures/exports/general_needs_log_24_25.xml vendored

@ -146,6 +146,12 @@
<duplicate_set_id/> <duplicate_set_id/>
<accessible_register>2</accessible_register> <accessible_register>2</accessible_register>
<nationality_all/> <nationality_all/>
<address_line1_as_entered>address line 1 as entered</address_line1_as_entered>
<address_line2_as_entered>address line 2 as entered</address_line2_as_entered>
<town_or_city_as_entered>town or city as entered</town_or_city_as_entered>
<county_as_entered>county as entered</county_as_entered>
<postcode_full_as_entered>AB1 2CD</postcode_full_as_entered>
<la_as_entered>la as entered</la_as_entered>
<formid>{id}</formid> <formid>{id}</formid>
<owningorgid>{owning_org_id}</owningorgid> <owningorgid>{owning_org_id}</owningorgid>
<owningorgname>DLUHC</owningorgname> <owningorgname>DLUHC</owningorgname>

2
spec/services/exports/lettings_log_export_service_spec.rb

@ -472,7 +472,7 @@ RSpec.describe Exports::LettingsLogExportService do
end end
context "and one lettings log is available for export" do context "and one lettings log is available for export" do
let!(:lettings_log) { FactoryBot.create(:lettings_log, :completed, created_by: user, ppostcode_full: "A1 1AA", nationality_all_group: 13, propcode: "123", postcode_full: "SE2 6RT", tenancycode: "BZ737", startdate: Time.zone.local(2024, 4, 2, 10, 36, 49), voiddate: Time.zone.local(2021, 11, 3), mrcdate: Time.zone.local(2022, 5, 5, 10, 36, 49), tenancylength: 5, underoccupation_benefitcap: 4) } let!(:lettings_log) { FactoryBot.create(:lettings_log, :completed, created_by: user, ppostcode_full: "A1 1AA", nationality_all_group: 13, propcode: "123", postcode_full: "SE2 6RT", tenancycode: "BZ737", startdate: Time.zone.local(2024, 4, 2, 10, 36, 49), voiddate: Time.zone.local(2021, 11, 3), mrcdate: Time.zone.local(2022, 5, 5, 10, 36, 49), tenancylength: 5, underoccupation_benefitcap: 4, address_line1_as_entered: "address line 1 as entered", address_line2_as_entered: "address line 2 as entered", town_or_city_as_entered: "town or city as entered", county_as_entered: "county as entered", postcode_full_as_entered: "AB1 2CD", la_as_entered: "la as entered") }
let(:expected_zip_filename) { "core_2024_2025_apr_mar_f0001_inc0001.zip" } let(:expected_zip_filename) { "core_2024_2025_apr_mar_f0001_inc0001.zip" }
let(:expected_data_filename) { "core_2024_2025_apr_mar_f0001_inc0001_pt001.xml" } let(:expected_data_filename) { "core_2024_2025_apr_mar_f0001_inc0001_pt001.xml" }
let(:xml_export_file) { File.open("spec/fixtures/exports/general_needs_log_24_25.xml", "r:UTF-8") } let(:xml_export_file) { File.open("spec/fixtures/exports/general_needs_log_24_25.xml", "r:UTF-8") }

Loading…
Cancel
Save