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