← Back to Podcast

Why finished jobs wait days for an invoice

The technician marks the job done, the manager approves it, and finance still cannot bill. Each of them is right about their own step in the process. The word that is wrong is "done": your system stores one flag where three different facts belong. The work is finished, the evidence is complete, and your finance team can act on it to send the invoice.

A woman in a navy work jacket stands on a rooftop among equipment units, holding a closed folder, a tool bag at her feet
You stop chasing paperwork to get paid.

Why one flag costs days

The flag hides what is missing. To bill, your finance team needs the customer's sign-off, the purchase order number, and a reason for any charge that differs from the work order. When one of them is missing, the job still shows complete, and nobody sees the gap until someone in finance asks for it. Until then, the invoice waits, and so does your cash.

Asking technicians to fill in everything before the job closes only moves the problem. They would need to know finance's rules for every job type and contract. Put those rules in the system instead, and have it show each requirement when the record is prepared.

One record, five named states

Give each job a single record that is always in exactly one of five states, and allow only the moves you list. Engineers call this a state machine. It differs from a status field with more options because each move carries its own rule about evidence and authority.

State diagram of a service job from done to cash. Work recorded moves to evidence checked when the customer's sign-off, the purchase order and any charge reason are attached; if one is missing, the job is held for an exception with one named owner, who resolves it and returns it to evidence checked. A person with authority approves the job for billing. The approved job is sent to finance with an idempotency key; a retry after a timeout reuses the same key and creates no second invoice. The job shows invoiced only after finance confirms that the invoice exists. Until then it stays approved for billing, in view and retried, not lost.
StateIt moves on whenWho acts
Work recordedEvidence attached, or an item is missingThe system
Evidence checkedA person with billing authority approvesThe approver
Held for an exceptionThe missing item is suppliedOne named owner
Approved for billingFinance confirms the invoice existsFinance
InvoicedIt stays; a correction links to itFinance

A job cannot be approved for billing until the sign-off, purchase order and any charge reason are attached. A job missing any of them is held for an exception, naming the missing item and one owner. Each move records who made it, when, and on what evidence. When an auditor asks why a job was billed, the record answers. A model can read technicians' notes and flag a charge that needs a reason; the state rules still decide if the job moves.

Time the four states on the main path and you see where your finished jobs wait; in this example, it is the approval queue.

Where it breaks: between systems

Your field system sends the approved job to finance and waits for a reply. The connection times out. Was the invoice created or not? The sender cannot know, so it sends the job again. If your finance system treats the second message as new, your customer gets two invoices. If the sender gives up instead, the job can go unbilled and nobody notices.

This is a known failure with a known fix. In 2012, Pat Helland wrote in ACM Queue that messages between systems do not have "crisp guarantees for delivery": they can get lost and, after a timeout, they are retried. So every step that changes something must be safe to run twice. The term is idempotence: doing it twice has the same effect as doing it once. His examples: sweeping a floor is idempotent, a withdrawal is not, and "[p]rocessing withdrawal XYZ ... if not already processed" is. Your invoice step should be the third kind.

An invoice step safe to repeat

The approved job travels with an idempotency key built from its job number, its version and the state it is moving to. Every retry reuses that same key, unchanged. Your finance system stores the key in the same step that creates the invoice, and accepts each key only once, so when the same message arrives again, even at the same moment, it creates nothing new and replies with the invoice it already made. The customer sees one invoice either way.

An IETF Internet-Draft, the Idempotency-Key header field, proposes the rule that separates a retry from a new request: a key "MUST NOT be reused" for a request with different contents. So a corrected job carries a new version, and with it a new key. It points back to the original invoice, so finance corrects that invoice under its own accounting rules instead of issuing a second, unrelated one. The job shows invoiced only after finance confirms that the invoice exists. Until then it stays approved for billing, in view and retried, not lost.

Three tests to see before go-live

You need not read the code to check this was built. Ask for three tests, run in front of you:

  1. Send the same approved job twice. Your customer gets just one invoice.
  2. Cut the connection after sending, then retry. Still a single invoice.
  3. Send a corrected job after the original. No new bill; it links to the invoice.

How you know it works

Measure the time a job spends in each state, not one average from done to invoice. The state where your jobs wait longest is the next thing to fix. Count the jobs billed twice and the jobs never billed as well. Both should be zero, and both are invisible in an average.

First steps this week

  1. Pull last month's jobs that finance sent back. Note what was missing from each.
  2. Name who could have supplied each item. That is the likely exception owner.
  3. Ask your integration owner two questions. One on no reply, one on a repeat.

If finance's system is silent, what does the sender do? And what does finance do when a job arrives twice? The answers show how many invoices a customer gets after a timeout today.

References

  1. Helland, P. Idempotence Is Not a Medical Condition. ACM Queue, 10(4), 2012; reprinted in Communications of the ACM, 55(5), 2012.
  2. Jena, J., & Dalal, S. The Idempotency-Key HTTP Header Field. IETF Internet-Draft, draft-ietf-httpapi-idempotency-key-header-07, 2025-10-15.

NEXT · TO PRODUCTION

Plan the first step.

Fifteen minutes with Omar.