All posts

Profit per container: matching invoices to supplier bills in Zoho Books

How I built a profit-per-container report for a UAE trucking company on Zoho Books: the container number as the trip key, why it isn't unique, the check digit that catches typos, and the matching rules that make the numbers honest.

· Zoho · Automation · Client Work

A UAE container trucking company had a question their accounts couldn’t answer: which containers actually make money?

Every trip has two pieces of paper. A customer invoice (what the customer owes the company) and a supplier bill (what the company owes the truck owner who did the job). The difference is the profit. Simple. Except that in Zoho Books, nothing connected the two. The invoice said “Transportation charges” with a container number typed in the description. The bill was entered separately, by someone else, days later. On thin trucking margins, not knowing profit per trip is not a reporting gap. It’s flying blind.

Here’s how we connected them, and what the data taught us on day one.

The trip key: the container number (almost)

Every trip already has a natural ID painted on the side of the box: the container number, like ZZZU4829170 (an example, not a real box). It’s on the port slip, the invoice and the supplier bill. So we use it as the key.

But it isn’t unique on its own, for two reasons:

  1. Containers come back. A shipping line’s box moves through the same port again next month for another customer. Same number, different trip.
  2. One trip, two slips. The truck leaves the port with the container and later returns it empty. Both slips show the same number. That’s two documents, one trip.

If you mark the container number as a unique field in Zoho, the second trip gets blocked. So the rule is: the container number identifies the box; the container number plus the date (or the booking number) identifies the trip. In the matching script, each invoice container pairs with the nearest-dated bill for the same container, within 45 days.

What the real invoices looked like

Before writing any code, I read a sample of real invoices through Zoho. Three patterns:

  • Container and route in the description: the route (port to depot), then the container number on the next line.
  • Many containers on one line: a quantity of ten or more at one rate, with all the container numbers stacked in the description.
  • Extras on their own lines: toll charges with no container number at all.

And one pattern I didn’t expect: typos. One invoice had a container number with ten characters instead of eleven. Another had a full eleven, but one digit was wrong. Neither would ever match a supplier bill.

The check digit that catches typos

Container numbers follow ISO 6346: three letters for the owner, a category letter (usually U), six serial digits, and a final check digit. That last digit is calculated from the other ten characters:

  1. Each letter gets a value (A = 10, B = 12, … skipping multiples of 11), and each digit keeps its own value.
  2. Multiply each of the ten values by 2 to the power of its position (1, 2, 4, 8, …).
  3. Add them up, take the remainder when divided by 11, and then the last digit of that.

The result must equal the eleventh character. So ZZZU4829170 passes, ZZZU4829171 fails, and ZZZU482917 (a digit missing) doesn’t even have the right shape. The script runs this check on everything that looks like a container number, so typos land on an Issues list with the invoice number, instead of silently becoming “unmatched”.

The matching rules

These are the decisions that make the numbers honest:

  • One container per occurrence. A line with 10 containers becomes 10 rows. Each gets the per-unit amount (line total ÷ quantity), so if one of the 10 numbers is a typo, the other 9 still get the per-container rate (say AED 1,000 each), not an inflated share.
  • Extras are shared. Tolls, tokens and waiting charges without a container number are split evenly across the containers on the same invoice or bill. Profit per container then means the real trip, not just the haulage line.
  • Nearest date wins. An invoice container pairs with the closest-dated bill for the same container within 45 days. Suppliers often bill late, so bills are fetched 45 days either side of the period.
  • No cost isn’t zero cost. An invoice container with no matching bill shows as “No cost found (own truck or bill missing)”. It is never counted as pure profit.
  • Read-only. The script only reads from Zoho through the API. It never writes.

What comes out

One Excel file per month with five sheets:

SheetWhat it answers
SummaryContainers invoiced, how many matched a bill, revenue, cost, profit and margin
Per containerEvery container: customer, route, supplier, revenue, cost, profit, margin %. Loss-making and low-margin rows at the top, highlighted
By customerWhich customers are profitable once cost is counted, not just which ones are big
By supplierAverage cost per container by truck supplier
IssuesTypos, invoices with no container, quantity that doesn’t match the containers written, bills with no invoice, and the same container billed twice within a week

The Issues sheet is the part I’d show an owner first. Every row is a concrete thing to fix, with the document number.

Fix the data entry, not just the report

A script that reads free-text descriptions works, and it’s the right first step because it needs no change to how anyone works. But the lasting fix is in Zoho itself:

  • A line-item custom field “Container No” on invoices and bills, so the number has its own box instead of living in the description.
  • One line per container. No more thirteen numbers stacked on one line.
  • Use route items. The company already had route items (port to a named depot) with a sale and a purchase rate set up. Staff were picking a generic “Transportation charges” item instead. With route items, every line carries an expected margin, and any deviation can be flagged automatically.
  • Tag trip costs. Tolls paid as expenses should carry the container number too, so they land on the right trip.

What I’d tell any trucking or logistics owner

You probably already have everything needed to know your profit per trip. It’s in your invoices and your supplier bills, typed by your own staff. It just isn’t connected. Connecting it doesn’t need a new ERP. It needs one shared key, a check that catches typos, and honest rules for the messy cases.

Start with the report on the data you have. Let the Issues list show you where data entry breaks. Then fix the entry, and the report gets sharper every month.

This project started with connecting Zoho Books to Claude safely, and you can read the full case study. If your margins live in Zoho Books and you can’t see them per job, let’s talk.

Frequently asked questions

How do I calculate profit per container in Zoho Books?

Write the container number on both sides of each trip: the customer invoice line (revenue) and the supplier bill line (cost). A script or report then pairs the two by container number and date, and subtracts cost from revenue for each container.

Is a container number a unique ID for a trip?

Not on its own. Shipping lines reuse containers, so the same number comes back on later jobs, and one trip often produces two documents with the same number. Pair by container number plus date, or container plus booking number.

How do you catch typos in container numbers?

Use the ISO 6346 check digit. The last digit of a container number is calculated from the other ten characters, so a mistyped or missing digit almost always fails the check and can be flagged before it breaks a match.

Can Zoho Books store a container number per invoice line?

Yes, with a line-item custom field on invoices and bills. Put one container per line, so an invoice with 10 containers has 10 lines, each with its own container number, rate and amount.

What about trucks the company owns?

Own trucks have no supplier bill, so their trips show as 'no cost found'. Give them a standard cost per trip, or a separate report, so they don't look 100% profitable.

Published Nov 8, 2026

All posts