Run the ledger's cumulative across the whole selection

It started at the baseline, so it accumulated only the part that can still
move and stopped short of the number on the screen. Now it accumulates in
display order from the top -- billed, then booked, then the baseline, then
each adjustment -- and closes on Selected total.

Adjustable keeps its own figure but no running cell: it is a subtotal of the
walk, not a point on the line, and printing the running there would put two
different totals side by side in one row.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Paul Trowbridge 2026-09-18 12:59:45 -04:00
parent 62c815da63
commit 344168abdd

View File

@ -490,13 +490,19 @@ function ScaleLedger({ currentTotals, scaleInputs, setScaleInputs, scalePlug, se
// Value only: a cumulative price is meaningless -- prices do not add -- and a
// second running column for units doubles the width to say something the
// value column already implies.
// Accumulates in display order across everything: the immovable segments
// first, then the walk. So it reads as the whole number being built up --
// billed, then booked, then the baseline, then each adjustment -- and closes
// on Selected total rather than on Adjustable, which is only the part of it
// that can still move.
const runningByKey = (() => {
const out = new Map()
let acc = 0
for (const seg of exclLines) { acc += seg.value || 0; out.set(`final:${seg.name}`, acc) }
for (const e of lines) { acc += e.value || 0; out.set(e.key, acc) }
return out
})()
const showRunning = !!valueCol && lines.length > 1
const showRunning = !!valueCol && (lines.length + exclLines.length) > 1
const numCell = 'text-right font-mono tabular-nums whitespace-nowrap px-2'
const rule = <td className="p-0"><div className="border-t border-gray-300 my-1" /></td>
@ -537,6 +543,11 @@ function ScaleLedger({ currentTotals, scaleInputs, setScaleInputs, scalePlug, se
{m.key === 'price' ? fmtNum(priceOf(seg), m.dp) : fmtNum(seg[m.key], m.dp)}
</td>
))}
{showRunning && (
<td className={`${numCell} text-amber-700`}>
{fmtNum(runningByKey.get(`final:${seg.name}`), 0)}
</td>
)}
</tr>
))}
@ -572,9 +583,7 @@ function ScaleLedger({ currentTotals, scaleInputs, setScaleInputs, scalePlug, se
{measures.map(m => (
<td key={m.key} className={numCell}>{fmtNum(m.current, m.dp)}</td>
))}
{showRunning && (
<td className={`${numCell} text-gray-500`}>{fmtNum(total.value, 0)}</td>
)}
{showRunning && <td className={numCell} />}
</tr>
@ -588,6 +597,9 @@ function ScaleLedger({ currentTotals, scaleInputs, setScaleInputs, scalePlug, se
: fmtNum(grand[m.key], m.dp)}
</td>
))}
{showRunning && (
<td className={`${numCell} font-semibold text-gray-700`}>{fmtNum(grand.value, 0)}</td>
)}
</tr>
)}