Skip to content

Commit

Permalink
Merge PR #12 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by mikevhe18
  • Loading branch information
ssi-bot committed Feb 23, 2024
2 parents 9afa999 + 7d4ce2a commit b1f336d
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions ssi_loan/models/loan_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from odoo import _, api, fields, models
from odoo.exceptions import UserError, ValidationError

from odoo.addons.ssi_decorator import ssi_decorator


Expand Down Expand Up @@ -642,8 +643,24 @@ def action_cancel(self, cancel_reason=False):
def _check_total_principle_amount(self):
self.ensure_one()
if self.total_principle_amount != self.loan_amount:
total_principle_amount = '{:0,.2f}'.format(self.total_principle_amount)
loan_amount = '{:0,.2f}'.format(self.loan_amount)
raise ValidationError(_(
f'Total principal amount ({total_principle_amount}) '
f'different with loan amount ({loan_amount}).'))
total_principle_amount = "{:0,.2f}".format(self.total_principle_amount)
loan_amount = "{:0,.2f}".format(self.loan_amount)
raise ValidationError(
_(
f"Total principal amount ({total_principle_amount}) "
f"different with loan amount ({loan_amount})."
)
)

@ssi_decorator.pre_confirm_check()
def _check_maximum_loan(self):
self.ensure_one()
if self.loan_amount > self.maximum_loan_amount:
loan_amount = "{:0,.2f}".format(self.loan_amount)
maximum_loan_amount = "{:0,.2f}".format(self.maximum_loan_amount)
raise ValidationError(
_(
f"Loan amount ({loan_amount}) "
f"cannot exceed the maximum total loan ({maximum_loan_amount})."
)
)

0 comments on commit b1f336d

Please sign in to comment.