Skip to content

Commit

Permalink
Merge pull request frappe#28073 from akhilnarang/guess-fieldtype-tota…
Browse files Browse the repository at this point in the history
…l-row

chore(add_total_row): guess fieldtype from cell data type if not defined
  • Loading branch information
akhilnarang authored Oct 11, 2024
2 parents bd07ae9 + dea09e5 commit fe3e22e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions frappe/desk/query_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,11 @@ def add_total_row(result, columns, meta=None, is_tree=False, parent_field=None):
if i >= len(row):
continue
cell = row.get(fieldname) if isinstance(row, dict) else row[i]
if fieldtype is None:
if isinstance(cell, int):
fieldtype = "Int"
elif isinstance(cell, float):
fieldtype = "Float"
if fieldtype in ["Currency", "Int", "Float", "Percent", "Duration"] and flt(cell):
if not (is_tree and row.get(parent_field)):
total_row[i] = flt(total_row[i]) + flt(cell)
Expand Down

0 comments on commit fe3e22e

Please sign in to comment.