Finfry::Recurrence
Maps a recurrence cadence to a per-day cost. We pay on a cadence (monthly, yearly, …) but want to see the cost amortized per day — derived purely from the cadence, not from accrual bookkeeping.
Constants
AVG_MONTH = 365.25 / 12
AVG_YEAR = 365.25
DAYS = {"daily" => 1.0, "weekly" => 7.0, "biweekly" => 14.0, "monthly" => 365.25 / 12, "quarterly" => 365.25 / 4, "yearly" => 365.25}
Average days per period. Months/quarters/years use 365.25/N so leap years and uneven month lengths wash out.
Class methods
The date one cadence after date (ISO "YYYY-MM-DD"). Month/year steps clamp
to valid days (Jan 31 + monthly => Feb 28/29).
Occurrence dates from from (inclusive) stepping by cadence up to and
including through. Used to catch up the due queue.
Per-day cost in (fractional) cents for an amount paid on this cadence.