A whole lot of stuff
This commit is contained in:
parent
faf319322a
commit
ad850d2be6
50 changed files with 3013 additions and 213 deletions
26
lib/services/estimated_refund.dart
Normal file
26
lib/services/estimated_refund.dart
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/// The Missouri Highway Fuel Tax Refund rate per gallon — the basis for
|
||||
/// [estimatedFuelRefund]. Set by Missouri law and subject to change at any
|
||||
/// time; the UI Settings toggle that turns these estimates on says as much,
|
||||
/// and this is deliberately the highway rate only (not the separate,
|
||||
/// higher non-highway-use refund) since that's the one that applies to
|
||||
/// ordinary vehicle fill-ups this app is built around.
|
||||
const moHighwayFuelTaxRefundRatePerGallon = 0.125;
|
||||
|
||||
/// A rough estimate of the Missouri Highway Fuel Tax Refund for [gallons]
|
||||
/// of fuel, at the current rate. Purely informational — not tax advice,
|
||||
/// and not a substitute for confirming the actual claimable amount with
|
||||
/// the Missouri Department of Revenue.
|
||||
///
|
||||
/// [gallons] is rounded to the nearest whole gallon *before* multiplying —
|
||||
/// matching how the actual refund calculation works, rather than
|
||||
/// multiplying the precise (fractional) logged amount. The result is then
|
||||
/// rounded down to the nearest cent, never up, so this never overstates
|
||||
/// what's actually claimable.
|
||||
double estimatedFuelRefund(double gallons) {
|
||||
final roundedGallons = gallons.roundToDouble();
|
||||
final rawRefund = roundedGallons * moHighwayFuelTaxRefundRatePerGallon;
|
||||
// The tiny epsilon guards against binary floating-point representation
|
||||
// error nudging an exact cent value (e.g. 2.50) just under its true
|
||||
// value and floor()ing it down a cent it doesn't actually owe.
|
||||
return (rawRefund * 100 + 1e-9).floorToDouble() / 100;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue