ADR β PR #1026
2026-05-20 10:30 β Fix rate override display logic to handle zero values correctly
Section titled β2026-05-20 10:30 β Fix rate override display logic to handle zero values correctlyβ- Comment: Inline comment in BillingSummary.tsx lines 344-346
- Priority: nice-to-have
- Decision: accept (revised β see 15:55 entry)
- Rationale: Initial attempt changed
!= nullto!== undefinedto treat0as a custom override. That regressed the βno overrideβ case (null !== undefined β always Custom). Revised below.
2026-05-20 10:31 β Fix usage charges calculation to use org-specific effective rates
Section titled β2026-05-20 10:31 β Fix usage charges calculation to use org-specific effective ratesβ- Comment: Outside diff range comment in billing-summary.ts lines 128-133
- Priority: must-fix
- Decision: accept
- Rationale: SQL query was using request-level rates instead of per-org effective rates causing incorrect billing calculations for organizations with custom rates
2026-05-20 10:32 β Fix effective rates fallback logic to handle zero overrides
Section titled β2026-05-20 10:32 β Fix effective rates fallback logic to handle zero overridesβ- Comment: Outside diff range comment in billing-summary.ts lines 164-165
- Priority: must-fix
- Decision: accept
- Rationale: Changed fallback logic from
!== nullto!== undefinedto properly handle explicit zero overrides instead of falling back to base rates.
2026-05-20 10:33 β Fix rate overrides assignment to handle zero values
Section titled β2026-05-20 10:33 β Fix rate overrides assignment to handle zero valuesβ- Comment: Outside diff range comment in billing-summary.ts lines 199-200
- Priority: must-fix
- Decision: accept
- Rationale: Changed assignment logic from
!= nullto!== undefinedto ensure zero value overrides are properly captured instead of being treated as missing.
2026-05-20 10:34 β Footer column mismatch in BillingSummary
Section titled β2026-05-20 10:34 β Footer column mismatch in BillingSummaryβ- Comment: CodeRabbit comment on BillingSummary.tsx lines 451-468 (outside diff)
- Priority: skip
- Decision: reject
- Rationale: Footer already aligns with header columns; extra MRR cell not present. No code change needed.
2026-05-20 15:55 β Rewrite billing-summary.ts to compile and apply overrides inside SUM (CR re-review on PR #1054)
Section titled β2026-05-20 15:55 β Rewrite billing-summary.ts to compile and apply overrides inside SUM (CR re-review on PR #1054)β-
Comment: https://github.com/ERP-Unlocked/ordermatic/pull/1054 (CR findings on billing-summary.ts:91-98, 128-141, 201)
-
Priority: must-fix
-
Decision: accept (major rewrite)
-
Rationale: The previous attempt left the file in a non-compiling state β the
.with(effectiveRates as (select {...}))block was pseudo-Drizzle that tsc rejected (error TS1005: ')' expectedand 5 other parse errors).Major changes implemented:
- Rewrote with a proper
leftJoin(organizationOverrides)and inlinedCOALESCE(organizationOverrides.perLineItemRate, $requestDefault)directly insideSUM(GREATEST(...))so each row uses the correct effective rate. - Dropped the
subscription.trialEnd/trialStartbranch because those columns do not exist on thesubscriptionsschema β trial state is derived fromstatus === 'trialing'until we ingest trial dates from Stripe webhooks. - Replaced
Number(null) β 0truthiness bugs with?? null(toNumberOrNullhelper) so stored overrides of0are preserved end-to-end throughoverridesMapand intorateOverrides. - Revised the
BillingSummary.tsxβCustom vs Defaultβ check from!== undefined(which always rendered βCustomβ because the API returnsnullfor missing overrides) to!== nullmatching the actual API contract.
- Rewrote with a proper
2026-05-28 β CR feedback on ADR filename casing (PR #1249)
Section titled β2026-05-28 β CR feedback on ADR filename casing (PR #1249)β- Comment: CodeRabbit suggested renaming
docs/adr/PR-1026.mdβpr-1026.mdanddocs/adr/PR-1054.mdβpr-1054.mdfor kebab-case compliance. - Priority: skip
- Decision: reject (false-positive β conflicts with existing convention)
- Rationale: Established ADR convention in
docs/adr/uses uppercasePR-prefix across 16 sibling files (PR-982 through PR-1099). Renaming only these two would create inconsistency. If we ever decide to switch the whole directory to lowercase, that should be a single sweep across all files, not a piecemeal change on individual PRs.