Files
baya-monorepo/mvp/blocker-phases/08-refunds-demock.md
T
2026-08-02 20:37:14 +03:30

33 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Phase 08 — Refunds are demo-only, and off by 100×
**Blocker:** blockers.md § "Payments" (refunds).
**Depends on:** nothing.
---
**Root cause — the mock.** `client/src/services/refunds/constants.ts:18``USE_REFUNDS_MOCK = true`. The
real server side (`RefundsController.cs`, `CreateRefundCommand`, `GetCancellationPolicyPreviewQuery`) is live
and correct; the client just never calls it for anything but the bare status read.
**Root cause — the ×100 bug, exact.** The server's `refundPercentageApplied`/`feePercentage` are **0100**
values (`GetCancellationPolicyPreviewQuery.Handler.cs:74`: `100m - policy.RefundPercentage`). The client's
own type comment claims **01** (`refunds/types.ts:110-112`) — true of the *mock* (`MOCK_POLICY_TIERS`,
`refunds/constants.ts:45-52`, uses `1 | 0.5 | 0`) but not the real server. The render function
(`CancellationPolicyDisclosure.tsx:19-21,36-37`) does `Math.round(fraction * 100)` — correct by luck against
the mock's 01 scale, but against the real server's `100.00` it produces **"10000%"**.
Important nuance: the actual IRR amounts shown are server-supplied strings passed straight through — **not**
multiplied by 100 themselves. It's specifically the percent-chip labels that are 100× too large.
## The fix
1. Flip `USE_REFUNDS_MOCK` to `false` — the real endpoints are live and correct.
2. Fix the scale mismatch at the contract level, not just the one render site: type
`CancellationPolicyPreview.refundPercentageApplied`/`feePercentage` as 0100 (matching the real server),
fix `CancellationPolicyDisclosure.tsx`'s `toPercent` to stop re-multiplying an already-0100 value, and fix
the mock (`mockApi.ts:127-128`, `MOCK_POLICY_TIERS`) to also emit 0100 so mock and real can never
silently disagree on scale again. Check `refunds/types.ts:167,201` for other render sites reusing the same
field before considering this fully closed.
3. Same cross-mock-import problem as BNPL (phase 05): `refunds/apis/mockApi.ts:3` imports directly from the
(real) `bookings` mock store — moot once step 1 lands.