JEISA-WEBAPP/pocketbase/pb_migrations
Dave d606345de4 fix(quotes,po): repair item storage, totals and PDF line items
Quotes and purchase orders were silently losing their line items.

Quote items field was a multi-relation to stock_items, but PocketBase
stored only the last id as a plain string no matter how it was sent
(JSON string via FormData, raw array, or repeated FormData entries).
Every quote created through the UI had `items: ""` or `items: "<id>"`.
Recreated the field as JSON so an array of stock_item ids round-trips
(companion fields quantities/unitPrices already line up with it).

PO snapshot_items had the same class of bug from the other direction:
String(obj) coerced the snapshot array to "[object Object]", which
PocketBase stored verbatim, rendering the PO as N rows of
"Unknown / £0.00". The form now sends JSON-stringified arrays, and
the reader only trusts a snapshot whose rows actually carry a name.

Also fixes:
- Quote item lines are hydrated from stock_items; the parallel
  quantities/unitPrices arrays are the source of truth, so quotes
  written before the schema fix still render and total correctly.
- Quote form rejects stock rows where no item was actually picked
  from the dropdown, instead of saving an empty stockItemId.
- PO PDF filename is now the plain order number (PO-20261015-001.pdf).

Adds the quotes.items schema migration plus three dev scripts for
creating a quote, re-applying the field fix and rendering a test PDF.
2026-10-20 20:13:46 +02:00
..
1779619885_deleted_book_out_records.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779619885_deleted_logs.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779619896_deleted_customers.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779619896_deleted_stock_items.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779619907_created_companies.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779619907_created_company_details.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779619907_created_customers.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779619907_created_order_items.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779619907_created_orders.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779619907_created_purchase_orders.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779619907_created_quote_items.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779619907_created_quotes.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779619907_created_suppliers.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779620553_created_companies.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779620553_created_company_details.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779620553_created_customers.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779620553_created_order_items.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779620553_created_orders.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779620553_created_purchase_orders.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779620553_created_quote_items.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779620553_created_quotes.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779620553_created_suppliers.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779620553_deleted_companies.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779620553_deleted_company_details.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779620553_deleted_customers.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779620553_deleted_order_items.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779620553_deleted_orders.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779620553_deleted_purchase_orders.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779620553_deleted_quote_items.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779620553_deleted_quotes.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779620553_deleted_suppliers.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1779623519_updated_quotes.js chore: untrack .env and pb_data, update gitignore 2026-09-01 07:45:02 +02:00
1786200001_created_customer_pos.js feat(automation): add PO-to-invoice pipeline 2026-09-06 23:40:33 +02:00
1786200002_created_customer_po_lines.js feat(automation): add PO-to-invoice pipeline 2026-09-06 23:40:33 +02:00
1786200003_created_invoices.js feat(automation): add PO-to-invoice pipeline 2026-09-06 23:40:33 +02:00
1786200004_created_invoice_items.js feat(automation): add PO-to-invoice pipeline 2026-09-06 23:40:33 +02:00
1786200005_created_email_inbox.js feat(automation): add PO-to-invoice pipeline 2026-09-06 23:40:33 +02:00
1786200006_created_workflow_runs.js feat(automation): add PO-to-invoice pipeline 2026-09-06 23:40:33 +02:00
1786200007_updated_purchase_orders.js feat(po): add MCP server, agent-friendly PO API, and PDF rendering 2026-09-07 11:12:13 +02:00
1786300001_fixed_quotes_items_field.js fix(quotes,po): repair item storage, totals and PDF line items 2026-10-20 20:13:46 +02:00