JEISA-WEBAPP/scripts
Dave 2b56053e1c fix(po): stop PocketBase auto-cancellation from killing PO creation
The Purchase Order form never reached the server. Creating a PO with two
or more "Manual Entry" rows fired N parallel POSTs to
/api/collections/stock_items/records via Promise.all. The PocketBase JS
SDK auto-cancels any in-flight request whose method + path match a newer
one, so the first POST was aborted with:

  ClientResponseError 0: The request was autocancelled.

Promise.all then rejected before the PO create ever ran, so the PO was
never created - only an orphan stock item per attempt. Confirmed against
the production PB logs: two stock_items POSTs today, zero
purchase_orders POSTs, and two orphan stock_items rows with no PO.

Fixes:
- src/lib/pocketbase.ts: pb.autoCancellation(false) on the browser
  client. Every server-side client in this repo already did this
  (scripts/*.mjs, server/po-api.mjs) - the browser client was the one
  place it was missing.
- PurchaseOrderForm: resolve rows sequentially instead of Promise.all,
  and build the snapshot in the same pass so manual rows carry the real
  stock item id instead of "".
- PurchaseOrderForm: disable the submit button while submitting, so a
  double click cannot create two POs.
- PurchaseOrderForm: compare SKUs trimmed, so a stray trailing space
  does not create a duplicate stock item.
- po-photo-ingest.mjs, jei_skill.ts, setup-users.js: same
  autoCancellation(false) guard.
2026-10-22 07:56:30 +02:00
..
add-customer-fields.mjs feat(quotes,customers): address + VAT on quotes, 30-day validity, searchable customer 2026-10-21 04:45:58 +02:00
add-quote-deleted-flag.mjs feat(quotes): delete quotes from the app, add customer inline with full details 2026-10-21 05:09:11 +02:00
backfill-quote-validity.mjs feat(quotes,customers): address + VAT on quotes, 30-day validity, searchable customer 2026-10-21 04:45:58 +02:00
create-user-quote.mjs fix(quotes,po): repair item storage, totals and PDF line items 2026-10-20 20:13:46 +02:00
fix-items-field.mjs fix(quotes,po): repair item storage, totals and PDF line items 2026-10-20 20:13:46 +02:00
fix-users-collection.mjs feat(settings): add user management, fix totals and mobile layout 2026-10-21 03:13:01 +02:00
generate-icons.mjs Add icon generation script and new icons for PWA and favicons 2025-09-25 00:50:36 +02:00
mcp-create-po.mjs feat(po): add MCP server, agent-friendly PO API, and PDF rendering 2026-09-07 11:12:13 +02:00
po-photo-ingest.mjs fix(po): stop PocketBase auto-cancellation from killing PO creation 2026-10-22 07:56:30 +02:00
preview-quote-pdf.mjs fix(quotes): wrap item descriptions on the quote PDF 2026-10-21 08:40:39 +02:00
probe-pb-schema.mjs feat(po): add MCP server, agent-friendly PO API, and PDF rendering 2026-09-07 11:12:13 +02:00
push-migrations.mjs feat(po): add MCP server, agent-friendly PO API, and PDF rendering 2026-09-07 11:12:13 +02:00
test-pb-mcp.mjs feat(po): add MCP server, agent-friendly PO API, and PDF rendering 2026-09-07 11:12:13 +02:00
test-po-api.mjs feat(po): add MCP server, agent-friendly PO API, and PDF rendering 2026-09-07 11:12:13 +02:00
test-quote-pdf.mjs fix(quotes,po): repair item storage, totals and PDF line items 2026-10-20 20:13:46 +02:00