From 8de0fe78eaa3c6798a9fa002513ee912852f661c Mon Sep 17 00:00:00 2001 From: marination Date: Mon, 6 Jan 2025 20:27:06 +0530 Subject: [PATCH 1/2] fix: Missing company filter breaks `get_account_balance` in Bank Reco --- .../bank_reconciliation_tool.js | 2 ++ .../bank_reconciliation_tool.py | 26 ++++++++++--------- .../data_table_manager.js | 3 ++- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.js b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.js index b15745d834c3..7a653e12c727 100644 --- a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.js +++ b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.js @@ -120,6 +120,7 @@ frappe.ui.form.on("Bank Reconciliation Tool", { args: { bank_account: frm.doc.bank_account, till_date: frappe.datetime.add_days(frm.doc.bank_statement_from_date, -1), + company: frm.doc.company, }, callback: (response) => { frm.set_value("account_opening_balance", response.message); @@ -135,6 +136,7 @@ frappe.ui.form.on("Bank Reconciliation Tool", { args: { bank_account: frm.doc.bank_account, till_date: frm.doc.bank_statement_to_date, + company: frm.doc.company, }, callback: (response) => { frm.cleared_balance = response.message; 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 ce7e9436ad5e..4b677d56f1ff 100644 --- a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py +++ b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py @@ -5,11 +5,6 @@ import json import frappe -from frappe import _ -from frappe.model.document import Document -from frappe.query_builder.custom import ConstantColumn -from frappe.utils import cint, flt - from erpnext import get_default_cost_center from erpnext.accounts.doctype.bank_transaction.bank_transaction import get_total_allocated_amount from erpnext.accounts.party import get_party_account @@ -19,6 +14,10 @@ ) from erpnext.accounts.utils import get_account_currency, get_balance_on from erpnext.setup.utils import get_exchange_rate +from frappe import _ +from frappe.model.document import Document +from frappe.query_builder.custom import ConstantColumn +from frappe.utils import cint, flt class BankReconciliationTool(Document): @@ -79,10 +78,17 @@ def get_bank_transactions(bank_account, from_date=None, to_date=None): @frappe.whitelist() -def get_account_balance(bank_account, till_date): +def get_account_balance(bank_account, till_date, company): # returns account balance till the specified date account = frappe.db.get_value("Bank Account", bank_account, "account") - filters = frappe._dict({"account": account, "report_date": till_date, "include_pos_transactions": 1}) + filters = frappe._dict( + { + "account": account, + "report_date": till_date, + "include_pos_transactions": 1, + "company": company, + } + ) data = get_entries(filters) balance_as_per_system = get_balance_on(filters["account"], filters["report_date"]) @@ -94,11 +100,7 @@ def get_account_balance(bank_account, till_date): amounts_not_reflected_in_system = get_amounts_not_reflected_in_system(filters) - bank_bal = ( - flt(balance_as_per_system) - flt(total_debit) + flt(total_credit) + amounts_not_reflected_in_system - ) - - return bank_bal + return flt(balance_as_per_system) - flt(total_debit) + flt(total_credit) + amounts_not_reflected_in_system @frappe.whitelist() diff --git a/erpnext/public/js/bank_reconciliation_tool/data_table_manager.js b/erpnext/public/js/bank_reconciliation_tool/data_table_manager.js index 4aa087e99cfe..ad5fd528cda9 100644 --- a/erpnext/public/js/bank_reconciliation_tool/data_table_manager.js +++ b/erpnext/public/js/bank_reconciliation_tool/data_table_manager.js @@ -16,7 +16,7 @@ erpnext.accounts.bank_reconciliation.DataTableManager = class DataTableManager { } make_dt() { - var me = this; + const me = this; frappe.call({ method: "erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool.get_bank_transactions", args: { @@ -193,6 +193,7 @@ erpnext.accounts.bank_reconciliation.DataTableManager = class DataTableManager { args: { bank_account: this.bank_account, till_date: this.bank_statement_to_date, + company: this.company, }, callback: (response) => (this.cleared_balance = response.message), }); From d7bf73cffa5628c185f4ceabd6020c7e4daf54a6 Mon Sep 17 00:00:00 2001 From: marination Date: Mon, 6 Jan 2025 21:14:41 +0530 Subject: [PATCH 2/2] fix: Override pre-commit behaviour due to conflicts with CI --- .../bank_reconciliation_tool/bank_reconciliation_tool.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 4b677d56f1ff..62a4c74a9330 100644 --- a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py +++ b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py @@ -5,6 +5,11 @@ import json import frappe +from frappe import _ +from frappe.model.document import Document +from frappe.query_builder.custom import ConstantColumn +from frappe.utils import cint, flt + from erpnext import get_default_cost_center from erpnext.accounts.doctype.bank_transaction.bank_transaction import get_total_allocated_amount from erpnext.accounts.party import get_party_account @@ -14,10 +19,6 @@ ) from erpnext.accounts.utils import get_account_currency, get_balance_on from erpnext.setup.utils import get_exchange_rate -from frappe import _ -from frappe.model.document import Document -from frappe.query_builder.custom import ConstantColumn -from frappe.utils import cint, flt class BankReconciliationTool(Document):