diff --git a/app/jobs/email_csv_job.rb b/app/jobs/email_csv_job.rb index 89b358e28..7658cf755 100644 --- a/app/jobs/email_csv_job.rb +++ b/app/jobs/email_csv_job.rb @@ -15,7 +15,7 @@ class EmailCsvJob < ApplicationJob when "sales" unfiltered_logs = organisation.present? && user.support? ? SalesLog.visible.where(owning_organisation_id: organisation.id) : user.sales_logs.visible filtered_logs = FilterManager.filter_logs(unfiltered_logs, search_term, filters, all_orgs, user) - csv_string = Csv::SalesLogCsvService.new(export_type:).prepare_csv(filtered_logs) + csv_string = Csv::SalesLogCsvService.new(user:, export_type:).prepare_csv(filtered_logs) end filename = "#{[log_type, 'logs', organisation&.name, Time.zone.now].compact.join('-')}.csv" diff --git a/app/services/bulk_upload/sales/year2024/row_parser.rb b/app/services/bulk_upload/sales/year2024/row_parser.rb index 928060dfa..3f4593db6 100644 --- a/app/services/bulk_upload/sales/year2024/row_parser.rb +++ b/app/services/bulk_upload/sales/year2024/row_parser.rb @@ -863,9 +863,11 @@ private attributes["builtype"] = field_21 attributes["la_known"] = field_29.present? ? 1 : 0 attributes["la"] = field_29 + attributes["la_as_entered"] = field_29 attributes["is_la_inferred"] = false attributes["pcodenk"] = 0 if postcode_full.present? attributes["postcode_full"] = postcode_full + attributes["postcode_full_as_entered"] = postcode_full attributes["wchair"] = field_30 attributes["type"] = sale_type @@ -931,9 +933,13 @@ private attributes["uprn_confirmed"] = 1 if field_22.present? attributes["skip_update_uprn_confirmed"] = true attributes["address_line1"] = field_23 + attributes["address_line1_as_entered"] = field_23 attributes["address_line2"] = field_24 + attributes["address_line2_as_entered"] = field_24 attributes["town_or_city"] = field_25 + attributes["town_or_city_as_entered"] = field_25 attributes["county"] = field_26 + attributes["county_as_entered"] = field_26 attributes["address_line1_input"] = address_line1_input attributes["postcode_full_input"] = postcode_full attributes["select_best_address_match"] = true if field_22.blank? diff --git a/app/services/csv/sales_log_csv_service.rb b/app/services/csv/sales_log_csv_service.rb index a1fbc1ca9..315b450b0 100644 --- a/app/services/csv/sales_log_csv_service.rb +++ b/app/services/csv/sales_log_csv_service.rb @@ -1,6 +1,7 @@ module Csv class SalesLogCsvService - def initialize(export_type:) + def initialize(user:, export_type:) + @user = user @export_type = export_type @attributes = sales_log_attributes end @@ -132,6 +133,8 @@ module Csv "managing_organisation_id" => %w[managing_organisation_name], }.freeze + def SUPPORT_ONLY_ATTRIBITES = %w[address_line1_as_entered address_line2_as_entered town_or_city_as_entered county_as_entered postcode_full_as_entered la_as_entered] + def sales_log_attributes ordered_questions = FormHandler.instance.ordered_sales_questions_for_all_years ordered_questions.reject! { |q| q.id.match?(/((?