|
|
|
|
@ -152,7 +152,7 @@ class BulkUpload::Sales::Year2026::RowParser
|
|
|
|
|
}.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 = [ |
|
|
|
|
:field_29, # Age of buyer 1 |
|
|
|
|
@ -478,7 +478,6 @@ class BulkUpload::Sales::Year2026::RowParser
|
|
|
|
|
}, |
|
|
|
|
on: :after_log |
|
|
|
|
|
|
|
|
|
validate :validate_service_charge_fields, on: :before_log |
|
|
|
|
|
|
|
|
|
validate :validate_buyer1_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_mortlen_field_if_buyer_interviewed, on: :after_log |
|
|
|
|
|
|
|
|
|
validate :validate_service_charge_fields, on: :after_log |
|
|
|
|
|
|
|
|
|
validate :validate_nulls, on: :after_log |
|
|
|
|
|
|
|
|
|
def self.question_for_field(field) |
|
|
|
|
@ -1400,12 +1401,12 @@ private
|
|
|
|
|
def validate_service_charge_fields |
|
|
|
|
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) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
@ -1414,7 +1415,7 @@ private
|
|
|
|
|
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) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|