updates on the calculation on the dropdown fix

This commit is contained in:
2026-06-08 19:31:57 +05:30
parent b477ad7023
commit 286f18abcc

View File

@@ -722,14 +722,22 @@ const Deliveries = () => {
// (`Dispatch.js:11981206`) — totals here should match the per-batch numbers // (`Dispatch.js:11981206`) — totals here should match the per-batch numbers
// visible on the dispatch page for the same date. // visible on the dispatch page for the same date.
const batchTotals = useMemo(() => { const batchTotals = useMemo(() => {
const totals = { all: countSourceRows.length }; // `all` is the SUM of the three batch buckets — not the raw row count.
// Rows that fall in a gap (89 AM, 12:304 PM, after 7 PM) or have no
// `assigntime` belong to no batch, so they're excluded here too. This keeps
// the "All Batches" badge equal to Morning + Afternoon + Evening
// (e.g. 36 + 89 + 53 = 178) instead of over-reporting the un-bucketed total.
const totals = { all: 0 };
BATCH_OPTIONS.forEach((b) => { BATCH_OPTIONS.forEach((b) => {
if (b.id === 'all') return; if (b.id === 'all') return;
totals[b.id] = 0; totals[b.id] = 0;
}); });
countSourceRows.forEach((r) => { countSourceRows.forEach((r) => {
const id = getRowBatchId(r); const id = getRowBatchId(r);
if (id) totals[id] = (totals[id] || 0) + 1; if (id) {
totals[id] = (totals[id] || 0) + 1;
totals.all += 1;
}
}); });
return totals; return totals;
}, [countSourceRows]); }, [countSourceRows]);