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:
@@ -25,12 +25,17 @@ async function smtpConfigured() {
|
||||
return !!(await smtpSettings()).host;
|
||||
}
|
||||
|
||||
/** Send an email; without SMTP it's logged instead (development). */
|
||||
async function sendMail({ to, subject, text }) {
|
||||
/**
|
||||
* Send an email; without SMTP it's logged instead (development). Billing emails (1.7.0) add
|
||||
* `html`, `attachments` (nodemailer's: { filename, content, contentType, cid? }), `replyTo` and
|
||||
* `fromName` (shown as the sender's name).
|
||||
*/
|
||||
async function sendMail({ to, subject, text, html, attachments, replyTo, fromName }) {
|
||||
if (!to) return;
|
||||
const smtp = await smtpSettings();
|
||||
if (!smtp.host) {
|
||||
console.info(`[mail] (SMTP not set up) to=${to} subject="${subject}"\n${text}`);
|
||||
const files = (attachments || []).filter(a => !a.cid).map(a => a.filename).join(', ');
|
||||
console.info(`[mail] (SMTP not set up) to=${to} subject="${subject}"${files ? ` attachments=${files}` : ''}\n${text}`);
|
||||
return;
|
||||
}
|
||||
const key = JSON.stringify(smtp);
|
||||
@@ -38,7 +43,9 @@ async function sendMail({ to, subject, text }) {
|
||||
transporter = createTransport(smtp);
|
||||
transporterFor = key;
|
||||
}
|
||||
await transporter.sendMail({ from: fromAddress(smtp), to, subject, text });
|
||||
const address = fromAddress(smtp);
|
||||
const from = fromName ? { name: fromName, address: address.replace(/^.*<([^>]+)>.*$/, '$1') } : address;
|
||||
await transporter.sendMail({ from, to, subject, text, html, attachments, replyTo });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user