current period $
This commit is contained in:
@@ -64,11 +64,15 @@ class BillingBloc extends Bloc<BillingEvent, BillingState> {
|
|||||||
.map(_mapInvoiceToUiModel)
|
.map(_mapInvoiceToUiModel)
|
||||||
.toList();
|
.toList();
|
||||||
final List<SpendingBreakdownItem> uiSpendingBreakdown = _mapSpendingItemsToUiModel(spendingItems);
|
final List<SpendingBreakdownItem> uiSpendingBreakdown = _mapSpendingItemsToUiModel(spendingItems);
|
||||||
|
final double periodTotal = uiSpendingBreakdown.fold(
|
||||||
|
0.0,
|
||||||
|
(double sum, SpendingBreakdownItem item) => sum + item.amount,
|
||||||
|
);
|
||||||
|
|
||||||
emit(
|
emit(
|
||||||
state.copyWith(
|
state.copyWith(
|
||||||
status: BillingStatus.success,
|
status: BillingStatus.success,
|
||||||
currentBill: currentBill,
|
currentBill: periodTotal,
|
||||||
savings: savings,
|
savings: savings,
|
||||||
pendingInvoices: uiPendingInvoices,
|
pendingInvoices: uiPendingInvoices,
|
||||||
invoiceHistory: uiInvoiceHistory,
|
invoiceHistory: uiInvoiceHistory,
|
||||||
@@ -94,10 +98,15 @@ class BillingBloc extends Bloc<BillingEvent, BillingState> {
|
|||||||
await _getSpendingBreakdown.call(event.period);
|
await _getSpendingBreakdown.call(event.period);
|
||||||
final List<SpendingBreakdownItem> uiSpendingBreakdown =
|
final List<SpendingBreakdownItem> uiSpendingBreakdown =
|
||||||
_mapSpendingItemsToUiModel(spendingItems);
|
_mapSpendingItemsToUiModel(spendingItems);
|
||||||
|
final double periodTotal = uiSpendingBreakdown.fold(
|
||||||
|
0.0,
|
||||||
|
(double sum, SpendingBreakdownItem item) => sum + item.amount,
|
||||||
|
);
|
||||||
emit(
|
emit(
|
||||||
state.copyWith(
|
state.copyWith(
|
||||||
period: event.period,
|
period: event.period,
|
||||||
spendingBreakdown: uiSpendingBreakdown,
|
spendingBreakdown: uiSpendingBreakdown,
|
||||||
|
currentBill: periodTotal,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user