Browse Source

Update csv parser on sales

pull/1665/head
Kat 3 years ago
parent
commit
0df8b00570
  1. 18
      app/services/bulk_upload/sales/year2023/csv_parser.rb

18
app/services/bulk_upload/sales/year2023/csv_parser.rb

@ -49,15 +49,9 @@ class BulkUpload::Sales::Year2023::CsvParser
end end
def correct_template_for_year? def correct_template_for_year?
if with_headers? collection_start_year_for_date(first_record_start_date) == 2023
has_field_in_header?(135) rescue Date::Error
else true
begin
collection_start_year_for_date(first_record_start_date) == 2023
rescue Date::Error
true
end
end
end end
private private
@ -107,6 +101,10 @@ private
end end
def first_record_start_date def first_record_start_date
Date.new(rows.first[3].to_i + 2000, rows.first[2].to_i, rows.first[1].to_i) if with_headers?
Date.new(row_parsers.first.field_4.to_i + 2000, row_parsers.first.field_3.to_i, row_parsers.first.field_2.to_i)
else
Date.new(rows.first[3].to_i + 2000, rows.first[2].to_i, rows.first[1].to_i)
end
end end
end end

Loading…
Cancel
Save