/* Missing stock over time: across all stock counts in a period, how much left without a sale, which products go missing most (and how often), and each count with a link to its full breakdown. */ import { Link, router } from '@inertiajs/react'; import { ChevronRight, ClipboardCheck, PackageSearch, Printer } from 'lucide-react'; import ShopLayout from '../../layouts/ShopLayout'; import { Badge, Button, ButtonLink, Card, CardHeader, EmptyState, Field, Input, PageHeader } from '../../components/ui'; type Props = { filters: { from: string; to: string }; totals: { counts: number; missingValue: string; missingCost: string; extraValue: string; moneyGap: string }; products: { name: string; times: number; qty: string; value: string; cost: string }[]; counts: { id: number; when: string; by: string | null; items: number; missingItems: number; missingValue: string; gap: string | null }[]; dayTotal: boolean; }; export default function StockLoss({ filters, totals, products, counts, dayTotal }: Props) { const apply = (patch: Partial) => router.get(route('stock-count.report'), { ...filters, ...patch }, { preserveState: true, replace: true }); const outWord = dayTotal ? 'went out' : 'missing'; return ( Count stock } />
apply({ from: e.target.value })} /> apply({ to: e.target.value })} />

Stock {outWord}, at your prices

{totals.missingValue}

{totals.missingCost} at cost · {totals.counts} count{totals.counts === 1 ? '' : 's'}

{dayTotal ? (

Money not accounted for

{totals.moneyGap}

Stock that went out minus the money recorded (full counts only)

) : null}

More than expected

{totals.extraValue}

Usually stock added without recording it

{products.length ? (
{products.map((p) => ( ))}
ProductTimesQuantityValue
{p.name} {p.times > 1 ? {p.times}× : 1×} {p.qty} {p.value}{p.cost} at cost
) :
{totals.counts ? `Nothing ${outWord} in this period.` : 'No stock counts in this period.'}
}
{counts.length ? (
    {counts.map((c) => (
  • {c.when}

    {c.missingItems} of {c.items} {outWord}{c.by ? ` · ${c.by}` : ''}{c.gap ? ` · ${c.gap} unaccounted` : ''}

    {c.missingValue}
  • ))}
) : No counts yet.}
); }