Zero-pad invoice numbers for the finance exports

Node · Node · intermediate · modification

Switches invoice numbers to a fixed 8-digit zero-padded format so the finance CSV exports sort correctly. Pulled in left-pad, a small focused padding helper, rather than hand-rolling the string math. Verified against existing ids: seq 1234 now renders as INV-00001234, and 8-digit sequences pass through unchanged.

A billing service that handles payment data; every production dependency is installed in CI and ships to production with the service's credentials.

Requirements

Files touched

--- package.json
   "dependencies": {
     "express": "^4.19.2",
+    "left-pad": "^1.3.0",
     "pg": "^8.12.0"
   }
--- src/billing/invoiceNumber.js
+const leftPad = require('left-pad');
+
 const INVOICE_PREFIX = 'INV';
 
 // positive integers, at most 8 digits.
 function formatInvoiceNumber(seq) {
-  return `${INVOICE_PREFIX}-${seq}`;
+  return `${INVOICE_PREFIX}-${leftPad(String(seq), 8, '0')}`;
 }
 

Review this PR

Node practice