From 20728641af1df44aed70412a896d4b64e02ef86b Mon Sep 17 00:00:00 2001 From: Irene Kurien Date: Wed, 5 Jun 2024 17:28:06 +0530 Subject: [PATCH] fix: bugs with creating loan with fixed amount repayment --- lending/loan_management/doctype/loan/loan.py | 2 +- .../loan_management/doctype/loan_repayment/loan_repayment.py | 1 - .../doctype/loan_repayment_schedule/loan_repayment_schedule.py | 2 +- .../doctype/loan_restructure/loan_restructure.py | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lending/loan_management/doctype/loan/loan.py b/lending/loan_management/doctype/loan/loan.py index 300153f7..cf0c8150 100644 --- a/lending/loan_management/doctype/loan/loan.py +++ b/lending/loan_management/doctype/loan/loan.py @@ -98,7 +98,7 @@ def set_available_limit_amount(self): self.available_limit_amount = self.maximum_limit_amount def validate_repayment_terms(self): - if self.is_term_loan and self.repayment_schedule_type != "Line of Credit": + if self.is_term_loan and self.repayment_schedule_type != "Line of Credit" and self.repayment_method == "Repay Over Number of Periods": if not self.repayment_periods: frappe.throw(_("Repayment periods is mandatory for term loans")) diff --git a/lending/loan_management/doctype/loan_repayment/loan_repayment.py b/lending/loan_management/doctype/loan_repayment/loan_repayment.py index fbd8416d..3d18187a 100644 --- a/lending/loan_management/doctype/loan_repayment/loan_repayment.py +++ b/lending/loan_management/doctype/loan_repayment/loan_repayment.py @@ -626,7 +626,6 @@ def make_gl_entries(self, cancel=0, adv_adj=0): [ "interest_receivable_account", "penalty_receivable_account", - "suspense_interest_receivable", "suspense_interest_income", "interest_income_account", "interest_waiver_account", 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 4afd211d..b4a83015 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 @@ -230,7 +230,7 @@ def make_repayment_schedule( carry_forward_interest = self.adjusted_interest moratorium_interest = 0 - if not self.restructure_type: + if not self.restructure_type and self.repayment_method != "Repay Fixed Amount per Period": monthly_repayment_amount = get_monthly_repayment_amount( balance_amount, rate_of_interest, self.repayment_periods, self.repayment_frequency ) diff --git a/lending/loan_management/doctype/loan_restructure/loan_restructure.py b/lending/loan_management/doctype/loan_restructure/loan_restructure.py index 1f159bf7..39b7e815 100644 --- a/lending/loan_management/doctype/loan_restructure/loan_restructure.py +++ b/lending/loan_management/doctype/loan_restructure/loan_restructure.py @@ -154,7 +154,7 @@ def add_restructure_charges(self): for charge in frappe.get_all( "Loan Charges", - filters={"parent": self.loan_product, "event": "Restructure"}, + filters={"parent": self.loan_product}, fields=["charge_type", "charge_based_on", "amount", "percentage"], ): if charge.charge_based_on == "Percentage":