Skip to content

Commit

Permalink
fix: closed status in loan disbursement
Browse files Browse the repository at this point in the history
  • Loading branch information
Nihantra-Patel committed Jan 1, 2025
1 parent a0130ff commit d98fdd1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions lending/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ lending.patches.v15_0.update_loan_product_accounts
lending.patches.v15_0.create_accounting_dimensions_for_loan_doctypes
lending.patches.v15_0.update_maturity_date
lending.patches.v15_0.loan_repayment_schedule_status_patch
lending.patches.v15_0.loan_disbursement_status_patch
25 changes: 25 additions & 0 deletions lending/patches/v15_0/loan_disbursement_status_patch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import frappe

loan_dis = frappe.db.get_all(
"Loan Disbursement",
filters={"status": ["!=", "Closed"]},
fields=["name", "docstatus"],
)
for ld in loan_dis:
if ld.docstatus == 0:
frappe.db.set_value("Loan Disbursement", ld.name, "status", "Draft", update_modified=False)
elif ld.docstatus == 1:
frappe.db.set_value("Loan Disbursement", ld.name, "status", "Submitted", update_modified=False)
elif ld.docstatus == 2:
frappe.db.set_value("Loan Disbursement", ld.name, "status", "Cancelled", update_modified=False)

loan_repay_sche = frappe.db.get_all(
"Loan Repayment Schedule",
filters={"status": "Closed"},
fields=["loan_disbursement"],
)
for lrs in loan_repay_sche:
if lrs.loan_disbursement:
frappe.db.set_value(
"Loan Disbursement", lrs.loan_disbursement, "status", "Closed", update_modified=False
)

0 comments on commit d98fdd1

Please sign in to comment.