Skip to content

Commit

Permalink
Merge pull request #239 from AyshaHakeem/loan-closure
Browse files Browse the repository at this point in the history
fix: auto-close loan on repayment for employee applicants,  add auto_close_loan flag to loan closure method
  • Loading branch information
deepeshgarg007 authored Feb 4, 2025
2 parents 7844cfc + e1feca8 commit e08a741
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lending/loan_management/doctype/loan/loan.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def get_sanctioned_amount_limit(applicant_type, applicant, company):


@frappe.whitelist()
def request_loan_closure(loan, posting_date=None):
def request_loan_closure(loan, posting_date=None, auto_close_loan=0):
from lending.loan_management.doctype.loan_repayment.loan_repayment import calculate_amounts

if not posting_date:
Expand All @@ -357,7 +357,8 @@ def request_loan_closure(loan, posting_date=None):
elif pending_amount > 0:
frappe.throw(_("Cannot close loan as there is an outstanding of {0}").format(pending_amount))

frappe.db.set_value("Loan", loan, "status", "Loan Closure Requested")
status = "Closed" if auto_close_loan else "Loan Closure Requested"
frappe.db.set_value("Loan", loan, "status", status)


@frappe.whitelist()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ def update_paid_amount(self):

pending_principal_amount = get_pending_principal_amount(loan)
if not loan.is_secured_loan and pending_principal_amount <= 0:
loan.update({"status": "Loan Closure Requested"})
status = "Closed" if loan.applicant_type == "Employee" else "Loan Closure Requested"
loan.update({"status": status})

for payment in self.repayment_details:
frappe.db.sql(
Expand Down

0 comments on commit e08a741

Please sign in to comment.