Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: auto-close loan on repayment for employee applicants, add auto_close_loan flag to loan closure method #239

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading