Skip to content

Commit

Permalink
Merge pull request frappe#45112 from marination/bank-reco-bank-balance
Browse files Browse the repository at this point in the history
fix: Missing company filter breaks `get_account_balance` in Bank Reco
  • Loading branch information
ruthra-kumar authored Jan 8, 2025
2 parents a24d7e8 + d7bf73c commit 5df9a8a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,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"])
Expand All @@ -94,11 +101,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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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),
});
Expand Down

0 comments on commit 5df9a8a

Please sign in to comment.