feat(warehouses): enforce yard/zone capacity limits; broaden dispatcher perms

Yard create/update now rejects capacities that overflow the parent warehouse,
and zone create/update rejects capacities that overflow the parent yard, via
BadRequestException. Dispatcher permission preset expanded to full CRUD on
warehouse and fleet management; allocation and fee rules remain view-only.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hagernesh
2026-07-22 11:59:36 +00:00
parent 09ac88f01d
commit 59f06a9bd1
3 changed files with 123 additions and 35 deletions

View File

@@ -808,41 +808,41 @@ export const POSITION_PERMISSION_PRESETS = {
// permission catalog (all CRUD across bookings, contracts, scheduling,
// fleet, warehouse, mile, finance, settings, staff).
operationsChief: dedupe([...BOOKING_RULE_ENGINE_PERMISSION_KEYS]),
// Dispatcher: warehouse floor operations — receive/GRN, move, load/unload,
// inspect, dispatch, gate, release/deliver, interchange docs, fee invoices,
// plus truck dispatch on the mile legs and read-only operational context.
// Allocation & fee rules are VIEW-ONLY — never create/update/delete.
// Dispatcher: full CRUD on warehouse management (incl. import/export/intercity
// inventory flows) and fleet management, plus truck dispatch on the mile legs
// and operational context. The ONE carve-out: allocation & fee rules stay
// VIEW-ONLY — a dispatcher never creates/updates/deletes those rules.
dispatcher: dedupe([
// Warehouse management — full CRUD.
FREIGHT_PERMS.warehouseDashboard.view,
FREIGHT_PERMS.warehouses.view,
FREIGHT_PERMS.warehouseYards.view,
FREIGHT_PERMS.warehouseZones.view,
FREIGHT_PERMS.warehouseInventory.view,
FREIGHT_PERMS.warehouseInventory.receive,
FREIGHT_PERMS.warehouseInventory.move,
FREIGHT_PERMS.warehouseInventory.load,
FREIGHT_PERMS.warehouseInventory.unload,
FREIGHT_PERMS.warehouseInventory.dispatch,
FREIGHT_PERMS.warehouseInventory.gatePass,
FREIGHT_PERMS.warehouseInventory.release,
FREIGHT_PERMS.warehouseInventory.deliver,
FREIGHT_PERMS.warehouseInventory.inspect,
FREIGHT_PERMS.warehouseInspectionReports.view,
FREIGHT_PERMS.warehouseInspectionReports.create,
FREIGHT_PERMS.warehouseInspectionReports.update,
FREIGHT_PERMS.interchangeDocuments.view,
FREIGHT_PERMS.interchangeDocuments.generate,
FREIGHT_PERMS.interchangeDocuments.acknowledge,
FREIGHT_PERMS.warehouseFeeInvoices.view,
FREIGHT_PERMS.warehouseFeeInvoices.generate,
...Object.values(FREIGHT_PERMS.warehouses),
...Object.values(FREIGHT_PERMS.warehouseYards),
...Object.values(FREIGHT_PERMS.warehouseZones),
...Object.values(FREIGHT_PERMS.warehouseInventory),
...Object.values(FREIGHT_PERMS.warehouseInspectionReports),
...Object.values(FREIGHT_PERMS.interchangeDocuments),
...Object.values(FREIGHT_PERMS.warehouseFeeInvoices),
// View-only on the rules that govern allocation and fees.
FREIGHT_PERMS.warehouseAllocationRules.view,
FREIGHT_PERMS.warehouseFeeRules.view,
// Fleet management — full CRUD.
...Object.values(FREIGHT_PERMS.fleet),
FREIGHT_PERMS.fleetDashboard.view,
...Object.values(FREIGHT_PERMS.fleetReports),
...Object.values(FREIGHT_PERMS.vehicles),
...Object.values(FREIGHT_PERMS.drivers),
...Object.values(FREIGHT_PERMS.tracking),
...Object.values(FREIGHT_PERMS.fuel),
...Object.values(FREIGHT_PERMS.maintenance),
...Object.values(FREIGHT_PERMS.locomotives),
...Object.values(FREIGHT_PERMS.wagons),
...Object.values(FREIGHT_PERMS.trains),
...Object.values(FREIGHT_PERMS.routes),
...Object.values(FREIGHT_PERMS.containers),
...Object.values(FREIGHT_PERMS.cargoes),
// Truck dispatch on the EDR mile legs + operational context.
FREIGHT_PERMS.firstMile.view,
FREIGHT_PERMS.firstMile.assignVehicles,
FREIGHT_PERMS.lastMile.view,
FREIGHT_PERMS.lastMile.assignVehicles,
...Object.values(FREIGHT_PERMS.firstMile),
...Object.values(FREIGHT_PERMS.lastMile),
FREIGHT_PERMS.trainScheduling.view,
FREIGHT_PERMS.bookings.operations,
]),