From 5eb3651527f5f6fe8d29ccf85c88fb8b5a3f4ae0 Mon Sep 17 00:00:00 2001 From: Nihantra Patel Date: Mon, 2 Dec 2024 11:24:07 +0530 Subject: [PATCH 1/4] fix: loan repayment schedule status --patch --- .../loan_repayment_schedule.py | 2 ++ lending/patches.txt | 3 ++- .../v15_0/loan_repayment_schedule_status_patch.py | 12 ++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 lending/patches/v15_0/loan_repayment_schedule_status_patch.py diff --git a/lending/loan_management/doctype/loan_repayment_schedule/loan_repayment_schedule.py b/lending/loan_management/doctype/loan_repayment_schedule/loan_repayment_schedule.py index 8c431cd8..3e2795f9 100644 --- a/lending/loan_management/doctype/loan_repayment_schedule/loan_repayment_schedule.py +++ b/lending/loan_management/doctype/loan_repayment_schedule/loan_repayment_schedule.py @@ -179,6 +179,8 @@ def on_cancel(self): self.ignore_linked_doctypes = ["Loan Interest Accrual", "Loan Demand"] + frappe.db.set_value("Loan Repayment Schedule", self.name, "status", "Cancelled") + def set_repayment_period(self): if self.repayment_frequency == "One Time": self.repayment_method = "Repay Over Number of Periods" diff --git a/lending/patches.txt b/lending/patches.txt index a4bc5d29..7ff7260b 100644 --- a/lending/patches.txt +++ b/lending/patches.txt @@ -34,4 +34,5 @@ lending.patches.v15_0.rename_irac_provisioning_configuration_loan_product lending.patches.v15_0.update_loan_product_accounts #lending.patches.v15_0.loan_interest_accrual_changes lending.patches.v15_0.create_accounting_dimensions_for_loan_doctypes -lending.patches.v15_0.update_maturity_date \ No newline at end of file +lending.patches.v15_0.update_maturity_date +lending.patches.v15_0.loan_repayment_schedule_status_patch diff --git a/lending/patches/v15_0/loan_repayment_schedule_status_patch.py b/lending/patches/v15_0/loan_repayment_schedule_status_patch.py new file mode 100644 index 00000000..7463a02f --- /dev/null +++ b/lending/patches/v15_0/loan_repayment_schedule_status_patch.py @@ -0,0 +1,12 @@ +import frappe +from frappe.query_builder import DocType + + +def execute(): + LoanRepaymentSchedule = DocType("Loan Repayment Schedule") + + frappe.qb.update(LoanRepaymentSchedule).set(LoanRepaymentSchedule.status, "Cancelled").where( + (LoanRepaymentSchedule.docstatus == 2) & (LoanRepaymentSchedule.status != "Cancelled") + ).run() + + frappe.db.commit() From 49f132b3aa5673ecc242bbbcddcf194257a9c506 Mon Sep 17 00:00:00 2001 From: Nihantra Patel Date: Mon, 2 Dec 2024 11:28:48 +0530 Subject: [PATCH 2/4] fix: loan repayment schedule status --patch --- .../process_loan_classification.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lending/loan_management/doctype/process_loan_classification/process_loan_classification.py b/lending/loan_management/doctype/process_loan_classification/process_loan_classification.py index c27f12fd..3abe0a7f 100644 --- a/lending/loan_management/doctype/process_loan_classification/process_loan_classification.py +++ b/lending/loan_management/doctype/process_loan_classification/process_loan_classification.py @@ -33,7 +33,7 @@ def on_submit(self): self.name, self.payment_reference, self.is_backdated, - self.force_update_dpd_in_loan + self.force_update_dpd_in_loan, ) else: BATCH_SIZE = 5000 @@ -76,7 +76,7 @@ def process_loan_classification_batch( ignore_freeze=True if payment_reference else False, is_backdated=is_backdated, via_background_job=via_scheduler, - force_update_dpd_in_loan=force_update_dpd_in_loan + force_update_dpd_in_loan=force_update_dpd_in_loan, ) if len(open_loans) > 1: From 276ad2f82755dcac14fc7f4b816b40772ac28cb6 Mon Sep 17 00:00:00 2001 From: "Nihantra C. Patel" <141945075+Nihantra-Patel@users.noreply.github.com> Date: Mon, 2 Dec 2024 12:08:38 +0530 Subject: [PATCH 3/4] fix: loan repayment schedule status --patch --- .../doctype/loan_repayment_schedule/loan_repayment_schedule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lending/loan_management/doctype/loan_repayment_schedule/loan_repayment_schedule.py b/lending/loan_management/doctype/loan_repayment_schedule/loan_repayment_schedule.py index 3e2795f9..da84680d 100644 --- a/lending/loan_management/doctype/loan_repayment_schedule/loan_repayment_schedule.py +++ b/lending/loan_management/doctype/loan_repayment_schedule/loan_repayment_schedule.py @@ -179,7 +179,7 @@ def on_cancel(self): self.ignore_linked_doctypes = ["Loan Interest Accrual", "Loan Demand"] - frappe.db.set_value("Loan Repayment Schedule", self.name, "status", "Cancelled") + self.db_set("status", "Cancelled") def set_repayment_period(self): if self.repayment_frequency == "One Time": From 598c046971beeb8454b1f43584848e9ff7e8e072 Mon Sep 17 00:00:00 2001 From: "Nihantra C. Patel" <141945075+Nihantra-Patel@users.noreply.github.com> Date: Mon, 9 Dec 2024 16:11:32 +0530 Subject: [PATCH 4/4] fix: loan repayment schedule status --patch --- lending/patches/v15_0/loan_repayment_schedule_status_patch.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/lending/patches/v15_0/loan_repayment_schedule_status_patch.py b/lending/patches/v15_0/loan_repayment_schedule_status_patch.py index 7463a02f..dbaa5176 100644 --- a/lending/patches/v15_0/loan_repayment_schedule_status_patch.py +++ b/lending/patches/v15_0/loan_repayment_schedule_status_patch.py @@ -8,5 +8,3 @@ def execute(): frappe.qb.update(LoanRepaymentSchedule).set(LoanRepaymentSchedule.status, "Cancelled").where( (LoanRepaymentSchedule.docstatus == 2) & (LoanRepaymentSchedule.status != "Cancelled") ).run() - - frappe.db.commit()