Browse Source

CLDC-4297: don't allow 0.0

pull/3240/head
Nat Dean-Lewis 2 months ago
parent
commit
0d0388f53b
  1. 11
      app/services/bulk_upload/sales/year2026/row_parser.rb

11
app/services/bulk_upload/sales/year2026/row_parser.rb

@ -152,7 +152,7 @@ class BulkUpload::Sales::Year2026::RowParser
}.freeze }.freeze
ERROR_BASE_KEY = "validations.sales.2026.bulk_upload".freeze ERROR_BASE_KEY = "validations.sales.2026.bulk_upload".freeze
SERVICE_CHARGE_FORMAT = /\A(\d+(\.\d+)?|R)\z/ SERVICE_CHARGE_FORMAT = /\A(\d+(\.\d+)?|R)\z/i
CASE_INSENSITIVE_FIELDS = [ CASE_INSENSITIVE_FIELDS = [
:field_29, # Age of buyer 1 :field_29, # Age of buyer 1
@ -478,7 +478,6 @@ class BulkUpload::Sales::Year2026::RowParser
}, },
on: :after_log on: :after_log
validate :validate_service_charge_fields, on: :before_log
validate :validate_buyer1_economic_status, on: :before_log validate :validate_buyer1_economic_status, on: :before_log
validate :validate_buyer2_economic_status, on: :before_log validate :validate_buyer2_economic_status, on: :before_log
@ -504,6 +503,8 @@ class BulkUpload::Sales::Year2026::RowParser
validate :validate_buyer_2_nationality, on: :after_log validate :validate_buyer_2_nationality, on: :after_log
validate :validate_mortlen_field_if_buyer_interviewed, on: :after_log validate :validate_mortlen_field_if_buyer_interviewed, on: :after_log
validate :validate_service_charge_fields, on: :after_log
validate :validate_nulls, on: :after_log validate :validate_nulls, on: :after_log
def self.question_for_field(field) def self.question_for_field(field)
@ -1400,12 +1401,12 @@ private
def validate_service_charge_fields def validate_service_charge_fields
message = I18n.t("#{ERROR_BASE_KEY}.mscharge.invalid") message = I18n.t("#{ERROR_BASE_KEY}.mscharge.invalid")
if shared_ownership_initial_purchase? && field_107.present? && (!field_107.match?(SERVICE_CHARGE_FORMAT) || field_107.to_d.zero?) if shared_ownership_initial_purchase? && field_107.present? && (!field_107.match?(SERVICE_CHARGE_FORMAT) || (field_107 != "R" && field_107.to_d.zero?))
errors.add(:field_107, message) errors.add(:field_107, message)
end end
if staircasing? if staircasing?
if field_125.present? && (!field_125.match?(SERVICE_CHARGE_FORMAT) || field_125.to_d.zero?) if field_125.present? && (!field_125.match?(SERVICE_CHARGE_FORMAT) || (field_125 != "R" && field_125.to_d.zero?))
errors.add(:field_125, message) errors.add(:field_125, message)
end end
@ -1414,7 +1415,7 @@ private
end end
end end
if discounted_ownership? && field_136.present? && (!field_136.match?(SERVICE_CHARGE_FORMAT) || field_136.to_d.zero?) if discounted_ownership? && field_136.present? && (!field_136.match?(SERVICE_CHARGE_FORMAT) || (field_136 != "R" && field_136.to_d.zero?))
errors.add(:field_136, message) errors.add(:field_136, message)
end end
end end

Loading…
Cancel
Save