Skip to content

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 != null to !== undefined to treat 0 as 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 !== null to !== undefined to 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 != null to !== undefined to ensure zero value overrides are properly captured instead of being treated as missing.
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: ')' expected and 5 other parse errors).

    Major changes implemented:

    • Rewrote with a proper leftJoin(organizationOverrides) and inlined COALESCE(organizationOverrides.perLineItemRate, $requestDefault) directly inside SUM(GREATEST(...)) so each row uses the correct effective rate.
    • Dropped the subscription.trialEnd/trialStart branch because those columns do not exist on the subscriptions schema β€” trial state is derived from status === 'trialing' until we ingest trial dates from Stripe webhooks.
    • Replaced Number(null) β†’ 0 truthiness bugs with ?? null (toNumberOrNull helper) so stored overrides of 0 are preserved end-to-end through overridesMap and into rateOverrides.
    • Revised the BillingSummary.tsx β€œCustom vs Default” check from !== undefined (which always rendered β€œCustom” because the API returns null for missing overrides) to !== null matching the actual API contract.

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.md and docs/adr/PR-1054.md β†’ pr-1054.md for kebab-case compliance.
  • Priority: skip
  • Decision: reject (false-positive β€” conflicts with existing convention)
  • Rationale: Established ADR convention in docs/adr/ uses uppercase PR- 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.