Commit Graph

5023 Commits

Author SHA1 Message Date
marshal
8bd8955ac5 Merge pull request #1432 from Tria-plc/staging
Staging
2026-08-27 14:24:54 +03:00
marshal
09ae1276c9 Merge pull request #1431 from Tria-plc/dev
dev
2026-08-27 14:18:04 +03:00
marshal
041c165d6c Merge pull request #1430 from Tria-plc/freight_feature/usermanagement
feat: simplify dispatch logic by removing manual loading checks and u…
2026-08-27 14:17:27 +03:00
Marshal
1626903192 feat: simplify dispatch logic by removing manual loading checks and updating related comments 2026-08-27 11:16:43 +00:00
Nathnael Wondisha
81334258d3 Merge pull request #1429 from Tria-plc/freight/nati-2
Freight/nati 2
2026-08-27 12:40:16 +03:00
Nathnael
3af3017b86 feat(backoffice): add an Account tab with the customer's portal logins
The detail page showed the company's business contact details but not the
credentials anyone actually signs in with, and the two drift apart
routinely — so "the customer says they can't log in" was unanswerable
from this screen.

Adds `GET /backoffice/customers/:companyId/accounts`, joining each
external profile to its IAM account, primary contact first. Deliberately
not filtered to active accounts: a suspended or never-activated login is
exactly the case being looked into. The user query selects columns
explicitly — the entity's relations include credentials and sessions, and
this response reaches a browser.

Rendered as cards rather than a table: it is a handful of rows of
mostly-optional fields, which a table renders as a field of dashes.
"Password never set" is called out on its own, being the usual answer to
"they never got in", and a profile whose IAM user is gone reads as a red
fault rather than an inactive status.
2026-08-27 09:30:24 +00:00
Nathnael
f8e8897f5c feat(backoffice): search customers by trade name and licence, filter by role
Staff search with whatever is in front of them. Company name, TIN, email
and profile reference already matched; a TIN's licence number and the
trade name of the business a role operates as did not, which is most of
what appears on a customer's own paperwork.

Adds a Role filter alongside it. Distinct from the existing Type pill:
that is the company's own kind, this asks "who does X?" — one `customer`
company routinely holds importer and exporter at once.

