From 3d49337e30645caddc3bfd771435e02e65e1255c Mon Sep 17 00:00:00 2001 From: anandbaburajan Date: Fri, 1 Dec 2023 15:59:25 +0530 Subject: [PATCH] chore: allow updating maximum_limit_amount --- lending/loan_management/doctype/loan/loan.json | 4 +++- lending/loan_management/doctype/loan/loan.py | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lending/loan_management/doctype/loan/loan.json b/lending/loan_management/doctype/loan/loan.json index 6ff1b3f1..224b3313 100644 --- a/lending/loan_management/doctype/loan/loan.json +++ b/lending/loan_management/doctype/loan/loan.json @@ -528,6 +528,7 @@ "label": "Limit Applicable End" }, { + "allow_on_submit": 1, "fieldname": "maximum_limit_amount", "fieldtype": "Currency", "label": "Maximum Limit Amount" @@ -540,6 +541,7 @@ "options": "Loan Category" }, { + "allow_on_submit": 1, "fieldname": "available_limit_amount", "fieldtype": "Currency", "label": "Available Limit Amount", @@ -555,7 +557,7 @@ "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2023-11-30 20:01:08.861608", + "modified": "2023-12-01 15:51:08.809933", "modified_by": "Administrator", "module": "Loan Management", "name": "Loan", diff --git a/lending/loan_management/doctype/loan/loan.py b/lending/loan_management/doctype/loan/loan.py index 09a7d1f4..47c96a1b 100644 --- a/lending/loan_management/doctype/loan/loan.py +++ b/lending/loan_management/doctype/loan/loan.py @@ -144,6 +144,17 @@ def on_update_after_submit(self): applicant_type=self.applicant_type, applicant=self.applicant, reverse=not self.manual_npa ) + def before_update_after_submit(self): + self.update_available_limit_amount() + + def update_available_limit_amount(self): + if self.maximum_limit_amount < self.utilized_limit_amount: + frappe.throw(_("New maximum limit amount cannot be lesser than the utilized limit amount")) + + self.available_limit_amount += self.maximum_limit_amount - frappe.db.get_value( + "Loan", self.name, "maximum_limit_amount" + ) + def set_missing_fields(self): if not self.company: self.company = erpnext.get_default_company()