Commit Graph

1050 Commits

Author SHA1 Message Date
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
Marshal
ed3c8307bb refactor(train-scheduling): rename and restructure container movement logic 2026-07-21 23:49:10 +00:00
marshal
d683f6da9c Merge pull request #891 from Tria-plc/freight_feature/usermanagement
feat(user-management): implement staff reference permissions for vari…
2026-07-22 02:29:55 +03:00
Marshal
d25612c2f0 feat(user-management): implement staff reference permissions for various controllers and update sidebar permissions 2026-07-21 23:25:43 +00:00
marshal
8927f38bfe Merge pull request #890 from Tria-plc/freight_feature/usermanagement
Freight feature/usermanagement
2026-07-22 02:17:00 +03:00
Marshal
835c9e111c feat(train-scheduling): implement container movement between wagons
- Added functionality to move containers between wagons in the train scheduling system.
- Introduced  API endpoint and service method to handle container movement.
- Updated  component to support drag-and-drop for rearranging containers.
- Enhanced  to allow moving containers to other wagons via a context menu.
- Implemented UI feedback for container movement actions, including loading states and success/error notifications.
- Updated relevant types and constants to accommodate new container movement logic.
- Added tests for the rule engine to ensure proper handling of hazardous bookings.
2026-07-21 23:02:06 +00:00
Hagernesh
b54cb2483e Card called GET /warehouse-inventory (staff perm) → 403 swallowed as
empty state. New customer-safe bookings/:id/location endpoint returns
location fields only; card now uses it.
2026-07-21 14:15:56 +00:00
Hagernesh
89d82f45c6 fix padding on portal 2026-07-21 14:01:10 +00:00
Hagernesh
61e59036cd Browser testing for modern teams
Create tests, debug failures, and improve quality faster than ever. Get AI-powered guidance at every stage of testing, with full code ownership, on a platform that connects your team.
2026-07-21 12:57:37 +00:00
Hagernesh
9da48bd61a fix 2026-07-21 12:57:37 +00:00
marshal
ca8a7602ef Merge pull request #876 from Tria-plc/freight_feature/usermanagement
changes
2026-07-21 15:15:19 +03:00
Marshal
07c390a3b2 changes 2026-07-21 12:14:47 +00:00
Hagernesh
7566c57ed9 feat(warehouses): per-truck EDR handover signing with auto-delivery on completion
EDR truck gate-out now generates a per-truck handover (new
edr_assignment_id link) and notifies the customer to sign from the
portal. New sign endpoint delivers the signed truck's containers; last
signature auto-delivers remaining inventory, frees trucks and completes
the booking via import.handover.completed. Adds gate-in truck-arrival
notification and per-truck handover PDFs.
2026-07-21 11:55:18 +00:00
Hagernesh
86569f7490 Customer portal card displays warehouse location data (warehouse/yard/zone + arrival time) once cargo arrives at warehouse. Shows loading state during fetch, placeholder text if not yet received. Type-check passes. 2026-07-21 11:55:18 +00:00
Hagernesh
1fae0752a0 Ticket: Warehouse dashboard Needs Attention cards — fix trucks-on-site aging counters (EDR trucks, UNLOADED status) and make each card open the exact list behind its count via new inventory drill-down filters. 2026-07-21 11:03:40 +00:00
Hagernesh
b616f520ae feat(fleet): validate vehicle plate numbers against a letters-and-digits format
Plate, power-plate and trailer accepted any free text — a vehicle could be
saved with a plate of "assadasd". They must be letters, a hyphen, then digits,
like ET-9875 or AA-8642.

The server now enforces it on CreateVehicleDto (and UpdateVehicleDto via
PartialType): each plate is trimmed and upper-cased, then matched against
^[A-Z]{2,3}-\d{2,6}$, so "et-9875" is accepted and stored as ET-9875 while an
empty optional trailer/power plate still passes.

