Commit graph

843 commits

Author SHA1 Message Date
DEls
ce238700a5 fix(deliveries): clear a batch's attention flag when its last document posts; read MEGA PO number variants; haulier is not the supplier
- 37 of 54 'needs attention' batches had every document finished: the flag
  was set while reading and never cleared by posting. Posting the last open
  document now marks the batch processed (batchSettledMutation).
- PO prefix variants (MEGA PO, MEGP0, MEDCPO, MEGCPC, extra leading zero)
  resolve when the supplier is confirmed and the digits are unchanged;
  dropped or changed digits stay unresolved.
- Reader prompt: supplier is the seller on the letterhead, never the
  transporter/haulier on a weighbridge ticket; copy the order number
  exactly. Prompt version unchanged so stored pages are not re-read.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-19 20:08:15 +02:00
DEls
a738b890bc fix(auth): keep named user sessions for 60 days 2026-10-19 20:04:14 +02:00
DEls
f6f441d1d7 fix(deliveries): put delivery note KPIs above the duplicate receipt notice
The delivery notes page showed the "Possible duplicate receipts need office
review" notice before the KPI strip, so the numbers the office acts on sat
below the thing it needs to act on. The notice now sits directly under the
KPIs and directly above the search and table.

The KPI strip moves out of the client-side table view into its own server
component, so the page owns the order of the three blocks. That also removes
a double padding bug: the page and the view each applied p-4 sm:p-6, which
indented the KPI and table column 32px while the notice sat at 16px.

The figures are unchanged - they always described the full site-scoped set
of delivery notes, not the filtered rows.

A page test locks the new order (KPI < notice < search < table) and fails
if the blocks are rearranged.
2026-10-19 17:22:07 +02:00
DEls
0857e56cb3 fix(workforce): let site managers add and rename employers and brokers
The employer and broker API routes were never named in the path
classifier, so they fell through to its admin-only default and the
proxy rejected a site manager with a bare {"error":"Not allowed"}
before the route handler ran. The handler's own site scoping was
always correct — it just never got the chance to apply.

- classify /api/employers as dashboard and map it to the workforce
  module, mirroring /api/employees
- let the site dropdown be chosen when adding an employer; only a
  rename freezes the site, which preserves assignment history
- cover the rename path, which had no route test, and the proxy
  gate for the site-manager role
2026-10-19 16:33:41 +02:00
DEls
8ef3c8f780 fix(deliveries): unblock new scans and match duplicate Drift supplier POs
- Tick runs new scans before batches requeued for PO rechecks; old
  uploaded_at dates kept rechecks ahead of today's scans for hours.
- Supplier records with the same normalised name and no conflicting
  registration/VAT count as one company, so PO9480 (held by the second
  Drift Laezonia record) no longer fails as a supplier conflict.
