Generate invoice PDFs attached to order confirmation, and send emails on order status changes
Invoice PDFs (§14 UStG line items, tenant-configurable VAT rate) are now generated at checkout and attached to the confirmation email, plus available on demand from the order-detail page. Payload-side, orders now also email the customer on shipped/cancelled/return_requested/returned, with Stornorechnung/Gutschrift correction PDFs attached for the latter two so the original invoice's immutable number stays honest.
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { getInvoiceSettings } from "./payload";
|
||||
import { renderInvoicePdf, type InvoiceOrder } from "./invoicePdf";
|
||||
|
||||
// Shared by app/lib/orderEmail.ts (checkout — attaches to the confirmation
|
||||
// mail) and app/api/account/orders/[orderNumber]/invoice/route.ts (on-demand
|
||||
// download) — same seller lookup + render call both times, so what a
|
||||
// customer downloads later always matches what they were emailed.
|
||||
export async function generateInvoicePdf(order: InvoiceOrder): Promise<Buffer | null> {
|
||||
const seller = await getInvoiceSettings();
|
||||
if (!seller) {
|
||||
console.error("generateInvoicePdf: no invoice-settings row found for tenant");
|
||||
return null;
|
||||
}
|
||||
return renderInvoicePdf(order, seller);
|
||||
}
|
||||
Reference in New Issue
Block a user