Improved layout, fixed transaction popup

This commit is contained in:
2024-02-11 17:28:21 +01:00
parent 44f6d433d1
commit cbaf94d866
21 changed files with 378 additions and 204 deletions

View File

@@ -96,22 +96,21 @@ class ChartBloc extends Bloc<ChartEvent, ChartState> {
ChartState _computeStateScopedStats(ChartState state) {
double globalTotal = 0;
double scoppedTotal = 0;
List<ChartItem> scopedCategoriesPositiveTotals = [];
List<ChartItem> scopedCategoriesNegativeTotals = [];
Map<int, FlSpot> scopedMonthlyTotals = {};
Map<int, Map<String, double>> scopedCategoriesMonthlyTotals = {};
for(var transaction in state.transactions) {
double subTotal = globalTotal + transaction.value;
globalTotal = subTotal;
globalTotal += transaction.value;
double subTotal = globalTotal;
if (transaction.date.year != state.currentYear) {
continue;
}
if (state.accountsTotals.containsKey(transaction.category)) {
continue;
}
scoppedTotal += transaction.value;
TransactionLine transactionLine = TransactionLine(transaction: transaction, subTotal: subTotal);
@@ -155,7 +154,6 @@ class ChartBloc extends Bloc<ChartEvent, ChartState> {
a?[transaction.category] = transaction.value.abs() + (a[transaction.category] ?? 0);
scopedCategoriesMonthlyTotals[transaction.date.month] = a!;
}
}
List<ChartItem> scopedCategoriesPositiveTotalsPercents = [];
@@ -205,6 +203,7 @@ class ChartBloc extends Bloc<ChartEvent, ChartState> {
scopedSimplifiedCategoriesNegativeTotalsPercents.sort((a, b) => a.value.compareTo(b.value));
return state.copyWith(
scoppedProfit: scoppedTotal,
scopedCategoriesPositiveTotals: scopedCategoriesPositiveTotals,
scopedCategoriesPositiveTotalsPercents: scopedCategoriesPositiveTotalsPercents,
scopedCategoriesNegativeTotals: scopedCategoriesNegativeTotals,