lat and long
This commit is contained in:
@@ -64,6 +64,28 @@ export interface Board {
|
||||
* headline that cries wolf is the one thing this page cannot afford.
|
||||
*/
|
||||
strandedBills: number;
|
||||
/**
|
||||
* What every counter in scope rang in the selected period.
|
||||
*
|
||||
* From the sales split, not from the heartbeats: a till reports its own
|
||||
* running total, and two tills whose clocks disagree would otherwise be added
|
||||
* together into a figure the books never saw.
|
||||
*
|
||||
* There is deliberately NO "amount stuck" twin. The health record carries
|
||||
* `pending_bills` — a count — and no value, so the money sitting on an
|
||||
* unreachable till is a number this backend cannot tell us. The page says how
|
||||
* many sales are waiting and stops there rather than estimating.
|
||||
*/
|
||||
takenAmount: number;
|
||||
takenBills: number;
|
||||
/**
|
||||
* How many COUNTERS need attention — not how many cards are on screen.
|
||||
*
|
||||
* A counter with a problem in both buckets produces two cards, so counting
|
||||
* cards against `total` reads "5 of 4 counters". Distinct terminals is the
|
||||
* only version of this number that can be shown beside a total.
|
||||
*/
|
||||
needCounters: number;
|
||||
isLoading: boolean;
|
||||
/** Branches whose health read FAILED — not branches with no counters. */
|
||||
failed: string[];
|
||||
@@ -243,12 +265,42 @@ export function useTerminalBoard({ branches, range, isHidden }: BoardOptions): B
|
||||
|
||||
const inBucket = (bucket: Bucket) => cards.filter((card) => card.problem.bucket === bucket);
|
||||
|
||||
// Summed per COUNTER, not per card. A counter with a problem in both
|
||||
// buckets produces two cards carrying the same period figures, so adding
|
||||
// the cards up would bill it twice — and it would be the counters in the
|
||||
// worst shape that got double-counted, which is the wrong direction for a
|
||||
// number the page leads with.
|
||||
const takings = new Map<string, { bills: number; amount: number }>();
|
||||
for (const card of cards) {
|
||||
takings.set(`${card.branchId}:${card.terminalId}`, {
|
||||
bills: card.periodBills,
|
||||
amount: card.periodAmount,
|
||||
});
|
||||
}
|
||||
for (const counter of fine) {
|
||||
takings.set(`${counter.branchId}:${counter.terminalId}`, {
|
||||
bills: counter.periodBills,
|
||||
amount: counter.periodAmount,
|
||||
});
|
||||
}
|
||||
const needing = new Set(cards.map((card) => `${card.branchId}:${card.terminalId}`));
|
||||
|
||||
let takenBills = 0;
|
||||
let takenAmount = 0;
|
||||
for (const entry of takings.values()) {
|
||||
takenBills += entry.bills;
|
||||
takenAmount += entry.amount;
|
||||
}
|
||||
|
||||
return {
|
||||
now: inBucket('now'),
|
||||
look: inBucket('look'),
|
||||
fine,
|
||||
total,
|
||||
strandedBills,
|
||||
takenAmount,
|
||||
takenBills,
|
||||
needCounters: needing.size,
|
||||
isLoading: health.some((query) => query.isLoading),
|
||||
failed,
|
||||
checked: branches.map((branch) => branch.locationname),
|
||||
|
||||
Reference in New Issue
Block a user