// FRAZIER Finance OS — Vendor Invoices (master sheet, 8 Oct 2026). // READ-ONLY view of the "Vendor Invoice Recap " tab of the finance // sheet, the bills dated in the selected calendar month (payload: // period.vendor, CONTRACT §2.2). Nothing is entered here: every bill is // edited in the sheet ("Edit in Google Sheets" opens the tab, or the exact // row from the detail). Live updates keep the filters and an open detail // (it follows its bill by invoice number if its row moved). // // Sibling of fin-invoices.jsx: the same anatomy (toolbar, status summary // whose chips filter the table, three metrics, table, read-only detail). // // Numbers are the sheet's own: DPP (H), PPN (I, blank = 0), PPh type (J, // trimmed) and amount (K), rate = K ÷ H, TOTAL PAYMENT (L). Status: "PAID" // in M means paid, anything else (blank too) unpaid, aged from the invoice // date (the sheet has no paid or due date). // // Every top-level name starts with finVinv / FinVinv / FIN_VINV: all .jsx // files share one global scope. const FIN_VINV_STATUS = { unpaid: { label: 'Unpaid', tone: 'warn' }, paid: { label: 'Paid', tone: 'ok' }, }; const FIN_VINV_ORDER = ['unpaid', 'paid']; function finVinvPlural(n, one, many) { return n + ' ' + (n === 1 ? one : (many || one + 's')); } // 0.005 → "0,5%", 0.1 → "10%" (decimal comma, like the money figures). function finVinvRate(r) { if (r === null || r === undefined || !isFinite(Number(r))) return null; return String(Math.round(Number(r) * 10000) / 100).replace('.', ',') + '%'; } // "28 Jan"; with the year when it differs from the period's year. function finVinvDay(iso, year) { if (!iso) return '—'; return finDate(iso, String(iso).slice(0, 4) === String(year || '') ? { year: false } : undefined); } // PPh label: "PPh 4(2) · 10%", or the rate alone when the type is blank. function finVinvPphLabel(row) { const type = String(row.pphType || '').trim(); const rate = Number(row.pph) > 0 ? finVinvRate(row.pphRate) : null; return [type || (Number(row.pph) > 0 ? 'PPh' : ''), rate].filter(Boolean).join(' · '); } // The secondary status line: how long an unpaid bill has been open. function finVinvAgeNote(row, overdueDays) { if (row.status === 'paid') return { text: 'Paid', tone: 'ok' }; const age = Number(row.ageDays); if (row.ageDays === null || row.ageDays === undefined || !isFinite(age)) return { text: 'Not paid' }; if (age <= 0) return { text: 'Dated today' }; return { text: finVinvPlural(age, 'day') + ' open', tone: age > overdueDays ? 'crit' : null }; } // Search over everything a row shows. function finVinvMatches(row, q) { if (!q) return true; const hay = [row.vendor, row.invoiceNo, row.description, row.npwp, row.account, row.pphType, row.statusRaw] .filter(Boolean).join(' ').toLowerCase(); return hay.indexOf(q) !== -1; } function FinVinvPill({ status, size }) { const meta = FIN_VINV_STATUS[status] || FIN_VINV_STATUS.unpaid; return {meta.label}; } // ── Table row ─────────────────────────────────────────────────────────── function FinVinvRow({ row, year, overdueDays, onOpen }) { const note = finVinvAgeNote(row, overdueDays); const open = () => onOpen(row); const pphLabel = finVinvPphLabel(row); const vendorTitle = [row.vendor, row.invoiceNo ? 'Invoice ' + row.invoiceNo : 'No invoice number', row.npwp ? 'NPWP ' + row.npwp : null, row.account ? 'Bank ' + row.account : null] .filter(Boolean).join(' · '); return ( { if (e.target === e.currentTarget && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); open(); } }}> {finVinvDay(row.date, year)} {row.invoiceNo ? {row.invoiceNo} : —} {row.npwp ? · NPWP {row.npwp} : null} {row.hiddenInSheet ? · hidden in sheet : null} · {row.description || 'No description'} } /> 0 ? 'PPN +' + finIDR(row.ppn) : 'No PPN'} /> 0 ? FIN_MINUS + finIDR(row.pph) : '—'} sub={pphLabel || 'No PPh'} /> {Number(row.pph) > 0 ? 'PPh ' + FIN_MINUS + finIDR(row.pph) : 'No PPh'}} /> {'Dated ' + finVinvDay(row.date, year) + (row.status === 'paid' ? '' : ' · ' + note.text)}
{row.status === 'paid' ? null : {note.text}}
); } // ── Read-only detail ──────────────────────────────────────────────────── function FinVinvDetail({ row, period, overdueDays, onClose }) { const paid = row.status === 'paid'; const note = finVinvAgeNote(row, overdueDays); const ppnOn = Number(row.ppn) > 0; const pphOn = Number(row.pph) > 0; // The bill's own tab (a 2025 bill can sit in the 2026 tab). const tabName = finRecTabName(row, 'vendor', period) || 'Vendor Invoice Recap'; const computed = Number(row.totalComputed); const diff = isFinite(computed) ? Math.round((Number(row.totalPayment) || 0) - computed) : 0; const notes = []; if (row.totalComputedUsed) notes.push('TOTAL PAYMENT is empty in the sheet, so it is computed here as DPP + PPN − PPh.'); else if (diff !== 0) notes.push('The sheet’s TOTAL PAYMENT differs from DPP + PPN − PPh (' + finIDR(computed) + ') by ' + finIDR(diff) + '. The sheet’s value is shown.'); if (row.ppnBlank) notes.push('PPN is blank in the sheet and counts as 0.'); if (row.hiddenInSheet) notes.push('This row is hidden by a filter in the sheet. It is still counted.'); if (!row.invoiceNo) notes.push('No invoice number in the sheet; shown as “—”.'); return ( {row.invoiceNo ? {row.invoiceNo} : 'No invoice number'} · Dated {finDate(row.date)}} footerLeft={} footerRight={}>
{paid ? 'The sheet has no paid date' : note.text + ' since the invoice date'}
{notes.length ? ( {notes.length === 1 ? notes[0] :
    {notes.map((n) =>
  • {n}
  • )}
}
) : null}
); } // ── Sheet notes for this tab (data checks) ────────────────────────────── function FinVinvChecks({ checks }) { const [open, setOpen] = React.useState(false); if (!checks.length) return null; const warn = checks.filter((c) => c.level === 'warn').length; const shown = open ? checks : checks.slice(0, 3); const manyTabs = finTypeHasTabs('vendor'); return ( <>
    {shown.map((c) => { // A bill in two year tabs, or one number used by two vendors: // a headline and a link to each row. const multi = finCheckHasLocs(c); const head = finCheckTitle(c); return (