MEGAINFRA-WEBAPP/docs/superpowers/plans/2026-10-17-plant-audit.md
DEls 0a7138f60c fix: harden workforce, plant and financials
Improve workforce scanning, site transfers and timesheet exports.
Audit plant imports, duplicate identities, rates and dashboard totals.
Repair delivery PO selection, periodic rechecks and receiving guards.
Align financial ledgers, supplier periods and mobile layouts.
Add the site map preview, shared theme controls and audit evidence.

Verify 3,455 application tests, six fuel export tests, TypeScript and
an optimized production build. Clean up a leaked test timer and keep
local worktrees and generated reports out of ESLint traversal.

Changed-file lint passes; repository-wide lint retains 33 existing
errors in unchanged files.
2026-10-19 13:18:31 +02:00

2.3 KiB

Plant audit and hardening

User scope: Plant overview, Vehicles, Equipment, Fuel Logs, per-unit details, import/QR entry flows and Map; desktop and narrow-phone views. Preserve accepted Workforce changes and unrelated dirty work. No automatic deletion/merging of real records, deployment or live attendance/fuel test writes.

  • Baseline tests and read-only inventory: duplicate QRs/fill fingerprints, active import indexes, prices, readings and site attribution.
  • Meter scanner: reject ambiguous identity and stale confirmations, fail closed on lookup outages, use chronological readings, validate monotonic meters server-side, idempotent and serialized saves, fresh GPS and accurate SA day/scan time. Keep zero-litre meter readings separate from fills.
  • Calculation consistency: shared meter ordering and fill-only efficiency; protect valid baseline from zero/invalid readings; correct rate averages and SA monthly bounds; historical-site records stay attributed to their work site. Align detail and overview totals.
  • Vehicle create/update identity validation and duplicate guards; preserve history on deletion; verify existing merge/import paths.
  • Fuel Logs: correct types, dates, zero-litre labels, counts and filters; keyboard navigation and local table scrolling.
  • Map: authorised site pins, valid coordinates, no misleading zero pins, filter-aware framing and usable phone controls.
  • Browser walkthrough: overview charts, each roster/detail table, filters/pagination, add/import/merge dialogs, all map layers at desktop and 320px phone width. Read-only interactions for live data.
  • Focused regression tests, typecheck, ESLint, independent final review; record verified findings and remaining physical-device limitations.

Initial observations: file importer already reconciles Buildsite identities and exact/near matches under a DB lock and partial unique indexes. QR meter scan currently accepts repeated writes and chooses first matching QR; lookup sorts by creation rather than reading time and treats every lookup failure as an empty history. Overview month boundary is UTC and includes future dates; equipment cost selects current-site vehicles only. Map passes every site's pins despite scoped vehicle reads. Investigate and reproduce before changing calculations.