Skip to content

Commit

Permalink
chore: allow updating maximum_limit_amount
Browse files Browse the repository at this point in the history
  • Loading branch information
anandbaburajan committed Dec 1, 2023
1 parent b0284bd commit 3d49337
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lending/loan_management/doctype/loan/loan.json
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@
"label": "Limit Applicable End"
},
{
"allow_on_submit": 1,
"fieldname": "maximum_limit_amount",
"fieldtype": "Currency",
"label": "Maximum Limit Amount"
Expand All @@ -540,6 +541,7 @@
"options": "Loan Category"
},
{
"allow_on_submit": 1,
"fieldname": "available_limit_amount",
"fieldtype": "Currency",
"label": "Available Limit Amount",
Expand All @@ -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",
Expand Down
11 changes: 11 additions & 0 deletions lending/loan_management/doctype/loan/loan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 3d49337

Please sign in to comment.