The fleet form gains the same check inline: FleetFormFieldDef takes an optional
pattern, the dialog tests it on submit against the upper-cased value, and the
vehicle config points plate and trailer at a regex that mirrors the server's.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-21 11:03:40 +00:00
Marshal
9ca4075c1e Implement intercity document handling and rejection notes for contracts 2026-07-21 10:39:21 +00:00
Marshal
6f8456631c Implement intercity document handling and rejection notes for contracts 2026-07-21 10:20:36 +00:00
Marshal
ceb32e0a80 Implement intercity document handling and rejection notes for contracts 2026-07-21 10:15:18 +00:00
Marshal
603537a20b add yard distances management to rule engine
- Introduced new yard distances resource with CRUD operations.
- Created migration for yard distances table with necessary constraints.
- Implemented service and repository for yard distances handling.
- Added controller for API endpoints to manage yard distances.
- Updated rule engine configuration to include yard distances.
- Enhanced rule engine resource page to support yard distance selection.
- Updated contracts and train builder pages to handle new yard distance logic.
- Added error handling utility for better error message extraction.
2026-07-21 08:50:50 +00:00
Hagernesh
2397c6bca4 fix(warehouse): show assigned trucks on the Trucks on Site page, not only arrived ones
The page filtered on arrived_at IS NOT NULL, so a truck appeared only once the
warehouse receive flow stamped its arrival. Assigned trucks that had not yet
reached the yard were invisible, which left the page empty whenever nothing had
been received — every assigned truck was missing.

It now lists every truck assigned to a booking that has not departed, from both
haulage paths, tagged INBOUND (assigned, not yet arrived) or ON_SITE (arrived).
A scope toggle filters between them, dwell time shows only once a truck has
actually arrived, and the KPI count on the dashboard stays strict (arrived only).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-21 08:24:39 +00:00
Hagernesh
1fe8c2fd8e feat(export): gate receive on payment and loading on received + GRN
Three export rules that the flow left open.

An unpaid export booking could be received at the warehouse. Receiving is
what starts storage and mints a GRN, so it must not happen against cargo the
customer has not settled. receive() now rejects an unpaid EXPORT booking.
Import is untouched — it arrives OFF a train and its receive is the unload,
so gating that on payment would strand cargo already at the yard.

