/** * Flattens a Codemax sync-invoice payload (FdtoCodemaxInvoice) into receipt * rows for the debug dialog: item lines with their modifier tree indented * beneath, then the money summary and payments. * * The payload is read back from ClickHouse's Nullable(JSON) column, which can * hand numbers back as strings — every amount is coerced, and the shape is * probed rather than zod-parsed so an old or partial payload still renders. */ export interface CodemaxReceiptLine { /** 0 = invoice item, 1 = tier-1 modifier, 2+ = nested modifier */ depth: number; code: string; name: string; quantity: number; /** Net amount (after discount) of this line alone — modifiers are priced separately */ amount: number; /** This line's OWN tax — the sum of its taxDetails[].taxAmount, not the subtree's */ tax: number; /** Tax-inclusive display total (amount + tax) — what the line itself shows beside * the info icon; the net/tax split lives only in the tooltip (see `lineBreakdown`). * Reconstructed from net + tax, so on a rounding-residual line it can be a cent off * the price actually charged by the POS — that cent lives in the invoice's * `roundingAdj` instead. Accepted by design. */ total: number; /** This line's own taxes, one entry per taxDetails row — for the per-line tooltip breakdown */ taxDetails: { label: string; amount: number; percentage: number; }[]; } export interface CodemaxReceiptTotal { label: string; amount: number; strong?: boolean; } export interface CodemaxReceiptTax { label: string; amount: number; } export interface CodemaxReceipt { lines: CodemaxReceiptLine[]; totals: CodemaxReceiptTotal[]; payments: { label: string; amount: number; }[]; /** Line-level taxes, summed per tax across the whole invoice */ taxes: CodemaxReceiptTax[]; } export interface CodemaxReceiptBreakdownRow { label: string; amount: string; } /** * Tax breakdown rows for a taxed line's tooltip (line.tax > 0 — the net was * extracted from a tax-inclusive paid price): a `Net` row, then one row per * tax. The payload carries no paid/divisor, and on a rounding-residual line * the real paid amount includes a cent that lives in the invoice's * `roundingAdj` — so a reconstructed "paid" total can be a cent off reality. * Rather than assert a total that might be wrong, this only lists the * components that are true on their own: net and each tax. * * Returns null for a tax-free line (no icon shown). */ export declare function lineBreakdown(line: CodemaxReceiptLine): CodemaxReceiptBreakdownRow[] | null; /** * Returns null when the value is not a Codemax invoice payload (skip rows, * run summaries). `billRounding` is the bill's own cash rounding: when it * differs from the payload's `roundingAdj`, the totals block splits rounding * into a `Rounding (bill)` row and a `Tax rounding` residual row; otherwise * (no `billRounding`, or nothing left over once split) it falls back to a * single `Rounding` row. */ export declare function buildCodemaxReceipt(payload: unknown, billRounding?: number): CodemaxReceipt | null;