Browse Source

Update csv parser on sales

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

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

@ -49,16 +49,10 @@ class BulkUpload::Sales::Year2023::CsvParser
end end
def correct_template_for_year? def correct_template_for_year?
if with_headers?
has_field_in_header?(135)
else
begin
collection_start_year_for_date(first_record_start_date) == 2023 collection_start_year_for_date(first_record_start_date) == 2023
rescue Date::Error rescue Date::Error
true true
end end
end
end
private private
@ -107,6 +101,10 @@ private
end end
def first_record_start_date def first_record_start_date
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) 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