← All tests

R4.3 — Per-product usage endpoint PROD

2026-04-29 on prod. Cpanel's TenantDetailView Subscriptions card now shows a live usage bar per (tenant, product). New backend endpoint GET /admin/tenants/:t/subscriptions/:productCode/usage branches on productCode: nix_cafe → COUNT cafe.orders WHERE state='paid' AND date_trunc('month', created_at) = current month; outdoor_sales → COUNT activities WHERE activity_type='visit' in current month; other products → 404 "no usage metric defined". Reads limit from subscriptions.limits_json (0/missing → null/∞). New UsageBar.vue in Cpanel auto-fetches on subscription expand and renders a green/amber/red progress bar (thresholds 70%/90%).

Surfaced during Gate 2 (fixed mid-run)

8/8 R4.3 prod checks passed.

All R4.3 prod checks (8)

107/107 total prod tests green — no regressions from this push.
test-r4-3-prod.mjs (NEW)8/8
test-r4-2-prod.mjs9/9
test-r4-1-prod.mjs9/9
test-phase1-prod.mjs11/11
test-receipt-preview-prod.mjs6/6
test-r2-followups3-prod.mjs7/7
test-r2-followups2-prod.mjs11/11
test-r2-followups-prod.mjs19/19
test-nix-os-r2-4b-prod.mjs12/12
test-nix-os-70-2-prod.mjs10/10
test-cafe-followups-prod.mjs5/5

What's new — code surface (2 repos)

nix-outdoor-sales-backend @ 09562a2:
  src/admin/subscription.service.ts                — getProductUsage(tenantId, productCode):
                                                      branches Cafe→cafe.orders, Outdoor→activities,
                                                      others→404 "not tracked". Reads limit from
                                                      subscriptions.limits_json; 0/missing → null.
  src/admin/subscription.router.ts                 — GET /:productCode/usage

nix-outdoor-sales-admin @ ca38c30 (Cpanel):
  src/components/UsageBar.vue                      — NEW. Live progress bar, auto-fetches on
                                                      mount, green/amber/red on threshold,
                                                      shows ∞ when limit is null.
  src/views/TenantDetailView.vue                   — UsageBar mounted above the Limits block
                                                      in each expanded subscription row.

D:/NIX Software/:
  test-r4-3-prod.mjs                               — NEW E2E (8 checks). Seeds 3 paid + 1
                                                      refunded order to verify the state filter.
                                                      Cleanup uses SELECT-into-UPDATE to avoid
                                                      JSON-literal-through-bash escape issues.

prod data fix (no commit, one-shot):
  subscriptions(tenant_id=get-coffee, product_code='nix_cafe', plan_code='cafe_pro')
  subscriptions(tenant_id=demo,       product_code='nix_cafe', plan_code='cafe_pro')
    — backfilled rows the Render→Supabase migration didn't carry.

R4 sub-phase status

R4.1 ─ Multi-shop activation E2E              ✓ shipped (2026-04-29)
R4.x ─ Carried-forward follow-ups bundle      ✓ shipped (2026-04-29)
R4.2 ─ Impersonation                           ✓ shipped (2026-04-29)
R4.3 ─ Per-product usage endpoint              ✓ shipped (2026-04-29)
R4.4 ─ Drop legacy tenant_limits/plan_code     pending (last)

Open follow-ups discovered by R4.3:
  - seed-supabase-getcoffee.ts should also insert a default subscription row
    (the Render→Supabase migration left tenants without subscriptions).
  - Pro Cafe usage shows 0 (Pro orders live in Odoo, not cafe.orders) —
    real fix needs a Pro mirror table; see project_pro_tier_odoo_latency.md.