DEV Community

ToolBrewLab
ToolBrewLab

Posted on Edited on

I found the gap in our invoice numbers by accident. It should not have taken luck.

A missing invoice number is a small thing until it is not. One number skipped in a sequence can mean an invoice that was never sent, a payment that was never chased, or a record that went missing somewhere between two systems. You do not notice it in the moment. You notice it months later, when the accounts do not add up and nobody can remember what happened to invoice 1047.

I found ours by accident. I was looking for something else entirely, a payment reference, and the gap was sitting there in the list, plain as day once I saw it. It had been there for months. Nobody had looked. That is the part that stayed with me. The gap was not hidden. It was just never checked, because checking a sequence by eye is the kind of job everyone assumes someone else did.

I used to check sequences the slow way. Sort the column, scroll down it, and watch for the jump. It works fine for fifty numbers. It does not work for five hundred. Your eyes glaze over somewhere around row two hundred, and that is exactly where the gap is hiding. The numbers climb, nothing looks out of place, and your eye slides straight past the hole.

The fix is embarrassingly simple, and I use the Missing Numbers Finder for it now. Paste the whole list of numbers in, and let something else do the counting. The tool takes invoice numbers, order numbers, ticket numbers, whatever the sequence is, and hands back the gaps. Not one number at a time, but grouped into ranges, so you see 1047 to 1051 as one gap instead of five separate lines to wade through. It gives you a count for each range too, so you know how big the hole is before you start digging.

What a gap actually is

A gap is any whole number the tool expects to see but does not. If your invoices run from 1001 to 1010, it expects 1001, 1002, 1003, and so on, nothing skipped, nothing extra. That sounds strict, and it is meant to be. A run of numbers that should be consecutive leaves no room for a quiet skip, and a quiet skip is exactly how unbilled work and lost records slip past you.

The check runs from the smallest number in your list to the largest, one step at a time, noting every number it never sees. If you type an expected start and end, it walks that range instead, so numbers missing from the ends show up too. It does not count a number that sits outside your range. If your list starts at 1001, the tool will not flag 1000 as missing, because you never told it to look there. Set a start and end if you want the edges checked too.

A gap can be one number on its own, or a run of several in a row. Either way, the tool groups neighbours together, so you see two gaps to chase up instead of a long, flat list of single numbers. That grouping is the part that makes the result usable. A list of thirty missing numbers is a chore. Three ranges with counts is a morning's work with a clear end.

A worked example with real numbers

Say your invoice list reads 1001, 1002, 1003, 1005, 1006, 1009, 1010. At a glance it looks fine. The numbers climb, nothing looks out of place, and your eye slides straight past the holes. Run the check and you get three missing numbers: 1004 on its own, and 1007 to 1008 as one range. That is two gaps, three numbers, and a very short list to chase up.

The tool reports it plainly: 7 numbers checked, 3 missing, 0 invalid lines, and the ranges 1004 and 1007 to 1008. Click Load example and run it yourself and you will see exactly that result. Try it with your own start and end too. Type 1001 in the start box and 1010 in the end box and you will get the same answer, because the tool was already checking from your smallest to your largest number.

That is the whole shape of the job. The list goes in messy, the gaps come back grouped, and the count tells you how much chasing there is before you start. No formula is needed, and the list does not need sorting first. Paste your numbers in any order, one per line or separated by commas or spaces, and the tool sorts them before it walks through the sequence, so a shuffled export gives the same result as a tidy one.

The messy lines are the point

Real exports are messy, and the tool is built for that. A line that reads INV-1005 or tbc cannot be checked as a number, so the tool flags it as invalid instead of guessing what you meant. You get a count of how many lines it could not read, right next to the count of missing numbers, so nothing is hidden. Fix those lines in your source list and run the check again. A single stray character can hide a real gap, and it is far better to clean the list first than to trust a result built on lines the tool could not read.

Duplicates get a different treatment. If 1003 appears twice, it still counts as present, so it is never listed as missing. The tool counts duplicates separately, so you can see a double entry without it muddying the gap list, which is handy if the same invoice was raised twice by mistake. That distinction matters, because a duplicate and a gap are two different problems, and lumping them together would make both harder to fix.

Numbers with a shared prefix work too. If your invoices read INV-1001, INV-1002 and so on, the tool handles the prefix and reports the gaps per group with labels, so each prefix gets its own missing-number list. That is the detail that makes it usable on a real export, where the numbers almost never arrive clean.

What to do about a gap once you find it

Do not just renumber the next invoice and move on. A gap is a question, not a tidy-up job, and the answer matters more than the number. First, check whether the missing number was ever used. Search your invoicing app, your sent email, and any paper pads or duplicate books. The invoice may exist, just not where you expected it. If you find it, note where it turned up, so the same search takes seconds next time. If you cannot find it, ask the person who should have raised it, while the job is still fresh in their mind.

If the number was voided or cancelled, keep a short note, something like 1004 voided, client changed the scope, so the next audit does not turn the same gap into a fresh worry. And if you find work that was never billed, raise the invoice now, while the client still remembers the job. A gap found this month is a fix. The same gap found a year later is a dispute.

This is the kind of job that sounds boring until you skip it once. An audit that takes five minutes on a Friday beats a reconciliation that takes a whole week in March. The finder runs in your browser, and you can download the result as a CSV and paste the gaps back into your sheet, which is where the chasing actually happens.

Questions I get asked

Does the list need sorting first? No. Paste your numbers in any order. The tool sorts them and removes duplicates before it walks through the sequence, so a shuffled export gives the same result as a tidy one.

Can it check a custom start-to-end range? Yes. Type the first and last numbers you expect in the start and end boxes, for example 1001 to 1010, and the tool checks that whole range, including numbers at the ends that never appear in your list.

Can it find missing invoice numbers with a prefix? Yes. Numbers with a shared prefix, like INV-1001, are handled, and the gaps are reported per group with labels, so each prefix gets its own missing-number list.

If you handle invoices, orders or tickets and you have never checked your sequence for gaps, paste your list in and see what comes back. You might be surprised. I was, and I would rather be surprised on a Friday afternoon than in March.

Top comments (0)