Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-10208-added-1708450451347.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Added
---

Invoice byline for powered down instances ([#10208](https://github.com/linode/manager/pull/10208))
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,16 @@ export const InvoiceDetail = () => {
wrapInParentheses={invoice.total < 0}
/>
</Typography>
<Typography>
This invoice may include Linode Compute Instances that have been
powered off as the data is maintained and resources are still
reserved. If you no longer need powered-down Linodes, you can{' '}
<Link to="https://www.linode.com/docs/products/platform/billing/guides/stop-billing/">
{' '}
remove the service{' '}
</Link>{' '}
from your account.
</Typography>
</Box>
)}
</Grid>
Expand Down
26 changes: 25 additions & 1 deletion packages/manager/src/features/Billing/PdfGenerator/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ interface CreateInvoiceItemsTableOptions {
export const createInvoiceItemsTable = (
options: CreateInvoiceItemsTableOptions
) => {
const { doc, items, regions, timezone, shouldShowRegions, startY } = options;
const { doc, items, regions, shouldShowRegions, startY, timezone } = options;

autoTable(doc, {
body: items.map((item) => {
Expand Down Expand Up @@ -233,6 +233,30 @@ export const createInvoiceTotalsTable = (doc: JSPDF, invoice: Invoice) => {
},
},
},
didDrawPage: (data) => {
let finalY = 0; // Initialize a variable to hold the final Y position after the table is drawn

if (data?.cursor?.y) {
finalY = data.cursor.y;
}

const footerText =
'This invoice may include Linode Compute Instances that have been powered off as the data is maintained and resources are still reserved. If you no longer need powered-down Linodes, you can remove the service (https://www.linode.com/docs/products/platform/billing/guides/stop-billing/) from your account.';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding your note about adding a link in the PDF, have we considered switching PDF libraries? The last version of jspdf was published 2 years ago, whereas, something like react-pdf/renderer was published 15 days ago and the package size is smaller by about 1/7.

const textHeight = doc.getTextDimensions(footerText).h;
const bottomMargin = pageMargin;
const pageHeight = doc.internal.pageSize.height;

// Check if adding footerText would exceed page height
if (finalY + 20 + textHeight + bottomMargin > pageHeight) {
doc.addPage();
finalY = pageMargin; // Reset finalY for the new page
}

doc.text(footerText, pageMargin, finalY + 20, {
align: 'justify',
maxWidth: doc.internal.pageSize.width - pageMargin * 2,
});
},
headStyles: {
fillColor: '#444444',
},
Expand Down