fix: honour currency precision while fetching balance

(cherry picked from commit bfaa93b0ca641352917be16a50e602a7fe458386)
This commit is contained in:
Dany Robert 2023-11-20 09:43:02 +00:00 committed by Mergify
parent e08c7bad63
commit e0a38207f6

View File

@ -240,7 +240,6 @@ def get_balance_on(
cond.append("""gle.cost_center = %s """ % (frappe.db.escape(cost_center, percent=False),))
if account:
if not (frappe.flags.ignore_account_permission or ignore_account_permission):
acc.check_permission("read")
@ -286,11 +285,11 @@ def get_balance_on(
cond.append("""gle.company = %s """ % (frappe.db.escape(company, percent=False)))
if account or (party_type and party) or account_type:
precision = get_currency_precision()
if in_account_currency:
select_field = "sum(debit_in_account_currency) - sum(credit_in_account_currency)"
select_field = f"sum(round(debit_in_account_currency, {precision})) - sum(round(credit_in_account_currency, {precision}))"
else:
select_field = "sum(debit) - sum(credit)"
select_field = f"sum(round(debit, {precision})) - sum(round(credit, {precision}))"
bal = frappe.db.sql(
"""
SELECT {0}