diff --git a/packages/invoice-dashboard/src/lib/view-requests.svelte b/packages/invoice-dashboard/src/lib/view-requests.svelte index 1e66c1d0..8b6a6fce 100644 --- a/packages/invoice-dashboard/src/lib/view-requests.svelte +++ b/packages/invoice-dashboard/src/lib/view-requests.svelte @@ -521,10 +521,9 @@ try { await exportToPDF( request, - // FIXME: Use a non deprecated function - currencyManager.from( - request.currencyInfo.value, - request.currencyInfo.network + getCurrencyFromManager( + request.currencyInfo, + currencyManager ), config.logo ); diff --git a/packages/invoice-dashboard/src/utils/generateInvoice.ts b/packages/invoice-dashboard/src/utils/generateInvoice.ts index 760383a3..18f61d0f 100644 --- a/packages/invoice-dashboard/src/utils/generateInvoice.ts +++ b/packages/invoice-dashboard/src/utils/generateInvoice.ts @@ -23,72 +23,65 @@ export const exportToPDF = async ( ) => { await ensureHtml2PdfLoaded(); + const formatDate = (date: string | undefined) => { + return date ? new Date(date).toLocaleDateString() : "-"; + }; + + const renderAddress = (info: any) => { + const parts = [ + info?.address?.["street-address"], + info?.address?.locality, + info?.address?.["postal-code"], + info?.address?.["country-name"], + ].filter(Boolean); + return parts.length > 0 ? parts.join(", ") : "-"; + }; + const content = `
+ -Issued on ${new Date( - invoice.contentData.creationDate - ).toLocaleDateString()}
-Payment due by ${new Date( - invoice.contentData.paymentTerms.dueDate - ).toLocaleDateString()}
+Issued on ${formatDate(invoice.contentData?.creationDate)}
+Payment due by ${formatDate(invoice.contentData?.paymentTerms?.dueDate)}
${invoice.payee.value}
- ${invoice.contentData.sellerInfo.firstName ?? ""} ${ - invoice.contentData.sellerInfo.lastName ?? "" - }${invoice.payee?.value || "-"}
+ ${invoice.contentData?.sellerInfo?.firstName || ""} ${invoice.contentData?.sellerInfo?.lastName || ""}${invoice.payer.value}
- ${invoice.contentData.buyerInfo.firstName ?? ""} ${ - invoice.contentData.buyerInfo.lastName ?? "" - }${invoice.payer?.value || "-"}
+ ${invoice.contentData?.buyerInfo?.firstName || ""} ${invoice.contentData?.buyerInfo?.lastName || ""}${invoice.contentData.note}