Files
mercadodevida/work/artifacts/F-019/implementer.md
2026-08-17 22:23:10 +02:00

30 lines
1.4 KiB
Markdown

# Implementer — F-019 Promotions v1
## Summary
Implemented server-side promo codes with percent/fixed-amount rules, validity/usage validation, cart promo-code application, and recalculated discounts during cart reads.
## Files changed
- `project/migrations/014_promotions.js`
- `project/src/modules/promotions/**`
- `project/src/modules/cart/**`
- `project/src/app/build-app.ts`
- `project/src/app/tests/promotions.itest.ts`
## Acceptance evidence
- AC1 valid promo: `promotions.itest.ts` applies `SAVE10`; cart returns server-calculated discount and reduced total.
- AC2 expired/exhausted promo: `promotions.itest.ts` verifies HTTP 422 for expired and usage-limit exhausted codes.
- AC3 client-supplied discount ignored: promo and cart schemas strip unknown discount fields; cart stores only selected promo code, not discount amount.
- `verify.sh`: passed.
## Commands run
- `cd project && npm run lint` — passed
- `cd project && npm run typecheck` — passed
- `cd project && npm run build` — passed
- `cd project && npm test` — passed
- `cd project && TEST_DATABASE_URL='postgres://mdv:mdv_dev_only@localhost:5432/mdv_test' npm run test:integration -- promotions.itest migrations.itest` — passed; 11 files, 44 tests
- `./scripts/verify.sh` — passed
## Notes
- No stacking in v1: one `promo_code` per cart.
- Usage count is validated for exhaustion; consumption/increment can be tied to checkout/order completion in a later feature.