Assets are now being displayed properly.
This commit is contained in:
parent
a92cc00291
commit
8b9e0bfe54
@ -70,26 +70,45 @@ class SummaryCardForTotals extends StatelessWidget {
|
||||
if (!snapshot.hasData) {
|
||||
return Text('Loading $summaryTypeLabel Section...');
|
||||
}
|
||||
// TODO: Do not show all 3 sections or any text for Assets.
|
||||
|
||||
// Calculate the total fields based on item type.
|
||||
double dailyTotal = 0, monthlyTotal = 0, yearlyTotal = 0;
|
||||
bool isAsset = false;
|
||||
for (TrackedItem e in snapshot.data!) {
|
||||
dailyTotal += e.calcComparableAmountDaily();
|
||||
monthlyTotal += e.calcComparableAmountYearly() / 12;
|
||||
yearlyTotal += e.calcComparableAmountYearly();
|
||||
if (e.type == ItemType.asset) {
|
||||
monthlyTotal += e.amount;
|
||||
isAsset = true;
|
||||
} else {
|
||||
dailyTotal += e.calcComparableAmountDaily();
|
||||
monthlyTotal += e.calcComparableAmountYearly() / 12;
|
||||
yearlyTotal += e.calcComparableAmountYearly();
|
||||
}
|
||||
}
|
||||
|
||||
// Determine what needs displayed for the item type.
|
||||
String dailyEstimate =
|
||||
dailyTotal.toStringAsFixed(3).endsWith("0") ? "" : "~",
|
||||
monthlyEstimate =
|
||||
monthlyTotal.toStringAsFixed(3).endsWith("0") ? "" : "~",
|
||||
yearlyEstimate =
|
||||
yearlyTotal.toStringAsFixed(3).endsWith("0") ? "" : "~";
|
||||
String leftText = "", middleText = "", rightText = "";
|
||||
if (isAsset) {
|
||||
middleText = "$monthlyEstimate${monthlyTotal.toStringAsFixed(2)}";
|
||||
} else {
|
||||
leftText = "$dailyEstimate${dailyTotal.toStringAsFixed(2)} Daily";
|
||||
middleText =
|
||||
"$monthlyEstimate${monthlyTotal.toStringAsFixed(2)} Monthly";
|
||||
rightText =
|
||||
"$yearlyEstimate${yearlyTotal.toStringAsFixed(2)} Yearly";
|
||||
}
|
||||
|
||||
// Return the UI element.
|
||||
return SummaryCard(
|
||||
name: "$summaryTypeLabel Totals",
|
||||
leftText: "$dailyEstimate${dailyTotal.toStringAsFixed(2)} Daily",
|
||||
middleText:
|
||||
"$monthlyEstimate${monthlyTotal.toStringAsFixed(2)} Monthly",
|
||||
rightText:
|
||||
"$yearlyEstimate${yearlyTotal.toStringAsFixed(2)} Yearly",
|
||||
leftText: leftText,
|
||||
middleText: middleText,
|
||||
rightText: rightText,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user