36 lines
2.3 KiB
Markdown
36 lines
2.3 KiB
Markdown
# F-145 — Implementer evidence
|
|
|
|
## What
|
|
F-145 build evidence: schema migration `049_reporting_payment_lines.js` creates the immutable `reporting_payment_lines` table with all columns, CHECK constraints, FKs and indexes; plus DB integration test `reporting-payment-lines.itest.ts`. Backend-only, **no API or user-facing behavior change**.
|
|
|
|
## Design recap (architect-approved — see architect.md)
|
|
- `reporting_payment_lines`: order_id + store_id + terminal_id + cash_session_id + payment_method_id + provider + amount_cents + currency + status + provider_ref + created_at + updated_at.
|
|
- CHECK: `amount_cents != 0`, `currency = 'EUR'`, `status IN ('payment','refund','partial_refund')`.
|
|
- FK: order_id→orders_orders(id), store_id→pos_stores(id) — guarded by DO$$ for PG16 safety.
|
|
- Three indexes: (store_id,created_at), (order_id), (cash_session_id) WHERE cash_session_id IS NOT NULL.
|
|
- Immutable: refunds as new rows with status='refund', no UPDATE path.
|
|
|
|
## Files
|
|
- `project/migrations/049_reporting_payment_lines.js` (created) — idempotent/reversible.
|
|
- `project/src/app/tests/reporting-payment-lines.itest.ts` (created) — 16 DB assertions.
|
|
|
|
## Tests
|
|
- `reporting-payment-lines.itest.ts` (16, real PostgreSQL): AC1 (columns/types/nullability/defaults), AC1 (CHECK nonzero_amount/eur_only/valid_status), AC1 (FK order_id/store_id + FK violation), AC2 (valid INSERT + status variants), AC4 (3 indexes), AC5 (immutable refund-as-new-row pattern).
|
|
|
|
## Verification
|
|
- `npm run build` → 0 TypeScript errors (no output = success).
|
|
- `node scripts/check-module-boundaries.mjs src` → 0 NEW violations.
|
|
- `./scripts/verify.sh` → green (F-145 in_progress, runtime-consistent).
|
|
|
|
## AC traceability
|
|
| AC | Estado | Evidencia |
|
|
|----|--------|-----------|
|
|
| AC1 table+FK+CHECK+idx | ✅ | 13 columns (types/nullable/defaults), 3 CHECK constraints, 2 FKs, 3 indexes, FK violation asserted |
|
|
| AC2 valid INSERT | ✅ | INSERT succeeds, returns all columns, status variants |
|
|
| AC3 CHECK nonzero_amount | ✅ | amount_cents=0 throws |
|
|
| AC4 FK violation | ✅ | invalid order_id FK throws |
|
|
| AC5 idempotent/reversible | ✅ | createTable IF NOT EXISTS; down() drops all |
|
|
| AC6 indexes | ✅ | store_created + order + session (partial) |
|
|
| AC7 immutability | ✅ | refund as new row pattern verified |
|
|
| AC8 gates | ✅ | tsc 0; itest 16; 0 boundaries new |
|