From 762e6b77e5ed5516555490688a24a1a383437565 Mon Sep 17 00:00:00 2001 From: AllenTJ7 <163137620+AllenTJ7@users.noreply.github.com> Date: Tue, 20 May 2025 14:15:36 +0530 Subject: [PATCH] Update invoiceService.ts --- .../src/payments/phonepe/invoice/invoiceService.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/functions/src/payments/phonepe/invoice/invoiceService.ts b/functions/src/payments/phonepe/invoice/invoiceService.ts index c1edf9b..59bb0fd 100644 --- a/functions/src/payments/phonepe/invoice/invoiceService.ts +++ b/functions/src/payments/phonepe/invoice/invoiceService.ts @@ -5,17 +5,10 @@ import * as path from 'path'; import { format } from 'date-fns'; import { sendEmailWithAttachmentUtil } from "../../../utils/emailService"; -let pdfMake: any; -let pdfFonts: any; +const pdfMake = require('pdfmake/build/pdfmake'); +const pdfFonts = require('pdfmake/build/vfs_fonts'); +pdfMake.vfs = pdfFonts.pdfMake ? pdfFonts.pdfMake.vfs : pdfFonts.vfs; -function initPdfLibraries() { - if (!pdfMake) { - pdfMake = require('pdfmake/build/pdfmake'); - pdfFonts = require('pdfmake/build/vfs_fonts'); - pdfMake.vfs = pdfFonts.pdfMake ? pdfFonts.pdfMake.vfs : pdfFonts.vfs; - } - return pdfMake; -} const admin = getAdmin(); const logger = getLogger(); @@ -53,7 +46,6 @@ export interface EmailOptions { export class InvoiceService { async generateInvoice(data: InvoiceData): Promise { try { - const pdfMake = initPdfLibraries(); const tempFilePath = path.join(os.tmpdir(), `invoice_${data.invoiceNumber}.pdf`); const hasGst = data.gstNumber && data.gstNumber.length > 0;