Add a daily estimate. Move estimates to the right of the list item.

This commit is contained in:
2025-02-07 10:24:20 -07:00
parent 9d478b9cbf
commit 8c31d868b9
3 changed files with 50 additions and 15 deletions

View File

@ -12,6 +12,7 @@ class Expense {
required this.frequency,
required this.description});
@override
String toString() {
return "$name, $cost, ${frequency.title}, $description";
}
@ -19,4 +20,8 @@ class Expense {
double calcComparableCost() {
return cost * frequency.timesPerYear;
}
double calcComparableCostDaily() {
return cost / frequency.numDays;
}
}

View File

@ -4,50 +4,60 @@ enum Frequency {
title: "Daily",
hint: "Once Per Day",
timesPerYear: 364.25,
numDays: 1,
),
weekly(
title: "Weekly",
hint: "Once Per Week",
timesPerYear: (364.25/7),
timesPerYear: (364.25 / 7),
numDays: 7,
),
biweekly(
title: "Biweekly",
hint: "Every Other Week",
timesPerYear: (364.25/7/2),
timesPerYear: (364.25 / 14),
numDays: 14,
),
bimonthly(
title: "Bimonthly",
hint: "Twice Per Month",
timesPerYear: 24,
numDays: (364.25 / 24),
),
monthly(
title: "Monthly",
hint: "Once Per Month",
timesPerYear: 12,
numDays: (364.25 / 12),
),
quarterly(
title: "Quarterly",
hint: "Every Three Months",
timesPerYear: 4,
numDays: (364.25 / 4),
),
biannual(
title: "Biannual",
hint: "Twice Per Year",
timesPerYear: 2,
numDays: (364.25 / 2),
),
yearly(
title: "Yearly",
hint: "Once Per Year",
timesPerYear: 1,
numDays: 364.25,
);
const Frequency({
required this.title,
required this.hint,
required this.timesPerYear,
required this.numDays,
});
final String title;
final String hint;
final double timesPerYear;
final double numDays;
}