Browse Source

fix: Loan disbursement amount validation (#24000)

develop
Deepesh Garg 4 years ago
committed by GitHub
parent
commit
a339752ba4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      erpnext/loan_management/doctype/loan/loan.json
  2. 13
      erpnext/loan_management/doctype/loan_disbursement/loan_disbursement.py

3
erpnext/loan_management/doctype/loan/loan.json

@ -332,6 +332,7 @@
"read_only": 1
},
{
"depends_on": "eval:doc.is_secured_loan",
"fetch_from": "loan_application.maximum_loan_amount",
"fieldname": "maximum_loan_amount",
"fieldtype": "Currency",
@ -352,7 +353,7 @@
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2020-11-05 10:04:00.762975",
"modified": "2020-11-24 12:27:23.208240",
"modified_by": "Administrator",
"module": "Loan Management",
"name": "Loan",

13
erpnext/loan_management/doctype/loan_disbursement/loan_disbursement.py

@ -171,10 +171,10 @@ def get_total_pledged_security_value(loan):
return security_value
@frappe.whitelist()
def get_disbursal_amount(loan):
loan_details = frappe.get_all("Loan", fields = ["loan_amount", "disbursed_amount", "total_payment",
"total_principal_paid", "total_interest_payable", "status", "is_term_loan", "is_secured_loan"],
filters= { "name": loan })[0]
def get_disbursal_amount(loan, on_current_security_price=0):
loan_details = frappe.get_value("Loan", loan, ["loan_amount", "disbursed_amount", "total_payment",
"total_principal_paid", "total_interest_payable", "status", "is_term_loan", "is_secured_loan",
"maximum_loan_amount"], as_dict=1)
if loan_details.is_secured_loan and frappe.get_all('Loan Security Shortfall', filters={'loan': loan,
'status': 'Pending'}):
@ -188,9 +188,12 @@ def get_disbursal_amount(loan):
- flt(loan_details.total_principal_paid)
security_value = 0.0
if loan_details.is_secured_loan:
if loan_details.is_secured_loan and on_current_security_price:
security_value = get_total_pledged_security_value(loan)
if loan_details.is_secured_loan and not on_current_security_price:
security_value = flt(loan_details.maximum_loan_amount)
if not security_value and not loan_details.is_secured_loan:
security_value = flt(loan_details.loan_amount)

Loading…
Cancel
Save