WFDASH-WEBAPP/src/lib/server
Dave 61c5d8c906 feat(visits): office pin tool for seeding customer coordinates
Radius-based rep check-in has nothing to match against until customers
carry real positions: 0 of 616 had any — every `coordinates` geoPoint
was PocketBase's `{lon: 0, lat: 0}` default, and most company addresses
are P.O. Boxes, so geocoding can't seed them either. This is the tool
that seeds the ~20 main West Rand shafts by hand.

- /visits            landing page; a launcher until the visit-history
                     view has data to show
- /visits/pin-tool   pick a customer, click the map, save
- setCustomerCoordinates() in customers-service.ts, with lat/lng range
  validation so a string off a form input can't write a poisoned row
- PATCH /api/v1/customers/[id]/coordinates for agent/MCP callers
- Visits entry in the sidebar's Management group, plus MOBILE_TITLE_MAP

The browser writes through a Server Action, not the /api/v1/ route:
that route sits behind `assertAgentAuth` and a browser has no
AGENT_API_KEY. Both paths share `setCustomerCoordinates`. Mirrors the
existing saveAiSettingsAction split.

Pure view logic lives in pin-tool-helpers.ts so it can be tested away
from the Leaflet runtime.

Also refreshes the PB schema export — `rep_visits`, `rep_stops`,
`rep_vehicle_positions` and `users.tracker_vehicle_id` now exist on the
live instance.