Both are EXISTS subqueries rather than constraints on the joined
`companyProfiles` alias. Filtering the join would drop the company's
other profiles from the loaded entity, so an importer-and-exporter would
render as importer-only.
2026-08-27 09:30:12 +00:00
Nathnael
a48d77aff8 feat(backoffice): show each role's eTrade business on the customer detail page
The reviewer approving a role had no way to see which business it claims
to operate as, so there was nothing to check the uploaded licence
document against. The Role profiles table now carries a column with the
trade name, the licensed activity (does it actually cover this role?),
the licence number (the only unambiguous handle — trade names repeat
across a TIN's licences) and the renewal date.

A role with nothing attached reads as a yellow "Not attached" rather than
a blank: it is a review finding. Yellow, not red, because a co-operative
or investment-licence company legitimately has none.

Two fixes alongside it:

- The profile reference was already rendered but is minted only on
  approval, so every pending role drew an empty line. It now says so.
- `TableCard` gained an optional header section, so padding sits per
  section and the table runs edge to edge. The header stays outside the
  scroll region — inside, a title slides away from its own table.
2026-08-27 09:29:41 +00:00
Nathnael
ab5e7e6db6 feat(billing): show the buyer's trade name on invoice documents
An invoice is billed to one company profile, and that profile's eTrade
licence is usually a different business from the one the company
registered under — so the buyer's name alone does not say which business
was billed.

Both document paths gain a row: the shared invoice/receipt model reads it
off the already-loaded `companyProfile` relation, and the warehouse fee
invoice joins `company_profiles` through the booking.

`sameCompanyName` suppresses the row when it merely repeats the buyer
name, which is the common case. It compares loosely because eTrade spells
one legal suffix three ways (PLC / P L C / PRIVATE LIMITED COMPANY) and
pads names with double spaces; it decides whether a row is worth printing
and nothing else.

The EIMS buyer `LegalName` is deliberately untouched — a MoR filing
carries the registered entity, same rule as the seller side.
2026-08-27 09:29:25 +00:00
Nathnael
604710bd25 feat(companies): attach an eTrade business to each company profile
A TIN holds many business licences split by activity — export of coffee,
freight forwarding, import of vehicles — but the company picked one for
its whole record, so every operational role shared it. Each profile now
names the business it actually operates as.

Stored on `company_profiles.etrade_business` as a snapshot (licence
number, trade name, activity, renewal) rather than a bare licence number,
so the portal and backoffice can show it without an eTrade round-trip —
that API is slow, serves a broken TLS chain and is regularly down. Not
unique: one business may legitimately back several roles.

The licence number is a client input, so it is never stored as sent —
`ETradeService.findBusinessOption` looks it up under the company's own
TIN and persists eTrade's record, which makes another company's licence
simply unfindable.

Choosing one is required wherever the customer adds a role with a TIN
already on file. The onboarding wizard is the exception by necessity: it
picks roles on its first step, before a TIN exists, so there is nothing
to choose from yet. There it is enforced through
`getOnboardingRequirements` instead — an unattached role is reported
outstanding and blocks submission — and the picker sits on the documents
step beside that role's licence upload.

Lifted entirely for a co-operative or investment-licence company: eTrade
holds no record for its TIN, so the requirement would be unsatisfiable.
2026-08-27 09:29:15 +00:00
Nathnael
1f5e6296b1 feat(etrade): take the selected licence's trade name as the company name
A TIN routinely trades under a name that is not its registered one, and
holds several licences with different trade names — of 58 TINs checked
against eTrade, 8 had at least one licence whose trade name differs from
the registered `BusinessName`, one of them across three licences.

`extractRegistrationData` now resolves `companyName` from the selected
licence's `TradeName`, falling back to `BusinessName` (16 of 309 licences
carry a blank trade name, so the fallback is load-bearing).

EIMS is pinned back to `BusinessName` for the seller's `LegalName`: an
invoice is a MoR tax filing and must carry the legal entity, not the
trade name. It is the only other caller.
2026-08-27 09:28:52 +00:00
Abubeker Yasin
689fc11355 Merge pull request #1428 from Tria-plc/alpha
feat(auth): stage passenger sign-in on a single identifier field
2026-08-27 11:41:48 +03:00
Abubeker Yasin
979053ea4f feat(auth): stage passenger sign-in on a single identifier field 2026-08-27 11:37:54 +03:00
marshal
14484d9d2a Merge pull request #1427 from Tria-plc/staging
Staging
2026-08-27 10:55:35 +03:00
marshal
29a0dc0db5 Merge pull request #1426 from Tria-plc/dev
dev
2026-08-27 10:55:02 +03:00
marshal
93cd3fc93f Merge pull request #1425 from Tria-plc/freight_feature/usermanagement
tracking ui
2026-08-27 10:49:18 +03:00
Marshal
065bdd0189 tracking ui 2026-08-27 07:45:32 +00:00
Nathnael Wondisha
edbe95a2cb Merge pull request #1424 from Tria-plc/dev
dev
2026-08-27 08:32:48 +03:00
Nathnael Wondisha
2cd1cea001 Merge pull request #1423 from Tria-plc/freight/nati-2
Freight/nati 2
2026-08-27 08:27:47 +03:00
Nathnael Wondisha
a3b29b2792 Merge pull request #1422 from Tria-plc/freight_feature/usermanagement
feat: refine loading window validation and improve error messaging fo…
2026-08-27 08:26:44 +03:00
Nathnael
4abb2af880 Merge branch 'dev' into freight/nati-2 2026-08-27 05:25:43 +00:00
Nathnael
3a7e16a746 fix(reports): stop finance reports dropping general-contract revenue
Every revenue report excluded invoices whose booking carries
contract_kind = 'GENERAL', on the premise that such a booking is an
umbrella contract row paid once and drawn down by many orders, so
counting it alongside those orders would double-count.

