fix: use company currency instead of global default in report

This commit is contained in:
S Sakthivel Murugan
2026-06-25 11:11:40 +05:30
committed by Sakthivel Murugan S
parent 607f0e943f
commit e6f9149ad7
9 changed files with 37 additions and 7 deletions

View File

@@ -6,6 +6,7 @@ import frappe
from frappe import _
from frappe.utils import DateTimeLikeObject, getdate, today
import erpnext
from erpnext.accounts.utils import get_fiscal_year
@@ -214,7 +215,7 @@ def get_data(filters, conditions):
data.append(des)
total_row = calculate_total_row(data1, conditions["columns"])
total_row = calculate_total_row(data1, conditions["columns"], filters.get("company"))
data.append(total_row)
else:
data = frappe.db.sql(
@@ -239,20 +240,23 @@ def get_data(filters, conditions):
as_list=1,
)
total_row = calculate_total_row(data, conditions["columns"])
total_row = calculate_total_row(data, conditions["columns"], filters.get("company"))
data.append(total_row)
return data
def calculate_total_row(data, columns):
def calculate_total_row(data, columns, company=None):
def wrap_in_quotes(label):
return f"'{label}'"
total_values = {}
currency_col_idx = None
for i, col in enumerate(columns):
if "Float" in col or "Currency/currency" in col:
total_values[i] = 0
if col.split(":")[0] == "Currency":
currency_col_idx = i
for row in data:
for i in total_values.keys():
@@ -262,6 +266,9 @@ def calculate_total_row(data, columns):
for i in range(1, len(columns)):
total_row.append(total_values.get(i, None))
if currency_col_idx is not None:
total_row[currency_col_idx] = company and erpnext.get_company_currency(company)
return total_row