Phase7b: Manual Invoice
All checks were successful
Build and Push / build (push) Successful in 1m46s
All checks were successful
Build and Push / build (push) Successful in 1m46s
This commit is contained in:
@@ -1411,7 +1411,19 @@ export async function issueCustomInvoiceDraft(params: {
|
|||||||
|
|
||||||
let pdfBuffer: Buffer | null = null;
|
let pdfBuffer: Buffer | null = null;
|
||||||
try {
|
try {
|
||||||
pdfBuffer = await renderInvoicePdf(placeholder, invoiceDraft.lines);
|
pdfBuffer = await renderInvoicePdf(
|
||||||
|
placeholder,
|
||||||
|
// Same pattern as the auto-cron generateInvoice: synthesize
|
||||||
|
// temporary ids for the PDF renderer. The real DB rows have
|
||||||
|
// these populated post-insert, but the renderer only reads
|
||||||
|
// them for React keys (display) and id-comparison-free
|
||||||
|
// operations, so synthetic values are fine.
|
||||||
|
invoiceDraft.lines.map((l, i) => ({
|
||||||
|
...l,
|
||||||
|
id: `tmp-${i}`,
|
||||||
|
invoiceId: placeholder.id,
|
||||||
|
}))
|
||||||
|
);
|
||||||
const filename = `${placeholder.invoiceNumber}.pdf`;
|
const filename = `${placeholder.invoiceNumber}.pdf`;
|
||||||
await updateInvoicePdf(placeholder.id, pdfBuffer, filename);
|
await updateInvoicePdf(placeholder.id, pdfBuffer, filename);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -1518,5 +1530,12 @@ export async function renderCustomDraftPreview(
|
|||||||
refundedTotalChf: 0,
|
refundedTotalChf: 0,
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
};
|
};
|
||||||
return renderInvoicePdf(fakeInvoice, invoiceDraft.lines);
|
return renderInvoicePdf(
|
||||||
|
fakeInvoice,
|
||||||
|
invoiceDraft.lines.map((l, i) => ({
|
||||||
|
...l,
|
||||||
|
id: `tmp-${i}`,
|
||||||
|
invoiceId: fakeInvoice.id,
|
||||||
|
}))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user