mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-14 23:18:40 +00:00
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:
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user