feat(po): admin-managed delivery locations + Place of Delivery dropdown (#19) #100

Merged
shad0w merged 2 commits from feat/delivery-locations into master 2026-06-23 20:43:57 +00:00
Owner

Closes #19.

Summary

The PO Place of Delivery is now a dropdown sourced from an admin-managed Delivery Locations list, instead of free text.

Admin

  • New DeliveryLocation model — a Company FK + free-text address + isActive (schema + migration).
  • New permission manage_delivery_locations → Manager + SuperUser + Admin (Manager-accessible, not admin-only, per the issue).
  • Admin screen at /admin/delivery-locations: searchable table + Add/Edit dialogs + activate/deactivate + delete (mirrors /admin/sites). Sidebar link under Administration.

PO forms

  • The three forms (new / edit / manager-edit) render a shared <DeliveryLocationField> — a native <select name="placeOfDelivery"> populated from the active locations, each formatted "Company — address" (lib/delivery-location.ts).

Design choice — snapshot, not FK

PurchaseOrder.placeOfDelivery stays a free-text snapshot. The dropdown only changes how the value is picked, so:

  • the export, import, and historical/imported POs are untouched;
  • editing a PO whose current value isn't in the active list preserves it as a leading "(current)" option (no silent data loss);
  • deleting a location is always safe — no PO references it.

Tests

  • delivery-locations.test.ts: create/update/toggle/delete + the manage_delivery_locations guard (6 tests).
  • Full integration suite green (248), tsc --noEmit clean.

Deploy note

Adds migration 20260624130000_delivery_locations → run prisma migrate deploy. Applied to the local dev DB already.

🤖 Generated with Claude Code

Closes #19. ## Summary The PO **Place of Delivery** is now a dropdown sourced from an admin-managed **Delivery Locations** list, instead of free text. ## Admin - New `DeliveryLocation` model — a **Company** FK + free-text **address** + `isActive` (schema + migration). - New permission **`manage_delivery_locations`** → Manager + SuperUser + Admin (Manager-accessible, **not** admin-only, per the issue). - Admin screen at **`/admin/delivery-locations`**: searchable table + Add/Edit dialogs + activate/deactivate + delete (mirrors `/admin/sites`). Sidebar link under **Administration**. ## PO forms - The three forms (new / edit / manager-edit) render a shared `<DeliveryLocationField>` — a native `<select name="placeOfDelivery">` populated from the **active** locations, each formatted `"Company — address"` (`lib/delivery-location.ts`). ## Design choice — snapshot, not FK `PurchaseOrder.placeOfDelivery` stays a **free-text snapshot**. The dropdown only changes how the value is *picked*, so: - the **export**, **import**, and **historical/imported** POs are untouched; - editing a PO whose current value isn't in the active list **preserves it** as a leading "(current)" option (no silent data loss); - **deleting** a location is always safe — no PO references it. ## Tests - `delivery-locations.test.ts`: create/update/toggle/delete + the `manage_delivery_locations` guard (6 tests). - Full integration suite green (248), `tsc --noEmit` clean. ## Deploy note Adds migration `20260624130000_delivery_locations` → run `prisma migrate deploy`. Applied to the local dev DB already. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
shad0w added 1 commit 2026-06-23 20:39:18 +00:00
feat(po): admin-managed delivery locations + Place of Delivery dropdown (#19)
All checks were successful
PR checks / checks (pull_request) Successful in 42s
PR checks / integration (pull_request) Successful in 30s
5aae45299b
Replaces the free-text "Place of Delivery" with a dropdown sourced from a new
admin-managed Delivery Locations list (each = a Company FK + free-text address).

- schema + migration: new DeliveryLocation model (companyId, address, isActive).
- permission: manage_delivery_locations granted to Manager + SuperUser + Admin
  (Manager-accessible, not admin-only, per the issue).
- admin screen /admin/delivery-locations: table + Add/Edit dialogs +
  activate/deactivate + delete (mirrors /admin/sites); sidebar link under
  Administration for Manager/SuperUser/Admin.
- PO forms (new / edit / manager-edit): shared <DeliveryLocationField> native
  select populated from active locations, formatted "Company — address".
- PurchaseOrder.placeOfDelivery stays a free-text SNAPSHOT (no FK) — the dropdown
  only changes how the value is picked, so export/import/historical POs are
  unchanged, and an edit preserves a current value not in the list as a
  "(current)" option. Deleting a location is therefore always safe.
- tests: delivery-location CRUD + permission guard (6).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
shad0w added 1 commit 2026-06-23 20:43:26 +00:00
Merge branch 'master' into feat/delivery-locations
All checks were successful
PR checks / checks (pull_request) Successful in 44s
PR checks / integration (pull_request) Successful in 31s
dc9ab327b8
shad0w merged commit 144d44ccca into master 2026-06-23 20:43:57 +00:00
Sign in to join this conversation.
No description provided.