Browse Source

Merge branch 'main' into Add-error-handling-for-JSON-parsing-to-UPRN-client

pull/2992/head
Manny Dinssa 2 months ago committed by GitHub
parent
commit
a2113ef6fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      app/models/validations/sales/property_validations.rb
  2. 7
      app/services/csv/lettings_log_csv_service.rb
  3. 7
      app/services/csv/sales_log_csv_service.rb

4
app/models/validations/sales/property_validations.rb

@ -49,9 +49,9 @@ module Validations::Sales::PropertyValidations
record.errors.add :uprn_confirmation, I18n.t("validations.sales.property_information.uprn_confirmation.not_in_england") record.errors.add :uprn_confirmation, I18n.t("validations.sales.property_information.uprn_confirmation.not_in_england")
record.errors.add :uprn_selection, I18n.t("validations.sales.property_information.uprn_selection.not_in_england") record.errors.add :uprn_selection, I18n.t("validations.sales.property_information.uprn_selection.not_in_england")
if record.uprn.present? if record.uprn.present?
record.errors.add :saledate, I18n.t("validations.sales.property_information.saledate.address_not_in_england") record.errors.add :saledate, :skip_bu_error, message: I18n.t("validations.sales.property_information.saledate.address_not_in_england")
else else
record.errors.add :saledate, I18n.t("validations.sales.property_information.saledate.postcode_not_in_england") record.errors.add :saledate, :skip_bu_error, message: I18n.t("validations.sales.property_information.saledate.postcode_not_in_england")
end end
end end
end end

7
app/services/csv/lettings_log_csv_service.rb

@ -284,13 +284,12 @@ module Csv
end end
def lettings_log_definitions def lettings_log_definitions
CsvVariableDefinition.lettings.group_by { |record| [record.variable, record.definition] } CsvVariableDefinition.lettings.group_by(&:variable).map { |_, options|
.map do |_, options|
exact_match = options.find { |definition| definition.year == @year } exact_match = options.find { |definition| definition.year == @year }
next exact_match if exact_match next exact_match if exact_match
options.max_by(&:year) options.select { |opt| opt.year < @year }.max_by(&:year)
end }.compact
end end
def insert_derived_and_related_attributes(ordered_questions) def insert_derived_and_related_attributes(ordered_questions)

7
app/services/csv/sales_log_csv_service.rb

@ -179,13 +179,12 @@ module Csv
end end
def sales_log_definitions def sales_log_definitions
CsvVariableDefinition.sales.group_by { |record| [record.variable, record.definition] } CsvVariableDefinition.sales.group_by(&:variable).map { |_, options|
.map do |_, options|
exact_match = options.find { |definition| definition.year == @year } exact_match = options.find { |definition| definition.year == @year }
next exact_match if exact_match next exact_match if exact_match
options.max_by(&:year) options.select { |opt| opt.year < @year }.max_by(&:year)
end }.compact
end end
def insert_derived_and_related_attributes(ordered_questions) def insert_derived_and_related_attributes(ordered_questions)

Loading…
Cancel
Save