feat(POS-008): completed feature
This commit is contained in:
18
work/artifacts/POS-008/architect.md
Normal file
18
work/artifacts/POS-008/architect.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# POS-008 — Architect
|
||||
|
||||
## Feature
|
||||
POS Phase 1 ticket 008: POST /pos/sales idempotent transaction.
|
||||
|
||||
## Objetivo
|
||||
POST /pos/sales: creates a POS sale atomically (order + line items + payments + cash session update) in a DB transaction. Idempotent via idempotency key.
|
||||
|
||||
## Diseño
|
||||
- `CreatePosSaleUseCase` takes: idempotencyKey, cashSessionId, terminalId, userId, items[], payments[]
|
||||
- Step 1: idempotency check (return existing if key found)
|
||||
- Step 2: verify cash session OPEN (FOR UPDATE lock)
|
||||
- Step 3: compute totals
|
||||
- Step 4: INSERT order
|
||||
- Step 5: INSERT line items
|
||||
- Step 6: INSERT payments + update cash session expected_cash_cents
|
||||
- All in BEGIN/COMMIT/ROLLBACK transaction
|
||||
- Provider types: pos_cash, pos_card, pos_other (not regular payment providers)
|
||||
4
work/artifacts/POS-008/documenter.md
Normal file
4
work/artifacts/POS-008/documenter.md
Normal file
@@ -0,0 +1,4 @@
|
||||
# POS-008 — Documenter evidence
|
||||
|
||||
## Scope
|
||||
POS-008 adds POST /pos/sales API. Swagger schema documented inline in route definition. No external docs.
|
||||
22
work/artifacts/POS-008/implementer.md
Normal file
22
work/artifacts/POS-008/implementer.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# POS-008 — Implementer evidence
|
||||
|
||||
## What
|
||||
POST /pos/sales idempotent sale endpoint. tsc 0, verify verde.
|
||||
|
||||
## Files
|
||||
- `src/modules/pos/domain/pos-sale.ts` — PosSaleInput, PosSaleResult, PosPaymentInput, PosPaymentResult types
|
||||
- `src/modules/pos/application/create-pos-sale.ts` — CreatePosSaleUseCase with transaction (BEGIN/COMMIT/ROLLBACK), idempotency check, cash session lock
|
||||
- `src/modules/pos/api/pos.routes.ts` — POST /pos/sales route with schema validation
|
||||
|
||||
## Verification
|
||||
- `npm run build` → 0 TypeScript errors.
|
||||
- `./scripts/verify.sh` → green.
|
||||
|
||||
## AC traceability
|
||||
| AC | Estado |
|
||||
|----|--------|
|
||||
| AC1 idempotent | ✅ idempotencyKey check returns existing |
|
||||
| AC2 atomic | ✅ BEGIN/COMMIT/ROLLBACK transaction |
|
||||
| AC3 items + payments | ✅ INSERT + total validation |
|
||||
| AC4 cash session update | ✅ UPDATE expected_cash_cents |
|
||||
| AC5 tsc/verify | ✅ |
|
||||
12
work/artifacts/POS-008/leader-close.json
Normal file
12
work/artifacts/POS-008/leader-close.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"feature_id": "POS-008",
|
||||
"agent": "leader",
|
||||
"stage": "close",
|
||||
"verdict": "APPROVED",
|
||||
"summary": "POS-008 closed: POST /pos/sales idempotent. tsc 0, verify.sh green.",
|
||||
"checks": [
|
||||
{"item": "Gates approved", "ok": true, "evidence": "reviewer.json, security.json, qa.json -> APPROVED"},
|
||||
{"item": "verify.sh", "ok": true, "evidence": "exit 0"}
|
||||
],
|
||||
"issues": []
|
||||
}
|
||||
12
work/artifacts/POS-008/qa.json
Normal file
12
work/artifacts/POS-008/qa.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"feature_id": "POS-008",
|
||||
"agent": "qa",
|
||||
"stage": "qa_gate",
|
||||
"verdict": "APPROVED",
|
||||
"summary": "tsc 0, verify.sh green.",
|
||||
"checks": [
|
||||
{"item": "tsc 0", "ok": true, "evidence": "npm run build 0 errors"},
|
||||
{"item": "verify.sh", "ok": true, "evidence": "exit 0"}
|
||||
],
|
||||
"issues": []
|
||||
}
|
||||
15
work/artifacts/POS-008/reviewer.json
Normal file
15
work/artifacts/POS-008/reviewer.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"feature_id": "POS-008",
|
||||
"agent": "reviewer",
|
||||
"stage": "review_gate",
|
||||
"verdict": "APPROVED",
|
||||
"summary": "POST /pos/sales idempotent atomic transaction. tsc 0, verify green.",
|
||||
"checks": [
|
||||
{"item": "Idempotency", "ok": true, "evidence": "EXISTS check on idempotency_key; returns existing"},
|
||||
{"item": "Transaction", "ok": true, "evidence": "BEGIN/COMMIT/ROLLBACK + FOR UPDATE lock"},
|
||||
{"item": "Totals validation", "ok": true, "evidence": "subtotal/tax/total computed; payment >= total"},
|
||||
{"item": "Cash session update", "ok": true, "evidence": "expected_cash_cents += tendered cash"},
|
||||
{"item": "tsc/verify", "ok": true, "evidence": "tsc 0, verify green"}
|
||||
],
|
||||
"issues": []
|
||||
}
|
||||
13
work/artifacts/POS-008/security.json
Normal file
13
work/artifacts/POS-008/security.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"feature_id": "POS-008",
|
||||
"agent": "security",
|
||||
"stage": "security_gate",
|
||||
"verdict": "APPROVED",
|
||||
"summary": "All inputs validated with Zod. No raw SQL values. Role-based access.",
|
||||
"checks": [
|
||||
{"item": "SQL injection", "ok": true, "evidence": "All values parameterized ($1, $2...)"},
|
||||
{"item": "Authorization", "ok": true, "evidence": "requireAnyRole admin/pos_manager/pos_cashier"},
|
||||
{"item": "Input validation", "ok": true, "evidence": "Zod schema on body + request parsing"}
|
||||
],
|
||||
"issues": []
|
||||
}
|
||||
Reference in New Issue
Block a user