Two things that meant going into PocketBase by hand or jumping between
screens.
Deleting a quote
- Quotes had no delete action - a test quote could only be removed
through the PocketBase admin UI. Purchase orders already soft delete
by flipping a `deleted` flag, so quotes now do the same: the Delete
action confirms first, then hides the quote from the list while the
record and its PDF stay in PocketBase for audit.
- The quotes list filters out soft-deleted quotes, so a deleted quote
is out of the way but recoverable by clearing the flag.
Adding a customer while writing a quote
- Typing a customer name that was not in the list used to create a
name-only stub, which then had to be edited from the Customers screen
before the quote could show an address or VAT number.
- The picker now opens the full customer form right there - address,
VAT number, email and phone - with the name pre-filled. The new
customer is created, added to the list and selected, so the quote
carries on and the PDF has the details.
A quote should look like a document from a real company, so this adds
the customer details a quote needs, gives every quote a valid-until
date, and makes the customer picker usable once there are 20+ of them.
Customer details on quotes
- The `customers` collection only had a name, so the quote PDF's
"Customer Information" block could only ever print a name. Added
optional address, VAT number, email and phone fields.
- The PDF block now grows to fit whatever is on file and prints the
VAT number and contact line, so a filled-in customer produces a
professional quote.
- The quote details dialog shows the same details.
- The customer form gained the new fields, and "Edit customer" now
works - it was a menu item that did nothing, so there was no way
to add a VAT number to an existing customer.
- The customers table shows Address and VAT Number columns.
Valid until
- Quotes were created with an empty validUntil, so the PDF printed
"Valid Until: N/A". The form now defaults it to 30 days after the
quote date and keeps it in step when the date moves. The three
existing quotes without one were backfilled the same way.
Searchable customer picker
- The customer dropdown listed every customer in a plain select with
no way to add one that was missing. It is now a searchable combobox
(by name, address or VAT number) that offers to create the customer
when nothing matches, and creates it inline.
Sidebar
- Settings moved to a gear in the corner next to the app name, and
Logs moved into Settings as a tab. The nav is now eight items with
no grouping - grouping them would add a layer for no gain at this
size. The old /logs link still lands on the logs tab.
Also fixes a real PDF bug: item descriptions were cut to 40 characters,
which is wider than the description column, so long names printed on
top of the SKU column. Descriptions and SKUs are now measured against
the real column width and truncated with an ellipsis.
Live PocketBase changes (see scripts/add-customer-fields.mjs):
- customers update and delete rules were null (superusers only), so a
member could not edit the customer they had just added. They now
match the other collections.
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.
Add a PocketBase migration and store snapshot_items on purchase order creation so POs keep item details even if stock items change or are deleted. Wire snapshot_items through the UI: PurchaseOrders list prefers snapshot data when present; EditPurchaseOrderDialog supports snapshot fallback, SKU, entryMode (stock/manual), add/remove rows, and updates stock item GBP prices for stock-mode items. BookOutForm now deducts stock quantities on booking out and surfaces precise errors. Minor UI and behavior tweaks: low-stock report filters only actual stock items, columns typing includes snapshotItems, and edit action/menu is always available with an Edit dialog integrated into the PurchaseOrders page.
Introduces a new 'cost_price_gbp' field to the stock items schema and database migration. Updates stock item forms to support both ZAR and GBP cost prices. Purchase order forms and PDF generation now use GBP pricing, with enhanced supplier and order metadata. Adds a searchable stock item selector for purchase orders and improves type definitions and UI labels for clarity.