fix: Add test for loan repayment cancellation

(cherry picked from commit 68d49817a1)
This commit is contained in:
Deepesh Garg
2021-12-28 18:10:52 +05:30
committed by mergify-bot
parent 4248bebe48
commit a4396d7f31
2 changed files with 9 additions and 1 deletions

View File

@@ -218,6 +218,14 @@ class TestLoan(unittest.TestCase):
self.assertEqual(flt(loan.total_principal_paid, 0), flt(repayment_entry.amount_paid -
penalty_amount - total_interest_paid, 0))
# Check Repayment Entry cancel
repayment_entry.load_from_db()
repayment_entry.cancel()
loan.load_from_db()
self.assertEqual(loan.total_principal_paid, 0)
self.assertEqual(loan.total_principal_paid, 0)
def test_loan_closure(self):
pledge = [{
"loan_security": "Test Security 1",

View File

@@ -135,7 +135,7 @@ class LoanRepayment(AccountsController):
})
pending_principal_amount = get_pending_principal_amount(loan)
if not loan.is_secured_loan and pending_principal_amount < 0:
if not loan.is_secured_loan and pending_principal_amount <= 0:
loan.update({'status': 'Loan Closure Requested'})
for payment in self.repayment_details: