Projects

Carriers and cost control

Four carriers, one logic: the cheapest rate with every surcharge included, and an automatic check of every invoice.

Details

Year 2024 – 2026
Outcome Logistics cost as a share of sales, down 24%
Tools Node.js, Express, MongoDB, SOAP, REST, SFTP

How it works

  1. 1 Order destination, weight and number of parcels
  2. 2 Rates total price with fuel and extras
  3. 3 Carrier the cheapest one, picked automatically
  4. 4 Label plus tracking with normalized statuses
  5. 5 Invoice imported exactly as the carrier sends it
  6. 6 Comparator discrepancies ready to claim

Context

We ship to Spain, Portugal and the rest of Europe with several carriers, and each one works its own way: some over SOAP, others over REST or with SFTP files, each with its own tracking statuses and surcharges that change every month.

What I did

I maintain a Node.js and MongoDB middleware that creates labels for GLS, SEUR/DPD, UPS and Correos Express, the last one also for Portugal and PaqPunto pickup points. For each order it works out the total price with fuel and extras and goes with the cheapest; surcharges are changed from a screen, without touching code. Every carrier’s statuses are translated into a common one, so the rest of our systems don’t need to know who is carrying the parcel.

When invoices arrive, a comparator matches them against actual shipments by reference, postcode and weight, and sets aside what should be claimed. I took Correos Express from the first tests to production in July 2026, after two months working with them.

Outcome

Logistics cost as a share of sales went down by 24%. And the comparator finds claimable discrepancies on every monthly invoice.

What I learned

Creating labels is the easy part; understanding each carrier’s statuses is the hard one. One rule has saved me a lot of grief: a meaningful status is never overwritten with “unknown”. And rates are data, not code: if they change every month, you must be able to change them without a deploy.