From 5af6aea9f9a94e8b77372002ddcd5180603ee079 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Wed, 7 Apr 2021 09:46:13 +0530 Subject: [PATCH] fix: Posting Date check --- .../doctype/loan_repayment/loan_repayment.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py index 2489f59670..5d57cedb41 100644 --- a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py +++ b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py @@ -72,7 +72,7 @@ class LoanRepayment(AccountsController): def check_future_entries(self): future_repayment_date = frappe.db.get_value("Loan Repayment", {"posting_date": (">", self.posting_date), - "docstatus": 1}, 'posting_date') + "docstatus": 1, "against_loan": self.against_loan}, 'posting_date') if future_repayment_date: frappe.throw("Repayment already made till date {0}".format(getdate(future_repayment_date))) @@ -315,7 +315,10 @@ def create_repayment_entry(loan, applicant, company, posting_date, loan_type, return lr -def get_accrued_interest_entries(against_loan, posting_date): +def get_accrued_interest_entries(against_loan, posting_date=None): + if not posting_date: + posting_date = getdate() + unpaid_accrued_entries = frappe.db.sql( """ SELECT name, posting_date, interest_amount - paid_interest_amount as interest_amount, @@ -343,7 +346,7 @@ def get_amounts(amounts, against_loan, posting_date): against_loan_doc = frappe.get_doc("Loan", against_loan) loan_type_details = frappe.get_doc("Loan Type", against_loan_doc.loan_type) - accrued_interest_entries = get_accrued_interest_entries(against_loan_doc.name) + accrued_interest_entries = get_accrued_interest_entries(against_loan_doc.name, posting_date) pending_accrual_entries = {}