fix: detect the currency column by fieldtype in trends total row

calculate_total_row tested each column with `"Link/Currency" in col`, but
based-on and group-by columns are dicts, so the test checked the dict's keys
and never matched. currency_col_idx stayed None and the grand-total row's
currency cell was left unset, so Total(Amt) rendered with the global default
currency instead of the company's.

Match the dict's fieldtype/options instead. Dict columns are never numeric
and string columns are never Link columns, so the two branches are now
mutually exclusive.
This commit is contained in:
pandiyan
2026-07-28 11:27:46 +05:30
parent 0ad0d7733b
commit 8cceb6af10

View File

@@ -248,10 +248,12 @@ def calculate_total_row(data, columns, company_currency=None):
total_values = {}
currency_col_idx = None
for i, col in enumerate(columns):
if "Float" in col or "Currency/currency" in col:
# based-on and group-by columns are dicts, periodic and total columns are strings
if isinstance(col, dict):
if col.get("fieldtype") == "Link" and col.get("options") == "Currency":
currency_col_idx = i
elif "Float" in col or "Currency/currency" in col:
total_values[i] = 0
if "Link/Currency" in col:
currency_col_idx = i
for row in data:
for i in total_values.keys():