An allocated export booking could be marked loaded onto its train without
ever reaching the warehouse. An allocation is a plan; the GRN is the proof
the goods are in hand. Two loading paths skipped that check — the per-yard
loadBooking and the workspace confirmScheduleLoading — and both now require
every export booking to be received with a GRN first, however it arrived
(first-mile or the customer's own truck) and whatever it is allocated to.
The rule lives in one shared guard (assertExportReceivedWithGrn) so the two
paths cannot drift.

Export self-haul without a first-mile leg already worked and is unchanged:
assertSelfHaulPaid allows a customer truck when there is no EDR mile leg and
the booking is paid, and addTruck applies the same one-40ft-or-two-20ft rule
to containers and the tonnage drawdown to bulk, exactly as import does.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-21 08:01:32 +00:00
Nathnael
af171974f8 Merge branch 'dev' into freight/feat/fixes-v1 2026-07-21 07:36:09 +00:00
Nathnael
fd5aedcec7 feat(companies): per-document change requests and resubmission review queue
Two review-workflow gaps for freight customer onboarding:

Request for change per document. Backoffice can now flag a single uploaded
document (company document, profile licence, or POA delegation letter) with a
note the customer sees, instead of rejecting the whole role over it. Adds
review_status/review_note/reviewed_by/reviewed_at to freight.files (migration
AddFileReviewStatus, partial index for the gate), a POST
documents/:fileId/request-change endpoint, the backoffice action + modal, and a
portal banner/badge so the customer knows what to re-upload. Re-uploading clears
the flag. Approving a role is blocked while any of its documents has an open
correction; the gate check and the status write share a pessimistic write lock
on the company row (as does the change-request write) so a correction can never
slip in between the check and the profile going Active.

Resubmission is visible to reviewers. When a customer resubmits a rejected role
or amends a change request, backoffice staff are notified (allBackoffice inbox
item, deep-linked to the customer) and the resubmission surfaces in a new
"Pending changes" list view + KPI, since such companies are status = active and
never matched the pending-approval filter.
2026-07-21 07:34:40 +00:00
Hagernesh
36f0045b5d auto generate grn on import arrival unloading 2026-07-21 07:25:45 +00:00
marshal
0a73b8edb5 Merge pull request #847 from Tria-plc/freight_feature/usermanagement
chnages
2026-07-20 20:52:57 +03:00
Marshal
26f73cbe5f chnages 2026-07-20 13:55:26 +00:00
Hagernesh
0c0de284b0 feat(warehouse): show the trucks in the yard, not just a count of them
Multi-truck self-haul had no list anywhere on the warehouse side. The ops
dashboard counted trucks on site and offered no way to open the list, and
the inventory table showed a blank plate on exactly the bookings that have
several trucks: it read booking.customer_truck_plate_number, which
multi-truck self-haul leaves null because plates live in
customer_truck_assignments. Booking BK-2026-000033 has a truck and a driver
on file and displayed neither.

Adds a Trucks on Site page listing every truck that has arrived and not yet
departed, across bookings, with plate, driver, booking, customer, containers
and dwell time. It covers both haulage paths because the gate does — a
customer's own truck and an EDR last-mile truck reach the same barrier — and
flags anything sitting over four hours. It lives under Warehouse Management
rather than Imports or Exports, since the yard is not per-direction.

The inventory queries now read plates and drivers from the assignments and
keep the booking columns as the fallback for single-truck bookings written
before that table existed.

Both new statements were EXPLAIN-validated against the live schema; the
plate fix returns the data that was previously null.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-20 12:54:10 +00:00
marshal
b9b2075207 Merge pull request #837 from Tria-plc/freight_feature/usermanagement
contrat nad booking modification
2026-07-20 15:25:51 +03:00
Marshal
b90afadfba contrat nad booking modification 2026-07-20 12:24:58 +00:00
Nathnael
804c72f14a Merge branch 'dev' into freight/feat/fixes-v1 2026-07-20 12:12:30 +00:00
Nathnael
0549a88d57 feat: otp double sending 2026-07-20 12:10:49 +00:00
Hagernesh
c8a70593cf fix(mile): apply one truck-load rule to customer and EDR haulage alike
A truck holds one 40ft or two 20ft, a container booking takes no more trucks
than it has containers, and a bulk booking takes trucks until its tonnage is
hauled away. The same physics whoever drives, but the rule was written out
four times — addTruck, updateTruck, departTruck and LastMileService — beside
a byte-identical container-size query. Copies drift: that is how the
self-haul guard ended up enforced on one side only.

The bulk cap was the real gap. EDR summed net_weight_tons of departed trucks
and refused another once the booking was drawn down. The customer side had
no cap at all: for bulk it skipped straight past every check, so a self-haul
bulk booking could take unlimited trucks.

It could not simply reuse the EDR sum. customer_truck_assignments had no net
and no tare, only a gross_weight_kg that holds tonnes despite its name and
that nothing in the live flow ever wrote — release() recorded exit weights
against the EDR table alone, which is why all five customer trucks on dev
have neither weight nor departure. Any drawdown keyed on it would have
summed zero forever and never fired.

So the customer table now carries tare_weight_tons and net_weight_tons to
match the EDR one, release() records the customer truck's exit as it already
did for EDR, and the drawdown counts both sources — a booking hauls by one
path or the other and "until no tonnage is left" means the same either way.

Also locks a load once its truck has arrived on the EDR side, which the
customer side has always done, and fills the arrival form from the customer
truck on file: the prefill read booking.customer_truck_*, which multi-truck
self-haul leaves null, so a booking with a truck assigned opened blank.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-20 11:41:57 +00:00
Marshal
540f4a1ff6 changes 2026-07-20 11:41:57 +00:00
Marshal
0727de0f4d Refactor clearance terminology to document approval across services and UI components 2026-07-20 11:41:57 +00:00
Nathnael
38bccaccf9 fix: normalized the region and logged the otp properly 2026-07-20 11:41:57 +00:00
Nathnael
6cb921e617 fix: 194 and 183 plane takss 2026-07-20 11:41:57 +00:00
Nathnael
9fbe1c5236 feat: setup attachment to the freight chat 2026-07-20 11:41:57 +00:00
Nathnael
5bf82bf531 fix: notify the backoffice of new booking 2026-07-20 11:28:18 +00:00
Nathnael
6420c72e89 feat(auth): implement staff-triggered password-reset links 2026-07-20 11:20:50 +00:00
Marshal
eb532399d9 changes 2026-07-20 10:52:20 +00:00
Nathnael Wondisha
bed1208dee Merge pull request #833 from Tria-plc/freight/feat/fixes-v1
Freight/feat/fixes v1
2026-07-20 11:26:30 +03:00
Nathnael Wondisha
f41463748d Merge pull request #788 from Tria-plc/freight/feat/chat-app
Freight/feat/chat app added attachment
2026-07-20 11:23:16 +03:00
Nathnael
2c7a4b7112 Merge branch 'dev' into freight/feat/fixes-v1 2026-07-20 08:20:34 +00:00
Nathnael
a45e1008fa fix: normalized the region and logged the otp properly 2026-07-20 08:19:59 +00:00
Hagernesh
c1c362ab9d fix(mile): only send bookings that bought EDR haulage to the mile queues
The rule that a customer's own truck and an EDR road leg are alternatives
existed on the truck side only (CustomerTruckService.assertSelfHaulPaid).
LastMileService had no counterpart: create checked payment and nothing else,
so any paid booking could be accepted into the queue. A booking took a
customer truck at 06:42 and an EDR last-mile leg with a real EDR truck at
06:47, neither side aware of the other, on a contract that had chosen no
road legs at all.

The road legs are chosen on the contract and copied onto the booking, and
the pickup/delivery address is the only per-booking record of that choice.
service_types cannot serve: every type ships with includes_first_mile and
includes_last_mile set to true, so reading them would mean no booking could
ever self-haul. That same always-true flag had already killed the first-mile
guard, whose `address || serviceType.includesFirstMile` admitted every paid
export booking.

One shared rule now answers it for both sides, so the two halves cannot
drift apart again: last-mile create rejects a booking that chose no road
legs and one already carrying a customer truck; first-mile no longer honours
the service-type flag; the customer-truck guard reads the same helper.

Existing legs are untouched — the guards are on creation, so the one booking
already carrying both needs a human to reconcile it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-20 08:03:16 +00:00
Marshal
e22b336e8c Refactor clearance terminology to document approval across services and UI components 2026-07-20 07:46:38 +00:00
Nathnael
c7195f077a fix: 194 and 183 plane takss 2026-07-20 07:41:25 +00:00
Hagernesh
2906c6bb45 test(train-scheduling): cover the checkpoint backdating guard on the DTO
The IsNotBackdated validator was covered in isolation, but not on the DTO
that actually carries it. Asserts a backdated occurredAt is rejected, that
"now" passes, and that omitting the field still validates so the service can
stamp it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-20 07:13:52 +00:00
Hagernesh
536d6043c2 fix(clearance): allow customs risk to be corrected and keep the trail
RiskStep returned early to a badge as soon as a risk level existed, so the
control was unreachable and a mis-assigned level could never be corrected.
Both the server and the sibling AssignRiskCard treat risk as correctable
until duty is advised off it — completeWithMetadata has no already-completed
guard and overwrites metadata.riskLevel. RiskStep was stricter than either.

It now keeps the control mounted alongside the assigned badge, offers
"Reassign risk", and locks to badge-only once DUTY_TAXES_ADVISED completes.
The control also reads the persisted level (it was hardcoded to GREEN, so
unhiding it alone would have misreported the assignment), and the T1 gate is
skipped once a level exists, since risk cannot be assigned without a closed
T1 and stale T1 data must not hide the badge.

Correcting a level previously left no record of the old value, who changed
it, or when — thin ground for a customer-visible level that may be disputed.
assignRisk now appends each decision to metadata.riskHistory: the level, the
level it replaced, the timestamp, the user id, and a display name resolved
at assignment time so the trail shows a person rather than a UUID. riskLevel
still carries the current value and always equals the last entry, so
existing consumers are unchanged.

History lives on the existing metadata JSONB column, so no migration is
needed, and the logic sits in assignRisk rather than the shared
completeWithMetadata that adviseDuty and others also use. Re-picking the
level already in force is not recorded — it changed nothing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-20 07:13:52 +00:00