Update invoiceService.ts
This commit is contained in:
		
							parent
							
								
									80b3829347
								
							
						
					
					
						commit
						762e6b77e5
					
				| @ -5,17 +5,10 @@ import * as path from 'path'; | |||||||
| import { format } from 'date-fns'; | import { format } from 'date-fns'; | ||||||
| import { sendEmailWithAttachmentUtil } from "../../../utils/emailService"; | import { sendEmailWithAttachmentUtil } from "../../../utils/emailService"; | ||||||
| 
 | 
 | ||||||
| let pdfMake: any; | const pdfMake = require('pdfmake/build/pdfmake'); | ||||||
| let pdfFonts: any; | const pdfFonts = require('pdfmake/build/vfs_fonts'); | ||||||
| 
 |  | ||||||
| function initPdfLibraries() { |  | ||||||
|   if (!pdfMake) { |  | ||||||
|     pdfMake = require('pdfmake/build/pdfmake'); |  | ||||||
|     pdfFonts = require('pdfmake/build/vfs_fonts'); |  | ||||||
| pdfMake.vfs = pdfFonts.pdfMake ? pdfFonts.pdfMake.vfs : pdfFonts.vfs; | pdfMake.vfs = pdfFonts.pdfMake ? pdfFonts.pdfMake.vfs : pdfFonts.vfs; | ||||||
|   } | 
 | ||||||
|   return pdfMake; |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| const admin = getAdmin(); | const admin = getAdmin(); | ||||||
| const logger = getLogger(); | const logger = getLogger(); | ||||||
| @ -53,7 +46,6 @@ export interface EmailOptions { | |||||||
| export class InvoiceService { | export class InvoiceService { | ||||||
|   async generateInvoice(data: InvoiceData): Promise<string> { |   async generateInvoice(data: InvoiceData): Promise<string> { | ||||||
|     try { |     try { | ||||||
|       const pdfMake = initPdfLibraries(); |  | ||||||
|       const tempFilePath = path.join(os.tmpdir(), `invoice_${data.invoiceNumber}.pdf`); |       const tempFilePath = path.join(os.tmpdir(), `invoice_${data.invoiceNumber}.pdf`); | ||||||
|        |        | ||||||
|       const hasGst = data.gstNumber && data.gstNumber.length > 0; |       const hasGst = data.gstNumber && data.gstNumber.length > 0; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 AllenTJ7
						AllenTJ7