Browse Source

CLDC-3910: BU Sales - Staircasing initial equity do not block log creation (#2985)

* Skip bu error on the setup question type

* Lint

* Skip bu error on setup question type for equity calculations

* Skip bu error on setup question type for mrent validations

* Skip bu error on setup question type for stairbought validations
pull/2997/head
Manny Dinssa 1 week ago committed by GitHub
parent
commit
b327d6725a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      app/models/validations/sales/financial_validations.rb
  2. 4
      app/models/validations/sales/sale_information_validations.rb

6
app/models/validations/sales/financial_validations.rb

@ -75,7 +75,7 @@ module Validations::Sales::FinancialValidations
if threshold && record.stairbought < threshold
shared_ownership_type = record.form.get_question("type", record).label_from_value(record.type).downcase
record.errors.add :stairbought, I18n.t("validations.sales.financial.stairbought.percentage_bought_must_be_at_least_threshold", threshold:, shared_ownership_type:)
record.errors.add :type, I18n.t("validations.sales.financial.type.percentage_bought_must_be_at_least_threshold", threshold:, shared_ownership_type:)
record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sales.financial.type.percentage_bought_must_be_at_least_threshold", threshold:, shared_ownership_type:)
end
end
@ -96,10 +96,10 @@ module Validations::Sales::FinancialValidations
return unless (range = ranges[record.type])
if record.equity < range.min
record.errors.add :type, I18n.t("validations.sales.financial.type.equity_under_min", min_equity: range.min)
record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sales.financial.type.equity_under_min", min_equity: range.min)
record.errors.add :equity, :under_min, message: I18n.t("validations.sales.financial.equity.equity_under_min", min_equity: range.min)
elsif !record.is_resale? && record.equity > range.max
record.errors.add :type, I18n.t("validations.sales.financial.type.equity_over_max", max_equity: range.max)
record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sales.financial.type.equity_over_max", max_equity: range.max)
record.errors.add :equity, :over_max, message: I18n.t("validations.sales.financial.equity.equity_over_max", max_equity: range.max)
record.errors.add :resale, I18n.t("validations.sales.financial.resale.equity_over_max", max_equity: range.max)
end

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

@ -108,7 +108,7 @@ module Validations::Sales::SaleInformationValidations
if record.shared_ownership_scheme? && !record.old_persons_shared_ownership? && record.mrent > 9999
record.errors.add :mrent, I18n.t("validations.sales.sale_information.mrent.monthly_rent_higher_than_expected")
record.errors.add :type, I18n.t("validations.sales.sale_information.type.monthly_rent_higher_than_expected")
record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sales.sale_information.type.monthly_rent_higher_than_expected")
end
end
@ -136,7 +136,7 @@ module Validations::Sales::SaleInformationValidations
if max_stairbought && record.stairbought > max_stairbought
record.errors.add :stairbought, I18n.t("validations.sales.sale_information.stairbought.stairbought_over_max", max_stairbought:, type: record.form.get_question("type", record).answer_label(record))
record.errors.add :type, I18n.t("validations.sales.sale_information.type.stairbought_over_max", max_stairbought:, type: record.form.get_question("type", record).answer_label(record))
record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sales.sale_information.type.stairbought_over_max", max_stairbought:, type: record.form.get_question("type", record).answer_label(record))
end
end

Loading…
Cancel
Save