Commit Graph

1103 Commits

Author SHA1 Message Date
Nathnael
dcc94643d0 feat(companies): enforce customers:* permissions on customer endpoints
The customers:* keys were seeded and present in the backoffice constants but
enforced nowhere except reset-password. Customer CRUD sat behind the coarse
edr_freight_app:admin umbrella, and every company read endpoint was unguarded.

Two routes could not be gated on the route alone, because the authority they
need depends on the request BODY, not the path:

  - PATCH /companies/:id carries `status` (UpdateCompanyDto extends
    PartialType(CreateCompanyDto)), so it both edits fields and blacklists.
  - PATCH /company-profiles/:profileId/status is approve, reject, suspend and
    blacklist on one route.

Both now take a one-of route guard and assert per-status against a shared
STATUS_PERM map: approving/reactivating needs customers:verify, suspending or
blacklisting needs customers:deactivate. PATCH /companies/:id additionally
requires customers:update when any non-status field is present, so a caller
holding only deactivate cannot rename a company. The backoffice mirrors the
same map so no button is offered that the server would reject.

GET /companies/:companyId/documents is left authenticated-only with the split
in the handler: it is dual-audience. The portal reads its own documents during
onboarding, and the contract-request detail page (gated on contracts:view)
reads the applicant's. Gating it on customers:view alone would have 403'd
customers on their own documents and blanked the contract reviewer's panel.

The two by-company customer-view reads take a one-of guard for the same reason
— otherwise a staffer granted only customers:view gets a detail page whose tabs
403 individually.

Frontend: the customers routes were sidebar-filtered but not wrapped in
RequirePermission, so direct URL navigation rendered them for anyone.

Verified: freight-api type-check clean; backoffice type-check unchanged from
HEAD (pre-existing errors only); 25 tests pass across the companies and
freight-permission suites. Not exercised against a running API.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 13:48:42 +00:00
Nathnael
48f1d08faf Merge branch 'dev' into freight/feat/fixes-v1 2026-07-23 11:51:04 +00:00
Hagernesh
73f36fe46e Export interchange document — a generation error after Djibouti unloading failed the whole request and left the document missing until a manual rerun. Generation is now best-effort (unload never fails on paperwork) and reruns backfill the document. 2026-07-23 11:31:44 +00:00
marshal
4df17f36ce Merge pull request #935 from Tria-plc/freight_feature/usermanagement
changes
2026-07-23 14:07:03 +03:00
Marshal
13609f8d59 changes 2026-07-23 11:06:10 +00:00
ghost2023
eab6f54e98 fix: rm iam seeder 2026-07-23 11:43:46 +03:00
Hagernesh
fb1e4ffcb3 fix(maintenance): schema-qualify maintenance_intervals migration
createUniqueConstraint/createForeignKey used bare table names, which
resolve against the default schema (public) while the table was created
in freight — the migration failed on boot and rolled back every start.
Rewritten as idempotent schema-qualified SQL (unique index replaces the
constraint, FK inline on the column).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-23 08:18:33 +00:00
Hagernesh
f2f6ac616f KM-Based Maintenance Scheduling 2026-07-23 07:53:11 +00:00
Hagernesh
4abcc909af feat(warehouses): persist saved signature image on handover sign
Store the signer's saved-signature URL on booking_handovers (new
signature_image_url column) when a handover is signed — per-truck or
booking-level — so signed handover documents can render the actual
signature, matching the contract-signing flow.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-23 07:53:11 +00:00
Hagernesh
fa59ccfc95 feat: implement KM-based maintenance scheduling
Add maintenance intervals configuration to track maintenance by kilometers
driven. When a maintenance is marked COMPLETED, automatically calculate and
schedule the next maintenance based on interval + current odometer reading.

Features:
- MaintenanceInterval entity: stores KM/day intervals per vehicle & type
- scheduleNextMaintenance(): creates next SCHEDULED item after completion
- nextDueKm field: tracks when next maintenance is due (in kilometers)
- getDueBoard() queries already support KM-based tracking

