Two Invoices, One Number: Allocate Invoice Numbers From the Log, Not a Cell
说明与用途
将单元格用作发票编号计数器会导致重复和日志缺失。通过从日志表生成编号,可确保唯一性、顺序和可审计性。
问题
Relying on a spreadsheet cell to hold the next invoice number causes duplicate numbers, missing log entries, and audit failures when the script runs concurrently or fails mid‑process.
结果
Duplicate invoice numbers are eliminated, log entries are always created, and the system meets audit requirements for sequential numbering.
工作流
- 1. Script reads the Log tab to find all issued numbers for the current prefix and year.
- 2. It determines the highest sequence number and increments it.
- 3. It formats the new number with leading zeros.
- 4. The script writes the new number to the sheet for display.
- 5. It proceeds to export the PDF, email, and append the new row to the Log with the generated number.
证据
The cell is the problem. B4 is a display: it shows the number the last person typed.
Flip the direction. The Log tab already holds every number you have issued, so let it hand out the next one.
- 记录日期: 2026-09-22T20:45:49.146Z