That premise does not hold. On the dev database all 169 GENERAL
bookings are real shipments with origin and destination yards, warehouse
receipts and their own invoices; there is no umbrella invoice to
double-count, and no invoice source of that kind exists at all. The
predicate simply deleted 119 invoices and ETB 164.6M of billed revenue
from every Finance report, which is why revenue-by-customer reported
ETB 39.4M collected while /billing/invoices/summary reported ETB 140.1M
- a gap of exactly ETB 100,741,976, the paid total of the 80 PAID
invoices the predicate hid.

Removing it from the shared revenue and invoice ledgers brings the
reports back in line with billing (ETB 210.6M billed, ETB 140.1M paid,
163 invoices), and removing it from the overview repository restores the
same bookings to the operational KPIs.

Also fixes what that exposed in the reports that build their own query:

- GATEWAY_PAID read the booking's whole gateway total onto every invoice
  sharing that booking. With 25 booking ids backing 58 invoices, the
  reconciliation report claimed ETB 113.2M of receipts against ETB 43.6M
  of settlement and showed ~ETB 89.4M of variance that does not exist.
  Receipts are now apportioned across an invoice's siblings by settled
  share, so the gateway column sums to the payments table and total
  variance is the real ETB 13.1M of manual settlements.
- Aging Receivables joined companies with an INNER JOIN, dropping
  shipping-line-billed arrears, and summed both currencies under a
  hardcoded ETB label. Both payer joins are now LEFT and the report
  takes a currency filter.
- Invoicing Pipeline summed ETB and USD invoices into one ETB total and
  applied no trade-direction scope, unlike every other Finance report.
  Both are now applied.

