40 lines
2.1 KiB
Markdown
40 lines
2.1 KiB
Markdown
# F-144 — Criterios de aceptación
|
|
|
|
## AC1 — store_id multi-tienda (snapshot, no rewrite)
|
|
- `orders_orders.store_id` es `uuid NOT NULL DEFAULT '00000000-0000-0000-0000-000000000001'::uuid`.
|
|
- FK `orders_orders_store_id_fkey → pos_stores(id)` existe y es `VALID`.
|
|
- Índice `orders_orders_store_id_created_at_idx ON orders_orders(store_id, created_at)` existe.
|
|
- Filas existentes heredan el default store (no table rewrite de datos).
|
|
- Un `INSERT INTO orders_orders DEFAULT VALUES` persiste `store_id = DEFAULT_STORE_ID`.
|
|
|
|
## AC2 — shipping_cents separado
|
|
- `orders_orders.shipping_cents` es `integer NOT NULL DEFAULT 0`.
|
|
- Filas existentes mantienen su `total_cents` (no se altera; shipping_cents = 0).
|
|
- El `INSERT ... DEFAULT VALUES` registra `shipping_cents = 0`.
|
|
|
|
## AC3 — snapshots de línea (cost_at_sale_cents, vat_rate)
|
|
- `orders_items.cost_at_sale_cents` es `bigint`, nullable (NULL para filas históricas → margen `unavailable`).
|
|
- `orders_items.vat_rate` es `text`, nullable (snapshot del tipo IVA aplicado; NULL → IVA-por-tipo `unavailable`).
|
|
- No se reescribe la historia: columnas nuevas no tocan datos existentes.
|
|
|
|
## AC4 — migración idempotente y reversible
|
|
- `up()` es no-op si se re-ejecuta (DDL `IF NOT EXISTS` / `DO $$` guards).
|
|
- `down()` elimina índice, constraint y columnas nuevas.
|
|
|
|
## AC5 — itest de snapshots (DB real)
|
|
- `reporting-snapshots.itest.ts` recrea la DB, migra (aplica 048), y verifica
|
|
columnas, nullabilidad, defaults, FK (contype='f') e índice vía
|
|
`information_schema`/`pg_constraint`/`pg_indexes`, más un insert
|
|
`DEFAULT VALUES` con backfill de `store_id`/`shipping_cents`.
|
|
|
|
## AC6 — verificación de gates
|
|
- `npx tsc --noEmit` → 0 errores.
|
|
- `TEST_DATABASE_URL=... npx vitest run` → itest F-144 3/3 verde + sin regresiones
|
|
(orders/catalog/checkout/sales/etc.) 0 fallos.
|
|
- `node scripts/check-module-boundaries.mjs src` → 0 violaciones nuevas.
|
|
|
|
## AC7 — sin regresión en flujos existentes
|
|
- El seed y el checkout siguen funcionando: `orders_orders` `INSERT` sin
|
|
`store_id` explícito sigue válido (column DEFAULT).
|
|
- `orders.itest.ts`, `catalog.itest.ts`, `checkout-flow.itest.ts` siguen verdes.
|