From 6bb9f92c9dfbf4a092ac87b002f214d4e13434bd Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 24 Jul 2022 13:02:08 +0300 Subject: [PATCH] Fix grouping in reports --- lib/ui/reports/reports_screen.dart | 4 +++- lib/ui/reports/reports_screen_vm.dart | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ui/reports/reports_screen.dart b/lib/ui/reports/reports_screen.dart index b82d0f334..31ed05b27 100644 --- a/lib/ui/reports/reports_screen.dart +++ b/lib/ui/reports/reports_screen.dart @@ -1338,11 +1338,13 @@ class ReportResult { } value = value + ' (' + values['count'].floor().toString() + ')'; } else if (columnType == ReportColumnType.number) { + final currencyId = values['${column}_currency_id']; value = formatNumber(values[column], context, formatNumberType: column == 'quantity' ? FormatNumberType.double : FormatNumberType.money, - currencyId: values['${column}_currency_id'].round().toString()); + currencyId: + currencyId == null ? null : currencyId.round().toString()); } else if (columnType == ReportColumnType.duration) { value = formatDuration(Duration(seconds: values[column].toInt())); } diff --git a/lib/ui/reports/reports_screen_vm.dart b/lib/ui/reports/reports_screen_vm.dart index ed3f01318..655704ace 100644 --- a/lib/ui/reports/reports_screen_vm.dart +++ b/lib/ui/reports/reports_screen_vm.dart @@ -617,7 +617,7 @@ GroupTotals calculateReportTotals({ totals[group][column] = 0; } - if (cell is ReportNumberValue) { + if (cell is ReportNumberValue && cell.currencyId != null) { totals[group]['${column}_currency_id'] = parseDouble(cell.currencyId); }