From 3899079bb9b0ef733e5b1100359afd7d94cfba5a Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 6 Nov 2020 17:39:54 +0530 Subject: [PATCH] fix: Loan seurity unpledge msg improvement --- .../loan_security_shortfall.py | 2 +- .../loan_security_unpledge/loan_security_unpledge.py | 12 ++++++++++-- .../process_loan_interest_accrual.json | 9 ++++++++- .../process_loan_interest_accrual.py | 4 ++-- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py b/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py index 0f42bde3c4..8ec0bfb62c 100644 --- a/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py +++ b/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py @@ -22,7 +22,7 @@ def update_shortfall_status(loan, security_value): if security_value >= loan_security_shortfall.shortfall_amount: frappe.db.set_value("Loan Security Shortfall", loan_security_shortfall.name, { "status": "Completed", - "shortfall_value": loan_security_shortfall.shortfall_amount}) + "shortfall_amount": loan_security_shortfall.shortfall_amount}) else: frappe.db.set_value("Loan Security Shortfall", loan_security_shortfall.name, "shortfall_amount", loan_security_shortfall.shortfall_amount - security_value) diff --git a/erpnext/loan_management/doctype/loan_security_unpledge/loan_security_unpledge.py b/erpnext/loan_management/doctype/loan_security_unpledge/loan_security_unpledge.py index 5d4447bf2b..c29f325bfc 100644 --- a/erpnext/loan_management/doctype/loan_security_unpledge/loan_security_unpledge.py +++ b/erpnext/loan_management/doctype/loan_security_unpledge/loan_security_unpledge.py @@ -67,10 +67,18 @@ class LoanSecurityUnpledge(Document): security_value += qty_after_unpledge * current_price if not security_value and flt(pending_principal_amount, 2) > 0: - frappe.throw("Cannot Unpledge, loan to value ratio is breaching") + self._throw(security_value, pending_principal_amount, ltv_ratio) if security_value and flt(pending_principal_amount/security_value) * 100 > ltv_ratio: - frappe.throw("Cannot Unpledge, loan to value ratio is breaching") + self._throw(security_value, pending_principal_amount, ltv_ratio) + + def _throw(self, security_value, pending_principal_amount, ltv_ratio): + msg = _("Loan Security Value after unpledge is {0}").format(frappe.bold(security_value)) + msg += '
' + msg += _("Pending principal amount is {0}").format(frappe.bold(flt(pending_principal_amount, 2))) + msg += '
' + msg += _("Loan To Security Value ratio must always be {0}").format(frappe.bold(ltv_ratio)) + frappe.throw(msg, title=_("Loan To Value ratio breach")) def on_update_after_submit(self): self.approve() diff --git a/erpnext/loan_management/doctype/process_loan_interest_accrual/process_loan_interest_accrual.json b/erpnext/loan_management/doctype/process_loan_interest_accrual/process_loan_interest_accrual.json index 4c354e6721..b78c3ba5d8 100644 --- a/erpnext/loan_management/doctype/process_loan_interest_accrual/process_loan_interest_accrual.json +++ b/erpnext/loan_management/doctype/process_loan_interest_accrual/process_loan_interest_accrual.json @@ -10,6 +10,7 @@ "loan_type", "loan", "process_type", + "accrual_type", "amended_from" ], "fields": [ @@ -47,12 +48,18 @@ "hidden": 1, "label": "Process Type", "read_only": 1 + }, + { + "fieldname": "accrual_type", + "fieldtype": "Select", + "label": "Accrual Type", + "options": "Regular\nRepayment\nDisbursement" } ], "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2020-11-05 10:49:35.657728", + "modified": "2020-11-06 04:43:56.581670", "modified_by": "Administrator", "module": "Loan Management", "name": "Process Loan Interest Accrual", diff --git a/erpnext/loan_management/doctype/process_loan_interest_accrual/process_loan_interest_accrual.py b/erpnext/loan_management/doctype/process_loan_interest_accrual/process_loan_interest_accrual.py index f0522657eb..11333dc2aa 100644 --- a/erpnext/loan_management/doctype/process_loan_interest_accrual/process_loan_interest_accrual.py +++ b/erpnext/loan_management/doctype/process_loan_interest_accrual/process_loan_interest_accrual.py @@ -20,11 +20,11 @@ class ProcessLoanInterestAccrual(Document): if (not self.loan or not loan_doc.is_term_loan) and self.process_type != 'Term Loans': make_accrual_interest_entry_for_demand_loans(self.posting_date, self.name, - open_loans = open_loans, loan_type = self.loan_type) + open_loans = open_loans, loan_type = self.loan_type, accrual_type=self.accrual_type) if (not self.loan or loan_doc.is_term_loan) and self.process_type != 'Demand Loans': make_accrual_interest_entry_for_term_loans(self.posting_date, self.name, term_loan=self.loan, - loan_type=self.loan_type) + loan_type=self.loan_type, accrual_type=self.accrual_type) def process_loan_interest_accrual_for_demand_loans(posting_date=None, loan_type=None, loan=None, accrual_type="Regular"):