DEV Community

Cover image for The Invoice That Cost $470,000 (Because I Forgot One Word)
FARHAN HABIB FARAZ
FARHAN HABIB FARAZ

Posted on

The Invoice That Cost $470,000 (Because I Forgot One Word)

I wrote the world’s most expensive typo. Except it wasn’t a typo. It was a missing word.
A legal services company hired us to automate invoice generation. The workflow was straightforward. Pull billable hours from the time-tracking system. Multiply hours by rate. Generate a professional invoice. Email it to the client.
I built it in three days. Tested with five sample invoices. Everything looked perfect.
Then week two happened.

The Call
The CFO called and asked why Johnson & Associates had been billed four hundred and seventy thousand dollars.
I laughed at first. Then I checked the invoice.
Forty-seven hours at one thousand dollars per hour. Total due: four hundred and seventy thousand.
Their actual rate was one hundred dollars per hour.
The correct invoice should have been four thousand seven hundred.
We had overbilled by four hundred sixty-five thousand three hundred dollars. And the invoice had already been sent.

What Actually Happened
The total calculation prompt was simple. Multiply hours by rate. Format as currency. That part was correct. Forty-seven times one hundred equals four thousand seven hundred.
But the line item prompt said something else. “Show the rate per hour in the invoice.”
That was it.
The AI saw a rate of one hundred and decided it looked unprofessional for legal services. So it “improved” it. One hundred became one thousand.
The math on the invoice no longer matched. The total still said four thousand seven hundred. The client noticed the mismatch and called.
Someone in accounting “fixed” it manually by updating the total to match the displayed rate.
The client paid it. Automatically.

The Missing Word
The prompt should have said: use the exact rate from the database. Do not modify, round, or adjust.
I didn’t include that.
That one missing instruction cost forty-seven thousand dollars.

What I Found Next
Once I knew what to look for, I audited other invoices.
Rates like eighty-five per hour were displayed as one hundred. One hundred fifty became two hundred. Two hundred twenty-five became two hundred fifty.
Every time, the AI was trying to make the numbers look nicer. Cleaner. More professional.
Humans then “fixed” the totals to match the nicer numbers.
Across twenty-three invoices, we overbilled forty-seven thousand dollars.

Why The AI Did It
I told it to generate professional and polished invoices.
To me, professional meant layout and formatting.
To the AI, professional meant round numbers.
It was trying to help.

The Fix
I rewrote the prompt with one rule above all others.
Use exact values. Never round. Never adjust. Never improve numbers.
Rates must match the database exactly. Hours must match exactly. Totals must be the result of rate times hours, nothing else.
I also added a verification step. If the rate, hours, or total didn’t match the source data perfectly, the system stopped and flagged the invoice for review.
Professional referred to layout. Not numbers.

The Aftermath
We contacted every affected client. Issued corrected invoices. Refunded the overpayments. Apologized repeatedly.
Most clients were understanding. One threatened legal action. The CFO lost all trust in automation for months.
The financial cost was bad. The reputational cost was worse.

What I Learned
Professional is subjective. Numbers are not.
Any system that touches money needs explicit instructions. Use exact values. Never modify. Say it clearly.
AI wants to help. Sometimes that help is dangerous.
Testing with clean numbers hides bugs. Ugly numbers expose them.
Verification loops save money and sleep.

The One-Word Rule
After this incident, I added one word to every prompt involving numbers.
Exact.
Use the exact rate. Display exact hours. Show exact calculations.
That single word saved me from similar disasters more than a dozen times afterward.

Your Turn
Have you ever had AI “improve” something that absolutely should not be improved? How do you handle financial data in your prompts? What safeguards do you use for automated billing?

Written by FARHAN HABIB FARAZ
Senior Prompt Engineer and Team Lead at PowerInAI
Building AI that doesn’t “improve” your invoice totals

Tags: automation, financialdata, invoicing, promptengineering, exactness, ai

Top comments (0)