Reports
This commit is contained in:
parent
8d7c68219a
commit
7bc64b1db4
|
|
@ -279,7 +279,7 @@ class _ReportDataTableState extends State<ReportDataTable> {
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
DataTable(
|
DataTable(
|
||||||
columns: reportResult.totalColumns(context),
|
columns: reportResult.totalColumns(context),
|
||||||
rows: [],
|
rows: reportResult.totalRows(context),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
@ -718,6 +718,40 @@ class ReportResult {
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<DataRow> totalRows(BuildContext context) {
|
||||||
|
final rows = <DataRow>[];
|
||||||
|
|
||||||
|
final Map<String, Map<String, double>> totals = {};
|
||||||
|
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
final row = data[i];
|
||||||
|
final cells = <DataCell>[
|
||||||
|
DataCell(Text('')),
|
||||||
|
DataCell(Text('')),
|
||||||
|
];
|
||||||
|
for (var j = 0; j < row.length; j++) {
|
||||||
|
final cell = row[j];
|
||||||
|
final column = columns[j];
|
||||||
|
if (getReportColumnType(column) == ReportColumnType.number) {
|
||||||
|
cells.add(DataCell(cell.renderWidget(context, column)));
|
||||||
|
final String currencyId = (cell as ReportNumberValue).currencyId;
|
||||||
|
|
||||||
|
if (!totals.containsKey(currencyId)) {
|
||||||
|
totals[currencyId] = {'count': 0};
|
||||||
|
}
|
||||||
|
if (!totals[currencyId].containsKey(column)) {
|
||||||
|
totals[currencyId][column] = 0;
|
||||||
|
}
|
||||||
|
totals[currencyId][column] += cell.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rows.add(DataRow(cells: cells));
|
||||||
|
}
|
||||||
|
|
||||||
|
print('## TOTALS: $totals');
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class ReportElement {
|
abstract class ReportElement {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue