ORIGINAL COMPANY-CONTEXT PRACTICE
Make a synthetic rewards ledger reversible
Original practice scenario: A fictional card program awards points for purchases, then handles refunds, charge corrections and partially redeemed rewards. Design its ledger.
Written for independent practice using company context; this is not a verified question from a company interview.
A REASONED APPROACH
Model answer.
Use immutable reward movements linked to the originating activity, with explicit reversal and redemption semantics. A mutable points balance alone cannot explain how a correction should affect prior awards.
Work through it
- Assign stable purchase and reward-event identifiers, version eligibility rules and make posting idempotent across repeated transaction notifications.
- Record awards, redemptions, expirations and compensating adjustments separately, defining what happens when a refund follows redemption under fictional program rules.
- Reconcile materialized balances to ledger totals and test partial refunds, duplicate events, late corrections and concurrent redemptions against declared invariants.
Tradeoffs to discuss
- An append-only ledger improves auditability but requires careful policy for negative balances and corrections to historical rule versions.
Common pitfalls
- Do not erase an award after it has affected later activity.
- A refunded purchase and its reward reversal need independent, linked event identities.