mega-plant/components
David 80ca4788a2 Give external invoices a supplier name; keep them off the sites page
The name on an invoice means two different things. On an internal invoice it is a
SITE, transcribed from the invoice's own description. On an external invoice it is
the SUPPLIER - and the PDF does not print the supplier's company name at all, so
there is nothing to transcribe and a human has to type it.

`invoices.site` stays the single field; the column header follows the page (Site on
Internal, Supplier on External) and only the external one is editable, via
components/SupplierCell.tsx and PATCH /api/invoices/:id/site. It saves on blur or
Enter, never per keystroke, and an empty value clears the name so a stray
description fragment can be removed rather than displayed as a supplier.

Sites stop taking their names from external invoices, in both places:

- syncSitesFromInvoices only creates sites from internal invoices, so a job
  description can never be registered as a yard.
- buildSiteSummaries only counts internal invoice lines towards a site, which is
  what /sites and the dashboard's per-site chart read.

This is the "Move containers" case. PHI 192's description is "Crane Truck Hire 17
September 2026 Move containers", which had registered a site literally called
"Move containers" - a job, not a yard - on /sites, on the dashboard's per-site
chart and in the plant register's site filter. The record stays in the collection
(sites are never deleted) but is no longer surfaced; the count went 13 -> 12.
External income is not lost by this - it is booked to a machine and still appears on
/income and /charts. It is simply not a site.

The intake route stops resolving an external invoice's text against the site list,
which would have invented a site out of a description, and reports needsSupplier so
the import toast says the name is outstanding.

npm run seed now captures existing invoice names before it wipes the collection and
re-applies them where data/source does not specify one - the same data-loss trap the
uploaded PDFs already had. A JSON name always wins, so internal sites are unchanged.

Verified: typecheck clean, 45 tests pass (4 new, covering the "Move containers" case
directly), production build green, the new PATCH route 401s when anonymous, and
/sites plus both invoice pages pass the mobile checklist at 375x812 and 768x1024. The
supplier edit was exercised end to end and the test value reverted.

Still open: the three external invoices (PHI 178/186/192) have no supplier name yet
and none can be derived from the data. They show "Set supplier" until the client
supplies them.

Note: lib/rows.ts, lib/server-data.ts and the running/insurance feature are
someone else's in-flight work and were deliberately left uncommitted here.
2026-10-08 12:04:42 +02:00
..
auth feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
AccountMenu.tsx feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
ChartsGrid.tsx feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
DashboardCharts.tsx feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
ExpenseSectionPage.tsx feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
GlobalSearch.tsx feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
IncomeView.tsx Income: the tiles and the machine list were sharing the title's flex row 2026-10-06 11:05:37 +02:00
InvoiceIntake.tsx Give external invoices a supplier name; keep them off the sites page 2026-10-08 12:04:42 +02:00
InvoiceList.tsx Give external invoices a supplier name; keep them off the sites page 2026-10-08 12:04:42 +02:00
InvoiceRegisterPage.tsx Give external invoices a supplier name; keep them off the sites page 2026-10-08 12:04:42 +02:00
InvoiceTable.tsx Invoices: a machine chosen in the dropdown was never actually booked 2026-10-03 15:43:46 +02:00
InvoiceUploader.tsx Invoices: line-item extraction, booking to plant items, VAT-inclusive income 2026-10-01 15:59:30 +02:00
MachineCombobox.tsx Invoices: a machine chosen in the dropdown was never actually booked 2026-10-03 15:43:46 +02:00
MachineLineChart.tsx feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
PlantMap.tsx feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
PlantMapLoader.tsx Map: dark tiles from Esri, because CARTO retired keyless access 2026-10-03 09:20:24 +02:00
PlantRegisterTable.tsx feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
RunningView.tsx Fix: the mobile table was mislabelled and clipping its own totals 2026-10-02 15:34:19 +02:00
ScrollFade.tsx Fix: the mobile table was mislabelled and clipping its own totals 2026-10-02 15:34:19 +02:00
Sidebar.tsx Mobile: the menu button was indenting every page 2026-10-03 16:08:04 +02:00
SiteBookingSelect.tsx Invoices: fix the tablet layout and make booking an unbooked line obvious 2026-10-03 09:59:05 +02:00
SiteContainerEditor.tsx Sites: auto-allocate container lines to the container the site hires 2026-10-02 18:32:12 +02:00
SiteCoordinateEditor.tsx Sites: give every site coordinates 2026-10-02 16:33:43 +02:00
SitesView.tsx Sites: a card list that reads like the income screen 2026-10-03 09:20:20 +02:00
Sparkline.tsx Invoices: keep the PDF on the invoice, and search the invoice's own words 2026-10-02 19:09:16 +02:00
SupplierCell.tsx Give external invoices a supplier name; keep them off the sites page 2026-10-08 12:04:42 +02:00
ThemeProvider.tsx Mega Plant dashboard — fix & harden (Parts 0-5) 2026-09-12 09:35:48 +02:00
ThemeToggle.tsx feat: add user access and improve plant dashboard 2026-10-06 04:02:08 +02:00
Toast.tsx Fix: toast and machine dropdown were rendering behind the page chrome 2026-10-02 18:42:29 +02:00