On October 2, 2026, I printed four reports from one customer's account, all for the same month, and laid them side by side. They should have told one story. They told three.
The sales invoices report included three canceled invoices in its total. The sales report showed a table of 10 invoices when the month had 44. I typed my message to the AI assistant with more anger than I usually allow myself: reports must show all the invoices for the selected period, not the last 50. We had said it many times. We had found the same "last 50" problem back in May, fixed it in some reports, and it had quietly survived in others.
A report is a promise. It says: this is what happened in your business between these two dates. Owners use it to pay taxes, pay commissions and decide what to buy. A report wrong by 5% is worse than no report, because people act on it.
The short answer
Reports show wrong totals when they add up rows in the app instead of in the database. Fix it with five rules: fetch the full period from the server, show canceled records but never add them into totals, do every sum inside a database function, give each metric one formula in one place, and ship PDF and Excel export with every report. The silent 1,000-row limit of Supabase's standard API is the most common cause.
Rule 1 and 3: The full period, summed in the database
Many list screens load 50 rows at a time, because loading 10,000 invoices to show the first screen is slow. That is fine for a list and a disaster for a total. In May 2026 we found the web reports showed only the last 50 invoices. The invoices list loaded 50 at a time, and the web sales, purchases, customers and suppliers reports had been built by reusing that list and adding up whatever it held. The bigger the customer, the bigger the lie. The fix was a database function that calculates totals, counts, the daily chart and top customers for the whole period and returns them in one answer.
Think of a librarian who can carry 1,000 books per trip. Ask how many books the library has and she brings one cart, so you count 1,000 every time. A bigger cart is not the fix. Ask her to count inside the library and bring back one number. Supabase's standard API, called PostgREST, returns at most 1,000 rows per request, silently, with no error. A database function (Supabase calls them RPCs, remote procedure calls) does the sum where the data lives.
In June, a customer's trial balance came out unbalanced. The financial statements code fetched journal lines and added them up in the app. The customer had 1,273 lines, so the last 273 were silently cut off. The next day another customer saw 983 of their 1,576 products. In July it was the branch report. In August it was worse: an import feature built its list of products that already exist from a query that only saw the first 1,000, treated everything after that as new, and created 603 duplicate products. The limit was no longer hiding numbers; it was writing wrong data. Even code that asked for 10,000 rows did not help, because the server applies its maximum anyway.
The way we proved the import bug is worth copying. We numbered the existing products in creation order and compared the duplicate rate inside the first 1,000 with the rate after it: 1.6% inside, 95% after. A sixty-fold jump at exactly row 1,000 is not a coincidence. It is a limit.
A quick way to spot this without reading code: look at the record counter on the screen. If it says exactly 50 or exactly 1,000, that is not your number of records. It is the size of a limit.
Rule 2: Canceled is shown, never summed
In accounting you never delete an invoice, you cancel it. A canceled invoice must still appear in lists and statements, clearly marked, so the history is honest, but it must not be added into any total. In June, web reports counted canceled invoices in totals and "top customers", and a customer whose only invoice was canceled showed up as a best customer. In August we found ten live database functions still counting canceled invoices, from shift totals to a sales rep's settlement.
Decide report by report whether you are counting documents or counting money. We deliberately left four functions alone, such as one that reports card sales per bank by following real money movements. If the money moved, that report must show it.
There is also a database trap here. A condition like "status is not canceled" sounds safe. But if the status is empty (NULL, meaning no value), the database answers "unknown", not "true", and rows with an unknown answer are dropped. A perfectly valid invoice with an empty status silently falls out of the report. The root fix was two lines: the status column can no longer be empty and defaults to "unpaid". That made 36 fragile checks in 25 functions safe at once, including any check written tomorrow.
Rule 4: One metric, one source
In September a customer sent a voice note: check the warehouse totals, I don't trust them. Her stock quantities were correct. What shook her trust was that "inventory value" showed different numbers on three screens. We had built accurate costing, valuing each batch at what it really cost, and used it on one screen only. The fix put the formula in the database once and made every screen call it. On one screen the summary card used the selling price while the table below used the purchase price. When you audit, check every number separately.
Another customer saw the sales report and the top-selling products report disagree. The product report added line totals, and line totals do not include a discount applied to the whole invoice. We spread each invoice discount across its lines in proportion to value, then checked 12,222 invoices: zero mismatches. Some differences are intentional, such as gross sales versus sales net of returns. That is fine if the screen says so. Unexplained differences destroy trust; explained ones do not.
Rule 5: Export is part of finished
In July I asked for Excel and PDF export on every report. The assistant checked: 19 reports, and only one had any export. We built one shared export helper so any new report gets export in about three lines. Twice afterward a new report shipped without export, because the written task never mentioned it. Now it is a standing rule in the assistant's memory.
Three export traps: export from the server, not from the 50 rows on screen; write real Excel files, because CSV files open with every column squeezed into one on computers whose list separator is a semicolon; and check printed tables in your language, since right-to-left text can mirror.
Key takeaways
- A list may be partial; a total may not. Never build a report on a list screen's loaded rows.
- The 1,000-row limit is silent. Do the sum inside the database and return one number.
- Canceled invoices stay visible and stay out of totals, but decide per report whether you count documents or money.
- One metric needs one formula in one place.
- A report is not finished until it can leave the screen.
Chapter 18 of the book has the full checklist and the exercise with 1,100 test invoices.
Frequently asked questions
Why does my Supabase query return only 1,000 rows?
Supabase's standard API (PostgREST) has a default maximum of 1,000 rows per request and does not raise an error when it cuts the result. Asking for a bigger range does not override it. For totals, use a database function that sums inside the database and returns one number.
Should canceled invoices appear in reports?
They should appear in lists and statements, clearly marked, so the history is honest. They should not be included in totals. For reports about actual money movements, follow the money instead of the document status.
How do I make two screens show the same number?
Write the formula once as a database function and make every screen, export and printout call it. Two copies of a formula will drift apart, and customers stop trusting both screens when they disagree.