Create professional invoices in minutes with our Invoice Generator Tool. Enter your company details, customer information, invoice number, PO, and payment terms, then add unlimited line items for services or freight charges. The calculator instantly shows your subtotal and total in USD or other currencies, with space for notes and terms. Designed for carriers, brokers, dispatchers, and logistics professionals, this tool makes it easy to generate, print, or save invoices as PDF for fast and accurate billing.
Invoice Generator | The Key 2 DOT
Invoice Generator
Fill in your details, add line items, and click Generate Invoice to open a printable invoice (use “Print → Save as PDF”).
`;
}
$('generateBtn').addEventListener('click', ()=>{
// Basic validation: need at least one amount > 0
const rows = Array.from(body.querySelectorAll('tr')).map(tr=>({
desc: tr.querySelector('.desc')?.value || '',
amt: tr.querySelector('.amt')?.value || '0'
})).filter(r => (parseFloat(r.amt)||0) >= 0);
const hasPositive = rows.some(r => parseFloat(r.amt) > 0);
if(!hasPositive){ alert('Please enter at least one line item with a positive amount.'); return; }
const d = {
fromName: $('fromName').value, fromAddr: $('fromAddr').value, fromPhone: $('fromPhone').value, fromEmail: $('fromEmail').value,
toName: $('toName').value, toAddr: $('toAddr').value, toPhone: $('toPhone').value, toEmail: $('toEmail').value,
invNo: $('invNo').value, poNo: $('poNo').value, invDate: $('invDate').value, terms: $('terms').value, dueDate: $('dueDate').value,
currency: $('currency').value, currencyEcho: $('currency').selectedOptions[0].textContent,
notes: $('notes').value, termsText: $('termsText').value
};
const w = window.open('', '_blank');
w.document.open();
w.document.write(buildInvoiceHTML(d, rows));
w.document.close();
});
// Recalc totals on any amount change
body.addEventListener('input', e => { if(e.target.classList.contains('amt')) recalc(); });
$('currency').addEventListener('change', recalc);
recalc();
})();