Two Invoices, One Number: Allocate Invoice Numbers From the Log, Not a Cell
A Google Sheets invoice template does one job well: it prints. The header, the line items, the four formulas at the bottom. The automation people bolt on afterwards reads the invoice number out of cell B4 , exports the sheet as a PDF, emails it, and appends a row to a Log tab: const invoiceNo = sheet . getRange ( ' B4 ' ). getValue (); // ... export, email ... ss . getSheetByName ( ' Log ' ).…
Two invoices issued under the same number can cause confusion and lost payments. A Google Sheets invoice template automatically generates invoice numbers from cell B4 and logs them in a Log tab, but this approach has flaws. When the script reads the value from cell B4, it doesn't claim it, leaving a gap between reading the number and appending it to the log.
If the script crashes during this process, the server won't record the invoice, leaving the client without a record and potentially causing payment issues. Moreover, most VAT and sales tax systems require invoice numbers to form a continuous sequence, which is impossible with a cell-based system. To avoid these problems, allocate invoice numbers from the Log tab instead of a cell.
The Log tab holds every issued invoice number, making it a reliable source for generating the next number. This pure function can be tested outside the spreadsheet, ensuring consistent invoicing.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.