Dashboard
This commit is contained in:
parent
384c0dd5e8
commit
b6e46fbf78
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:built_value/built_value.dart';
|
||||
import 'package:built_value/serializer.dart';
|
||||
import 'package:invoiceninja_flutter/constants.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/entities.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||
|
|
@ -204,5 +205,14 @@ abstract class PaymentEntity extends Object
|
|||
@override
|
||||
FormatNumberType get listDisplayAmountType => FormatNumberType.money;
|
||||
|
||||
double get completedAmount {
|
||||
if ([kPaymentStatusVoided, kPaymentStatusFailed]
|
||||
.contains(paymentStatusId)) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
return amount - refunded;
|
||||
}
|
||||
|
||||
static Serializer<PaymentEntity> get serializer => _$paymentEntitySerializer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ List<ChartMoneyData> chartPayments(
|
|||
if (totals[payment.paymentDate] == null) {
|
||||
totals[payment.paymentDate] = 0.0;
|
||||
}
|
||||
totals[payment.paymentDate] += payment.amount;
|
||||
totals[payment.paymentDate] += payment.completedAmount;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ List<PaymentEntity> paymentsByInvoiceSelector(int invoiceId,
|
|||
|
||||
InvoiceEntity paymentInvoiceSelector(int paymentId, AppState state) {
|
||||
final payment = state.paymentState.map[paymentId] ?? PaymentEntity();
|
||||
return state.invoiceState.map[payment.invoiceId];
|
||||
return state.invoiceState.map[payment.invoiceId] ?? InvoiceEntity();
|
||||
}
|
||||
|
||||
ClientEntity paymentClientSelector(int paymentId, AppState state) {
|
||||
|
|
|
|||
|
|
@ -68,7 +68,11 @@ class _DashboardChartState extends State<DashboardChart> {
|
|||
final String changeAmount = (isIncrease ? '+' : '') +
|
||||
formatNumber(widget.amount - widget.previousAmount, context);
|
||||
final changePercent = (isIncrease ? '+' : '-') +
|
||||
formatNumber(widget.previousAmount / widget.amount * 100, context,
|
||||
formatNumber(
|
||||
widget.amount != 0 && widget.previousAmount != 0
|
||||
? round(widget.previousAmount / widget.amount * 100, 2)
|
||||
: 0.0,
|
||||
context,
|
||||
formatNumberType: FormatNumberType.percent);
|
||||
final String changeString = widget.amount == 0 || widget.previousAmount == 0
|
||||
? ''
|
||||
|
|
|
|||
Loading…
Reference in New Issue