Maintenance now "marches forward" based on distance driven, not just dates.
Each vehicle type can have different intervals (e.g., oil every 10k km, tires 50k km).

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-23 07:53:11 +00:00
Nathnael
cbff529e31 feat: rebuild the admin pages 2026-07-23 07:40:48 +00:00
marshal
b756ae2f1c Merge pull request #929 from Tria-plc/freight_feature/usermanagement
fix configratio
2026-07-23 09:50:49 +03:00
Marshal
8f143b2341 fix configratio 2026-07-23 06:48:03 +00:00
marshal
b43763ad39 Merge pull request #927 from Tria-plc/freight_feature/usermanagement
implement freight permissions for trains, wagons, and routes
2026-07-23 09:04:24 +03:00
Marshal
fd05655ecc implement freight permissions for trains, wagons, and routes 2026-07-23 06:03:43 +00:00
marshal
f5f41e0a5a Merge pull request #926 from Tria-plc/freight_feature/usermanagement
implement freight permissions for trains, wagons, and routes
2026-07-23 08:57:59 +03:00
Marshal
129a4d1d0a implement freight permissions for trains, wagons, and routes 2026-07-23 05:57:14 +00:00
marshal
edfd0a859d Merge pull request #925 from Tria-plc/freight_feature/usermanagement
add e2e test
2026-07-23 08:27:29 +03:00
Marshal
2481f43f1f add e2e test 2026-07-22 23:44:32 +00:00
marshal
091dd0bfa3 Merge pull request #923 from Tria-plc/freight_feature/usermanagement
Freight feature/usermanagement
2026-07-23 00:02:55 +03:00
Marshal
b0f561a935 Add end-to-end tests for import corridor flows
- Implement full train import journey with six container bookings filling a 54-wagon train.
- Create tests for split offer and rebooking scenarios, handling payment expiry and waiting list promotions.
- Add tests for handling waiting bookings expiration when the train is full.
- Implement tests for reopening booking windows after expired reservations.
- Seed database with necessary corridor data for import flows, including yards, container types, locomotives, and rates.
2026-07-22 21:02:17 +00:00
Marshal
5709801590 enhance shipment form and booking process 2026-07-22 17:25:01 +00:00
Hagernesh
15540f78e2 fix(portal): Table has no size prop in BulkTruckUploadModal 2026-07-22 14:11:58 +00:00
Hagernesh
ec066f3d29 Fix:
Added assertCapacity() checks before saving (matches single receive)
Added applyCapacityDelta() after save to increment counters
Now validates warehouse → yard → zone capacity hierarchy
Single receive already had both checks; bulk receive was gap.
2026-07-22 13:18:36 +00:00
marshal
a3037749b4 Merge pull request #912 from Tria-plc/freight_feature/usermanagement
Freight feature/usermanagement
2026-07-22 15:35:11 +03:00
Marshal
ef840241c0 permision 2026-07-22 12:34:08 +00:00
Marshal
5640c43eb1 permision 2026-07-22 12:33:57 +00:00
marshal
d1c67e4acd Merge pull request #911 from Tria-plc/freight_feature/usermanagement
changes
2026-07-22 15:21:25 +03:00
Marshal
410bfa5b2b changes 2026-07-22 12:19:51 +00:00
Hagernesh
8dc4dd585e feat(procurement): validate acquisition lease fields and enforce bulk-receive capacity
Reject lease start/end and monthly payment on PURCHASE acquisitions (create and
update, validated against the resulting record). Add asset_acquisitions.item_name
column + migration. Enforce warehouse/yard/zone capacity on bulk receive and apply
capacity-counter deltas on save. Adds acquisition-guard spec.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 12:15:47 +00:00
Hagernesh
59f06a9bd1 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>
2026-07-22 12:15:47 +00:00
marshal
4f0071894d Merge pull request #906 from Tria-plc/freight_feature/usermanagement
Freight feature/usermanagement
2026-07-22 13:58:28 +03:00
Hagernesh Tadesse
11437cfd35 Merge pull request #905 from Tria-plc/testfixes
Fixes
Download Excel template with instructions
Parse uploaded file, preview trucks
Validate container assignments (1x40ft OR 2x20ft per truck)
Commit bulk upload in one call
2026-07-22 13:54:59 +03:00
Marshal
996df4a7f8 chnages 2026-07-22 10:52:27 +00:00
Marshal
44cad7a52b changes 2026-07-22 10:50:36 +00:00
Nathnael Wondisha
0fb8eba4df Merge pull request #899 from Tria-plc/freight/feat/fixes-v1
Freight/feat/fixes v1
2026-07-22 11:02:11 +03:00
Nathnael
24c2ef5d65 fix: payement table 2026-07-22 08:01:54 +00:00
Hagernesh
7763d67ea8 feat: bulk upload for customer truck assignments
Add Excel template-based bulk upload for customer truck assignments
(self-haul + EDR). Supports up to 2x20ft or 1x40ft containers per truck.

API: POST /bookings/:id/customer-trucks/bulk accepts array of trucks.
Portal: DownloadTemplate → ParseExcel → PreviewUpload → Commit flow.
Validates truck load rules per booking container configuration.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-22 08:01:16 +00:00
Hagernesh
5395d4f346 Customer Name + Customer ID columns removed from the Export Marshalling Document 2026-07-22 08:01:15 +00:00
Nathnael
905bf75bce fix: test 2026-07-22 07:47:25 +00:00
Nathnael
1be6744f09 fix: test 2026-07-22 07:34:41 +00:00
Hagernesh
64b205a71e feat(seed): operations_chief and dispatcher freight positions
Operations Chief gets the full freight permission catalog (all CRUD).
Dispatcher gets warehouse floor operations — receive/GRN, load/unload,
inspect, dispatch, gate, release/deliver, interchange docs, fee
invoices, mile truck assignment — with allocation & fee rules view-only.
2026-07-22 07:25:52 +00:00
Hagernesh
19906b273e fix(operations): prefill booking context on single assign; enforce per-truck container loads
- single-row Assign vehicle uses the full single-record flow (details + containers)
- release() rejects exit containers not assigned to the departing truck
- weighing modal offers only the selected truck's assigned containers
2026-07-22 07:24:14 +00:00
Nathnael
179d6eea9e Merge branch 'dev' into freight/feat/fixes-v1 2026-07-22 07:20:08 +00:00
Nathnael
a5ab6fe5c1 chore: filter out safari phone as foreign 2026-07-22 07:18:07 +00:00
Hagernesh
fd3212f326 fix(warehouses): exit-paper truck weight from summed container VGM
Per-truck weight now sums the departing truck's container vgm_tons
(recorded net for bulk); weighed gross only as fallback.
2026-07-22 07:05:26 +00:00
Nathnael
82cb5508cc chore: rm the active company profile 2026-07-22 06:43:05 +00:00
marshal
31343282b3 Merge pull request #893 from Tria-plc/freight_feature/usermanagement
feat(freight-me): add position type lookup and enrich user profile wi…
2026-07-22 03:08:56 +03:00
Marshal
2524109f00 feat(freight-me): add position type lookup and enrich user profile with position type 2026-07-22 00:06:38 +00:00
marshal
03dfc2df09 Merge pull request #892 from Tria-plc/freight_feature/usermanagement
refactor(train-scheduling): rename and restructure container movement…
2026-07-22 02:49:59 +03:00