Billing reconciliation aligns bill periods to calendar months, corrupting the delta #24

Open
opened 2026-07-17 03:06:31 +00:00 by claude-bot · 0 comments
Contributor

buildBillingReconciliation (src/lib/billing.js:39-40) maps each bill to periodEnd.slice(0,7) and compares its total against that calendar month's modeled bill. Ameren billing cycles run mid-month to mid-month, so the modeled and actual windows overlap by only ~50–60%, and at season boundaries (June, October) they straddle different rate seasons. The reconciliation delta — the feature's entire output — therefore contains a large alignment component unrelated to model accuracy.

Fix: compute the modeled cost over the exact bill window. The hourly simulation already produces per-hour costs (hourlyImpact behind the includeHourlyImpact option in src/lib/simulation.js); expose a per-day cost rollup from the monthly summary path and sum days in [periodStart, periodEnd]. If that is too heavy for the default calculation, fall back to blending adjacent calendar months by day overlap. Label any remaining approximation in the Billing tab.

Acceptance criteria

  • Modeled figure for each bill covers the bill's actual date window
  • Season-straddling periods (Jun/Oct) reconcile without systematic sign error
  • Test with a synthetic mid-month bill period against known hourly costs

Relations: relates to #14 (both concern billing-data fidelity)

(Audit finding F-03, 2026-07-16 — Severity: Medium, Confidence: High)

`buildBillingReconciliation` (`src/lib/billing.js:39-40`) maps each bill to `periodEnd.slice(0,7)` and compares its total against that calendar month's modeled bill. Ameren billing cycles run mid-month to mid-month, so the modeled and actual windows overlap by only ~50–60%, and at season boundaries (June, October) they straddle different rate seasons. The reconciliation delta — the feature's entire output — therefore contains a large alignment component unrelated to model accuracy. Fix: compute the modeled cost over the exact bill window. The hourly simulation already produces per-hour costs (`hourlyImpact` behind the `includeHourlyImpact` option in `src/lib/simulation.js`); expose a per-day cost rollup from the monthly summary path and sum days in [periodStart, periodEnd]. If that is too heavy for the default calculation, fall back to blending adjacent calendar months by day overlap. Label any remaining approximation in the Billing tab. **Acceptance criteria** - [ ] Modeled figure for each bill covers the bill's actual date window - [ ] Season-straddling periods (Jun/Oct) reconcile without systematic sign error - [ ] Test with a synthetic mid-month bill period against known hourly costs **Relations:** relates to #14 (both concern billing-data fidelity) *(Audit finding F-03, 2026-07-16 — Severity: Medium, Confidence: High)*
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rbrooks/BatteryStorageCalculator#24
No description provided.