mega-plant/lib
David 4a76b08617 Running cost = everything linked to a vehicle: repairs, purchases, insurance, finance
A machine with no repairs and no purchase order still carries an insurance premium
and, while it is financed, a monthly instalment. So a blank row was never "this
vehicle costs nothing" — it was "nothing recorded", which is a gap rather than a
figure. The Overview now totals all four kinds per machine per month.

Everything is read from POCKETBASE, the registers the client maintains in the app.
The original spreadsheet only bootstrapped the page (monthly_running_costs, Jan-Aug);
it is not a source here. September having no workbook data is expected and correct —
the figures there now come from the app.

Two finance sources existed and OVERLAPPED. The cost_lines instalment rows are the old
workbook's subset (5 machines, R115 576,14/mo); financing_terms is the client's current
sheet (18 agreements, R428 585,04/mo). Using both double-counted MG02, RV04, TLB06 and
TLB07, so financing_terms wins and the stale rows are ignored. TB01 has no financing_terms
row, so its old instalment no longer counts — consistent with it being absent from the
current sheet. Insurance has one source and no such problem.

Insurance is resolved from the RATE PERIODS rather than the derived cost_lines, so a
premium that moves mid-year is charged at the price that applied that month.

Also: settled agreements contribute nothing (a paid-off machine is not a running cost),
purchase lines are filed under the PO date, and the bottom row keeps showing incl above
excl. The page carries one line saying this is a re-cut of costs already inside fixed
expenses — adding it to them would count the same premium twice.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-10-09 12:28:29 +02:00
..
auth-policy.test.ts feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
auth-policy.ts feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
auth-service.test.ts feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
auth-service.ts feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
auth.ts feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
chart-profit.ts Income: hide stood-down machines, with an active/inactive filter 2026-10-03 18:40:32 +02:00
cost-code.ts Add Running Costs sub-pages: insurance, financing, purchases, oil, operators, mechanics 2026-10-09 01:06:27 +02:00
data.ts Add Running Costs sub-pages: insurance, financing, purchases, oil, operators, mechanics 2026-10-09 01:06:27 +02:00
financing.ts Add Running Costs sub-pages: insurance, financing, purchases, oil, operators, mechanics 2026-10-09 01:06:27 +02:00
insurance-rate-policy.json Add Running Costs sub-pages: insurance, financing, purchases, oil, operators, mechanics 2026-10-09 01:06:27 +02:00
insurance-rate-policy.ts Add Running Costs sub-pages: insurance, financing, purchases, oil, operators, mechanics 2026-10-09 01:06:27 +02:00
insurance.ts Add Running Costs sub-pages: insurance, financing, purchases, oil, operators, mechanics 2026-10-09 01:06:27 +02:00
intake-retry.test.ts feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
intake-retry.ts feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
invoice-booking-policy.json Invoices: line-item extraction, booking to plant items, VAT-inclusive income 2026-10-01 15:59:30 +02:00
invoice-booking.ts Invoices: line-item extraction, booking to plant items, VAT-inclusive income 2026-10-01 15:59:30 +02:00
invoice-parser.test.ts Test: a site typed without its space is deliberately NOT folded 2026-10-08 19:06:30 +02:00
invoice-parser.ts Invoices: one line per charge, and fold an abbreviated site 2026-10-06 11:25:10 +02:00
invoice-party-policy.json Split the invoice register into Internal and External Invoices 2026-10-08 11:49:48 +02:00
invoice-party.test.ts Split the invoice register into Internal and External Invoices 2026-10-08 11:49:48 +02:00
invoice-party.ts Split the invoice register into Internal and External Invoices 2026-10-08 11:49:48 +02:00
invoice-revalidate.ts Split the invoice register into Internal and External Invoices 2026-10-08 11:49:48 +02:00
invoice-routes.ts Split the invoice register into Internal and External Invoices 2026-10-08 11:49:48 +02:00
mechanics.ts Add Running Costs sub-pages: insurance, financing, purchases, oil, operators, mechanics 2026-10-09 01:06:27 +02:00
oil.ts Add Running Costs sub-pages: insurance, financing, purchases, oil, operators, mechanics 2026-10-09 01:06:27 +02:00
pb.ts Round 4: regressions fixed + mobile standard 2026-09-12 12:05:43 +02:00
plant-location-policy.json feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
plant-map.test.ts feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
plant-map.ts feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
profit.test.ts Mega Plant dashboard — fix & harden (Parts 0-5) 2026-09-12 09:35:48 +02:00
profit.ts Mega Plant dashboard — fix & harden (Parts 0-5) 2026-09-12 09:35:48 +02:00
purchase-booking.ts Fold purchase orders into the Running Costs Overview, with incl/excl totals 2026-10-09 12:10:13 +02:00
purchase-parser.ts Add Running Costs sub-pages: insurance, financing, purchases, oil, operators, mechanics 2026-10-09 01:06:27 +02:00
qr-pdf.ts Add Running Costs sub-pages: insurance, financing, purchases, oil, operators, mechanics 2026-10-09 01:06:27 +02:00
qr.ts Add Running Costs sub-pages: insurance, financing, purchases, oil, operators, mechanics 2026-10-09 01:06:27 +02:00
rows.test.ts Invoices: line-item extraction, booking to plant items, VAT-inclusive income 2026-10-01 15:59:30 +02:00
rows.ts Running cost = everything linked to a vehicle: repairs, purchases, insurance, finance 2026-10-09 12:28:29 +02:00
running-costs.ts Running cost = everything linked to a vehicle: repairs, purchases, insurance, finance 2026-10-09 12:28:29 +02:00
server-data.ts Add Running Costs sub-pages: insurance, financing, purchases, oil, operators, mechanics 2026-10-09 01:06:27 +02:00
sites.test.ts Give external invoices a supplier name; keep them off the sites page 2026-10-08 12:04:42 +02:00
sites.ts Give external invoices a supplier name; keep them off the sites page 2026-10-08 12:04:42 +02:00
utils.ts Mega Plant dashboard — fix & harden (Parts 0-5) 2026-09-12 09:35:48 +02:00