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

39 lines
2.0 KiB
Markdown

# Implementer — F-017 Pricing module
## Summary
Implemented server-side pricing with VAT behind a public `PricingService`, including PostgreSQL persistence, append-only price history, API routes, migration, and tests.
## Files changed
- `project/migrations/012_pricing.js`
- `project/src/app/build-app.ts`
- `project/src/app/tests/pricing.itest.ts`
- `project/src/modules/pricing/index.ts`
- `project/src/modules/pricing/api/pricing.routes.ts`
- `project/src/modules/pricing/application/pricing-service.ts`
- `project/src/modules/pricing/domain/errors.ts`
- `project/src/modules/pricing/domain/ports.ts`
- `project/src/modules/pricing/domain/price.ts`
- `project/src/modules/pricing/infrastructure/pg-pricing-repository.ts`
- `project/src/modules/pricing/tests/boundary.test.ts`
- `project/src/modules/pricing/tests/pricing-service.test.ts`
## Acceptance evidence
- AC1 variant + quantity returns total with VAT: covered by `pricing-service.test.ts` and `pricing.itest.ts`.
- AC2 client-supplied price ignored: `pricing.itest.ts` sends bogus client price fields to `/pricing/calculate`; response uses persisted server-side price.
- AC3 price change writes history row: `pricing.itest.ts` verifies creation and update both append rows to `pricing_price_history`.
- `verify.sh`: passed.
## Commands run
- `cd project && npm run typecheck` — passed
- `cd project && npm run lint` — passed after Prettier formatting
- `cd project && npm run build` — passed
- `cd project && npm test` — passed; DB integration tests skipped without `TEST_DATABASE_URL`
- `cd project && TEST_DATABASE_URL='postgres://mdv:mdv_dev_only@localhost:5432/mdv_test' npm run test:integration -- pricing.itest migrations.itest` — passed; 9 files, 39 tests
- `./scripts/verify.sh` — passed
## Notes
- No new runtime dependency was added.
- Money is represented as integer cents only.
- VAT rates are `general` 21% and `reduced` 10%.
- Pricing stores `variant_id` as an opaque UUID and does not import or join catalog internals.