Support charting invoice age in reports
This commit is contained in:
parent
70cd5d2b8b
commit
f40043f8e2
|
|
@ -42,7 +42,7 @@ abstract class ReportsUIState
|
|||
|
||||
BuiltMap<String, String> get filters;
|
||||
|
||||
bool get isGroupByFIltered =>
|
||||
bool get isGroupByFiltered =>
|
||||
filters.containsKey(group) && filters[group].isNotEmpty;
|
||||
|
||||
static Serializer<ReportsUIState> get serializer =>
|
||||
|
|
|
|||
|
|
@ -46,10 +46,13 @@ class ReportCharts extends StatelessWidget {
|
|||
Widget child;
|
||||
final columnType = getReportColumnType(reportState.group, context);
|
||||
|
||||
print('## DATA: ${viewModel.groupTotals.totals}');
|
||||
|
||||
switch (columnType) {
|
||||
case ReportColumnType.age:
|
||||
case ReportColumnType.string:
|
||||
case ReportColumnType.bool:
|
||||
case ReportColumnType.number:
|
||||
case ReportColumnType.age:
|
||||
child = charts.BarChart(
|
||||
[
|
||||
charts.Series<dynamic, String>(
|
||||
|
|
@ -61,13 +64,13 @@ class ReportCharts extends StatelessWidget {
|
|||
? localization.lookup(item['name'])
|
||||
: item['name'],
|
||||
measureFn: (dynamic item, _) => item['value'],
|
||||
data: viewModel.groupTotals.rows
|
||||
.map((key) => {
|
||||
'name': key,
|
||||
'value': viewModel.groupTotals.totals[key]
|
||||
[reportState.chart]
|
||||
})
|
||||
.toList())
|
||||
data: viewModel.groupTotals.rows.map((key) {
|
||||
return {
|
||||
'name': key,
|
||||
'value': viewModel.groupTotals.totals[key]
|
||||
[reportState.chart]
|
||||
};
|
||||
}).toList())
|
||||
],
|
||||
animate: true,
|
||||
primaryMeasureAxis: numericAxis,
|
||||
|
|
@ -88,13 +91,13 @@ class ReportCharts extends StatelessWidget {
|
|||
charts.ColorUtil.fromDartColor(state.accentColor),
|
||||
domainFn: (dynamic item, _) => DateTime.tryParse(item['name']),
|
||||
measureFn: (dynamic item, _) => item['value'],
|
||||
data: keys
|
||||
.map((key) => {
|
||||
'name': key,
|
||||
'value': viewModel.groupTotals.totals[key]
|
||||
[reportState.chart]
|
||||
})
|
||||
.toList())
|
||||
data: keys.map((key) {
|
||||
return {
|
||||
'name': key,
|
||||
'value': viewModel.groupTotals.totals[key]
|
||||
[reportState.chart]
|
||||
};
|
||||
}).toList())
|
||||
],
|
||||
animate: true,
|
||||
primaryMeasureAxis: numericAxis,
|
||||
|
|
@ -108,7 +111,6 @@ class ReportCharts extends StatelessWidget {
|
|||
*/
|
||||
);
|
||||
break;
|
||||
case ReportColumnType.number:
|
||||
}
|
||||
|
||||
return child == null
|
||||
|
|
|
|||
|
|
@ -164,8 +164,9 @@ class ReportsScreen extends StatelessWidget {
|
|||
},
|
||||
items: reportResult.columns
|
||||
.where((column) =>
|
||||
getReportColumnType(column, context) ==
|
||||
ReportColumnType.number)
|
||||
[ReportColumnType.number, ReportColumnType.age,].contains(
|
||||
getReportColumnType(column, context))
|
||||
)
|
||||
.map((column) =>
|
||||
DropdownMenuItem(
|
||||
child: Text(localization.lookup(column)),
|
||||
|
|
@ -576,7 +577,7 @@ class ReportDataTableSource extends DataTableSource {
|
|||
int get rowCount {
|
||||
final reportState = viewModel.reportState;
|
||||
|
||||
if (reportState.group.isEmpty || reportState.isGroupByFIltered) {
|
||||
if (reportState.group.isEmpty || reportState.isGroupByFiltered) {
|
||||
return viewModel.reportResult.data.length + 1;
|
||||
} else {
|
||||
return viewModel.groupTotals.totals.length + 1;
|
||||
|
|
@ -1014,7 +1015,7 @@ class ReportResult {
|
|||
final groupBy = reportState.group;
|
||||
final sorted = sortedColumns(reportState);
|
||||
|
||||
if (groupBy.isEmpty || reportState.isGroupByFIltered) {
|
||||
if (groupBy.isEmpty || reportState.isGroupByFiltered) {
|
||||
final row = data[index - 1];
|
||||
final cells = <DataCell>[];
|
||||
for (var j = 0; j < row.length; j++) {
|
||||
|
|
@ -1054,9 +1055,11 @@ class ReportResult {
|
|||
value = group;
|
||||
}
|
||||
value = value + ' (' + values['count'].floor().toString() + ')';
|
||||
} else if (columnType ==
|
||||
ReportColumnType.number) {
|
||||
} else if (columnType == ReportColumnType.number) {
|
||||
value = formatNumber(values[column], context);
|
||||
} else if (columnType == ReportColumnType.age) {
|
||||
value = formatNumber(
|
||||
values[column], context, formatNumberType: FormatNumberType.int);
|
||||
}
|
||||
cells.add(DataCell(Text(value), onTap: () {
|
||||
if (group.isEmpty) {
|
||||
|
|
|
|||
|
|
@ -309,7 +309,7 @@ class ReportsScreenVM {
|
|||
final reportState = state.uiState.reportsUIState;
|
||||
String csvData = '';
|
||||
|
||||
if (reportState.group.isEmpty || reportState.isGroupByFIltered) {
|
||||
if (reportState.group.isEmpty || reportState.isGroupByFiltered) {
|
||||
reportResult.columns.forEach((column) {
|
||||
csvData += '${localization.lookup(column)},';
|
||||
});
|
||||
|
|
@ -446,7 +446,7 @@ GroupTotals calculateReportTotals({
|
|||
if (column == reportState.group) {
|
||||
totals['$group']['count'] += 1;
|
||||
}
|
||||
if (cell is ReportNumberValue) {
|
||||
if (cell is ReportNumberValue || cell is ReportAgeValue) {
|
||||
if (!totals['$group'].containsKey(column)) {
|
||||
totals['$group'][column] = 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue