MEGAINFRA-WEBAPP/src/components
DEls a3e4702159 refactor(schema): resolve project_code through site, not a stored copy
project_code was a text copy of the parent site's code, denormalised
onto 8 child collections that each already have a real site relation.
Written once at insert, never updated -- docs/data-model.md documents
the drift risk. On purchase_orders it never even held a real project
code: production had requisition numbers, site names, and the PO's own
number in that field.

Every read site now resolves the code through site/expand.site/siteById
instead, reusing each page's existing site map where one already
existed. Every create() call stops writing the column. The chat agent's
list_imports tool no longer reads data_import_batches -- it now reads
timesheets, fuel_sheets, plant_hours_sheets, purchase_orders and
delivery_notes filtered by processing_status, which was necessary before
the pool can be dropped (Task 20 would otherwise 404 the agent).

Also closed a Task 17 gap found while doing this: the agent tools' vehicle
and fuel-log handlers still resolved project code from the now-removed
vehicles.project_code column.

Wrote scripts/migrations/2026-09-15-drop-legacy-columns.py, the one
irreversible step in this whole restructure. Its guard against orphaning
fuel_logs rows checked the wrong condition -- "fuel_sheet is empty" --
which produced a false abort: 73 fuel_logs rows have no fuel_sheet
because they predate batch tracking entirely and never had a
batch_reference to begin with, so dropping data_import_batches costs
them nothing. Fixed the guard to check what it actually claims to check:
a row that HAD a batch_reference and was never relinked. Verified live
that no such row exists on any of the three affected collections.

Script run in dry-run only; not yet applied.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-11 16:01:14 +02:00
..
layout feat(chat): sidebar link, editable-while-waiting, sticky footer, limit warning 2026-08-30 23:51:45 +02:00
ui
add-plant-button.tsx refactor(schema): resolve project_code through site, not a stored copy 2026-09-11 16:01:14 +02:00
auth-gate.tsx
edit-mode-bar.tsx
fixed-cost-dialog.tsx refactor(fixed-cost-dialog): drop defaultType prop, use field-message lookup, local-date default 2026-08-28 13:22:07 +02:00
import-fuel-logs-button.tsx fix(fuel): document-first import with honest status 2026-09-11 14:02:02 +02:00
import-plant-hours-button.tsx fix(plant-hours): document-first import with honest status 2026-09-11 13:56:11 +02:00
import-timesheets-button.tsx fix(timesheets): document-first import, site stamped per entry 2026-09-11 14:07:01 +02:00
logo.tsx
needs-review-dns.tsx feat(purchasing): add searchable picker for PO assignment 2026-09-07 14:20:16 +02:00
pwa-register.tsx
rain-outlook-card.tsx feat(dashboard): enhance operations dashboard with rain outlook and coordinate support 2026-09-06 19:59:52 +02:00
site-form-dialog.tsx feat(dashboard): enhance operations dashboard with rain outlook and coordinate support 2026-09-06 19:59:52 +02:00
slip-preview.tsx fix(purchasing): proxy PB files so PDFs render in the slip iframe 2026-09-07 14:53:22 +02:00
theme-toggle.tsx
upload-delivery-note-button.tsx feat(delivery-notes): dedup by SHA-256 at upload time 2026-09-07 14:49:33 +02:00
upload-purchase-order-button.tsx feat(purchasing): create the PO row at upload with a placeholder number 2026-09-11 14:14:19 +02:00
vehicle-unit-type-cell.tsx fix(components): keep UnitTypePill text on a single line 2026-08-31 14:18:19 +02:00