Billing: invoices, approval, receipts, statements, licence changes (1.7.0)

- Invoices drafted 14 days before each licence's invoice date and emailed
  to the alert email for approval; approved ones go out on their date from
  08:00 SA time. Drafts can be edited, recalculated, sent early, put back
  to draft or voided; one-off invoices too.
- Annual tier review from the 12-month event-income band; approving a tier
  change emails a notice of licence change, applied when the invoice goes out.
  Notices can also be sent by hand.
- Founding churches (35% off as its own line), payments with receipts,
  statements for any dates.
- Every billing email is styled HTML with a PDF (invoice / tax invoice,
  receipt, statement, licence change) and logged per customer.
- Settings -> Billing: business and bank details, VAT (off: plain invoices;
  on: VAT-inclusive tax invoices), timing and numbering.
- Migration 20261103111645_invoicing; pdfkit 0.17.2; tests/billing.test.js;
  scripts/sample-billing-pdfs.js.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-03 13:42:45 +02:00
co-authored by Claude Opus 5.5
parent cc7d62690b
commit 6fce0fe90e
33 changed files with 3579 additions and 53 deletions
+31
View File
@@ -37,6 +37,37 @@ const DEFAULTS = {
ai_usd_zar: '',
// Default markup on the real cost, in %; a licence can override it.
ai_markup_percent: '40',
// Billing (1.7.0, utils/billing/). Drafts are made billing_draft_days before an invoice's date
// and emailed to alert_email for approval; approved invoices go out on their date at
// billing_send_hour (South African time).
billing_enabled: 'true',
billing_draft_days: '14',
billing_send_hour: '8',
payment_terms_days: '7',
invoice_prefix: 'INV',
receipt_prefix: 'REC',
change_prefix: 'LC',
// Printed on every document.
business_name: 'Cross Code',
business_owner: 'Joshua Oosthuizen',
business_address: '44 Gordon Road, Henley on Klip, Gauteng, South Africa',
business_email: 'admin@crosscode.co.za',
business_phone: '+27 68 903 8075',
business_website: 'crosscode.co.za',
business_registration: '',
// Not VAT registered: no VAT on documents. Once registered, prices are VAT-inclusive: the
// totals stay the same, documents become tax invoices and show the VAT included.
vat_registered: '',
vat_number: '',
vat_rate: '15',
bank_name: '',
bank_account_name: '',
bank_account_number: '',
bank_branch_code: '',
bank_account_type: '',
invoice_footer: 'Thank you for using Cross Events.',
// Replies to billing emails go here (blank: business_email).
billing_reply_to: '',
};
// Stored encrypted and never sent to the browser: only "is one saved" (<key>_set).