utilities/backend
jtricerolph 7ab048931f Split cost/estimate across mid-period tariff changes
Rate changes are often scheduled ahead of time or confirmed by finance
after the fact and backdated — assign-tariff already supported any
effective_from date, but cost-calc previously priced a whole period at
a single tariff (whichever was in force on the period-end date),
silently mispricing the days on the other side of a change.

getTariffSegments() finds every tariff assignment overlapping a date
range; getMeterCostForPeriod/getMeterEstimateForPeriod now split
consumption pro-rata by day count across segments and price each
against its own tariff, summing to the period total. Estimates project
the remaining days across a future-scheduled change the same way,
rather than assuming today's tariff holds for the rest of the period.

Also consolidates internal.js's cost/estimate routes (previously their
own duplicate calc) onto the same shared functions reports.js and
estimates.js use, so the Directors' report can't drift from the in-app
numbers.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-26 17:43:45 +00:00
..
src Split cost/estimate across mid-period tariff changes 2026-07-26 17:43:45 +00:00
Dockerfile Initial commit — utilities app (meter readings, tariffs, cost tracking) 2026-07-26 17:33:42 +00:00
package.json Initial commit — utilities app (meter readings, tariffs, cost tracking) 2026-07-26 17:33:42 +00:00