Browse Source

fix bulk upload error

- show correct year info when outside of collection window
pull/1603/head
Phil Lee 2 years ago
parent
commit
5f0664aaac
  1. 4
      app/models/bulk_upload.rb
  2. 6
      app/services/bulk_upload/lettings/year2022/row_parser.rb
  3. 6
      app/services/bulk_upload/lettings/year2023/row_parser.rb
  4. 6
      app/services/bulk_upload/sales/year2022/row_parser.rb
  5. 6
      app/services/bulk_upload/sales/year2023/row_parser.rb
  6. 2
      config/locales/en.yml

4
app/models/bulk_upload.rb

@ -14,6 +14,10 @@ class BulkUpload < ApplicationRecord
"#{year}/#{year - 2000 + 1}"
end
def end_year
year + 1
end
def logs
if lettings?
lettings_logs

6
app/services/bulk_upload/lettings/year2022/row_parser.rb

@ -680,9 +680,9 @@ private
return if start_date.blank? || bulk_upload.form.blank?
unless bulk_upload.form.valid_start_date_for_form?(start_date)
errors.add(:field_96, I18n.t("validations.date.outside_collection_window"), category: :setup)
errors.add(:field_97, I18n.t("validations.date.outside_collection_window"), category: :setup)
errors.add(:field_98, I18n.t("validations.date.outside_collection_window"), category: :setup)
errors.add(:field_96, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
errors.add(:field_97, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
errors.add(:field_98, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
end
end

6
app/services/bulk_upload/lettings/year2023/row_parser.rb

@ -624,9 +624,9 @@ private
return if start_date.blank? || bulk_upload.form.blank?
unless bulk_upload.form.valid_start_date_for_form?(start_date)
errors.add(:field_7, I18n.t("validations.date.outside_collection_window"), category: :setup)
errors.add(:field_8, I18n.t("validations.date.outside_collection_window"), category: :setup)
errors.add(:field_9, I18n.t("validations.date.outside_collection_window"), category: :setup)
errors.add(:field_7, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
errors.add(:field_8, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
errors.add(:field_9, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
end
end

6
app/services/bulk_upload/sales/year2022/row_parser.rb

@ -941,9 +941,9 @@ private
return if saledate.blank? || bulk_upload.form.blank?
unless bulk_upload.form.valid_start_date_for_form?(saledate)
errors.add(:field_2, I18n.t("validations.date.outside_collection_window"), category: :setup)
errors.add(:field_3, I18n.t("validations.date.outside_collection_window"), category: :setup)
errors.add(:field_4, I18n.t("validations.date.outside_collection_window"), category: :setup)
errors.add(:field_2, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
errors.add(:field_3, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
errors.add(:field_4, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup)
end
end

6
app/services/bulk_upload/sales/year2023/row_parser.rb

@ -1102,9 +1102,9 @@ private
return if saledate.blank? || bulk_upload.form.blank?
unless bulk_upload.form.valid_start_date_for_form?(saledate)
errors.add(:field_3, I18n.t("validations.date.outside_collection_window"))
errors.add(:field_4, I18n.t("validations.date.outside_collection_window"))
errors.add(:field_5, I18n.t("validations.date.outside_collection_window"))
errors.add(:field_3, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year))
errors.add(:field_4, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year))
errors.add(:field_5, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year))
end
end
end

2
config/locales/en.yml

@ -165,7 +165,7 @@ en:
date:
invalid_date: "Enter a date in the correct format, for example 31 1 2022"
outside_collection_window: Enter a date within the 22/23 collection year, which is between 1st April 2022 and 31st March 2023
outside_collection_window: Enter a date within the %{year_combo} collection year, which is between 1st April %{start_year} and 31st March %{end_year}
postcode: "Enter a postcode in the correct format, for example AA1 1AA"
location_admin_district: "Select a local authority"
email:

Loading…
Cancel
Save