From 5ba37dca9f78c4bfd3fd4949dc4cc1ed02a17ca1 Mon Sep 17 00:00:00 2001 From: kennyboy55 Date: Fri, 28 Jun 2024 20:52:46 +0200 Subject: [PATCH] Fix rounding error --- app/utils/pdf/pdf.generate.server.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/utils/pdf/pdf.generate.server.ts b/app/utils/pdf/pdf.generate.server.ts index faaecee..1e80ca8 100644 --- a/app/utils/pdf/pdf.generate.server.ts +++ b/app/utils/pdf/pdf.generate.server.ts @@ -10,7 +10,7 @@ export async function createPdf(filename: string, reportId: string, dateStart: s let total : number = 0; for(let container of containers){ - let price = (container.price * container.checkouts.length); + let price = Math.round((container.price * container.checkouts.length) * 100) / 100; total += price; let bodyRow = [ @@ -38,7 +38,7 @@ export async function createPdf(filename: string, reportId: string, dateStart: s startY: 40, head: [['Drink', 'Price', 'Amount', 'Total']], body: body, - foot: [["", "", "Total", "€" + total]] + foot: [["", "", "Total", "€" + (Math.round(total*100)/100)]] }); let finalY = doc.autoTable.previous.finalY;