32 tests. The suite's 9 pre-existing failing files are unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-06 16:58:07 +02:00
..
agent-auth.test.ts
agent-auth.ts
ai-settings-service.ts
ai-system-prompt.ts
attachment-extractor.ts
boss-dashboard-service.test.ts test(boss-dashboard): honour expand in mock + assert customer name in rep activity 2026-08-28 00:02:02 +02:00
boss-dashboard-service.ts chore: update page.tsx 2026-09-02 01:38:33 +02:00
browser-session.test.ts feat: add getBrowserSessionUser for routes that need the caller's identity 2026-09-01 01:33:10 +02:00
browser-session.ts feat: add getBrowserSessionUser for routes that need the caller's identity 2026-09-01 01:33:10 +02:00
buyer-tasks-service.test.ts feat(quotes): enhance scoring logic to include price matching 2026-08-24 07:09:39 +02:00
buyer-tasks-service.ts feat(quotes): enhance scoring logic to include price matching 2026-08-24 07:09:39 +02:00
collection-confirm-service.test.ts feat(collection-confirm): update stock item filtering logic in listCollectedItems 2026-08-17 08:27:36 +02:00
collection-confirm-service.ts feat(collection-confirm): update stock item filtering logic in listCollectedItems 2026-08-17 08:27:36 +02:00
collection-confirm-upload.test.ts
completed-window.test.ts feat(quotes): enhance scoring logic to include price matching 2026-08-24 07:09:39 +02:00
counter-service.ts feat(counter): add standalone counter order PWA 2026-08-13 09:27:20 +02:00
customers-coordinates.test.ts feat(visits): office pin tool for seeding customer coordinates 2026-09-06 16:58:07 +02:00
customers-service.test.ts feat(tv): add TV dashboard + refine workflows 2026-08-13 20:55:22 +02:00
customers-service.ts feat(visits): office pin tool for seeding customer coordinates 2026-09-06 16:58:07 +02:00
dashboard-service.test.ts
dashboard-service.ts
deliveries-service.test.ts feat(deliveries): enhance delivery notes management and UI 2026-08-17 01:27:03 +02:00
deliveries-service.ts feat(deliveries): click-to-expand DN items panel 2026-09-01 12:15:35 +02:00
delivery-note-order-match.test.ts feat(orders): include selling_price in duplicate-detection line match 2026-08-31 09:03:00 +02:00
delivery-note-order-match.ts feat(orders): include selling_price in duplicate-detection line match 2026-08-31 09:03:00 +02:00
delivery-notes-service.test.ts feat(orders): enhance order handling with email_message_id deduplication and displayContactName utility 2026-08-21 19:18:02 +02:00
delivery-notes-service.ts fix(orders): bill the customer quantity, not the supplier order_qty 2026-08-30 18:28:33 +02:00
driver-stops.ts fix(orders): bill the customer quantity, not the supplier order_qty 2026-08-30 18:28:33 +02:00
item-history-service.test.ts
item-history-service.ts
item-intel-service.ts feat(mcp): implement structured MCP error handling for upstream fetches 2026-08-15 22:32:11 +02:00
management-service.ts
mcp-upstream-fetch.test.ts feat(mcp): implement structured MCP error handling for upstream fetches 2026-08-15 22:32:11 +02:00
mcp-upstream-fetch.ts feat(mcp): implement structured MCP error handling for upstream fetches 2026-08-15 22:32:11 +02:00
order-completion.test.ts
order-completion.ts
order-delivery-note-link-service.test.ts feat(orders): include selling_price in duplicate-detection line match 2026-08-31 09:03:00 +02:00
order-delivery-note-link-service.ts feat(orders): include selling_price in duplicate-detection line match 2026-08-31 09:03:00 +02:00
order-item-context-service.test.ts
order-item-context-service.ts
order-item-margin-approval-service.test.ts feat(orders): bypass margin gate for non-invoiceable extras 2026-08-30 17:21:28 +02:00
order-item-margin-approval-service.ts feat(orders): bypass margin gate for non-invoiceable extras 2026-08-30 17:21:28 +02:00
order-item-status.test.ts
order-item-status.ts
order-items-service.test.ts feat(order-splitting): enhance order item splitting functionality and error handling 2026-08-17 14:14:27 +02:00
order-items-service.ts feat(order-splitting): enhance order item splitting functionality and error handling 2026-08-17 14:14:27 +02:00
order-number-duplicate-link-service.test.ts fix(orders): document PB schema prerequisite + strengthen duplicate-matcher tests 2026-08-30 22:08:24 +02:00
order-number-duplicate-link-service.ts fix(orders): document PB schema prerequisite + strengthen duplicate-matcher tests 2026-08-30 22:08:24 +02:00
order-order-duplicate-link-service.test.ts perf(orders): bulk-fetch candidate items in suggestOrderDuplicate (kill N+1) 2026-08-30 23:57:20 +02:00
order-order-duplicate-link-service.ts feat(orders): include selling_price in duplicate-detection line match 2026-08-31 09:03:00 +02:00
order-quote-link-service.test.ts feat(orders): add quote-match backlog sweep with age-gap reporting 2026-08-30 08:45:23 +02:00
order-quote-link-service.ts feat(orders): add quote-match backlog sweep with age-gap reporting 2026-08-30 08:45:23 +02:00
order-quote-match.test.ts fix(orders): parse PocketBase date format explicitly in the matcher 2026-08-29 13:20:40 +02:00
order-quote-match.ts fix(orders): parse PocketBase date format explicitly in the matcher 2026-08-29 13:20:40 +02:00
orders-service-review.test.ts fix(orders): update order_number collision-checking logic 2026-08-31 01:24:56 +02:00
orders-service.test.ts refactor(orders): rename runQuoteMatch to runPostCreateMatchers, update stale comments 2026-08-30 22:26:05 +02:00
orders-service.ts fix(orders): improve error handling for order creation and enforce email body length limit 2026-09-04 12:55:53 +02:00
po-email-template.ts
po-number.test.ts feat: add server-side quote search & PO number format update 2026-08-14 11:15:38 +02:00
po-number.ts feat: add server-side quote search & PO number format update 2026-08-14 11:15:38 +02:00
pocketbase-admin.test.ts
pocketbase-admin.ts
pos-auth.test.ts feat(pos): add assertPosAuth for POS_API_KEY-gated routes 2026-08-31 01:30:52 +02:00
pos-auth.ts feat(pos): add assertPosAuth for POS_API_KEY-gated routes 2026-08-31 01:30:52 +02:00
pos-letterhead-service.ts feat(pos): letterhead service + 2 API endpoints + vat_percent on Letterhead type 2026-09-04 09:13:53 +02:00
pos-service.test.ts feat: implement discount functionality in POS system 2026-09-03 12:19:21 +02:00
pos-service.ts fix(pos): fix uncaught 500 on checkout, allow overselling into negative stock 2026-09-04 13:00:12 +02:00
pos-slip-layout-service.test.ts feat(pos): add pos-slip-layout-service for reading/writing per-letterhead slip layouts 2026-09-04 13:23:09 +02:00
pos-slip-layout-service.ts feat(pos): add pos-slip-layout-service for reading/writing per-letterhead slip layouts 2026-09-04 13:23:09 +02:00
price-list-match.test.ts
price-list-match.ts
price-list-service.test.ts feat(mcp): add price_list.add_items tool for agent-driven catalogue upsert 2026-08-10 12:45:05 +02:00
price-list-service.ts feat(mcp): add price_list.add_items tool for agent-driven catalogue upsert 2026-08-10 12:45:05 +02:00
purchase-order-agent-service.test.ts feat(collection-confirm): add stock item edits 2026-08-14 16:39:46 +02:00
purchase-order-agent-service.ts feat(collection-confirm): add stock item edits 2026-08-14 16:39:46 +02:00
purchase-orders-service.test.ts
purchase-orders-service.ts
quote-email-template.ts feat(quotes): add approval page and email updates 2026-08-11 16:09:40 +02:00
quote-items-insights-service.test.ts
quote-items-insights-service.ts
quote-items-service.test.ts feat(mcp): add walk-in quote creation and enhance customer filtering 2026-08-15 11:50:48 +02:00
quote-items-service.ts feat(quotes): enhance quotes.submit functionality and error handling 2026-08-15 23:57:51 +02:00
quoted-before-service.test.ts feat(quotes): add quote-level "Quoted before?" panel to the process page 2026-08-29 08:52:19 +02:00
quoted-before-service.ts feat(quotes): add quote-level "Quoted before?" panel to the process page 2026-08-29 08:52:19 +02:00
quotes-ai-processor.ts
quotes-from-email-service.ts feat(quotes): add person_hint for customer resolution in forwarded emails 2026-08-27 11:11:44 +02:00
quotes-search-service.test.ts feat(quotes): enhance search functionality and user experience 2026-08-28 20:13:44 +02:00
quotes-search-service.ts feat(quotes): enhance search functionality and user experience 2026-08-28 20:13:44 +02:00
quotes-service.test.ts feat(quotes): add repeat-request detection service 2026-08-29 08:42:37 +02:00
quotes-service.ts fix(orders): pin matcher's field deps, project queries, and stop swallowing real errors 2026-08-29 13:44:56 +02:00
rep-dashboard-service.test.ts feat(dashboard2): trim Row 1 to Selling-only with last-month delta 2026-09-01 01:55:52 +02:00
rep-dashboard-service.ts perf(dashboard2): consolidate 14 PB count queries into 1 fetch 2026-09-01 02:08:52 +02:00
repairs-service.ts chore: update AGENTS.md 2026-09-02 01:17:05 +02:00
stock-booking-service.test.ts feat: add split views, stock picking slips, and invoice viewer 2026-08-09 23:16:55 +02:00
stock-booking-service.ts feat: add split views, stock picking slips, and invoice viewer 2026-08-09 23:16:55 +02:00
stock-cost-service.ts
stock-items-export.test.ts feat: implement discount functionality in POS system 2026-09-03 12:19:21 +02:00
stock-items-import.test.ts feat: implement discount functionality in POS system 2026-09-03 12:19:21 +02:00
stock-items-service.test.ts
stock-items-service.ts feat: implement discount functionality in POS system 2026-09-03 12:19:21 +02:00
stock-out.ts
stock-pricing-service.test.ts test(stock): cover validation + not_found + per-row independence 2026-08-31 16:48:40 +02:00
stock-pricing-service.ts fix(stock): skip ledger row on first-time pricing + include cost delta in notes 2026-08-31 16:46:42 +02:00
stock-purchase-invoice-matching-service.test.ts
stock-purchase-invoice-matching-service.ts feat: add split views, stock picking slips, and invoice viewer 2026-08-09 23:16:55 +02:00
stock-purchase-items-service.test.ts chore(tests): fix ~60 pre-existing TS errors across 11 test files 2026-08-27 04:43:40 +02:00
stock-purchase-items-service.ts feat(collection-confirm): add quantity collection handling and deduplication improvements 2026-08-17 02:17:27 +02:00
stock-purchases-migration.test.ts
stock-purchases-service.attachments.test.ts
stock-purchases-service.test.ts feat: add split views, stock picking slips, and invoice viewer 2026-08-09 23:16:55 +02:00
stock-purchases-service.ts feat: add split views, stock picking slips, and invoice viewer 2026-08-09 23:16:55 +02:00
stock-quick-draft-service.test.ts
stock-quick-draft-service.ts
stock-surplus.test.ts fix(orders): bill the customer quantity, not the supplier order_qty 2026-08-30 18:28:33 +02:00
stock-surplus.ts fix(orders): bill the customer quantity, not the supplier order_qty 2026-08-30 18:28:33 +02:00
tracker-service.test.ts feat(rep-visits): FleetAI tracker adapter, nearby-customer matching, stop detection 2026-09-06 14:22:28 +02:00
tracker-service.ts feat(rep-visits): FleetAI tracker adapter, nearby-customer matching, stop detection 2026-09-06 14:22:28 +02:00
tv-dashboard-service.ts feat(tv-dashboard): enhance TV dashboard with driver stops and performance metrics 2026-08-19 10:16:49 +02:00
tv-session.ts feat(tv): add TV dashboard + refine workflows 2026-08-13 20:55:22 +02:00