Implement the core calculation engine for a loyalty program, including points accrual based on eligible spend and redemption value. This focuses on the calculation logic, without implementing full loyalty commands or provider API integration yet.
## Priority: P2 — Revenue Recognition **Ref:** BA §11, §14.4 | **Effort:** XL (2-4 weeks) ## Current State - `loyalty.ts` calculation engine exists (points accrual, redemption value, tier bonus) - Calculation route at `/v1/calculations/loyalty/*` works - **No loyalty commands** (no accrue, redeem, re-credit) - **No loyalty provider API integration** - No loyalty_transactions table ## What the Doc Requires ### Points Accrual (§11.1) - At checkout: eligible spend → accrual rate → points earned - Exclude taxes, comps, discounts from accrual base - Tier multiplier (Gold 1.5x, Platinum 2x) - Async POST to loyalty provider (5s timeout, queue on failure) ### Points Redemption (§11.2) - Sync validation with loyalty provider (3s timeout, block on failure) - Post as REDEMPTION_CREDIT on folio (not a payment) - GL: DR 2300 (Loyalty Liability) / CR 1200 (Guest Ledger) ### Re-credit on Cancellation - Reverse accrual, re-credit redeemed points - Async to loyalty provider, queue for retry ## Wo