Rechnungsbeträge deutsch formatieren

This commit is contained in:
2026-07-20 10:17:00 +02:00
parent ae379b0f22
commit 720c70845e
4 changed files with 27 additions and 10 deletions

View File

@@ -25,6 +25,10 @@ const getCoordinatesForPDFLib = (x:number ,y:number, page:any) => {
}
}
const getRightAlignedX = (rightEdgeMm: number, text: string, size: number, font: any, page: any) => {
return getCoordinatesForPDFLib(rightEdgeMm, 0, page).x - font.widthOfTextAtSize(text, size)
}
const getBackgroundSourceBuffer = async (server:FastifyInstance, path:string) => {
@@ -372,8 +376,10 @@ export const createInvoicePDF = async (server:FastifyInstance, returnMode, invoi
font: fontBold
})
pages[pageCounter - 1].drawText("Einheitspreis", {
...getCoordinatesForPDFLib(150, 137, page1),
const unitPriceHeader = "Einheitspreis"
pages[pageCounter - 1].drawText(unitPriceHeader, {
y: getCoordinatesForPDFLib(150, 137, page1).y,
x: getRightAlignedX(177, unitPriceHeader, 12, fontBold, page1),
size: 12,
color: rgb(0, 0, 0),
lineHeight: 12,
@@ -508,7 +514,8 @@ export const createInvoicePDF = async (server:FastifyInstance, returnMode, invoi
maxWidth: 240
})
pages[pageCounter - 1].drawText(row.price, {
...getCoordinatesForPDFLib(150, rowHeight, page1),
y: getCoordinatesForPDFLib(150, rowHeight, page1).y,
x: getRightAlignedX(177, row.price, 10, font, page1),
size: 10,
color: rgb(0, 0, 0),
lineHeight: 10,
@@ -689,8 +696,10 @@ export const createInvoicePDF = async (server:FastifyInstance, returnMode, invoi
font: fontBold
})
page.drawText("Einheitspreis", {
...getCoordinatesForPDFLib(150, 22, page1),
const unitPriceHeader = "Einheitspreis"
page.drawText(unitPriceHeader, {
y: getCoordinatesForPDFLib(150, 22, page1).y,
x: getRightAlignedX(177, unitPriceHeader, 12, fontBold, page1),
size: 12,
color: rgb(0, 0, 0),
lineHeight: 12,