// FRAZIER Finance OS — Payroll (master sheet, 8 Oct 2026). READ-ONLY. // The selected month's block of the Salary tab of the finance sheet (one // sheet covers every month): the rows between two // "TOTAL " rows (the backend finds the block by its TOTAL row // and sends it as period.payroll, CONTRACT §2.3). Nothing is typed here: // every change is made in Google Sheets ("Edit in Google Sheets" links to // the block and to each row). // - roster: no., name, type (column N, blank → "—"), bank + masked account // - amounts (H–L, M): shown only when the sheet has them; while they are // empty the page says "Amounts not filled in the sheet", never Rp 0 // - take-home: the sheet's own M AND H + I + J + K − L, rows that differ flagged // - 15 Oct 2026: the owner added a THR (holiday bonus) column at J in the // live sheet, shifting pph21Allowance/pph21/takeHome/type one letter // right — re-aligned here and in fin-sheet-model.php/fin-sheet-derive.php // - headcount by type, joiners / leavers against the previous month, // repeated names counted as "2 payments" (never merged) // - payroll cost booked in the JV tab (620100 + 501000) as a cross-check // Live updates keep the search, the type filter and an open person (found // again by name when a row inserted above moved them). const FIN_PAY_TYPE_TONE = { Fulltime: 'info', Remote: 'violet' }; function finPayTypeTone(t) { return FIN_PAY_TYPE_TONE[t] || 'neutral'; } function finPayPlural(n, one, many) { return n + ' ' + (n === 1 ? one : (many || one + 's')); } function finPayNameKey(s) { return String(s || '').trim().replace(/\s+/g, ' ').toLowerCase(); } function finPayHas(v) { return v !== null && v !== undefined && v !== '' && isFinite(Number(v)); } // An amount cell: the value when the row has amounts, else a quiet dash. function finPayAmt(row, k) { return row.amountsFilled && finPayHas(row[k]) ? finIDR(row[k]) : null; } function finPayMatches(r, q) { if (!q) return true; return [r.name, r.type, r.bank, r.no, r.row].some((v) => v !== null && v !== undefined && String(v).toLowerCase().indexOf(q) !== -1); } // ── One roster row, read-only detail ─────────────────────────────────── function FinPayRowModal({ row, rows, payroll, period, onClose, onMove }) { const idx = rows.findIndex((r) => r.key === row.key); const prev = idx > 0 ? rows[idx - 1] : null; const next = idx >= 0 && idx < rows.length - 1 ? rows[idx + 1] : null; const same = (payroll.rows || []).filter((r) => finPayNameKey(r.name) === finPayNameKey(row.name)); const filled = !!row.amountsFilled; const money = (k) => (finPayHas(row[k]) ? finIDR(row[k]) : 'Empty'); return ( } footerRight={}> 1 ? 'rows ' + same.map((r) => r.row).join(', ') : null, value: finPayPlural(row.payments || same.length || 1, 'payment') }, row.hiddenInSheet ? { id: 'hid', label: 'In the sheet', value: 'Hidden by a filter', tone: 'warn' } : null, ]} /> {filled ? ( ) : ( Amounts not filled in the sheet: salary, commission, THR, PPh 21 allowance and PPh 21 (columns H–L) are empty on this row. )} {row.takeHomeDiffers ? ( The sheet’s take-home (M) differs from H + I + J + K − L. The sheet’s formula adds H + I only; check which one is right. ) : null}

