From 815e15b5aedc550148d4ef7549dfa83b32dcab6b Mon Sep 17 00:00:00 2001 From: Allen T J Date: Tue, 20 May 2025 08:47:28 +0000 Subject: [PATCH] phonepe (#32) Co-authored-by: AllenTJ7 <163137620+AllenTJ7@users.noreply.github.com> Reviewed-on: https://git.cosqnet.com/cosqnet/fitlien-services/pulls/32 --- .../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;