// VMAX Store Manager — Reports: sales & operations read derived from the day's records. (function () { const DS = window.VMAX365DesignSystem_0f78b2; const { StatTile, Badge, SegmentedControl } = DS; const { Icon, Overline } = window.VMAXUI; const { Avatar } = window.VMAXW; const { K, dashboard } = window.VMAXP; const { useVMAX } = window.VMAXStore; const { Panel } = window.VMAXMGRUI; function ReportsPage({ mobile }) { const [s] = useVMAX(); const [range, setRange] = React.useState('today'); const t = s.tally; const mobileTotal = Object.values(t.mobile).reduce((a, b) => a + b, 0); const turnover = t.cash + mobileTotal; const cashPct = turnover ? Math.round((t.cash / turnover) * 100) : 0; const mobPct = turnover ? Math.round((mobileTotal / turnover) * 100) : 0; const cups = t.coldCups + t.hotCups; const coldPct = cups ? Math.round((t.coldCups / cups) * 100) : 0; const members = new Set(s.sales.filter((x) => x.member).map((x) => x.member)).size; const refunds = s.ledger.filter((e) => e.type === 'refund' && !e.reverted).length; const remakes = s.ledger.filter((e) => e.type === 'remake' && !e.reverted).length; const byCashier = {}; s.sales.forEach((o) => { byCashier[o.by] = byCashier[o.by] || { name: o.by, count: 0, value: 0 }; byCashier[o.by].count += 1; byCashier[o.by].value += o.amount; }); const cashiers = Object.values(byCashier).sort((a, b) => b.value - a.value); const maxVal = Math.max(1, ...cashiers.map((c) => c.value)); return (