feat(email): split invoice email into paid/unpaid variants
Persist paymentStatus on the Invoice at generation time and use it at send
time to pick the default email body. Paid orders (paid/refunded/voided) now
get a body without the bank-transfer reference hint; outstanding orders keep
it. Custom merchant templates still override the defaults for both cases.
- Add Invoice.paymentStatus column + migration
- Split DEFAULT_EMAIL_BODY_{DE,EN} into _PAID/_UNPAID variants
- Persist paymentStatus in generateInvoice; select default in email.server
- Document behaviour on the settings page
- Add email-templates test (paid omits hint, unpaid keeps it)
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { strict as assert } from "node:assert";
|
||||
import { describe, it } from "node:test";
|
||||
|
||||
import {
|
||||
DEFAULT_EMAIL_BODY_DE_PAID,
|
||||
DEFAULT_EMAIL_BODY_DE_UNPAID,
|
||||
DEFAULT_EMAIL_BODY_EN_PAID,
|
||||
DEFAULT_EMAIL_BODY_EN_UNPAID,
|
||||
} from "../app/services/invoice/emailTemplates";
|
||||
|
||||
describe("invoice email templates (paid vs unpaid)", () => {
|
||||
const HINT_EN = /bank transfer/i;
|
||||
const HINT_DE = /Überweisung/i;
|
||||
|
||||
it("unpaid defaults keep the bank-transfer reference hint", () => {
|
||||
assert.match(DEFAULT_EMAIL_BODY_EN_UNPAID, HINT_EN);
|
||||
assert.match(DEFAULT_EMAIL_BODY_EN_UNPAID, /\{\{invoiceNumber\}\}/);
|
||||
assert.match(DEFAULT_EMAIL_BODY_DE_UNPAID, HINT_DE);
|
||||
assert.match(DEFAULT_EMAIL_BODY_DE_UNPAID, /\{\{invoiceNumber\}\}/);
|
||||
});
|
||||
|
||||
it("paid defaults omit the bank-transfer reference hint", () => {
|
||||
assert.doesNotMatch(DEFAULT_EMAIL_BODY_EN_PAID, HINT_EN);
|
||||
assert.doesNotMatch(DEFAULT_EMAIL_BODY_DE_PAID, HINT_DE);
|
||||
});
|
||||
|
||||
it("paid and unpaid variants otherwise share header/footer structure", () => {
|
||||
for (const tpl of [
|
||||
DEFAULT_EMAIL_BODY_EN_PAID,
|
||||
DEFAULT_EMAIL_BODY_EN_UNPAID,
|
||||
DEFAULT_EMAIL_BODY_DE_PAID,
|
||||
DEFAULT_EMAIL_BODY_DE_UNPAID,
|
||||
]) {
|
||||
assert.match(tpl, /cid:invoice-logo/);
|
||||
assert.match(tpl, /\{\{companyName\}\}/);
|
||||
assert.match(tpl, /\{\{shopEmail\}\}/);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user