{payroll.privacy || 'NIK, NPWP and full account numbers are never sent to the browser.'}

); } // ── Joiners / leavers against the previous period ─────────────────────── function FinPayChanges({ payroll, prevLabel }) { const j = payroll.joiners; const l = payroll.leavers; if (j === null || j === undefined || l === null || l === undefined) { return ( ); } const group = (title, list, tone) => (
{title}{list.length}
{list.length ? (
    {list.map((n, i) =>
  • {n}
  • )}
) :

Nobody

}
); return ( {group('Joined', j, 'in')} {group('Left', l, 'out')} ); } // ── Amounts: sheet totals, or the honest "not filled" + JV cost ───────── function FinPayAmounts({ payroll, period }) { const t = payroll.totals || {}; const cost = payroll.costFromJournal || null; const jvOk = !!(period.journal && period.journal.available !== false); const costRows = cost ? [ { id: 's', label: 'Salaries', note: '620100', value: jvOk ? (cost.salaries620100 ? finIDR(cost.salaries620100) : 'Nothing booked') : 'JV not readable', tone: jvOk && cost.salaries620100 ? undefined : 'muted' }, { id: 'f', label: 'Fees', note: '501000', value: jvOk ? (cost.fees501000 ? finIDR(cost.fees501000) : 'Nothing booked') : 'JV not readable', tone: jvOk && cost.fees501000 ? undefined : 'muted' }, jvOk && cost.total ? { id: 't', label: 'Payroll cost in the JV', value: finIDR(cost.total), total: true } : null, ] : []; return ( }> {payroll.amountsFilled ? ( <> {payroll.takeHomeDiffRows ? ( {finPayPlural(payroll.takeHomeDiffRows, 'row')} {payroll.takeHomeDiffRows === 1 ? 'has' : 'have'} a take-home in the sheet that differs from H + I + J + K − L (the sheet’s formula adds H + I only). ) : null} {payroll.sheetTotalRangeOk === false ? ( The sheet’s “{payroll.sheetLabel}” row adds up the wrong rows. The totals above add every row of the month. ) : null} ) : (
{payroll.amountsNote || 'Amounts not filled in the sheet'}

