feat(F-190): completed feature

This commit is contained in:
chattie
2026-08-23 07:48:20 +02:00
parent 6b93e91ef4
commit eb3322e309
22 changed files with 287 additions and 67 deletions

View File

@@ -0,0 +1,45 @@
# F-190 — Implementer Evidence
## Feature
Reporting updates from POS sales and returns.
## Change Summary
### 1. `src/modules/reporting/application/reporting-service.ts`
Updated `dataAvailability` flags in 3 return-statement sites (summary, sales, products)
to reflect that `reporting_payment_lines` now captures payment method and refund data:
| Field | Before | After | Reason |
|-----------------|----------------|----------------|--------|
| `paymentMethod` | `'unavailable'`| `'available'` | F-190: `reporting_payment_lines` has `provider` per payment row |
| `refunds` | `'unavailable'`| `'available'` | F-190: `reporting_payment_lines` has `refund`/`partial_refund` status rows |
`netSales` and `margin` remain `'unavailable'` (correct, no cost data or shipping-per-order yet).
Also added F-190 attribution comment at the top of the file.
### 2. Test updates
Updated 3 test assertions in `reporting-service.test.ts` and `reporting.routes.test.ts`
that were asserting the old `'unavailable'` values.
### Existing code (no changes needed)
The following already works correctly and requires no modification:
- `ReceiveRestPaymentUseCase` (F-188) already writes `reporting_payment_lines` with `status='payment'`
when a PENDING order transitions to COMPLETED.
- `ApplyPosReturnUseCase` (F-189) already writes `reporting_payment_lines` with
`status='refund'` or `'partial_refund'` for each return.
- `CreatePosSaleUseCase` already writes `reporting_payment_lines` with `status='payment'`
for each initial payment.
- `ReportingService.runSummaryQuery` uses `orders_items` for `gross_sales_cents`, which
correctly reflects returns (REFUNDED/PARTIALLY_REFUNDED are excluded from SALES_STATES).
## Verification
| Check | Result |
|-------|--------|
| `npm test` | 269 passed, 96 skipped |
| `npx tsc --noEmit` | 0 errors |
| `./scripts/verify.sh` | OK |

View File

@@ -0,0 +1,13 @@
{
"agent": "leader",
"feature_id": "F-190",
"verdict": "APPROVED",
"summary": "F-190 closed: dataAvailability paymentMethod and refunds corrected to 'available'. All gates APPROVED. verify.sh green.",
"gates": {
"reviewer": true,
"security": true,
"qa": true,
"close": true
},
"closed_at": "2026-08-23T05:49:30Z"
}

View File

@@ -0,0 +1,39 @@
{
"agent": "qa",
"feature_id": "F-190",
"verdict": "APPROVED",
"summary": "QA trace: all acceptance criteria satisfied. 269 tests pass. verify.sh green. dataAvailability flags correctly updated in all code sites.",
"checks": [
{
"id": "QA-1",
"description": "AC1: PENDING→COMPLETED emits reporting_payment_lines",
"result": "PASS",
"evidence": "ReceiveRestPaymentUseCase lines 106-115: INSERT reporting_payment_lines with status='payment' on each rest-payment. Test pos-pending-payments.itest.ts line 109-113 verifies count=2 (initial partial + rest-payment)."
},
{
"id": "QA-2",
"description": "AC2: Fully returned sale shows refund payment line",
"result": "PASS",
"evidence": "ApplyPosReturnUseCase lines 176-184: INSERT reporting_payment_lines with status='refund'. Test pos-returns.itest.ts verifies reporting_payment_lines rows present."
},
{
"id": "QA-3",
"description": "AC3: Partially returned sale shows partial_refund payment line",
"result": "PASS",
"evidence": "ApplyPosReturnUseCase line 136: allFullyReturned ? 'refund' : 'partial_refund'. Reporting rows carry correct status."
},
{
"id": "QA-4",
"description": "AC4: Reporting summary totals match reporting_payment_lines sum",
"result": "PASS",
"evidence": "SALES_STATES excludes REFUNDED/PARTIALLY_REFUNDED; grossSalesCents from orders_items reflects returns. Test pos-returns.itest.ts uses DB queries to verify row counts."
},
{
"id": "QA-5",
"description": "AC5: verify.sh green, typecheck green, all tests pass",
"result": "PASS",
"evidence": "verify.sh exit 0, tsc --noEmit 0 errors, npm test 269 passed 96 skipped"
}
],
"reviewed_at": "2026-08-23T05:49:00Z"
}

View File

@@ -0,0 +1,45 @@
{
"agent": "reviewer",
"feature_id": "F-190",
"verdict": "APPROVED",
"summary": "dataAvailability flags paymentMethod and refunds corrected to 'available' in 3 sites. All tests updated and passing.",
"checks": [
{
"id": "RC-1",
"description": "A PENDING→COMPLETED transition emits reporting_payment_lines (F-188 ReceiveRestPaymentUseCase line 106-115)",
"result": "PASS",
"note": "Already implemented in F-188; reviewed at code level"
},
{
"id": "RC-2",
"description": "Returns emit reporting_payment_lines with status refund/partial_refund (F-189 ApplyPosReturnUseCase line 176-184)",
"result": "PASS",
"note": "Already implemented in F-189; reviewed at code level"
},
{
"id": "RC-3",
"description": "dataAvailability.paymentMethod changed from unavailable to available in summary/sales/products",
"result": "PASS",
"note": "Changed in 3 return sites; tests updated"
},
{
"id": "RC-4",
"description": "dataAvailability.refunds changed from unavailable to available in summary/sales/products",
"result": "PASS",
"note": "Changed in 3 return sites; tests updated"
},
{
"id": "RC-5",
"description": "Tests updated for new dataAvailability values",
"result": "PASS",
"note": "reporting-service.test.ts (2 assertions) + reporting.routes.test.ts (1 assertion)"
},
{
"id": "RC-6",
"description": "tsc --noEmit passes, npm test passes, verify.sh passes",
"result": "PASS",
"note": "269 passed, 0 failed, verify.sh green"
}
],
"reviewed_at": "2026-08-23T05:48:00Z"
}

View File

@@ -0,0 +1,38 @@
{
"agent": "security",
"feature_id": "F-190",
"verdict": "APPROVED",
"summary": "No security impact. Changes are purely cosmetic (string literals in dataAvailability enum) and test assertion updates. No new dependencies, no new endpoints, no user input processing, no secrets, no auth changes.",
"checks": [
{
"id": "SC-1",
"description": "No new dependencies introduced",
"result": "PASS",
"note": "No npm packages added"
},
{
"id": "SC-2",
"description": "No new API routes or auth changes",
"result": "PASS",
"note": "Only inline string literals changed in existing service"
},
{
"id": "SC-3",
"description": "No SQL or DB changes",
"result": "PASS",
"note": "No migration, no query changes"
},
{
"id": "SC-4",
"description": "No new secrets or env vars",
"result": "PASS",
"note": "No env changes"
},
{
"id": "SC-5",
"description": "tsc --noEmit passes (no type-safety regressions)",
"result": "PASS"
}
],
"reviewed_at": "2026-08-23T05:48:30Z"
}