Merge pull request #25138 from deepeshgarg007/loan_shortfall_percentage
fix: Add shortfall ratio in Loan Security Shortfall
This commit is contained in:
commit
b7e7eeaf8d
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"actions": [],
|
||||||
"autoname": "LM-LSS-.#####",
|
"autoname": "LM-LSS-.#####",
|
||||||
"creation": "2019-09-06 11:33:34.709540",
|
"creation": "2019-09-06 11:33:34.709540",
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
@ -14,6 +15,7 @@
|
|||||||
"shortfall_amount",
|
"shortfall_amount",
|
||||||
"column_break_8",
|
"column_break_8",
|
||||||
"security_value",
|
"security_value",
|
||||||
|
"shortfall_percentage",
|
||||||
"section_break_8",
|
"section_break_8",
|
||||||
"process_loan_security_shortfall"
|
"process_loan_security_shortfall"
|
||||||
],
|
],
|
||||||
@ -85,10 +87,18 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "column_break_8",
|
"fieldname": "column_break_8",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "shortfall_percentage",
|
||||||
|
"fieldtype": "Percent",
|
||||||
|
"label": "Shortfall Percentage",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"in_create": 1,
|
"in_create": 1,
|
||||||
"modified": "2019-10-24 06:24:26.128997",
|
"index_web_pages_for_search": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2021-04-01 08:13:43.263772",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Loan Management",
|
"module": "Loan Management",
|
||||||
"name": "Loan Security Shortfall",
|
"name": "Loan Security Shortfall",
|
||||||
|
@ -22,7 +22,9 @@ def update_shortfall_status(loan, security_value):
|
|||||||
if security_value >= loan_security_shortfall.shortfall_amount:
|
if security_value >= loan_security_shortfall.shortfall_amount:
|
||||||
frappe.db.set_value("Loan Security Shortfall", loan_security_shortfall.name, {
|
frappe.db.set_value("Loan Security Shortfall", loan_security_shortfall.name, {
|
||||||
"status": "Completed",
|
"status": "Completed",
|
||||||
"shortfall_amount": loan_security_shortfall.shortfall_amount})
|
"shortfall_amount": loan_security_shortfall.shortfall_amount,
|
||||||
|
"shortfall_percentage": 0
|
||||||
|
})
|
||||||
else:
|
else:
|
||||||
frappe.db.set_value("Loan Security Shortfall", loan_security_shortfall.name,
|
frappe.db.set_value("Loan Security Shortfall", loan_security_shortfall.name,
|
||||||
"shortfall_amount", loan_security_shortfall.shortfall_amount - security_value)
|
"shortfall_amount", loan_security_shortfall.shortfall_amount - security_value)
|
||||||
@ -65,7 +67,8 @@ def check_for_ltv_shortfall(process_loan_security_shortfall):
|
|||||||
outstanding_amount = flt(loan.total_payment) - flt(loan.total_interest_payable) \
|
outstanding_amount = flt(loan.total_payment) - flt(loan.total_interest_payable) \
|
||||||
- flt(loan.total_principal_paid)
|
- flt(loan.total_principal_paid)
|
||||||
else:
|
else:
|
||||||
outstanding_amount = loan.disbursed_amount
|
outstanding_amount = flt(loan.disbursed_amount) - flt(loan.total_interest_payable) \
|
||||||
|
- flt(loan.total_principal_paid)
|
||||||
|
|
||||||
pledged_securities = get_pledged_security_qty(loan.name)
|
pledged_securities = get_pledged_security_qty(loan.name)
|
||||||
ltv_ratio = ''
|
ltv_ratio = ''
|
||||||
@ -81,14 +84,15 @@ def check_for_ltv_shortfall(process_loan_security_shortfall):
|
|||||||
if current_ratio > ltv_ratio:
|
if current_ratio > ltv_ratio:
|
||||||
shortfall_amount = outstanding_amount - ((security_value * ltv_ratio) / 100)
|
shortfall_amount = outstanding_amount - ((security_value * ltv_ratio) / 100)
|
||||||
create_loan_security_shortfall(loan.name, outstanding_amount, security_value, shortfall_amount,
|
create_loan_security_shortfall(loan.name, outstanding_amount, security_value, shortfall_amount,
|
||||||
process_loan_security_shortfall)
|
current_ratio, process_loan_security_shortfall)
|
||||||
elif loan_shortfall_map.get(loan.name):
|
elif loan_shortfall_map.get(loan.name):
|
||||||
shortfall_amount = outstanding_amount - ((security_value * ltv_ratio) / 100)
|
shortfall_amount = outstanding_amount - ((security_value * ltv_ratio) / 100)
|
||||||
if shortfall_amount <= 0:
|
if shortfall_amount <= 0:
|
||||||
shortfall = loan_shortfall_map.get(loan.name)
|
shortfall = loan_shortfall_map.get(loan.name)
|
||||||
update_pending_shortfall(shortfall)
|
update_pending_shortfall(shortfall)
|
||||||
|
|
||||||
def create_loan_security_shortfall(loan, loan_amount, security_value, shortfall_amount, process_loan_security_shortfall):
|
def create_loan_security_shortfall(loan, loan_amount, security_value, shortfall_amount, shortfall_ratio,
|
||||||
|
process_loan_security_shortfall):
|
||||||
existing_shortfall = frappe.db.get_value("Loan Security Shortfall", {"loan": loan, "status": "Pending"}, "name")
|
existing_shortfall = frappe.db.get_value("Loan Security Shortfall", {"loan": loan, "status": "Pending"}, "name")
|
||||||
|
|
||||||
if existing_shortfall:
|
if existing_shortfall:
|
||||||
@ -101,6 +105,7 @@ def create_loan_security_shortfall(loan, loan_amount, security_value, shortfall_
|
|||||||
ltv_shortfall.loan_amount = loan_amount
|
ltv_shortfall.loan_amount = loan_amount
|
||||||
ltv_shortfall.security_value = security_value
|
ltv_shortfall.security_value = security_value
|
||||||
ltv_shortfall.shortfall_amount = shortfall_amount
|
ltv_shortfall.shortfall_amount = shortfall_amount
|
||||||
|
ltv_shortfall.shortfall_percentage = shortfall_ratio
|
||||||
ltv_shortfall.process_loan_security_shortfall = process_loan_security_shortfall
|
ltv_shortfall.process_loan_security_shortfall = process_loan_security_shortfall
|
||||||
ltv_shortfall.save()
|
ltv_shortfall.save()
|
||||||
|
|
||||||
@ -114,6 +119,7 @@ def update_pending_shortfall(shortfall):
|
|||||||
frappe.db.set_value("Loan Security Shortfall", shortfall,
|
frappe.db.set_value("Loan Security Shortfall", shortfall,
|
||||||
{
|
{
|
||||||
"status": "Completed",
|
"status": "Completed",
|
||||||
"shortfall_amount": 0
|
"shortfall_amount": 0,
|
||||||
|
"shortfall_percentage": 0
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -63,9 +63,11 @@ def get_active_loan_details(filters):
|
|||||||
currency = erpnext.get_company_currency(filters.get('company'))
|
currency = erpnext.get_company_currency(filters.get('company'))
|
||||||
|
|
||||||
for loan in loan_details:
|
for loan in loan_details:
|
||||||
|
total_payment = loan.total_payment if loan.status == 'Disbursed' else loan.disbursed_amount
|
||||||
|
|
||||||
loan.update({
|
loan.update({
|
||||||
"sanctioned_amount": flt(sanctioned_amount_map.get(loan.applicant_name)),
|
"sanctioned_amount": flt(sanctioned_amount_map.get(loan.applicant_name)),
|
||||||
"principal_outstanding": flt(loan.total_payment) - flt(loan.total_principal_paid) \
|
"principal_outstanding": flt(total_payment) - flt(loan.total_principal_paid) \
|
||||||
- flt(loan.total_interest_payable) - flt(loan.written_off_amount),
|
- flt(loan.total_interest_payable) - flt(loan.written_off_amount),
|
||||||
"total_repayment": flt(payments.get(loan.loan)),
|
"total_repayment": flt(payments.get(loan.loan)),
|
||||||
"accrued_interest": flt(accrual_map.get(loan.loan, {}).get("accrued_interest")),
|
"accrued_interest": flt(accrual_map.get(loan.loan, {}).get("accrued_interest")),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user