Browse Source

feat: keep system date fields in iso8601 format

pull/1954/head
natdeanlewissoftwire 3 years ago
parent
commit
8e9ba6bbf4
  1. 13
      app/services/csv/lettings_log_csv_service.rb
  2. 6
      app/services/csv/sales_log_csv_service.rb

13
app/services/csv/lettings_log_csv_service.rb

@ -136,12 +136,15 @@ module Csv
"prevloc_label" => "prevloc",
}.freeze
DATE_FIELDS = %w[
SYSTEM_DATE_FIELDS = %w[
created_at
updated_at
].freeze
USER_DATE_FIELDS = %w[
mrcdate
startdate
voiddate
created_at
updated_at
].freeze
def value(attribute, log)
@ -155,7 +158,9 @@ module Csv
attribute = FIELDS_ALWAYS_EXPORTED_AS_LABELS[attribute]
value = log.public_send(attribute)
get_label(value, attribute, log)
elsif DATE_FIELDS.include? attribute
elsif SYSTEM_DATE_FIELDS.include? attribute
log.public_send(attribute)&.iso8601
elsif USER_DATE_FIELDS.include? attribute
log.public_send(attribute)&.strftime("%F")
elsif PERSON_DETAILS.any? { |key, _value| key == attribute } && person_details_not_known?(log, attribute)
case @export_type

6
app/services/csv/sales_log_csv_service.rb

@ -58,7 +58,7 @@ module Csv
"prevloc_label" => "prevloc",
}.freeze
DATE_FIELDS = %w[
SYSTEM_DATE_FIELDS = %w[
created_at
updated_at
].freeze
@ -73,8 +73,8 @@ module Csv
attribute = FIELDS_ALWAYS_EXPORTED_AS_LABELS[attribute]
value = log.send(attribute)
get_label(value, attribute, log)
elsif DATE_FIELDS.include? attribute
log.public_send(attribute)&.strftime("%F")
elsif SYSTEM_DATE_FIELDS.include? attribute
log.public_send(attribute)&.iso8601
else
value = log.public_send(attribute)
case @export_type

Loading…
Cancel
Save