fix: Do not reduce for empty arrays (#7679)
This commit is contained in:
parent
f40dc7b840
commit
a4e97d4606
1 changed files with 12 additions and 7 deletions
|
|
@ -660,13 +660,18 @@ Object.assign(frappe.utils, {
|
|||
},
|
||||
|
||||
report_column_total: function(values, column, type) {
|
||||
if (column.column.fieldtype == "Percent" || type === "mean") {
|
||||
return values.reduce((a, b) => a + flt(b)) / values.length;
|
||||
} else if (column.column.fieldtype == "Int") {
|
||||
return values.reduce((a, b) => a + cint(b));
|
||||
} else if (frappe.model.is_numeric_field(column.column.fieldtype)) {
|
||||
return values.reduce((a, b) => a + flt(b));
|
||||
} else {
|
||||
if (values.length > 0) {
|
||||
if (column.column.fieldtype == "Percent" || type === "mean") {
|
||||
return values.reduce((a, b) => a + flt(b)) / values.length;
|
||||
} else if (column.column.fieldtype == "Int") {
|
||||
return values.reduce((a, b) => a + cint(b));
|
||||
} else if (frappe.model.is_numeric_field(column.column.fieldtype)) {
|
||||
return values.reduce((a, b) => a + flt(b));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue