From a4986a8e3daf4e33e7cf94bcc02a74c3a24478ef Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Thu, 13 Feb 2020 22:26:54 +0200 Subject: [PATCH] Reports --- lib/ui/reports/client_report.dart | 1 + lib/ui/reports/reports_screen.dart | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/ui/reports/client_report.dart b/lib/ui/reports/client_report.dart index b56433cd6..40c89c06a 100644 --- a/lib/ui/reports/client_report.dart +++ b/lib/ui/reports/client_report.dart @@ -88,6 +88,7 @@ ReportResult clientReport( ClientReportFields.name, ClientReportFields.idNumber, ClientReportFields.balance, + ClientReportFields.paidToDate, ClientReportFields.country, ]); } diff --git a/lib/ui/reports/reports_screen.dart b/lib/ui/reports/reports_screen.dart index 4ef0cbae1..875cb1b47 100644 --- a/lib/ui/reports/reports_screen.dart +++ b/lib/ui/reports/reports_screen.dart @@ -522,14 +522,19 @@ class ReportResult { final row = data[i]; for (var j = 0; j < row.length; j++) { final cell = row[j]; - if (cell is ReportAmount) { - final column = columns[j]; - final value = row[columns.indexOf(groupBy)].sortString(); - if (!totals.containsKey(value)) { - totals[value] = {'count': 0, 'total': 0}; - } + final column = columns[j]; + final value = row[columns.indexOf(groupBy)].sortString(); + if (!totals.containsKey(value)) { + totals[value] = {'count': 0}; + } + if (column == groupBy) { totals[value]['count'] += 1; - totals[value]['total'] += cell.value; + } + if (cell is ReportAmount) { + if (!totals[value].containsKey(column)) { + totals[value][column] = 0; + } + totals[value][column] += cell.value; } } } @@ -540,6 +545,8 @@ class ReportResult { String value = ''; if (column == groupBy) { value = group + ' (' + values['count'].floor().toString() + ')'; + } else if (getReportColumnType(column) == ReportColumnType.number) { + //value = values } cells.add(DataCell(Text(value))); }