ui/ux improvement

This commit is contained in:
2026-09-18 16:57:24 +05:30
parent 115a06a02c
commit 041dc37861
43 changed files with 1697 additions and 746 deletions

View File

@@ -436,6 +436,34 @@ export function useStockStatement(
});
}
/**
* The stock statement for EVERY branch in scope, one request each.
*
* `getstockstatement` takes a single `locationid` and there is no tenant-wide
* stock read, so a multi-branch view fans out — the same constraint, and the same
* shape of answer, as `usePosSalesByBranch`.
*
* The Reports inventory tab read `scoped[0]` before this: whatever branch
* happened to sort first stood in for the whole tenant, on a page where every
* other figure covers all of them. A reader comparing inventory value against
* this period's revenue was comparing one shop against the chain.
*/
export function useStockStatementByBranch(
tenantid: number | undefined,
locationIds: readonly number[],
params: { keyword?: string; pagesize?: number } = {},
) {
return useQueries({
queries: locationIds.map((locationid) => ({
queryKey: queryKeys.stock.statement(tenantid ?? 0, locationid, params),
queryFn: () =>
stockApi.statement({ tenantid: tenantid as number, locationid, ...params }),
enabled: Boolean(tenantid),
...live,
})),
});
}
/* ── Store Admin: order and bill rows ────────────────────────────────────── */
/**
@@ -457,6 +485,30 @@ export function useOrders(query: OrderQuery | undefined) {
});
}
/**
* Every order in the window, paged until the rows run out.
*
* For the screens that TOTAL orders rather than list them. `useOrders` returns
* one page and is right for a table with a pager under it; a sum built from one
* page is simply wrong past that page, and wrong without saying so.
*
* Returns the flag as well as the rows: at the page bound the figures ARE partial
* and the screen has to say so. A caller that ignores `truncated` has recreated
* the bug this exists to fix.
*/
export function useAllOrders(query: OrderQuery | undefined, pagesize = 500) {
return useQuery({
queryKey: queryKeys.insights.orderList({
...((query ?? {}) as unknown as Record<string, unknown>),
all: true,
pagesize,
}),
queryFn: () => insightsApi.ordersAll(query as OrderQuery, { pagesize }),
enabled: Boolean(query?.tenantid || query?.partnerid),
...live,
});
}
/**
* Counter bills, per branch.
*