|
|
@@ -113,22 +113,27 @@ def get_report_module_dotted_path(module, report_name): |
|
|
|
def add_total_row(result, columns): |
|
|
|
total_row = [""]*len(columns) |
|
|
|
has_percent = [] |
|
|
|
for row in result: |
|
|
|
for i, col in enumerate(columns): |
|
|
|
fieldtype = None |
|
|
|
if isinstance(col, basestring): |
|
|
|
col = col.split(":") |
|
|
|
if len(col) > 1: |
|
|
|
fieldtype = col[1] |
|
|
|
if "/" in fieldtype: |
|
|
|
fieldtype = fieldtype.split("/")[0] |
|
|
|
else: |
|
|
|
fieldtype = col.get("fieldtype") |
|
|
|
|
|
|
|
for i, col in enumerate(columns): |
|
|
|
fieldtype, options = None, None |
|
|
|
if isinstance(col, basestring): |
|
|
|
col = col.split(":") |
|
|
|
if len(col) > 1: |
|
|
|
fieldtype = col[1] |
|
|
|
if "/" in fieldtype: |
|
|
|
fieldtype, options = fieldtype.split("/") |
|
|
|
else: |
|
|
|
fieldtype = col.get("fieldtype") |
|
|
|
options = col.get("options") |
|
|
|
|
|
|
|
for row in result: |
|
|
|
if fieldtype in ["Currency", "Int", "Float", "Percent"] and flt(row[i]): |
|
|
|
total_row[i] = flt(total_row[i]) + flt(row[i]) |
|
|
|
|
|
|
|
if fieldtype == "Percent" and i not in has_percent: |
|
|
|
has_percent.append(i) |
|
|
|
|
|
|
|
if fieldtype=="Link" and options == "Currency": |
|
|
|
total_row[i] = result[0][i] |
|
|
|
|
|
|
|
for i in has_percent: |
|
|
|
total_row[i] = total_row[i] / len(result) |
|
|
|