fix: Sanctioned loan security unpledge
This commit is contained in:
parent
a56a5ccefa
commit
dd768a07c5
@ -362,6 +362,27 @@ class TestLoan(unittest.TestCase):
|
||||
unpledge_request.load_from_db()
|
||||
self.assertEqual(unpledge_request.docstatus, 1)
|
||||
|
||||
def test_santined_loan_security_unpledge(self):
|
||||
pledge = [{
|
||||
"loan_security": "Test Security 1",
|
||||
"qty": 4000.00
|
||||
}]
|
||||
|
||||
loan_application = create_loan_application('_Test Company', self.applicant2, 'Demand Loan', pledge)
|
||||
create_pledge(loan_application)
|
||||
|
||||
loan = create_demand_loan(self.applicant2, "Demand Loan", loan_application, posting_date='2019-10-01')
|
||||
loan.submit()
|
||||
|
||||
self.assertEquals(loan.loan_amount, 1000000)
|
||||
|
||||
unpledge_map = {'Test Security 1': 4000}
|
||||
unpledge_request = unpledge_security(loan=loan.name, security_map = unpledge_map, save=1)
|
||||
unpledge_request.submit()
|
||||
unpledge_request.status = 'Approved'
|
||||
unpledge_request.save()
|
||||
unpledge_request.submit()
|
||||
|
||||
def test_disbursal_check_with_shortfall(self):
|
||||
pledges = [{
|
||||
"loan_security": "Test Security 2",
|
||||
|
@ -44,10 +44,16 @@ class LoanSecurityUnpledge(Document):
|
||||
"valid_upto": (">=", get_datetime())
|
||||
}, as_list=1))
|
||||
|
||||
total_payment, principal_paid, interest_payable, written_off_amount = frappe.get_value("Loan", self.loan, ['total_payment', 'total_principal_paid',
|
||||
'total_interest_payable', 'written_off_amount'])
|
||||
loan_details = frappe.get_value("Loan", self.loan, ['total_payment', 'total_principal_paid',
|
||||
'total_interest_payable', 'written_off_amount', 'disbursed_amount', 'status'], as_dict=1)
|
||||
|
||||
if loan_details.status == 'Disbursed':
|
||||
pending_principal_amount = flt(loan_details.total_payment) - flt(loan_details.interest_payable) \
|
||||
- flt(loan_details.principal_paid) - flt(loan_details.written_off_amount)
|
||||
else:
|
||||
pending_principal_amount = flt(loan_details.disbursed_amount) - flt(loan_details.total_interest_payable) \
|
||||
- flt(loan_details.total_principal_paid) - flt(loan_details.written_off_amount)
|
||||
|
||||
pending_principal_amount = flt(total_payment) - flt(interest_payable) - flt(principal_paid) - flt(written_off_amount)
|
||||
security_value = 0
|
||||
unpledge_qty_map = {}
|
||||
ltv_ratio = 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user