Salary, commission, THR, PPh 21 allowance and PPh 21 (columns H–L) are empty in rows {payroll.firstRow}–{payroll.lastRow}, so no pay is totalled here.

)} {costRows.length ? (

Booked in the JV tab cross-check, {period.label || finMonthLabel(period.key)}

) : null}
); } // ── Month index (front page, 22 Oct 2026) ─────────────────────────────── // Owner: "make the front page payroll every info each month input on // gsheet, then when clicked the detail of month clicked." Every month // that has a "TOTAL " block, most recent first; tap one for // the full roster (FinPayMonthDetail, the page this whole file used to // be). Independent of the global month pill on purpose, the same way the // per-row "Edit in Google Sheets" links already are — Payroll is read as // a history to browse, not a single selected month like Home/Cash flow. function FinPayMonthRow({ p, onOpen }) { const pr = p.payroll; const label = p.label || finMonthLabel(p.key); const hc = pr.headcount || {}; const filled = pr.amountsFilled; return ( onOpen(p.key)} onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); onOpen(p.key); } }}> {finPayPlural(hc.people || 0, 'person', 'people')} {pr.joiners ? pr.joiners.length : '—'} {pr.leavers ? pr.leavers.length : '—'} {filled ? finIDR(pr.totals.takeHomeComputed) : Not filled} ); } function FinPayMonthIndex({ periods, onOpen }) { const blocks = (periods || []).filter((p) => p.payroll && p.payroll.available).slice().reverse(); const current = (periods || []).find((p) => p.isCurrent); const currentHasData = !!(current && current.payroll && current.payroll.available); return ( <> {current && !currentHasData ? ( {current.label || finMonthLabel(current.key)} has no salary block yet in the sheet. ) : null} {blocks.length ? ( {blocks.map((p) => )}
Month People Joined Left Take-home Open
) : ( " block in the Salary tab.'} /> )}
); } // ── One month's full roster (the page before 22 Oct 2026) ────────────── function FinPayMonthDetail({ period, periods, args, onBack }) { const { data } = useFinSheet(); const [query, setQuery] = React.useState(''); const [type, setType] = React.useState(null); const [openKey, setOpenKey] = React.useState(null); // Jump to… a name (args.q). React.useEffect(() => { if (args && args.q) { setQuery(String(args.q)); setType(null); } }, [args && args.nonce]); // eslint-disable-line const periodName = period.label || finMonthLabel(period.key); const pr = period.payroll; const ok = !!(pr && pr.available && Array.isArray(pr.rows)); const rows = ok ? pr.rows : []; const idx = (periods || []).findIndex((p) => p.key === period.key); const prevPeriod = idx > 0 ? periods[idx - 1] : null; const prevLabel = prevPeriod ? (prevPeriod.label || finMonthLabel(prevPeriod.key)) : null; // The block's own tab (several years: "Salary 2025", "Salary 2026"). const tabName = (ok && pr.tabName) || (period.tabs && period.tabs.salary && period.tabs.salary.name) || 'Salary'; const tabLeftOut = !ok && finTabsLeftOut(data, 'salary').some((x) => x.name === tabName); // Another month: its types and rows differ. const first = React.useRef(true); React.useEffect(() => { if (first.current) { first.current = false; return; } setType(null); setOpenKey(null); }, [period.key]); const q = query.trim().toLowerCase(); const visible = rows.filter((r) => (!type || (r.type || '—') === type) && finPayMatches(r, q)); const anyBank = rows.some((r) => r.bank || r.accountMasked); const anyAmounts = rows.some((r) => r.amountsFilled); const repeated = Array.from(new Set(rows.filter((r) => (r.payments || 1) > 1).map((r) => finPayNameKey(r.name)))).length; const byType = ok && pr.headcount && pr.headcount.byType ? pr.headcount.byType : {}; const typeList = Object.keys(byType).sort((a, b) => (byType[b] - byType[a]) || (a === '—' ? 1 : b === '—' ? -1 : a.localeCompare(b))); // The open person, kept across live updates (same name and No. when a // row inserted above moved them to another sheet row). const open = useFinRowKeeper(openKey, setOpenKey, (k) => rows.find((r) => r.key === k), rows, (a, b) => finPayNameKey(b.name) === finPayNameKey(a.name) && String(b.no === null || b.no === undefined ? '' : b.no) === String(a.no === null || a.no === undefined ? '' : a.no)); const back = ( ); const head = ( Salary roster for {periodName}. The “{tabName}” tab is left out, see below. : <>Salary roster for {periodName}, read from the “{tabName}” tab{ok ? <> ({pr.sheetLabel}, rows {pr.firstRow}–{pr.lastRow}) : null}.} actions={} /> ); const staleAlert = <>; // The sheet changed under us (a live update) and this month no longer // has a block: say so, show the JV cost, offer the way back. if (!ok) { const cost = pr && pr.costFromJournal; const jvOk = !!(period.journal && period.journal.available !== false); const noRows = period.hasData === false; return (
{head} {staleAlert}
} /> {cost && jvOk && cost.total ? (

Booked in the JV tab payroll cost, {periodName}

) : null} ); } const hc = pr.headcount || { rows: rows.length, people: rows.length }; const thFilled = pr.amountsFilled; const segments = typeList.map((t) => ({ tone: finPayTypeTone(t), n: byType[t], label: t === '—' ? 'No type' : t })); const legend = typeList.map((t) => ({ id: t, label: t === '—' ? 'No type' : t, n: byType[t], tone: finPayTypeTone(t), on: type === t, title: (t === '—' ? 'Column N is empty' : t) + ': ' + finPayPlural(byType[t], 'person', 'people') + '. Show only these rows.', onClick: () => setType((cur) => (cur === t ? null : t)), })); const facts = [ { id: 'j', label: 'Joined', value: pr.joiners ? String(pr.joiners.length) : '—', title: pr.joiners ? 'New since ' + prevLabel : 'No previous month to compare with' }, { id: 'l', label: 'Left', value: pr.leavers ? String(pr.leavers.length) : '—', title: pr.leavers ? 'Not on the roster since ' + prevLabel : 'No previous month to compare with' }, { id: 't', label: 'Take-home', value: thFilled ? finIDRCompact(pr.totals.takeHomeComputed) : 'Not filled', title: thFilled ? finIDR(pr.totals.takeHomeComputed) + ' (H + I + J + K − L)' : 'Amounts not filled in the sheet' }, ]; const metaBits = []; if (type) metaBits.push(type === '—' ? 'No type' : type); if (q) metaBits.push('"' + query.trim() + '"'); metaBits.push('Sheet order'); const hidden = []; if (!anyBank) hidden.push('bank details'); if (!anyAmounts) hidden.push('amounts'); return (
{head} {staleAlert} {hc.people}{hc.people === 1 ? 'person' : 'people'}} hint={finPayPlural(hc.rows, 'row') + ' in ' + pr.sheetLabel + (repeated ? ' · ' + finPayPlural(repeated, 'person', 'people') + ' paid more than once' : '')} caption="By type (column N) · tap to filter the roster" segments={segments} barLabel={typeList.map((t) => (t === '—' ? 'No type' : t) + ' ' + byType[t]).join(', ')} legend={legend} facts={facts} className="fin-pay-sum" />
} /> {hidden.length ? (

Not filled in the sheet this month, so not shown: {hidden.join(' and ')}.

) : null} {visible.length ? ( {anyBank ? : null} {anyAmounts ? : null} {anyAmounts ? : null} {anyAmounts ? : null} {anyAmounts ? : null} {anyAmounts ? : null} {anyAmounts ? : null} {visible.map((r) => { const sub = []; if ((r.payments || 1) > 1) sub.push(finPayPlural(r.payments, 'payment')); if (r.hiddenInSheet) sub.push('hidden in the sheet'); return ( setOpenKey(r.key)} onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); setOpenKey(r.key); } }}> {anyBank ? ( ) : null} {anyAmounts ? : null} {anyAmounts ? : null} {anyAmounts ? : null} {anyAmounts ? : null} {anyAmounts ? : null} {anyAmounts ? ( ) : null} ); })} {anyAmounts && !type && !q ? ( ) : null}
No. Name TypeBankSalaryCommissionTHRPPh 21 allow.PPh 21Take-homeSheet row
{r.no !== null && r.no !== undefined && r.no !== '' ? r.no : '—'} {sub.length || anyBank ? ( {sub.length ? 1 ? 'fin-pay-twice' : ''}>{sub.join(' · ')} : null} {anyBank ? {sub.length ? ' · ' : ''}{r.bank || 'No bank'}{r.accountMasked ? ' ' + r.accountMasked : ''} : null} } /> ) : {r.name}} {r.type || 'No type'}Not filled} sub={r.accountMasked} />{finPayAmt(r, 'salary') || —}{finPayAmt(r, 'commission') || —}{finPayAmt(r, 'thr') || —}{finPayAmt(r, 'pph21Allowance') || —}{r.amountsFilled && finPayHas(r.pph21) ? finIDR(-Number(r.pph21)) : —} {r.amountsFilled ? ( r.takeHomeDiffers ? : {finIDR(r.takeHomeComputed)} ) : Not filled} e.stopPropagation()}>
Total · {finPayPlural(hc.rows, 'row')} {anyBank ? : null} {finIDR(pr.totals.salary)} {finIDR(pr.totals.commission)} {finIDR(pr.totals.thr)} {finIDR(pr.totals.pph21Allowance)} {finIDR(-Number(pr.totals.pph21 || 0))} {finIDR(pr.totals.takeHomeComputed)}
) : ( { setQuery(''); setType(null); }}>Clear filters} /> )}
{open ? ( r.key === open.key) ? visible : rows} payroll={pr} period={period} onClose={() => setOpenKey(null)} onMove={setOpenKey} /> ) : null}
); } // ── Page ──────────────────────────────────────────────────────────────── function FinPayroll({ args }) { const { data } = useFinSheet(); const { period, periods } = useFinPeriod(); const [openMonthKey, setOpenMonthKey] = React.useState(null); // Jump to… a name: open straight into the right month's detail instead // of the index, same as this page always did before the index existed. // Prefers the globally selected (real current) month when it has a // block; otherwise the latest month that does, same "never silently // mislabel" spirit as the old per-page fallback this replaced. React.useEffect(() => { if (!(args && args.q)) return; const hasBlock = (p) => !!(p && p.payroll && p.payroll.available); const target = hasBlock(period) ? period : (periods || []).filter((p) => (!period || p.key < period.key) && hasBlock(p)).slice(-1)[0] || (periods || []).filter(hasBlock).slice(-1)[0] || null; if (target) setOpenMonthKey(target.key); }, [args && args.nonce]); // eslint-disable-line if (openMonthKey) { const vp = (periods || []).find((p) => p.key === openMonthKey); if (vp) return setOpenMonthKey(null)} />; // The month disappeared from a live update: fall through to the index. } const head = ( : null} /> ); return (
{head} {data ? : null}
); } Object.assign(window, { FinPayroll });