Verified against the shared dev database: every new statement passes
EXPLAIN, and the report totals reconcile with billing and with
freight.payments. Type-check and the reports and overview suites pass;
the five failures in billing.service.spec.ts are pre-existing on this
branch and untouched by this change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-27 05:22:37 +00:00
Marshal
d9017df730 feat: refine loading window validation and improve error messaging for dispatching 2026-08-27 03:26:44 +00:00
marshal
a1a59f0f7c Merge pull request #1421 from Tria-plc/dev
dev
2026-08-27 05:56:19 +03:00
marshal
3f353e52b8 Merge pull request #1420 from Tria-plc/freight_feature/usermanagement
feat: enhance station work logging with user display names and improv…
2026-08-27 05:30:58 +03:00
Marshal
6ec3c8c5e0 feat: enhance station work logging with user display names and improve loading/unloading logic 2026-08-27 02:29:50 +00:00
Hagernesh Tadesse
2b377a9724 Merge pull request #1419 from Tria-plc/credit-invoice
feat(train-scheduling): show coupled/uncoupled wagons on intercity ma…
2026-08-26 22:06:26 +03:00
Hagernesh
42ae6b9752 feat(train-scheduling): show coupled/uncoupled wagons on intercity marshalling doc
Marshalling 2 rendered only the final consist after a mid-corridor
adjustScheduleConsist call, with no signal that anything changed.
Reuses the existing ScheduleWagonAdjustmentLog (already recording
every ADD/REMOVE/SWITCH) filtered to the printed stop's yard and to
ADD/SWITCH, and prints a Consist changed at this stop box. Origin
import/export docs are untouched — the option is only passed from
intercityMarshallingDocument.
2026-08-26 19:00:43 +00:00
Hagernesh Tadesse
d08096e1c9 Merge pull request #1418 from Tria-plc/credit-invoice
fix(train-scheduling): marshalling docs respect mid-corridor wagon co…
2026-08-26 11:32:54 +03:00
Hagernesh
69062389c7 fix(train-scheduling): marshalling docs respect mid-corridor wagon coupling
Origin marshalling (import + export) now prints leg slots as
TO BE LOADED AT <board yard> with board/alight stations and keeps
their containers out of the loaded tallies. Intercity Marshalling 2 no
longer hides whole-route cargo whose allocation never left PLANNED
(import flow confirms loading at schedule level), so the on-board view
matches the physical consist before and after mid-corridor coupling.
2026-08-26 08:30:38 +00:00
marshal
81237606bd Merge pull request #1404 from Tria-plc/staging
Staging
2026-08-26 01:29:45 +03:00
marshal
90d9852a4d Merge pull request #1417 from Tria-plc/dev
dev
2026-08-26 01:08:42 +03:00
marshal
1205e2cdc1 Merge pull request #1416 from Tria-plc/freight_feature/usermanagement
Freight feature/usermanagement
2026-08-26 01:07:22 +03:00
Marshal
058535d648 Merge branch 'staging' of github.com:Tria-plc/edr-platform into freight_feature/usermanagement 2026-08-25 22:05:57 +00:00
marshal
bcc5daa137 Merge pull request #1415 from Tria-plc/freight_feature/usermanagement
feat: implement MANUAL_ONLY status for bookings and update related logic
2026-08-26 01:02:18 +03:00
Marshal
29371b0b39 feat: implement MANUAL_ONLY status for bookings and update related logic 2026-08-25 22:01:03 +00:00
marshal
1459e646f6 Merge pull request #1414 from Tria-plc/freight_feature/usermanagement
feat: enhance train scheduling and contract management features
2026-08-26 00:46:17 +03:00
Marshal
b926a3116e feat: enhance train scheduling and contract management features
- Added StationWorkControls to manage loading/unloading phases in TrainScheduleV2DetailPage.
- Implemented API endpoints for recording station work and managing wagon detach requests.
- Updated contract templates to include Ethiopian customs handling options.
- Enhanced shipment forms to collect customs clearing agent details for without-customs bookings.
- Introduced NUMBER_OF_WAGONS as a unit of measure for bulk cargo, allowing customers to specify wagon counts.
- Improved validation for customs clearing agent information in shipment forms.
- Updated various components and services to accommodate new features and ensure data integrity.
2026-08-25 21:44:21 +00:00
Nathnael Wondisha
731e4dd2d0 Merge pull request #1413 from Tria-plc/freight/nati-2
Freight/nati 2
2026-08-25 16:08:52 +03:00
Nathnael
8adbb05479 Merge branch 'dev' into freight/nati-2 2026-08-25 13:07:09 +00:00
Nathnael
08aba3fb4d fix 2026-08-25 13:05:55 +00:00
Nathnael
ac325a6282 feat(reports): report charged vs actual volume in revenue categories
Four changes the business asked for on Charged and Actual Volumes:

- Split the Leg column into From and To, both sortable.
- Add 20ft and 40ft container counts beside TEU, off the marshalling
  record's container items.
- Classify cargo into the revenue vocabulary rather than the operational
  one, so a corridor's tonnage and its revenue read in the same buckets.
  Charge-only buckets (incidental, first/last mile, customs) cannot be
  emitted — no physical wagon is one.
- Carry the empty wagons as rows of their own, the way the marshalling
  document lists them. `allocationLedgerQb` gains `includeEmptyWagons`,
  which starts the ledger from the wagon instead of the allocation; the
  empty and total wagon counts become plain group aggregates, so a
  departure's wagons now add up down its rows instead of every row
  repeating the train's total. Vehicle-Km lands on the empty rows and
  sums across legs.

`LOADED_WAGONS_EXPR` gains a FILTER on the allocation being present — a
no-op for every allocation-grain report, and the fix at the one place
all of them route through. `SCHEDULE_EMPTY_WAGONS` had no callers left
and is deleted.

