This commit is contained in:
Hillel Coren 2020-02-15 21:19:02 +02:00
parent 7e79bfda81
commit fa420e23e1
1 changed files with 16 additions and 7 deletions

View File

@ -696,6 +696,7 @@ class ReportResult {
List<DataColumn> totalColumns(BuildContext context) { List<DataColumn> totalColumns(BuildContext context) {
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
columns.sort((String str1, String str2) => str1.compareTo(str2));
return [ return [
DataColumn( DataColumn(
@ -730,8 +731,8 @@ class ReportResult {
for (var j = 0; j < row.length; j++) { for (var j = 0; j < row.length; j++) {
final cell = row[j]; final cell = row[j];
final column = columns[j]; final column = columns[j];
if (getReportColumnType(column) == ReportColumnType.number) { if (cell is ReportNumberValue) {
final String currencyId = (cell as ReportNumberValue).currencyId; final String currencyId = cell.currencyId;
if (!totals.containsKey(currencyId)) { if (!totals.containsKey(currencyId)) {
totals[currencyId] = {'count': 0}; totals[currencyId] = {'count': 0};
@ -744,15 +745,23 @@ class ReportResult {
} }
} }
totals.forEach((group, values) { totals.forEach((currencyId, values) {
final cells = <DataCell>[ final cells = <DataCell>[
DataCell(Text( DataCell(Text(
store.state.staticState.currencyMap[group]?.listDisplayName ?? '')), store.state.staticState.currencyMap[currencyId]?.listDisplayName ??
DataCell(Text('')), '')),
DataCell(Text(values.toString())),
]; ];
cells.add(DataCell(Text(group ?? ''))); final List<String> fields = values.keys.toList()
cells.add(DataCell(Text(group ?? ''))); ..sort((String str1, String str2) => str1.compareTo(str2));
fields.forEach((field) {
final amount = values[field];
final value = formatNumber(amount, context, currencyId: currencyId);
if (field != 'count') {
cells.add(DataCell(Text(value)));
}
});
rows.add(DataRow(cells: cells)); rows.add(DataRow(cells: cells));
}); });