From 8cceb6af101e5f2af2f3575b1f0a2abf0e9136e3 Mon Sep 17 00:00:00 2001 From: pandiyan Date: Tue, 28 Jul 2026 11:27:46 +0530 Subject: [PATCH] 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. --- erpnext/controllers/trends.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/erpnext/controllers/trends.py b/erpnext/controllers/trends.py index 38e37f6ddbe..76a809c1b8a 100644 --- a/erpnext/controllers/trends.py +++ b/erpnext/controllers/trends.py @@ -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():