Verified: type-check clean, 50 report specs pass (incl. a new one
asserting the cargo expression only emits keys the revenue vocabulary
offers), and the report SQL EXPLAINs and runs against edr_dev — 60 empty
wagons over 4 rows, 53,539 Vehicle-Km, 20ft/40ft counts populating.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-25 13:05:18 +00:00
Nathnael
6d1e4a630e feat(reports): publish per-stop times when loading & unloading groups by train
Grouped by Train, a row was a period average over the train's stops, which
threw away the one thing that grain is for: when the work actually happened.
The row is now the stop itself — logged arrival, departure, unloading and
loading times, and that stop's own durations. Grouped by Station it still
averages over every train that called there.

The two shapes need different columns, so `ReportColumn.hideWhen` names the
filter values that hide a column, and the runner resolves sort against the
visible set — sorting by an average and then switching to Train falls back to
the default sort instead of a 42703 on a column the query no longer selects.
`ReportFilterDef.defaultValue` pins the unset grain to `train`, so "no value"
is never a third shape. The table, the export field list and the chart toggle
all follow the visible set; the chart is station-grain only, since per-stop
rows have nothing to bar-chart.

Both grains EXPLAIN-validated and run against the dev database.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-25 13:01:47 +00:00
Nathnael
01ea05f013 fix(auth): keep secondary positions in permission checks
IAM lets an employee hold several positions, but the vendored JwtGuard
collapses employee.positions[] down to a single employee.position and
drops the rest. Non-delegate secondary positions vanished entirely, so
staff on two posts resolved to one post's permissions and every check
on the other rejected them.

FreightJwtGuard re-attaches the full list from the same session
snapshot the parent guard already read, so nothing extra is fetched
per request beyond a cached session lookup. employee.position is left
untouched, keeping audit logging and delegation unaffected.
collectPermissionKeys and collectPositionTypeKeys now union across
every position, and /me returns them all.

Verified against a real two-position user (djibouti-gl-director +
djibouti-gl-chief) on the local dev database:

  /me positions                     1   -> 2
  /me permissionKeys                17  -> 28
  GET /api/interchange-documents    403 -> 200
  GET /api/trains                   403 -> 200

11 permissions recovered, none lost. Six single-position users return
byte-identical payloads before and after.
2026-08-25 12:00:43 +00:00
marshal
a4e9466915 Merge pull request #1412 from Tria-plc/freight_feature/usermanagement
feat: enhance booking and audit log functionalities
2026-08-25 02:50:34 +03:00
Marshal
d5a5085d6d feat: enhance booking and audit log functionalities
- Implemented read-only locking for customer-requested container sizes and billing currency in the GlCreateBookingForm component.
- Added functionality to lock partner quantities based on shipment requests in the ConsolidationPartnerPanel.
- Introduced a new Leave action in the LogPassYardWorkModal to unassign bookings from trains.
- Enhanced the AuditLogsPage to support filtering by action and added a Go button for direct navigation to entity detail pages.
- Updated WagonCancellationsPage to handle odd-20ft credits requiring partner selection during rebooking.
- Improved TrainScheduleV2DetailPage to allow manual loading of cargo and display warnings for unassigned bookings.
- Added a new reference field to the audit logs for better searchability and tracking of actions.
- Created a migration to add the reference column to the audit logs table and established an index for efficient querying.
- Defined a registry for audit reference sources to streamline the retrieval of human identifiers for various entities.
2026-08-24 23:49:20 +00:00
Roba Boru
5c2100e76d Fix passenger list alignment 2026-08-24 18:14:10 +03:00
Roba Boru
1abfbc1ceb Merge branch 'main' of https://github.com/Tria-plc/edr-platform into feature/group-booking 2026-08-24 18:05:42 +03:00
Roba Boru
2037e8bf30 Merge branch 'dev' of https://github.com/Tria-plc/edr-platform into feature/group-booking 2026-08-24 18:05:21 +03:00
Roba Boru
a5385e1462 Added group booking option 2026-08-24 18:04:13 +03:00