Aging report
This commit is contained in:
parent
ad33333e81
commit
06d5a45c44
|
|
@ -38,6 +38,7 @@ class EntityType extends EnumClass {
|
||||||
static const EntityType gatewayToken = _$gatewayToken;
|
static const EntityType gatewayToken = _$gatewayToken;
|
||||||
static const EntityType invoiceItem = _$invoiceItem;
|
static const EntityType invoiceItem = _$invoiceItem;
|
||||||
static const EntityType design = _$design;
|
static const EntityType design = _$design;
|
||||||
|
|
||||||
// STARTER: entity type - do not remove comment
|
// STARTER: entity type - do not remove comment
|
||||||
static const EntityType quoteItem = _$quoteItem;
|
static const EntityType quoteItem = _$quoteItem;
|
||||||
static const EntityType contact = _$contact;
|
static const EntityType contact = _$contact;
|
||||||
|
|
@ -228,6 +229,12 @@ abstract class BaseEntity implements SelectableEntity {
|
||||||
ReportBoolValue getReportBool({bool value}) =>
|
ReportBoolValue getReportBool({bool value}) =>
|
||||||
ReportBoolValue(entityId: id, entityType: entityType, value: value);
|
ReportBoolValue(entityId: id, entityType: entityType, value: value);
|
||||||
|
|
||||||
|
ReportAgeValue getReportAge({int value, String currencyId}) => ReportAgeValue(
|
||||||
|
entityType: entityType,
|
||||||
|
entityId: id,
|
||||||
|
value: value,
|
||||||
|
currencyId: currencyId);
|
||||||
|
|
||||||
ReportNumberValue getReportNumber(
|
ReportNumberValue getReportNumber(
|
||||||
{double value,
|
{double value,
|
||||||
String currencyId,
|
String currencyId,
|
||||||
|
|
|
||||||
|
|
@ -131,11 +131,8 @@ ReportResult agingReport(
|
||||||
if (value.runtimeType == bool) {
|
if (value.runtimeType == bool) {
|
||||||
row.add(invoice.getReportBool(value: value));
|
row.add(invoice.getReportBool(value: value));
|
||||||
} else if (column == AgingReportFields.age) {
|
} else if (column == AgingReportFields.age) {
|
||||||
row.add(invoice.getReportNumber(
|
row.add(invoice.getReportAge(
|
||||||
value: value,
|
value: value.round(), currencyId: client.settings.currencyId));
|
||||||
// TODO figure out why this line is needed
|
|
||||||
currencyId: client.settings.currencyId,
|
|
||||||
formatNumberType: FormatNumberType.int));
|
|
||||||
} else if (value.runtimeType == double || value.runtimeType == int) {
|
} else if (value.runtimeType == double || value.runtimeType == int) {
|
||||||
row.add(invoice.getReportNumber(
|
row.add(invoice.getReportNumber(
|
||||||
value: value, currencyId: client.settings.currencyId));
|
value: value, currencyId: client.settings.currencyId));
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,9 @@ class ReportCharts extends StatelessWidget {
|
||||||
|
|
||||||
Widget child;
|
Widget child;
|
||||||
switch (getReportColumnType(reportState.group, context)) {
|
switch (getReportColumnType(reportState.group, context)) {
|
||||||
|
case ReportColumnType.age:
|
||||||
|
child = SizedBox();
|
||||||
|
break;
|
||||||
case ReportColumnType.string:
|
case ReportColumnType.string:
|
||||||
case ReportColumnType.bool:
|
case ReportColumnType.bool:
|
||||||
child = charts.BarChart(
|
child = charts.BarChart(
|
||||||
|
|
|
||||||
|
|
@ -474,6 +474,7 @@ enum ReportColumnType {
|
||||||
date,
|
date,
|
||||||
number,
|
number,
|
||||||
bool,
|
bool,
|
||||||
|
age,
|
||||||
}
|
}
|
||||||
|
|
||||||
ReportColumnType getReportColumnType(String column, BuildContext context) {
|
ReportColumnType getReportColumnType(String column, BuildContext context) {
|
||||||
|
|
@ -496,6 +497,8 @@ ReportColumnType getReportColumnType(String column, BuildContext context) {
|
||||||
return ReportColumnType.dateTime;
|
return ReportColumnType.dateTime;
|
||||||
} else if (['date', 'due_date'].contains(column)) {
|
} else if (['date', 'due_date'].contains(column)) {
|
||||||
return ReportColumnType.date;
|
return ReportColumnType.date;
|
||||||
|
} else if (column == 'age') {
|
||||||
|
return ReportColumnType.age;
|
||||||
} else if ([
|
} else if ([
|
||||||
'balance',
|
'balance',
|
||||||
'paid_to_date',
|
'paid_to_date',
|
||||||
|
|
@ -509,7 +512,6 @@ ReportColumnType getReportColumnType(String column, BuildContext context) {
|
||||||
'tax_rate',
|
'tax_rate',
|
||||||
'tax_amount',
|
'tax_amount',
|
||||||
'tax_paid',
|
'tax_paid',
|
||||||
'age',
|
|
||||||
'payment_amount'
|
'payment_amount'
|
||||||
].contains(column)) {
|
].contains(column)) {
|
||||||
return ReportColumnType.number;
|
return ReportColumnType.number;
|
||||||
|
|
@ -789,7 +791,7 @@ class ReportResult {
|
||||||
],
|
],
|
||||||
))
|
))
|
||||||
else
|
else
|
||||||
if (column == 'age')
|
if (getReportColumnType(column, context) == ReportColumnType.age)
|
||||||
DataCell(AppDropdownButton<String>(
|
DataCell(AppDropdownButton<String>(
|
||||||
value: (textEditingControllers[column].text ?? '')
|
value: (textEditingControllers[column].text ?? '')
|
||||||
.isNotEmpty &&
|
.isNotEmpty &&
|
||||||
|
|
@ -1063,7 +1065,8 @@ class ReportResult {
|
||||||
onSort: onSortCallback,
|
onSort: onSortCallback,
|
||||||
),
|
),
|
||||||
for (String column in columns)
|
for (String column in columns)
|
||||||
if (getReportColumnType(column, context) == ReportColumnType.number)
|
if ([ReportColumnType.number, ReportColumnType.age,].contains(
|
||||||
|
getReportColumnType(column, context)))
|
||||||
DataColumn(
|
DataColumn(
|
||||||
label: Text(
|
label: Text(
|
||||||
localization.lookup(column),
|
localization.lookup(column),
|
||||||
|
|
@ -1090,8 +1093,14 @@ 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 (cell is ReportNumberValue || cell is ReportAgeValue) {
|
||||||
|
String currencyId;
|
||||||
if (cell is ReportNumberValue) {
|
if (cell is ReportNumberValue) {
|
||||||
final String currencyId = cell.currencyId;
|
currencyId = cell.currencyId;
|
||||||
|
} else if (cell is ReportAgeValue) {
|
||||||
|
currencyId = cell.currencyId;
|
||||||
|
}
|
||||||
|
|
||||||
if (!totals.containsKey(currencyId)) {
|
if (!totals.containsKey(currencyId)) {
|
||||||
totals[currencyId] = {'count': 0};
|
totals[currencyId] = {'count': 0};
|
||||||
|
|
@ -1213,6 +1222,27 @@ class ReportStringValue extends ReportElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ReportAgeValue extends ReportElement {
|
||||||
|
ReportAgeValue({
|
||||||
|
@required dynamic value,
|
||||||
|
@required EntityType entityType,
|
||||||
|
@required String entityId,
|
||||||
|
@required this.currencyId,
|
||||||
|
}) : super(value: value, entityType: entityType, entityId: entityId);
|
||||||
|
|
||||||
|
final String currencyId;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget renderWidget(BuildContext context, String column) {
|
||||||
|
return Text(renderText(context, column));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String renderText(BuildContext context, String column) {
|
||||||
|
return '$value';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class ReportNumberValue extends ReportElement {
|
class ReportNumberValue extends ReportElement {
|
||||||
ReportNumberValue({
|
ReportNumberValue({
|
||||||
dynamic value,
|
dynamic value,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue