B2B Second Inventory Reports Feature
What the bb phase 6 reports show, who may open them, the surfaces in Admin
B2B Second Inventory (bb) — Reports Feature
Reports give bb staff read-only totals and tables over orders, refunds, returns, stock and customers, plus CSV or XLSX files of any table. Admin #2 shows them.
Surface matrix
| Surface | Route | Auth |
|---|---|---|
| Overview | /dashboard/reports | BB_Reports_READ |
| Report list | /dashboard/reports/tables | BB_Reports_READ |
| One report | /dashboard/reports/tables/[reportId] | BB_Reports_READ |
| Export list and queue form | /dashboard/reports/exports | BB_Reports_READ |
| One export | /dashboard/reports/exports/[exportId] | BB_Reports_READ |
| Export download | /dashboard/reports/exports/[exportId]/download (a route handler) | BB_Reports_READ |
| Dashboard home tiles | /dashboard | BB_Reports_READ |
| Backend | /api/admin/bb/reports | BB_Reports_READ |
BB_Reports_READ is the only report code any route checks. The sidebar has one Reports row and the sub-routes inherit its code. Source: lib/Data/SidebarNav.ts in Admin #2.
Holding BB_Reports_READ shows buyer names and what each buyer spent, even without BB_Customers_READ. Phone, email and address are not part of any report. The Roles screen prints this as a note under the Reports heading.
What the figures mean
- Gross is the total of
paidorders only. - Net is gross minus refunds that have settled. Approved refunds that are not yet settled appear beside net and are never subtracted.
- A cancelled order is not in gross. Its value and its settled refunds are shown separately and never change net.
- Orders counts every order placed, cancelled ones included.
- Units sold counts
paidorders only. Units returned counts accepted units of completed returns. - Average order value is empty when the window has no paid order.
- Cash paid out counts settled refunds by the day they settled, on any order. It can differ from "settled refunded" on purpose.
- Days are Kathmandu days.
- Soft-deleted customers, products and variants stay in historical sums. Live stock reports leave them out.
The full rules are in Reports backend.
Periods
The default window is the last 30 days. The preset list is the backend's ANALYTICS_PERIOD_PRESETS; last_7_days is labelled "Last 7 days" in Admin #2. A custom range may be at most 366 * 3 days, and to may not be later than today.
Exports
- CSV or XLSX, of one report and one window. XLSX stops at 10,000 rows and any export at 50,000.
- Each admin may have 2 export or import jobs queued or running at once, and may queue 5 report exports an hour.
- Files last 48 hours after they finish. The export row stays.
- An export belongs to the admin who queued it. Nobody else can see, cancel or download it.
- A CSV cell that starts with a minus sign is written with a leading quote, so a negative money value opens as text in a spreadsheet.
Error UX
Admin #2 prints one of a closed set of four sentences for a failed export, and the backend sends the same four. Anything outside the set prints as "This export failed. Queue it again." A rate limit on cancel has its own sentence, because the hourly cap applies to queuing. Source: exports/_components/export-copy.ts.
| Code | Where it shows |
|---|---|
BB_JOB_TOO_MANY_ACTIVE | "You already have two active jobs. Cancel one or wait for it to finish, then queue this again." |
BB_JOB_NOT_CANCELLABLE | "This export has already finished." |
BB_JOB_NOT_FOUND | "This export no longer exists." |
BB_REPORT_PERIOD_INVALID, BB_REPORT_PERIOD_TOO_LONG | The period copy in report-failure-copy.ts |
| 429 on queue | "You can queue 5 exports an hour. Wait a while and try again." |
| 429 on cancel | "Too many requests. Wait a moment and try cancelling again." |
See Also
B2B Second Inventory Returns and Refunds Deploy Notes
Deploy order, migrations 0067 and 0068, the locks they take, the required permissions:sync, the manual grant step and rollback limits for bb phase 5. Phase 5 ships together with phase 4.
B2B Second Inventory Reports Backend
Module layout, the money rules every report figure follows, the read snapshot and its budget, and the export worker and file lifecycle for bb phase 6.