← All tests

Branch Performance ranking STAGING

Narong Next-Phase — the "Ranking of POS" bug. nix-cafe staging 3f94812no migration, no backend. Verified locally on lumiere 4/4 + on get-coffee.staging + staging smoke 5/5.

What Narong asked. "we do list by registers but we want to sum all registers in a branch and show just 1 for the ranking, as it is aimed to provide the overall sales performance of the branch." So the Reports "Ranking of POS" card — which ranked each register as its own row — becomes Branch Performance: one row per branch, summing every register's sales.

The change

New DAO aggregateRevenueByBranch sums every paid order per shop (GROUP BY shop_id) → one row per branch. The old aggregateRevenueByPosConfig is kept (a regression probe hits it) but the card no longer uses it. Crucially the old per-register DAO INNER JOINed pos_configs and filtered pos_config_id IS NOT NULL — so orders not tied to a register were silently dropped. On lumiere, 3 of 4 branches have such orders, so the old card showed almost nothing; the new branch DAO counts them all. Card title → "Branch Performance", rows labeled by branch name. One DAO added; no schema change.

1 · Branch Performance card (lumiere — 4 branches)

branch performance card
4 branches ranked by revenue, each summing its registers: BKK1 $56.9k > Toul Kork $39.7k > Riverside $33.5k > BKK3 $22.9k.
reports page full
The card in context on the Reports page (period Jan–Jun 2026 to cover the seeded orders).

2 · On staging (get-coffee.staging — real data)

Verified on the deployed staging Worker via a real SSO login. get-coffee is single-branch, so the card shows one branch row — proving it renders branch-level on the live deploy.

staging branch card
Branch Performance on get-coffee.staging — one branch, its registers summed.

Checks

Card titled "Branch Performance" (was "Ranking of POS")pass
One row per branch, registers summed (4 branch rows on lumiere)pass
Rows labeled by branch name (not "Register —")pass
Register-less orders now counted (old card dropped 3/4 branches)pass
Per-register DAO + ranking-of-pos testid kept → r7 / r-followups greenpass
tsc --noEmitclean
Staging smoke5/5

No schema change. Parked on staging for the scheduled prod promote.