From e8d6eb207d3ffac2999135ba6321d70b687b32ad Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Tue, 3 May 2022 12:55:04 +0530 Subject: [PATCH] fix: Ignore loan repayments made from salary slip (cherry picked from commit b7e1d40e43c136f0e967111e10af95ddc80e2fd5) --- erpnext/accounts/doctype/bank_clearance/bank_clearance.py | 1 + .../bank_reconciliation_tool/bank_reconciliation_tool.py | 1 + .../bank_reconciliation_statement.py | 7 +++++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/bank_clearance/bank_clearance.py b/erpnext/accounts/doctype/bank_clearance/bank_clearance.py index 0f617b5dda78..98ba399a35d2 100644 --- a/erpnext/accounts/doctype/bank_clearance/bank_clearance.py +++ b/erpnext/accounts/doctype/bank_clearance/bank_clearance.py @@ -118,6 +118,7 @@ def get_payment_entries(self): ) .where(loan_repayment.docstatus == 1) .where(loan_repayment.clearance_date.isnull()) + .where(loan_repayment.repay_from_salary == 0) .where(loan_repayment.posting_date >= self.from_date) .where(loan_repayment.posting_date <= self.to_date) .where(loan_repayment.payment_account.isin([self.bank_account, self.account])) diff --git a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py index 4c25d7ccbe80..0efe086d94e9 100644 --- a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py +++ b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py @@ -467,6 +467,7 @@ def get_lr_matching_query(bank_account, amount_condition, filters): loan_repayment.posting_date, ) .where(loan_repayment.docstatus == 1) + .where(loan_repayment.repay_from_salary == 0) .where(loan_repayment.clearance_date.isnull()) .where(loan_repayment.payment_account == bank_account) ) diff --git a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py index 2ac1fea5afc2..f3ccc868c4cb 100644 --- a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py +++ b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py @@ -203,7 +203,7 @@ def get_loan_entries(filters): posting_date = (loan_doc.posting_date).as_("posting_date") account = loan_doc.payment_account - entries = ( + query = ( frappe.qb.from_(loan_doc) .select( ConstantColumn(doctype).as_("payment_document"), @@ -217,9 +217,12 @@ def get_loan_entries(filters): .where(account == filters.get("account")) .where(posting_date <= getdate(filters.get("report_date"))) .where(ifnull(loan_doc.clearance_date, "4000-01-01") > getdate(filters.get("report_date"))) - .run(as_dict=1) ) + if doctype == "Loan Repayment": + query.where(loan_doc.repay_from_salary == 0) + + entries = query.run(as_dict=1) loan_docs.extend(entries) return loan_docs