No description
Find a file
David f7ce429c04 Re-link invoice lines whose target asset a seed replaced
`booked_asset` stores an asset record ID, and `npm run seed` deletes and
re-creates every asset — so the id a line was booked against stops existing after
a seed. The line then points at nothing and silently drops out of monthly_income,
which is exactly the reported symptom: booked yesterday, unbooked today, with the
line still carrying the correct code.

The booking step now re-derives the pointer from the register code the line
already carries (`asset_code`, falling back to the machine code) whenever the
stored target is empty or no longer exists. It only ever points a line at the
asset its own code names, so it never invents a match and never clears a
site booking. A line with no matching code stays unbooked exactly as before.

This makes the documented run order self-healing:
`npm run seed && node scripts/book-invoice.mjs` now restores the links, so a
reset cannot silently unbook the register.

Verified by running a full seed and re-booking: 29 pointers were invalidated by the
seed and all 29 were re-linked, giving 45 posted rows and 3 unbooked lines — the
two MPLANT05 containers and one WT02 trailer, which have no matching plant item.
2026-10-09 00:52:52 +02:00
.mavis/canvas-assets Mega Plant dashboard — fix & harden (Parts 0-5) 2026-09-12 09:35:48 +02:00
app Attach the uploaded PDF to the invoice it creates 2026-10-08 21:45:42 +02:00
components Give external invoices a supplier name; keep them off the sites page 2026-10-08 12:04:42 +02:00
data/source Invoices: add PHI 169 (Rooihuiskraal) 2026-10-02 06:44:10 +02:00
docs feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
lib Test: a site typed without its space is deliberately NOT folded 2026-10-08 19:06:30 +02:00
public Brand logo: 3D cube/map icon replaces the M gradient mark 2026-09-12 12:12:30 +02:00
scripts Re-link invoice lines whose target asset a seed replaced 2026-10-09 00:52:52 +02:00
worker feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
.dockerignore Round 4: regressions fixed + mobile standard 2026-09-12 12:05:43 +02:00
.env.example Mega Plant dashboard — fix & harden (Parts 0-5) 2026-09-12 09:35:48 +02:00
.gitignore feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
AGENTS.md Give external invoices a supplier name; keep them off the sites page 2026-10-08 12:04:42 +02:00
COOLIFY.md Round 4: regressions fixed + mobile standard 2026-09-12 12:05:43 +02:00
Dockerfile Invoices: ship pdfjs-dist's worker into the standalone image 2026-10-06 10:49:10 +02:00
HANDOFF-PROMPT-2.md Round 2 (Parts B-D): asset register restructure, type field, sequential codes, flat sortable table, cost_lines, removed synthetic code, fail loudly 2026-09-12 10:24:26 +02:00
HANDOFF-PROMPT-3.md Round 3 (Parts A-B): charts fixes + expenses/overheads cleanup 2026-09-12 11:24:18 +02:00
HANDOFF-PROMPT-4.md Round 4: regressions fixed + mobile standard 2026-09-12 12:05:43 +02:00
HANDOFF-PROMPT.md Auto-create synthetic assets for unmatched machines in seed; update open-questions report 2026-09-12 09:40:18 +02:00
next.config.ts feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
package-lock.json Sites: give every site coordinates 2026-10-02 16:33:43 +02:00
package.json feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
postcss.config.mjs Mega Plant dashboard — fix & harden (Parts 0-5) 2026-09-12 09:35:48 +02:00
proxy.ts feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
tsconfig.json Mega Plant dashboard — fix & harden (Parts 0-5) 2026-09-12 09:35:48 +02:00