- Inbox shows a queued scan as waiting rather than being read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 14:27:52 +02:00
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
DEls
4c4106fe8b fix(dev): prevent production service workers from controlling local builds 2026-10-16 07:13:39 +02:00
DEls
c3566a1f02 Merge origin/main with delivery receiving fixes 2026-10-15 20:26:32 +02:00
DEls
69b941e198 fix(deliveries): preserve saved line decisions and correct receiving units 2026-10-15 20:25:04 +02:00
DEls
e01bb31c8c feat(ui): simplify dashboard table controls 2026-10-15 19:57:09 +02:00
DEls
757861c293 feat(workforce): simplify toolbar and add workers 2026-10-15 16:17:12 +02:00
DEls
bb2d15a39b feat(workforce): add employer and broker management 2026-10-15 15:58:06 +02:00
DEls
0d8e4b5566 Allow manual worker times to override recorded scans 2026-10-15 09:11:55 +02:00
DEls
a388796e4d Allow explicitly confirmed delivery note unit overrides 2026-10-15 09:09:17 +02:00
DEls
828e859455 feat(site-map): full screen map for phones and tablets
Full screen button fills the screen with the map (and asks the browser for real
full screen where allowed; iPhone falls back to filling the page). Tapping a road
section, pipe, peg etc. shows a floating card so progress can be ticked without
leaving full screen; section tick-offs moved into a shared SectionDetail component.
Exit with the button or Esc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 08:24:45 +02:00
DEls
03394c8005 feat(site-map): tablet touch navigation
One finger slides the map, pinch zooms smoothly towards the fingers, two-finger
drag turns and tilts, double-tap zooms in, tap selects (10 px tolerance for fingers).
On touch screens the arrow pad is hidden and the hint shows the gestures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 08:14:53 +02:00
DEls
d21303f3af Prefill clock correction times from recorded daily scans 2026-10-14 16:19:10 +02:00
DEls
921e906d55 Fix corrected arrival datetime in clock correction form 2026-10-14 14:24:30 +02:00
DEls
ab20d681b2 fix(site-map): review fixes — batches of 50, survey CSV locales, save recovery
- write PocketBase batches in chunks of at most 50 (production limit)
- survey import: refuse files with no rows, write peg events before the import record
- read en-ZA Excel CSVs (decimal comma), quoted fields, CR line endings; no crash without pegs
- save queue: reset on model reload, drop 400-refused items instead of blocking,
  keep queued values on screen when a server state arrives, flush on leaving the page

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 08:56:05 +02:00
DEls
f06d545e02 fix(site-map): allow tab-separated survey files
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 08:52:19 +02:00
DEls
0b04613ae1 feat(site-map): Site map entry on the site page and in the sidebar
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 07:31:24 +02:00
DEls
3770830e86 feat(site-map): progress, services, earthworks, signs, rain and accuracy panels
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 07:29:35 +02:00
DEls
de727e7129 feat(site-map): map page with layers panel, navigation pad and saving 2026-10-14 07:19:54 +02:00
DEls
f583814776 feat(site-map): services, earthworks, signs and rain layers; client save queue 2026-10-14 07:15:46 +02:00
DEls
220ca7bc45 feat(site-map): three.js scene engine, navigation and road layers 2026-10-14 07:12:32 +02:00
DEls
54a631c6ba feat(site-map): rain/ponding analysis as a pure module 2026-10-14 07:09:49 +02:00
DEls
70c0784b18 feat(site-map): surveyor CSV import marks matched pegs checked 2026-10-14 07:08:32 +02:00
DEls
a2db3a2b13 feat(site-map): model and progress API routes 2026-10-14 07:07:57 +02:00
DEls
226e3e6fcb feat(site-map): server helpers and view/edit permission check 2026-10-14 07:07:19 +02:00
DEls
dae2aeb044 feat(site-map): chainage, surface heights and BoQ quantities 2026-10-14 07:06:50 +02:00
DEls
300b1d2a07 feat(site-map): model upload script with progress-key parity 2026-10-14 07:06:13 +02:00
DEls
a5e5660893 feat(site-map): model types, progress keys and validation 2026-10-14 07:05:49 +02:00
DEls
c4da9d4a65 feat(site-map): PocketBase collections for models, progress and survey imports 2026-10-14 07:05:11 +02:00
DEls
d66c213712 feat(site-map): model pipeline with 20 m chainage sections 2026-10-14 07:04:34 +02:00
DEls
8dd01007bd docs(site-map): phase 1 spec and implementation plan 2026-10-14 07:02:23 +02:00
DEls
337b77be3f feat(management): refresh workbook plans and reconcile cashflow 2026-10-14 05:48:01 +02:00
DEls
f47e73044d fix(openmaus): use supported portable requirements 2026-10-12 22:57:22 +02:00
DEls
b2ce17814d feat(foreman): add checked receiving operator package 2026-10-12 22:48:46 +02:00
DEls
bab2ea7a43 feat(receiving): add Inbox 2 and strengthen duplicate checks 2026-10-12 20:20:27 +02:00
DEls
68f3e1eea6 feat(scanner): crop and review delivery and PO photos 2026-10-12 20:20:05 +02:00
DEls
c7c48fde10 fix(financial): keep each month's order and delivery bars side by side
The bars were capped at 36px but centred in half-month slots, so on a
wide screen a month's pair drifted ~65px apart. A fixed 32px bar with a
3px gap keeps them together (recharts still shrinks them if space runs
out).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 04:12:31 +02:00
DEls
1fb65a9d9c chore(n8n): keep the stored PO-ingest callback in step with the published workflow
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 00:47:00 +02:00
DEls
c55676bff0 fix(po): photographed POs get their order date from the PO Creation Date
Text PDFs already get it from pdftotext; photos and scans have no text,
so 4 of 5 undated POs were photos that do print a PO Creation Date.
- n8n PO reader (stored patch): asked for order_date = 'PO Creation
  Date' (day/month/year), never Required By or Printed; the callback
  passes it on.
- process-batch accepts extracted.order_date (YYYY-MM-DD); the PDF text
  wins when both exist.
- create_purchase_order / update_purchase_order / move_to_purchase_orders
  take order_date, so agents record it too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 00:45:14 +02:00
DEls
a41653ce87 fix(dn): date deliveries by the slip and orders by the PO's order date
The reader always read the slip date (and receiver, site name, customer
VAT, supplier registration), but dn_batch_notes never had those fields,
so they were dropped on save and every receipt was dated the moment it
was posted. The Financial dashboard dated orders by upload date, so 24
of 41 POs (R7.08M) sat in no month and deliveries piled up in the month
they were booked: 'R1.1M ordered, R2.4M delivered'.

- scripts/pb-add-dn-dates.py: adds the five header fields,
  delivery_notes.posted_at and purchase_orders.order_date (applied).
- scripts/dn-backfill-dates.py: filled 270 documents from the stored
  readings, moved 192 receipts to their slip date (booking time kept in
  posted_at) and read 36 PO order dates from the PDFs (applied; replaced
  values in docs/audits/2026-10-11-dates-backfill-backup.json).
- Posting refuses a slip without a delivery date instead of using today;
  receipts record posted_at. The review page shows the date and locks
  Post with a plain message when it is missing.
- PO intake reads 'PO Creation Date' from the PDF text (pdftotext).
- Dashboard tile and monthly chart date orders by order_date only; an
  order without one is undated, never put on its upload month.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 00:35:00 +02:00
DEls
ffe8901d15 Merge branch 'feat/financial-combined-chart' 2026-10-11 00:17:08 +02:00
DEls
6e3e9ec27c Merge branch 'fix/dashboard-figures' 2026-10-11 00:17:08 +02:00
DEls
f26d79a89c feat(financial): one chart of PO value against deliveries per month
Orders and deliveries now share a grouped bar chart. Orders with no date
(most of The Hills' value: date_uploaded is empty and the `created`
fallback does not exist on purchase_orders) cannot be placed on a month,
so the chart now totals them in a note instead of dropping them silently.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-11 00:13:38 +02:00
DEls
c16fae3f73 chore: allow the Mega purchasing MCP server in local settings
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-11 00:03:38 +02:00
DEls
b9d6cdedb8 chore: add the dn-inbox-review skill under .agents
Identical to the copy in .claude/skills.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-11 00:03:37 +02:00
DEls
cca41d5bb1 chore(clock): keep the pre-recalc paid-hours backups
Row ids with the hours_worked values from before the 2026-10-09
paid-hours recalculation, so the run can be reversed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-11 00:03:35 +02:00