import { PayTypeEnum } from "../../enums/enums"; import { Add } from "../../shared/math-operations"; import { SharedPDFService } from "../../shared/shared-pdf.service"; import { PrintSharedService } from "../../shared/shared-print.service"; import { MyDate } from "../../utils/my-date"; import { TrUtils } from "../../utils/tr-utils"; /** * Unified Invoice Print Service * Consolidates InvoicePortraitPrintService, InvoiceLandscapePdfService, * HCInvoiceprintService, and InvoiceprintService into a single service */ export class InvoicePrintService { FontSize: number = 8; static TableHeaders: number = 9; // ==================== UNIFIED PUBLIC API ==================== /** * Unified Invoice Print Method - handles all invoice print types * Automatically routes to appropriate print variant based on options * * @param data - Invoice data containing all necessary information * @param options - Print options determining format and settings * @returns PDF document definition for pdfmake */ static GetInvoicePrint(data: any, options: any) { const printType = options.printType || 'portrait'; switch (printType.toLowerCase()) { case 'portrait': return InvoicePrintService.GetPortraitPrint( data, options.size || 'full', options.printOptions || {}, options.moreDiscDetails || false ); case 'landscape': return InvoicePrintService.GetLandscapePrint( data, options.numberofCopies || null, options.moreDiscDetails || false ); case 'hc': case 'healthcare': case 'hospital': return InvoicePrintService.GetHCInvoicePrint( data, options.numberofCopies || null, options.isotherIndustry || false, options.withPass || false, options.isAuto || false, options.size || 'full', options.moreDiscDetails || false ); case 'standard': return InvoicePrintService.GetStandardInvoicePrint( data, options.numberofCopies || null, options.isotherIndustry || false, options.withPass || false, options.isAuto || false, options.moreDiscDetails || false ); default: // Default to portrait if type not recognized return InvoicePrintService.GetPortraitPrint( data, options.size || 'full', options.printOptions || {}, options.moreDiscDetails || false ); } } // ==================== INTERNAL VARIANT METHODS ==================== /** * Portrait invoice print (Original InvoicePortraitPrintService.GetPrint) * @internal - Use GetInvoicePrint() instead */ private static GetPortraitPrint(InvoicePDFData: any, size: string, printOptions: any, moreDiscDetails: boolean) { if (TrUtils.IsNull(InvoicePDFData.Name)) { InvoicePDFData.Name = ''; } let dd: any = { info: { title: 'TAX INVOICE', }, background: function (currentPage: any, pageSize: any) { if (size !== 'full') { pageSize.height = pageSize.height - 435.945; } return SharedPDFService.GetWatermarkImage(InvoicePDFData.Image, pageSize, InvoicePDFData.Entity.Wmark); }, header: function (currentPage: any, pageCount: any, pageSize: any) { return { text: currentPage.toString() + ' of ' + pageCount, alignment: 'right', marginRight: 25, fontSize: 8, marginTop: 2 }; }, pageMargins: InvoicePrintService.GetMarginsBasedOnPaperSize(size), pageSize: 'A4', content: [ InvoicePrintService.GetMainHeaderInfo(InvoicePDFData), { style: 'tableExample', table: { widths: [200, '*', 'auto'], body: InvoicePrintService.GetCustomerAndBankDetails(InvoicePDFData) }, layout: InvoicePrintService.HeaderLayOut() }, InvoicePrintService.GetItemsTable(InvoicePDFData.Ops, InvoicePDFData.Items, InvoicePDFData.ShowTaxColumn, InvoicePDFData.SType, printOptions, size, InvoicePDFData.Entity.DecimalsNumber), [InvoicePrintService.TotalDetails(InvoicePDFData, moreDiscDetails, InvoicePDFData.Entity.DecimalsNumber)], [InvoicePrintService.GetNumberInWords(InvoicePDFData.CustRoundedTotal)], [InvoicePrintService.InvoiceDueStatus(InvoicePDFData.Type, InvoicePDFData.Paid, InvoicePDFData.Due, InvoicePDFData.Sts, InvoicePDFData.isCountersale, InvoicePDFData.Entity.DecimalsNumber)], { style: 'tableExample', table: { widths: ['*', 'auto'], body: InvoicePrintService.GetSignatures(InvoicePDFData.Entity.CName, InvoicePDFData.CustRoundedTotal) }, layout: 'noBorders' }, ], styles: { headerstyle: { fontFamily: 'Calibri', fontSize: 9 }, Sign: { fontSize: 8, margin: [0, 15, 0, 5] }, forCompany: { marginRight: 5, marginTop: 10, fontSize: 9, alignment: 'right' }, forCompany1: { margin: [0, 5, 15, 0], fontSize: 8 }, tableheader: { bold: true, fontFamily: 'Calibri', margin: [0, 1, 0, 5], alignment: 'center' }, tableheader1: { bold: true, fontFamily: 'Calibri', margin: [0, 2, 0, 2], alignment: 'center' }, tableExample: { fontSize: 9 }, tableExample1: { fontSize: 8 } } }; return dd; } /** * Landscape invoice print (Original InvoiceLandscapePdfService.GetInvoiceLandscapePrint) * @internal - Use GetInvoicePrint() instead */ private static GetLandscapePrint(ROPrintData: any, numberofCopies: any, moreDiscDetails: boolean) { var contents = []; if (TrUtils.IsNull(numberofCopies) || numberofCopies.length === 0) { contents.push( InvoicePrintService.GetLandscapeHeaderDetails(ROPrintData, null), InvoicePrintService.PrepareLandscapePartsTable(ROPrintData), InvoicePrintService.GetLandscapeTotalDetails(ROPrintData, null, numberofCopies, moreDiscDetails) ); } else { numberofCopies.forEach((text: any, index: any) => { contents.push( InvoicePrintService.GetLandscapeHeaderDetails(ROPrintData, text), InvoicePrintService.PrepareLandscapePartsTable(ROPrintData), InvoicePrintService.GetLandscapeTotalDetails(ROPrintData, index, numberofCopies, moreDiscDetails) ); }); } var dd = { info: { title: InvoicePrintService.GetFileName(ROPrintData), }, background: function (currentPage: any, pageSize: any) { return SharedPDFService.GetWatermarkImage(ROPrintData.Image, pageSize, ROPrintData.Entity.Wmark); }, header: function (currentPage: any, pageCount: any) { return { text: currentPage.toString() + ' of ' + pageCount, alignment: 'right', marginRight: 7, fontSize: 8, marginTop: 2 }; }, pageMargins: [10, 15, 10, 15], pageOrientation: 'landscape', content: contents, styles: SharedPDFService.GetStyles() }; return dd; } /** * Healthcare/Hospital invoice print (Original HCInvoiceprintService.GetInvoicePrint) * @internal - Use GetInvoicePrint() instead */ private static GetHCInvoicePrint(ROPrintData: any, numberofCopies: any, isotherIndustry: boolean, withPass: boolean, isAuto: boolean, size: any, moreDiscDetails: boolean) { ROPrintData.Entity.IsProforma = ROPrintData.IsProforma; var contents = []; if (TrUtils.IsNull(numberofCopies) || numberofCopies.length === 0) { contents.push( InvoicePrintService.GetHCHeaderDetails(ROPrintData, null, isotherIndustry), InvoicePrintService.PrepareHCPartsTable(ROPrintData, isAuto), InvoicePrintService.GetHCTotalDetails(ROPrintData, null, numberofCopies, withPass, isAuto, moreDiscDetails) ); } else { numberofCopies.forEach((text: any, index: any) => { contents.push( InvoicePrintService.GetHCHeaderDetails(ROPrintData, text, isotherIndustry), InvoicePrintService.PrepareHCPartsTable(ROPrintData, isAuto), InvoicePrintService.GetHCTotalDetails(ROPrintData, index, numberofCopies, withPass, isAuto, moreDiscDetails) ); }); } var dd = { watermark: InvoicePrintService.GetHCWatermark(ROPrintData), info: { title: InvoicePrintService.GetFileName(ROPrintData), }, background: function (currentPage: any, pageSize: any) { if (size !== 'full') { pageSize.height = pageSize.height - 435.945; } return SharedPDFService.GetWatermarkImage(ROPrintData.Image, pageSize, ROPrintData.Entity.Wmark); }, header: function (currentPage: any, pageCount: any) { return { text: currentPage.toString() + ' of ' + pageCount, alignment: 'right', marginRight: 7, fontSize: 8, marginTop: 2 }; }, pageBreakBefore: function (currentNode: any, followingNodesOnPage: any, nodesOnNextPage: any, previousNodesOnPage: any) { return currentNode.startPosition.top >= 700 && !TrUtils.IsNull(currentNode?.id) && currentNode?.id === '567'; }, pageMargins: InvoicePrintService.GetHCMarginsBasedOnPaperSize(size), pageSize: 'A4', content: contents, styles: SharedPDFService.GetStyles() }; return dd; } /** * Standard invoice print (Original InvoiceprintService.GetInvoicePrint) * @internal - Use GetInvoicePrint() instead */ private static GetStandardInvoicePrint(ROPrintData: any, numberofCopies: any, isotherIndustry: boolean, withPass: boolean, isAuto: boolean, moreDiscDetails: boolean) { var contents = []; if (TrUtils.IsNull(numberofCopies) || numberofCopies.length === 0) { contents.push( InvoicePrintService.GetStandardHeaderDetails(ROPrintData, null, isotherIndustry), InvoicePrintService.PrepareStandardPartsTable(ROPrintData, isAuto), InvoicePrintService.GetStandardTotalDetails(ROPrintData, null, numberofCopies, withPass, isAuto, moreDiscDetails) ); } else { numberofCopies.forEach((text: any, index: any) => { contents.push( InvoicePrintService.GetStandardHeaderDetails(ROPrintData, text, isotherIndustry), InvoicePrintService.PrepareStandardPartsTable(ROPrintData, isAuto), InvoicePrintService.GetStandardTotalDetails(ROPrintData, index, numberofCopies, withPass, isAuto, moreDiscDetails) ); }); } var dd = { info: { title: InvoicePrintService.GetFileName(ROPrintData), }, watermark: InvoicePrintService.GetStandardWatermark(ROPrintData, isAuto), background: function (currentPage: any, pageSize: any) { return SharedPDFService.GetWatermarkImage(ROPrintData.Image, pageSize, ROPrintData.Entity.Wmark); }, header: function (currentPage: any, pageCount: any) { return { text: currentPage.toString() + ' of ' + pageCount, alignment: 'right', marginRight: 7, fontSize: 8, marginTop: 2 }; }, pageBreakBefore: function (currentNode: any, followingNodesOnPage: any, nodesOnNextPage: any, previousNodesOnPage: any) { return currentNode.startPosition.top >= 700 && !TrUtils.IsNull(currentNode?.id) && currentNode?.id === '567'; }, pageMargins: [10, 15, 10, 15], content: contents, styles: SharedPDFService.GetStyles() }; return dd; } // ==================== COMMON UTILITY METHODS ==================== static GetFileName(ROPrintData: any) { let fileName: string = ROPrintData.HeaderName; if (!TrUtils.IsNull(ROPrintData.Product) && !TrUtils.IsEmpty(ROPrintData.Product.RegNo)) { fileName = fileName + '-' + ROPrintData.Product.RegNo; } return fileName; } static emptyObject() { let a: any = {}; return a; } // ==================== PORTRAIT-SPECIFIC METHODS ==================== static GetMarginsBasedOnPaperSize(size: any) { if (size === 'full') { return [20, 15, 20, 15]; } else { return [20, 15, 20, 435.945]; } } static GetMainHeaderInfo(InvoicePDFData: any) { if (!TrUtils.IsNull(InvoicePDFData.Image)) { return { columns: [{ image: InvoicePDFData.Image, width: 60, height: 60, marginBottom: 5 }, { stack: [ { text: InvoicePDFData.Entity.CName, style: ['headerstyle'], alignment: 'left', fontSize: 15 }, { text: InvoicePrintService.GetPortraitAddress(InvoicePDFData.Entity), alignment: 'left', style: ['headerstyle'] }, { columns: InvoicePrintService.GetHeaderInfo(InvoicePDFData, 0) }, { text: InvoicePDFData.HeaderName, alignment: 'left', style: ['Receiptheader1'], marginTop: 5 } ] } ], columnGap: 10 } } else { return { stack: [ { text: InvoicePDFData.Entity.CName, style: ['headerstyle'], alignment: 'center', fontSize: 15 }, { text: InvoicePrintService.GetPortraitAddress(InvoicePDFData.Entity), alignment: 'center', style: ['headerstyle'] }, { columns: InvoicePrintService.GetHeaderInfo(InvoicePDFData, 5) }, { text: InvoicePDFData.HeaderName, alignment: 'center', style: ['Receiptheader1'] } ] } } } static GetPortraitAddress(Entity: any) { return Entity.Adrs1 + ', ' + Entity.Adrs2 + ', ' + Entity.City + '-' + Entity.PIN + ', Cell : ' + Entity.Phone; } static GetCustomerAndBankDetails(InvoicePDFData: any) { let CustDetails: any = []; CustDetails.push([{ marginLeft: 3, stack: [ InvoicePrintService.GetCustomerDetails(InvoicePDFData.Customer, InvoicePDFData.Type, null, null, 'Customer Name & Address') ] }, { marginLeft: 5, marginRight: 5, stack: [InvoicePrintService.GetCustomerGSTIN(InvoicePDFData.Customer), InvoicePrintService.GetCustomerDLNo(InvoicePDFData.Customer)] }, { marginRight: 5, stack: [{ text: 'Invoice No : ' + InvoicePDFData._id, style: ['headerstyle'] }, { text: 'Date : ' + InvoicePDFData.CrDate, style: ['headerstyle'] }] }]); if (InvoicePDFData.Entity.PrBank) { CustDetails.push([{ text: 'Note: OUR BANK A/C: ' + InvoicePDFData.Entity.Bank.ACNo + ', IFSC CODE: ' + InvoicePDFData.Entity.Bank.IFSC + ', Account Holder Name: ' + InvoicePDFData.Entity.Bank.ACName + ', BANK NAME: ' + InvoicePDFData.Entity.Bank.Name, colSpan: 3, fontSize: 8 }]); } return CustDetails; } static GetCustomerDetails(Customer: any, Type: any, Vehicle: any, Settings: any, CustHeader: string) { if (TrUtils.IsNull(Customer)) { return InvoicePrintService.emptyObject(); } let Data: any = [{ text: CustHeader + ':', style: 'hed', bold: true }, { text: Customer.Name, marginTop: 2 }, { text: InvoicePrintService.GetAddress1(Customer), marginTop: 3, fontSize: 7 }, InvoicePrintService.GetCustPhoneNumber(Customer, Type), InvoicePrintService.GetCustomerName(Customer.CustName)] return { style: 'colum1', stack: Data }; } static GetAddress1(Customer: any) { var Address = InvoicePrintService.GetFormatAddress(Customer); if (Address.length !== 5) { return Address; } else { let a: any = ''; return a; } } static GetFormatAddress(CustomerObj: any) { var Addressnew = ''; if (!TrUtils.IsNull(CustomerObj.Adrs)) { CustomerObj.Adrs.forEach((Adrs: any, index: any) => { Addressnew = Addressnew + Adrs; if (CustomerObj.Adrs.length > (index + 1)) { Addressnew = Addressnew + ', ' } }); } return Addressnew; } static GetFormatContact(CustomerObj: any) { var contactnew = ''; if (!TrUtils.IsNull(CustomerObj.Cons)) { CustomerObj.Cons.forEach((Contact: any) => { contactnew = contactnew + '(' + Contact.Type + '):' + Contact.No + '\n'; }); } return contactnew; } static GetCustPhoneNumber(Customer: any, Type: any) { if (Type !== 'Technician Copy') { var contact = InvoicePrintService.GetFormatContact(Customer); if (contact.length !== 0) { return { columns: [{ text: 'Phone', width: 27, style: 'hed' }, contact] }; } else { return InvoicePrintService.emptyObject(); } } else { return InvoicePrintService.emptyObject(); } } static GetCustomerName(Customer: any) { if (!TrUtils.IsEmpty(Customer)) { let GSTIN = { columns: [{ text: 'Customer Name :', width: 65, bold: true }, { text: Customer }] }; return GSTIN; } else { return InvoicePrintService.emptyObject(); } } static GetCustomerGSTIN(Customer: any) { if (!TrUtils.IsEmpty(Customer.GSTIN)) { let GSTIN = { columns: [{ text: 'GSTIN :', width: 33, style: 'hed' }, { text: Customer.GSTIN, marginTop: 1.5 }] }; return GSTIN; } else { return InvoicePrintService.emptyObject(); } } static GetCustomerDLNo(Customer: any) { if (!TrUtils.IsEmpty(Customer.DLNo)) { let GSTIN = { columns: [{ text: 'DL No :', width: 33, style: 'hed' }, { text: Customer.DLNo, marginTop: 1.5 }] }; return GSTIN; } else { return InvoicePrintService.emptyObject(); } } static HeaderLayOut() { return { hLineWidth: function (i: any, node: any) { return (i === 0 || i === 1 || i === node.table.body.length) ? 1 : 0; }, vLineWidth: function (i: any, node: any) { return (i === 0 || i === node.table.widths.length) ? 1 : 0; }, hLineColor: function (i: any, node: any) { return 'gray'; }, vLineColor: function (i: any, node: any) { return 'gray'; }, }; } static GetHeaderInfo(InvoicePDFData: any, marginleft: number) { let TaxInfo: any = []; if (!TrUtils.IsEmpty(InvoicePDFData.Entity.GSTIN)) { TaxInfo.push({ text: 'GSTIN : ' + InvoicePDFData.Entity.GSTIN, marginTop: 2, marginLeft: marginleft, alignment: 'left', fontSize: 9, width: 'auto' }); } if (!TrUtils.IsEmpty(InvoicePDFData.Entity.DLNo)) { TaxInfo.push({ text: 'D.L.NO : ' + InvoicePDFData.Entity.DLNo, marginTop: 2, marginLeft: 5, alignment: 'left', fontSize: 9, width: '*' }); } TaxInfo.push(InvoicePrintService.GetBillofSupplyName(InvoicePDFData.Settings)); return TaxInfo; } static GetBillofSupplyName(Settings: any) { return { text: Settings.Tax === 'BS' ? ' Bill of Supply' : null, alignment: 'center', marginLeft: 15, marginTop: 2, marginBottom: 3, fontSize: 9, width: 'auto' }; } static GetItemsTable(Services: any, Items: any, ShowTaxColumn: boolean, SType: any, printOptions: any, size: any, DecimalsNumber: number) { return { style: 'tableExample', marginTop: 3, marginBottom: 5, table: { widths: InvoicePrintService.GetPortraitWidths(ShowTaxColumn, printOptions), headerRows: 1, body: InvoicePrintService.BuildPortraitTableBody(Services, Items, ShowTaxColumn, SType, printOptions, size, DecimalsNumber) }, layout: { hLineWidth: function (i: any, node: any) { return (i === 0 || i === 1 || i === node.table.body.length) ? 1 : 0; }, vLineWidth: function (i: any, node: any) { return (i === 0 || i === node.table.widths.length) ? 1 : 0.5; }, hLineColor: function (i: any, node: any) { return 'gray'; }, vLineColor: function (i: any, node: any) { return 'gray'; }, } }; } static GetPortraitWidths(ShowTaxColumn: any, printOptions: any) { if (ShowTaxColumn && printOptions.ShowTax !== 'NO') { if (printOptions.Disc === 'NO') { return [16, '*', 40, 45, 25, 20, 20, 45, 45, 30, 50]; } else { return [16, '*', 40, 45, 25, 20, 20, 45, 45, 35, 35, 45]; } } else { if (printOptions.Disc === 'NO') { return [22, '*', 40, 45, 25, 20, 20, 50, 50, 50]; } else { return [22, '*', 40, 45, 25, 20, 20, 50, 50, 50, 50]; } } } static BuildPortraitTableBody(Services: any, Items: any, ShowTaxColumn: any, SType: any, printOptions: any, size: any, DecimalsNumber: number) { let body: any = InvoicePrintService.GetPortraitHeaderNames(ShowTaxColumn, SType, printOptions); let j = 1; // Process Services if (!TrUtils.IsNull(Services) && Services.length !== 0) { Services.forEach((item: any, index: any) => { let dataRow: any = []; dataRow.push({ text: index + 1 }); if (!TrUtils.IsEmpty(item.EDesc)) { let DescData: any = []; DescData.push({ text: item.Desc }); DescData.push({ text: item.EDesc, color: 'grey' }); dataRow.push({ stack: DescData }); } else { dataRow.push({ text: item.Desc }); } if (ShowTaxColumn) { dataRow.push({ text: item.SAC, alignment: 'center', style: ['headerstyle'] }); } dataRow.push({ text: '', alignment: 'center', style: ['headerstyle'] }); dataRow.push({ text: '', alignment: 'center', style: ['headerstyle'] }); dataRow.push({ text: item.Qty, alignment: 'right', style: ['headerstyle'] }); dataRow.push({ text: '', alignment: 'right', style: ['headerstyle'] }); dataRow.push({ text: '', alignment: 'right', style: ['headerstyle'] }); dataRow.push({ text: TrUtils.FixPriceValue(item.Pr, DecimalsNumber), alignment: 'right', style: ['headerstyle'] }); if (printOptions.Disc !== 'NO') { if (printOptions.Disc === 'PERC') { dataRow.push({ text: TrUtils.FixPriceValue(item.DiscPerc, DecimalsNumber), alignment: 'right', style: ['headerstyle'] }); } else { dataRow.push({ text: TrUtils.FixPriceValue(item.Disc, DecimalsNumber), alignment: 'right', style: ['headerstyle'] }); } } if (ShowTaxColumn && printOptions.ShowTax !== 'NO') { let Tax: any = item.TaxName?.split('%'); dataRow.push({ text: TrUtils.IsNull(Tax) ? '' : Tax[0], alignment: 'right', style: ['headerstyle'] }); } dataRow.push({ text: item.Ret ? '-' + TrUtils.FixPriceValue(item.LineTotal, DecimalsNumber) : TrUtils.FixPriceValue(item.LineTotal, DecimalsNumber), alignment: 'right', style: ['headerstyle'] }); body.push(dataRow); if (index + 1 === j * 9) { j++; if (size === 'diff') { let dataRow1: any = [{ text: '', pageBreak: 'after' }, '', '', '', '', '']; if (ShowTaxColumn) { dataRow1.push(''); dataRow1.push(''); } body.push(dataRow1); } } }); } // Process Items if (!TrUtils.IsNull(Items) && Items.length !== 0) { if (!TrUtils.IsNull(Services) && Services.length !== 0) { // Add separator row let dataRow: any = []; dataRow.push({ text: '' }); dataRow.push({ text: '' }); if (ShowTaxColumn) { dataRow.push({ text: '', alignment: 'center', style: ['headerstyle'] }); } dataRow.push({ text: '', alignment: 'center', style: ['headerstyle'] }); dataRow.push({ text: '', alignment: 'center', style: ['headerstyle'] }); dataRow.push({ text: '', alignment: 'right', style: ['headerstyle'] }); dataRow.push({ text: '', alignment: 'right', style: ['headerstyle'] }); dataRow.push({ text: '', alignment: 'right', style: ['headerstyle'] }); dataRow.push({ text: '', alignment: 'right', style: ['headerstyle'] }); if (printOptions.Disc !== 'NO') { dataRow.push({ text: '', alignment: 'right', style: ['headerstyle'] }); } if (ShowTaxColumn && printOptions.ShowTax !== 'NO') { dataRow.push({ text: '', alignment: 'right', style: ['headerstyle'] }); } dataRow.push({ text: '', alignment: 'right', style: ['headerstyle'] }); body.push(dataRow); } Items.forEach((item: any, index: any) => { let dataRow: any = []; dataRow.push({ text: index + 1 }); if (!TrUtils.IsEmpty(item.EDesc)) { let DescData: any = []; DescData.push({ text: item.Desc }); DescData.push({ text: item.EDesc, color: 'grey' }); dataRow.push({ stack: DescData }); } else { dataRow.push({ text: item.Desc }); } if (ShowTaxColumn) { dataRow.push({ text: item.HSN, alignment: 'center', style: ['headerstyle'] }); } dataRow.push({ text: item.Batch?.BN, alignment: 'center', style: ['headerstyle'] }); dataRow.push({ text: MyDate.ConvertUTCDateToReadableExDate(item['Batch']?.ExDt), alignment: 'center', style: ['headerstyle'] }); dataRow.push({ text: item.QtyAndUoM, alignment: 'right', style: ['headerstyle'] }); dataRow.push({ text: item.OfQty, alignment: 'right', style: ['headerstyle'] }); dataRow.push({ text: TrUtils.FixPriceValue(item.MRP, DecimalsNumber), alignment: 'right', style: ['headerstyle'] }); dataRow.push({ text: TrUtils.FixPriceValue(item.UnPr, DecimalsNumber), alignment: 'right', style: ['headerstyle'] }); if (printOptions.Disc !== 'NO') { if (printOptions.Disc === 'PERC') { dataRow.push({ text: TrUtils.FixPriceValue(item.DiscPerc, DecimalsNumber), alignment: 'right', style: ['headerstyle'] }); } else { dataRow.push({ text: TrUtils.FixPriceValue(item.Disc, DecimalsNumber), alignment: 'right', style: ['headerstyle'] }); } } if (ShowTaxColumn && printOptions.ShowTax !== 'NO') { let Tax: any = item.TaxName?.split('%'); dataRow.push({ text: TrUtils.IsNull(Tax) ? '' : Number(Tax[0]), alignment: 'right', style: ['headerstyle'] }); } dataRow.push({ text: item.Ret ? '-' + TrUtils.FixPriceValue(item.LineTotal, DecimalsNumber) : TrUtils.FixPriceValue(item.LineTotal, DecimalsNumber), alignment: 'right', style: ['headerstyle'] }); body.push(dataRow); if (index + 1 === j * 9) { j++; if (size === 'diff') { let dataRow1: any = [{ text: '', pageBreak: 'after' }, '', '', '', '', '']; if (ShowTaxColumn) { dataRow1.push(''); dataRow1.push(''); } body.push(dataRow1); } } }); } return body; } static GetPortraitHeaderNames(ShowTaxColumn: any, SType: any, printOptions: any) { let HeadingNames: any; if (ShowTaxColumn) { HeadingNames = [[{ text: 'S.No', style: 'tableheader1', Field: 'SNo', alignment: 'left', fontSize: 7 }, { text: 'Item Name', style: 'tableheader1', Field: 'Desc', alignment: 'left', line: true }, { text: 'HSN/SAC', style: 'tableheader1', Field: 'HSN' }, { text: 'Batch No.', style: 'tableheader1', Field: 'Batches' }, { text: 'Ex.Dt', style: 'tableheader1', Field: 'ExDate' }, { text: 'Qty', style: 'tableheader1', Field: 'Qty', alignment: 'right' }, { text: 'Free', style: 'tableheader1', Field: 'OfQty', alignment: 'right' }, { text: 'MRP', style: 'tableheader1', Field: 'MRP', alignment: 'right' }, { text: 'Price', style: 'tableheader1', Field: 'UnPr', alignment: 'right' }, { text: 'Line Total', style: 'tableheader1', Field: 'LineTotal', alignment: 'right' }]]; if (printOptions.Disc !== 'NO') { HeadingNames[0].splice(9, 0, { text: (printOptions.Disc === 'PERC') ? 'Disc(%)' : 'Disc(Rs)', style: 'tableheader1', Field: 'Disc' }); } if (printOptions.ShowTax !== 'NO') { HeadingNames[0].splice(10, 0, { text: (SType === 'Intra') ? 'GST(%)' : 'IGST(%)', style: 'tableheader1', Field: 'TaxAmount', alignment: 'right' }); } } else { HeadingNames = [[{ text: 'S.No', style: 'tableheader1', Field: 'SNo', alignment: 'left' }, { text: 'Item Name', style: 'tableheader1', Field: 'Desc', alignment: 'left', line: true }, { text: 'Batch No.', style: 'tableheader1', Field: 'Batches', alignment: 'left' }, { text: 'Ex.Dt', style: 'tableheader1', Field: 'ExDate', alignment: 'left' }, { text: 'Qty', style: 'tableheader1', Field: 'Qty', alignment: 'right' }, { text: 'Free', style: 'tableheader1', Field: 'OfQty', alignment: 'right' }, { text: 'MRP', style: 'tableheader1', Field: 'MRP', alignment: 'right' }, { text: 'Price', style: 'tableheader1', Field: 'UnPr', alignment: 'right' }, { text: 'Line Total', style: 'tableheader1', Field: 'LineTotal', alignment: 'right' }]]; if (printOptions.Disc !== 'NO') { HeadingNames[0].splice(8, 0, { text: (printOptions.Disc === 'PERC') ? 'Disc(%)' : 'Disc(Rs)', style: 'tableheader1', Field: 'Disc' }); } } return HeadingNames; } static TotalDetails(ROPrintData: any, moreDiscDetails: boolean, DecimalsNumber: number) { let totalDisc: any; let totalTax: any; if (!ROPrintData.Consolidate) { totalTax = TrUtils.FixPriceValue(Add(Number(ROPrintData.CustLaborITax), Number(ROPrintData.CustPartITax)), DecimalsNumber); if (TrUtils.isTaxable(ROPrintData.Settings.Tax)) { totalDisc = TrUtils.FixPriceValue(Add(Number(ROPrintData.CustLaborDiscTotal), Number(ROPrintData.CustPartsDiscTotal)), DecimalsNumber); } else { totalDisc = TrUtils.FixPriceValue(Add(Number(ROPrintData.CustLaborDiscTotal), Number(ROPrintData.CustPartsDiscTotal)), DecimalsNumber); } } return [ { style: 'tableExample', marginTop: -3, table: { widths: ['*', '*'], body: [ [ { stack: [InvoicePrintService.PartsTaxAmounts1(ROPrintData.TaxSummary, true, ROPrintData.ShowIGST, ROPrintData.ShowTaxColumn)] }, { columns: [{ text: '', width: moreDiscDetails ? 120 : 150 }, InvoicePrintService.GrandTotal(ROPrintData, '0.00', ROPrintData.CustPartsTotalBeforeDisc, totalDisc, totalTax, ROPrintData.For, ROPrintData.FixedTotal, ROPrintData.CustTotalRoundedBy, ROPrintData.CustRoundedTotal, null, ROPrintData.Consolidate, ROPrintData.STotal, moreDiscDetails, ROPrintData.Entity.DecimalsNumber)], } ], ] }, layout: 'noBorders' }, ]; } static GrandTotal(InvoiceData: any, LaborAfterGST: any, PartsAfterGST: any, OverAllRecordDiscount: any, totalTax: any, For: any, OverAllRecordTotal: any, Rounded: any, GrandTotal: any, Adj: any, Consolidate: any, subTotal: any, moreDiscDetails: boolean, DecimalsNumber: number) { let AccountFields = []; if (moreDiscDetails) { if (!TrUtils.IsZero(InvoiceData.PDisc)) { AccountFields.push({ name: 'Items Discount', value: TrUtils.FixPriceValue(InvoiceData.PDisc, DecimalsNumber) }); } if (!TrUtils.IsZero(InvoiceData.LDisc)) { AccountFields.push({ name: 'Services Discount', value: TrUtils.FixPriceValue(InvoiceData.LDisc, DecimalsNumber) }); } if (!TrUtils.IsZero(InvoiceData.Disc)) { AccountFields.push({ name: 'Overall Discount', value: TrUtils.FixPriceValue(InvoiceData.Disc, DecimalsNumber) }); } } else { AccountFields.push({ name: 'Discount', value: OverAllRecordDiscount }); } if (!Consolidate && !TrUtils.IsNull(subTotal)) { AccountFields.unshift({ name: 'SubTotal', value: TrUtils.FixPriceValue(TrUtils.SetValueToZeroIfNull(Number(subTotal)), DecimalsNumber) }); } else { if (!Consolidate) { AccountFields.unshift({ name: 'SubTotal', value: TrUtils.FixPriceValue(Add(TrUtils.SetValueToZeroIfNull(Number(LaborAfterGST)), TrUtils.SetValueToZeroIfNull(Number(PartsAfterGST))), DecimalsNumber) }); } } if (!TrUtils.IsEmpty(totalTax)) { AccountFields.push({ name: 'Total Tax', value: totalTax }); } if (!TrUtils.IsEmpty(Adj)) { if (Adj > 0) { Adj = '+' + TrUtils.FixPriceValue(Adj, DecimalsNumber); } AccountFields.push({ name: 'Adjust', value: Adj }); } if (For === PayTypeEnum.Insurance) { let total = { name: 'Total', value: OverAllRecordTotal }; let Rounding = { name: 'Rounding', value: Rounded }; if (Rounding.value > 0) { Rounding.value = '+' + Rounding.value; } let FinalTotal = { name: 'Final Total', value: GrandTotal, bold: true, fontSize: 12 }; AccountFields.push(total); AccountFields.push(Rounding); if (!TrUtils.IsFixedZero(Rounded)) { AccountFields.push(FinalTotal); } } else { let total = { name: 'Total', value: OverAllRecordTotal }; let Rounding = { name: 'Rounding', value: Rounded }; let FinalTotal = { name: 'Final Total', value: GrandTotal }; if (Rounding.value > 0) { Rounding.value = '+' + Rounding.value; } AccountFields.push(Rounding); if (!TrUtils.IsFixedZero(Rounded)) { AccountFields.push(FinalTotal); } } return { style: ['columnheader', 'TotalsStyles'], lineHeight: 0.7, marginBottom: 5, width: 'auto', table: { widths: ['auto', 'auto', 60], body: InvoicePrintService.GrandTotalTable(AccountFields) }, layout: 'noBorders' }; } static GrandTotalTable(data: any) { var body: any = []; data.forEach((row: any) => { if (!TrUtils.IsFixedZero(row.value) || row.name === 'Total') { var dataRow: any = []; dataRow.push({ text: (row.name).toString(), noWrap: true }); dataRow.push(':'); if (row.name === 'Final Total') { dataRow.push({ text: (row.value).toString(), noWrap: true, bold: true, fontSize: 12, alignment: 'right' }); } else if (!TrUtils.IsNull(row.value)) { dataRow.push({ text: (row.value).toString(), noWrap: true, alignment: 'right' }); } else { dataRow.push({ text: '', noWrap: true, alignment: 'right' }); } body.push(dataRow); } }); return body; } static PartsTaxAmounts1(PartsTaxInfo: any, ShowAccParts: any, ShowIGST: any, ShowTaxColumn: any) { if (ShowTaxColumn && !TrUtils.IsNull(PartsTaxInfo) && PartsTaxInfo.length > 0) { return { stack: [InvoicePrintService.AllHSNPartCGSTTaxListTable1(PartsTaxInfo, ShowAccParts, ShowIGST, ShowTaxColumn)] }; } else { return ''; } } static AllHSNPartCGSTTaxListTable1(PartsTaxInfo: any, ShowAccParts: any, ShowIGST: any, ShowTaxColumn: any) { if (ShowIGST) { return { style: 'tableExample', table: { widths: [25, 60, 50], headerRows: 1, body: InvoicePrintService.CreateHSNTaxTable1(PartsTaxInfo, ShowAccParts, ShowIGST, ShowTaxColumn) }, layout: InvoicePrintService.HeaderLineStyle(), }; } else { return { style: 'tableExample', table: { widths: [25, 60, 40, 40], headerRows: 1, body: SharedPDFService.CreateHSNTaxTable1(PartsTaxInfo, ShowAccParts, ShowIGST, ShowTaxColumn) }, layout: InvoicePrintService.HeaderLineStyle(), }; } } static CreateHSNTaxTable1(PartsTaxInfo: any, ShowAccParts: any, ShowIGST: any, ShowTaxColumn: any) { if (!TrUtils.IsNull(PartsTaxInfo) && PartsTaxInfo.length !== 0 && ShowAccParts && ShowTaxColumn) { var body: any = []; let columns: any = InvoicePrintService.CreateHeadingAllTaxList(ShowIGST); body.push(columns); PartsTaxInfo.forEach((part: any) => { var dataRow: any = []; columns.forEach((column: any) => { if (!TrUtils.IsFixedZero(part[column.Field]) && !TrUtils.IsNull(part[column.Field]) || column.Field === 'SGST' || column.Field === 'CGST' || column.Field === 'SGSTAmt' || column.Field === 'CGSTAmt' || column.Field === 'TotalTaxableAmount') { if (column.Field === 'TotalTaxableAmount' || column.Field === 'SGSTAmt' || column.Field === 'CGSTAmt' || column.Field === 'IGSTAmt') { dataRow.push({ text: TrUtils.FixPriceValue(part[column.Field]), alignment: 'right', opacity: 0.7, nowrap: true, fontSize: 6 }); } else if (column.Field === 'CombinedTaxPercentage') { dataRow.push({ text: part[column.Field].toString() + '%', alignment: 'left', opacity: 0.7, nowrap: true, fontSize: 6 }); } else { dataRow.push({ text: part[column.Field].toString(), alignment: 'left', opacity: 0.7, nowrap: true, fontSize: 6 }); } } else { part[column.Field] = ''; dataRow.push({ text: part[column.Field].toString(), alignment: 'left', opacity: 0.7, fontSize: 6 }); } }); body.push(dataRow); }); return body; } else { return [{}]; } } static CreateHeadingAllTaxList(ShowIGST: any) { let HeaderNames = [ { text: 'Tax Rate', style: 'tableheader2', fontSize: 6, lineHeight: 0.8, Field: 'CombinedTaxPercentage', alignment: 'left' }, { text: 'Taxable Amount', style: 'tableheader2', fontSize: 6, lineHeight: 0.8, Field: 'TotalTaxableAmount', alignment: 'right' }, ]; if (ShowIGST) { HeaderNames.splice(2, 0, { text: 'IGST(Rs.)', style: 'tableheader2', fontSize: 6, lineHeight: 0.8, Field: 'IGSTAmt', alignment: 'right' }); } else { HeaderNames.splice(2, 0, { text: 'CGST(Rs.)', style: 'tableheader2', fontSize: 6, lineHeight: 0.8, Field: 'CGSTAmt', alignment: 'right' }); HeaderNames.splice(3, 0, { text: 'SGST(Rs.)', style: 'tableheader2', fontSize: 6, lineHeight: 0.8, Field: 'SGSTAmt', alignment: 'right' }); } return HeaderNames; } static HeaderLineStyle() { return { hLineWidth: function (i: any, node: any) { return (i === 1) ? 0.1 : 0; }, vLineWidth: function (i: any, node: any) { return (i === 0 || i === node.table.widths.length) ? 0 : 0; }, hLineColor: function (i: any, node: any) { let color; if (i === 0 || i === node.table.body.length) { color = 'black'; } else { if (i === 1) { color = 'lightgray'; } else { color = 'lightgray'; } } return color; }, }; } static GetNumberInWords(TotalAmount: any) { var rupee = SharedPDFService.convertNumberToWords(TotalAmount); return { columns: [{ text: 'In Words :', fontSize: 8, width: 45 }, { text: rupee, bold: true, fontSize: 8, width: '*' }] } } static InvoiceDueStatus(Type: any, Paid: any, Due: any, Status: any, isCounter: boolean, DecimalsNumber: number) { if (Type === 'Invoice' && !isCounter) { return { fontSize: InvoicePrintService.TableHeaders, marginTop: 3, marginBottom: 5, table: { widths: ['*', 'auto'], body: [[{ text: 'Paid : ' + TrUtils.FixPriceValue(Paid, DecimalsNumber), marginLeft: 20 }, { text: 'Due : ' + TrUtils.FixPriceValue(Due, DecimalsNumber), marginRight: 20 }]] }, layout: SharedPDFService.LayOutLineStyle(), }; } else { return InvoicePrintService.emptyObject(); } } static GetSignatures(CName: any, Total: any) { return [['', InvoicePrintService.CompanyName(CName)]]; } static CompanyName(CName: any) { return { style: 'forCompany1', text: ['For ', { text: CName, bold: 'true' }], }; } // ==================== LANDSCAPE-SPECIFIC METHODS (placeholder - continue from original) ==================== static GetLandscapeHeaderDetails(ROPrintData: any, text: any) { return [ { text: ROPrintData?.HeaderName, alignment: 'center', bold: true, fontSize: 10 }, { text: text, color: 'grey', alignment: 'right', width: 100, marginTop: (text !== null) ? -11 : 0, fontSize: 10 }, { style: 'tableExample', table: { widths: ['*', '*', '*'], body: [ [ { stack: [ { text: ROPrintData.Entity.CName, alignment: 'center', bold: true, fontSize: 13 }, { text: ROPrintData.Entity.Adrs1 + ', ' + ROPrintData.Entity.Adrs2 + ', ', alignment: 'center', style: ['headerstyle'] }, { text: ROPrintData.Entity.City + '-' + ROPrintData.Entity.PIN + ', Cell : ' + ROPrintData.Entity.Phone, alignment: 'center', style: ['headerstyle'] }, { stack: InvoicePrintService.GetLandscapeHeaderInfo(ROPrintData) }, ] }, SharedPDFService.GetCustomer(ROPrintData.Customer, ROPrintData.Type, ROPrintData.For, ROPrintData.Product, ROPrintData.Settings, 'Customer Name & Address', false), SharedPDFService.GetVehicleDetails(ROPrintData.Type, ROPrintData._id, ROPrintData.CrDate, ROPrintData.PrDate, ROPrintData.MOut, ROPrintData.MIn, ROPrintData.Product, ROPrintData.PrintType, ROPrintData.IsProforma, ROPrintData.Settings, false, ROPrintData.BL, null, null, null, ROPrintData.DoS)], ] }, layout: PrintSharedService.LayOutStyle() }, ]; } static GetLandscapeHeaderInfo(InvoicePDFData: any) { let TaxInfo: any = []; if (!TrUtils.IsEmpty(InvoicePDFData.Entity.GSTIN)) { TaxInfo.push({ text: 'GSTIN : ' + InvoicePDFData.Entity.GSTIN, marginTop: 2, marginLeft: 5, alignment: 'left', fontSize: 9, width: 'auto' }); } if (!TrUtils.IsEmpty(InvoicePDFData.Entity.DLNo)) { TaxInfo.push({ text: 'D.L.NO : ' + InvoicePDFData.Entity.DLNo, marginTop: 2, marginLeft: 5, alignment: 'left', fontSize: 9, width: '*' }); } TaxInfo.push({ text: InvoicePDFData.Settings.Tax === 'BS' ? 'Bill of Supply' : null, alignment: 'right', marginRight: 5, marginTop: 2, marginBottom: 3, fontSize: 9, width: 'auto' }); return TaxInfo; } static PrepareLandscapePartsTable(ROPrintData: any) { let List: any = []; if (ROPrintData.Entity.Body === 1) { for (let i = 0; i < ROPrintData.PrintInfo.length; i++) { if (TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) { ROPrintData.PrintInfo[i].Text = ''; } } } else { if (ROPrintData.Entity.Body === 2) { for (let i = 0; i < ROPrintData.PrintInfo.length; i++) { if (TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) { ROPrintData.PrintInfo[i].Text = ''; } List.push(ROPrintData.PrintInfo[i].Text, InvoicePrintService.WithOutDiscountFieldTable(TrUtils.Stringify(ROPrintData.PrintInfo[i].Items), ROPrintData.ShowTaxColumn, ROPrintData.Entity.MPN, ROPrintData.Entity.Body, ROPrintData.ShowIGST, ROPrintData.ConsolidateGST, ROPrintData.ShowDiscountColumn) ); } } else { if (ROPrintData.Summary) { // Summary view - empty for now } else { for (let i = 0; i < ROPrintData.PrintInfo.length; i++) { if (TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) { ROPrintData.PrintInfo[i].Text = ''; } List.push(ROPrintData.PrintInfo[i].Text, InvoicePrintService.GetWithOutDiscAndTaxFieldHeader(TrUtils.Stringify(ROPrintData.PrintInfo[i].Items), ROPrintData.ShowTaxColumn, ROPrintData.Entity.MPN, ROPrintData.Entity.Body, ROPrintData.ShowIGST, ROPrintData.ConsolidateGST, ROPrintData.ShowDiscountColumn) ); } } } } return List; } static WithOutDiscountFieldTable(Parts: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any) { if (Parts.length !== 0) { if (PrintPartNo) { return { style: 'tableExample', marginLeft: 20, table: { widths: [15, 67, 160, 25, 50, 60, 30, 53], headerRows: 1, body: InvoicePrintService.BuildLandscapeTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyleanother() }; } else { return { style: 'tableExample', marginLeft: 20, table: { widths: [15, 215, 25, 50, 60, 45, 60], headerRows: 1, body: InvoicePrintService.BuildLandscapeTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyleanother() }; } } else { let a: any = ''; return a; } } static BuildLandscapeTableBodyForLaborAndParts(Parts: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any) { var body: any = []; let columns: any = InvoicePrintService.GetLandscapeWithOutDiscountFieldHeader(PrintPartNo, ShowTaxColumn, Body, ShowIGST, ShowDiscountColumn); for (let i = 0; i < columns.length; i++) { body.push(columns[i]); } columns = columns[1]; let DummyOps: any = []; if (Parts.length !== 0) { if (Parts.length <= 15) { let Count: number = 18 - Parts.length; for (let i = 0; i < Count; i++) { Parts.push({}); } } else { let Count: number = 58 - Parts.length; for (let i = 0; i < Count; i++) { Parts.push({}); } } } let SNo: number = 1; Parts.forEach((part: any) => { var dataRow: any = []; columns.forEach((column: any) => { if ( (!TrUtils.IsFixedZero(part[column.Field]) && !TrUtils.IsNull(part[column.Field])) || (column.text === 'Line Total' || column.text === 'Expiry')) { if (part[column.Field] === 'Spare Parts') { dataRow.push({ text: part[column.Field].toString(), marginLeft: 50, style: 'InlineHeader' }); } else { if (((column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt' || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc') && TrUtils.CheckInvalidSelect(part.TCode))) { part[column.Field] = ''; dataRow.push({ text: part[column.Field].toString(), alignment: 'center' }); } else { if (column.text === 'Line Total' || column.Field === 'UnPr' || column.Field === 'MRP' || column.Field === 'Batch' || column.Field === 'ExDate' || column.Field === 'QtyAndUoM' || column.text === 'Tax' || column.Field === 'Disc' || column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt' || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc') { if (column.Field === 'Disc') { if (column.type === 'percentage') { if (!TrUtils.IsEmpty(part[column.Field])) { dataRow.push({ text: part[column.Field].toString(), noWrap: true }); } else { dataRow.push({ text: '', noWrap: true }); } } else { if (!TrUtils.IsZero(part[column.Field])) { dataRow.push({ text: part[column.Field].toString(), noWrap: true }); } else { dataRow.push({ text: '', noWrap: true }); } } } else { if (column.Field === 'Batch') { if (!TrUtils.IsNull(part[column.Field])) { dataRow.push({ text: part[column.Field].BN, nowrap: true }); } else { dataRow.push({ text: '', noWrap: true }); } } else if (column.Field === 'ExDate') { if (!TrUtils.IsNull(part['Batch'])) { dataRow.push({ text: MyDate.ConvertUTCDateToReadableExDate(part['Batch'].ExDt), nowrap: true }); } else { dataRow.push({ text: '', noWrap: true }); } } else { if (!TrUtils.IsZero(part[column.Field])) { dataRow.push({ text: part[column.Field].toString(), alignment: 'right', nowrap: true }); } else { dataRow.push({ text: '', noWrap: true }); } } } } else { if (TrUtils.IsNull(part[column.Field])) { part[column.Field] = ''; } if (column.Field === 'Desc') { let DescData: any = []; DescData.push(part[column.Field].toString()); if (!TrUtils.IsEmpty(part['EDesc'])) { DescData.push({ text: part['EDesc'].toString(), color: 'grey' }); } dataRow.push({ stack: DescData }); } else { dataRow.push({ text: part[column.Field].toString() }); } } } } } else { if (column.Field === 'SNo' && !TrUtils.IsNull(part.Desc)) { part[column.Field] = SNo; SNo = SNo + 1; } else { part[column.Field] = ''; } dataRow.push({ text: part[column.Field].toString(), alignment: 'center' }); } }); body.push(dataRow); }); return body; } static GetLandscapeWithOutDiscountFieldHeader(permission: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ShowDiscountColumn: any) { if (Body === 2) { let headersNames: any = [{ text: 'Description', style: 'tableheader', Field: 'Desc' }, { text: 'Qty', style: 'tableheader', Field: 'QtyAndUoM' }, { text: 'Unit Price', style: 'tableheader', Field: 'UnPr' }, { text: 'Labor Charges', style: 'tableheader', Field: 'Price' }, { text: 'Tax', style: 'tableheader', Field: 'TaxAmount' }, { text: 'Line Total', style: 'tableheader', Field: 'LineTotal' }]; if (permission) { let sno = { text: 'S.No.', style: 'tableheader', Field: 'SNo' }; let MPN = { text: 'Part No', style: 'tableheader', Field: 'MPN' }; headersNames.unshift(sno, MPN); } else { let sno = { text: 'S.No.', style: 'tableheader', Field: 'SNo' }; headersNames.unshift(sno); } return headersNames; } else { if (ShowTaxColumn) { return InvoicePrintService.GetLandscapeWithOutDiscountFieldHeader1(permission, Body, ShowIGST, ShowDiscountColumn); } else { return InvoicePrintService.GetLandscapeWithOutDiscountFieldHeader2(permission, Body, ShowDiscountColumn); } } } static GetLandscapeWithOutDiscountFieldHeader1(permission: any, Body: any, ShowIGST: any, ShowDiscountColumn: any) { let headersNames: any; if (permission) { headersNames = [[{ text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }, { text: 'Part No', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }, { text: 'Description', rowSpan: 2, style: 'tableheader', alignment: 'center', lineHeight: 0.5 }, { text: 'HSN/SAC', rowSpan: 2, style: 'tableheader', lineHeight: 1 }, { text: 'Batch No', rowSpan: 2, style: 'tableheader', lineHeight: 1 }, { text: 'Expiry', rowSpan: 2, style: 'tableheader', lineHeight: 1 }, { text: 'Qty', style: 'tableheader', rowSpan: 2, lineHeight: 0.5 }, { text: 'Offer Qty', style: 'tableheader', rowSpan: 2, lineHeight: 1 }, { text: 'M.R.P', style: 'tableheader', rowSpan: 2, lineHeight: 0.5, alignment: 'center', }, { text: 'Unit Price', style: 'tableheader', rowSpan: 2, lineHeight: 0.5, alignment: 'center', }, { text: 'Line Total', rowSpan: 2, lineHeight: 0.5, style: 'tabFleheader' } ], [{ text: '', Field: 'SNo', lineHeight: 0.5 }, { text: '', Field: 'MPN', lineHeight: 0.5 }, { text: '', Field: 'Desc', lineHeight: 0.5 }, { text: 'HSN/SAC', Field: 'HSN', lineHeight: 0.5 }, { text: '', Field: 'Batch', lineHeight: 0.5 }, { text: 'Expiry', Field: 'ExDate', lineHeight: 0.5 }, { text: '', Field: 'QtyAndUoM', lineHeight: 0.5 }, { text: '', Field: 'OfQty', lineHeight: 0.5 }, { text: '', Field: 'MRP', lineHeight: 0.5 }, { text: '', Field: 'UnPr', lineHeight: 0.5 }, { text: 'Line Total', Field: 'LineTotal', lineHeight: 0.5 } ] ]; let Count: number = 10; if (ShowDiscountColumn) { headersNames[0].splice(Count, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 }); headersNames[1].splice(Count + 1, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }); Count = 12; } if (ShowIGST) { headersNames[0].splice(Count, 0, { text: 'IGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'IGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'IGSTAmt', type: 'amount', lineHeight: 0.5 }); } else { headersNames[0].splice(Count, 0, { text: 'CGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'CGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'CGSTAmt', type: 'amount', lineHeight: 0.7 }); headersNames[0].splice(Count + 2, 0, { text: 'SGST/UTGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 3, 0, {}); headersNames[1].splice(Count + 2, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'SGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 3, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'SGSTAmt', type: 'amount', lineHeight: 0.5 }); } } else { headersNames = [[{ text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.6 }, { text: 'Description', rowSpan: 2, style: 'tableheader', alignment: 'center', lineHeight: 0.6 }, { text: 'HSN/SAC', rowSpan: 2, style: 'tableheader', lineHeight: 1 }, { text: 'Batch No', rowSpan: 2, style: 'tableheader', lineHeight: 1 }, { text: 'Expiry', rowSpan: 2, style: 'tableheader', lineHeight: 1 }, { text: 'Qty', style: 'tableheader', rowSpan: 2, lineHeight: 0.6 }, { text: 'Offer Qty', style: 'tableheader', rowSpan: 2, lineHeight: 1 }, { text: 'M.R.P', style: 'tableheader', rowSpan: 2, lineHeight: 0.5, alignment: 'center', }, { text: 'Unit Price', style: 'tableheader', rowSpan: 2, alignment: 'center', lineHeight: 0.6 }, { text: 'Line Total', rowSpan: 2, style: 'tableheader', lineHeight: 0.6 } ], [{ text: '', Field: 'SNo', lineHeight: 0.5 }, { text: '', Field: 'Desc', lineHeight: 0.5 }, { text: 'HSN/SAC', Field: 'HSN', lineHeight: 0.5 }, { text: '', Field: 'Batch', lineHeight: 0.5 }, { text: 'Expiry', Field: 'ExDate', lineHeight: 0.5 }, { text: '', Field: 'QtyAndUoM', lineHeight: 0.5 }, { text: '', Field: 'OfQty', lineHeight: 0.5 }, { text: '', Field: 'MRP', lineHeight: 0.5 }, { text: '', Field: 'UnPr', lineHeight: 0.5 }, { text: 'Line Total', Field: 'LineTotal', lineHeight: 0.5 } ]]; let Count: number = 9; if (ShowDiscountColumn) { headersNames[0].splice(Count, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 }); headersNames[1].splice(Count + 1, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }); Count = 11; } if (ShowIGST) { headersNames[0].splice(Count, 0, { text: 'IGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'IGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'IGSTAmt', type: 'amount', lineHeight: 0.5 }); } else { headersNames[0].splice(Count, 0, { text: 'CGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'CGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'CGSTAmt', type: 'amount', lineHeight: 0.5 }); headersNames[0].splice(Count + 2, 0, { text: 'SGST/UTGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 3, 0, {}); headersNames[1].splice(Count + 2, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'SGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 3, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'SGSTAmt', type: 'amount', lineHeight: 0.5 }); } } return headersNames; } static GetLandscapeWithOutDiscountFieldHeader2(permission: any, Body: any, ShowDiscountColumn: any) { let headersNames: any = [[ { text: 'Description', rowSpan: 2, style: 'tableheader', alignment: 'left', lineHeight: 0.5 }, { text: 'Batch No', rowSpan: 2, style: 'tableheader', lineHeight: 1 }, { text: 'Expiry', rowSpan: 2, style: 'tableheader', lineHeight: 1 }, { text: 'Qty', style: 'tableheader', rowSpan: 2, lineHeight: 0.5 }, { text: 'Offer Qty', style: 'tableheader', rowSpan: 2, lineHeight: 1 }, { text: 'M.R.P', style: 'tableheader', rowSpan: 2, lineHeight: 0.5, alignment: 'center', }, { text: 'Unit Price', style: 'tableheader', rowSpan: 2, lineHeight: 0.5, alignment: 'right', }, { text: 'Line Total', rowSpan: 2, lineHeight: 0.5, style: 'tableheader' } ], [ { text: '', Field: 'Desc', lineHeight: 0.5 }, { text: '', Field: 'Batch', lineHeight: 0.5 }, { text: 'Expiry', Field: 'ExDate', lineHeight: 0.5 }, { text: '', Field: 'QtyAndUoM', lineHeight: 0.5 }, { text: '', Field: 'OfQty', lineHeight: 0.5 }, { text: '', Field: 'MRP', lineHeight: 0.5 }, { text: '', Field: 'UnPr', lineHeight: 0.5 }, { text: 'Line Total', Field: 'LineTotal', lineHeight: 0.5 } ]]; if (permission) { let sno = { text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }; let MPN = { text: 'Part No', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }; let sno1 = { text: '', Field: 'SNo', lineHeight: 0.5 }; let MPN1 = { text: '', Field: 'MPN', lineHeight: 0.5 }; headersNames[0].unshift(sno, MPN); headersNames[1].unshift(sno1, MPN1); if (ShowDiscountColumn) { headersNames[0].splice(9, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 }); headersNames[0].splice(10, 0, {}); headersNames[1].splice(9, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 }); headersNames[1].splice(10, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }); } } else { let sno = { text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }; let sno1 = { text: '', Field: 'SNo', lineHeight: 0.5 }; headersNames[0].unshift(sno); headersNames[1].unshift(sno1); if (ShowDiscountColumn) { headersNames[0].splice(8, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 }); headersNames[0].splice(9, 0, {}); headersNames[1].splice(8, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 }); headersNames[1].splice(9, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }); } } return headersNames; } static GetWithOutDiscAndTaxFieldHeader(Parts: any, ShowTaxColumn: any, PrintPartNo: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any) { if (Parts.length !== 0) { if (ShowTaxColumn) { return InvoicePrintService.TaxDataTable(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn); } else { if (ConsolidateGST) { return InvoicePrintService.ConsolidateDataTable(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn); } else { return InvoicePrintService.NoTaxDataTable(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn); } } } else { let a: any = ''; return a; } } static TaxTableWidths(PrintPartNo: any, ShowIGST: any, ShowDiscountColumn: any) { if (PrintPartNo) { if (ShowIGST) { if (ShowDiscountColumn) { return [24, 50, '*', 50, 35, 35, 30, 25, 40, 35, 20, 35, 20, 35, 45]; } else { return [24, 50, '*', 50, 35, 35, 30, 25, 40, 40, 20, 35, 51]; } } else { if (ShowDiscountColumn) { return [24, 45, '*', 50, 35, 35, 30, 22, 40, 40, 20, 34, 20, 32, 20, 32, 48]; } else { return [24, 45, '*', 50, 35, 35, 30, 22, 40, 40, 20, 32, 20, 32, 54]; } } } else { if (ShowIGST) { if (ShowDiscountColumn) { return [24, '*', 50, 41, 35, 30, 25, 40, 40, 20, 35, 20, 35, 41]; } else { return [24, '*', 50, 50, 35, 30, 25, 40, 40, 20, 40, 50]; } } else { if (ShowDiscountColumn) { return [24, '*', 50, 45, 35, 30, 22, 40, 40, 20, 34, 20, 35, 20, 35, 45]; } else { return [24, '*', 50, 50, 35, 30, 22, 40, 40, 20, 35, 20, 35, 50]; } } } } static TaxDataTable(Parts: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any) { if (PrintPartNo) { if (ShowIGST) { return { style: 'tableExample', marginTop: -6, table: { widths: InvoicePrintService.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn), body: InvoicePrintService.BuildLandscapeTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } else { return { style: 'tableExample', marginTop: -6, table: { widths: InvoicePrintService.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn), body: InvoicePrintService.BuildLandscapeTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } } else { if (ShowIGST) { return { style: 'tableExample', marginTop: -6, table: { widths: InvoicePrintService.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn), body: InvoicePrintService.BuildLandscapeTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } else { return { style: 'tableExample', marginTop: -6, table: { widths: InvoicePrintService.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn), body: InvoicePrintService.BuildLandscapeTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } } } static WidthForInsuranceOrNot(ShowDiscountColumn: any, PrintPartNo: boolean) { if (PrintPartNo) { if (ShowDiscountColumn) { return [24, 70, '*', 45, 45, 25, 25, 60, 60, 45, 45, 50]; } else { return [25, 70, '*', 45, 45, 35, 35, 60, 60, 80]; } } else { if (ShowDiscountColumn) { return [25, '*', 50, 50, 50, 50, 70, 70, 70, 70, 70]; } else { return [25, '*', 45, 45, 40, 40, 60, 60, 80]; } } } static ConsolidateDataTable(Parts: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any) { if (PrintPartNo) { return { style: 'tableExample', marginTop: -6, table: { widths: InvoicePrintService.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo), body: InvoicePrintService.BuildLandscapeTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } else { return { style: 'tableExample', marginTop: -6, table: { widths: InvoicePrintService.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo), body: InvoicePrintService.BuildLandscapeTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } } static NoTaxDataTable(Parts: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any) { if (PrintPartNo) { return { style: 'tableExample', marginTop: -6, table: { widths: InvoicePrintService.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo), body: InvoicePrintService.BuildLandscapeTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } else { return { style: 'tableExample', marginTop: -6, table: { widths: InvoicePrintService.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo), body: InvoicePrintService.BuildLandscapeTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } } static GetLandscapeTotalDetails(ROPrintData: any, index: any, numberofCopies: any, moreDiscDetails: boolean) { let totalDisc: any; let totalTax: any; if (!ROPrintData.Consolidate) { totalTax = TrUtils.FixPriceValue(Add(Number(ROPrintData.CustLaborITax), Number(ROPrintData.CustPartITax), ROPrintData.Entity.DecimalsNumber)); if (TrUtils.isTaxable(ROPrintData.Settings.Tax)) { totalDisc = TrUtils.FixPriceValue(Add(Number(ROPrintData.CustLaborDiscTotal), Number(ROPrintData.CustPartsDiscTotal), ROPrintData.Entity.DecimalsNumber)); } else { totalDisc = TrUtils.FixPriceValue(Add(Number(ROPrintData.CustLaborDiscTotal), Number(ROPrintData.CustPartsDiscTotal), ROPrintData.Entity.DecimalsNumber)); } } let CommonDetails = [ [{ style: 'tableExample', marginTop: -6, table: { widths: ['*', '*', '*'], heights: [105, 105, 105], body: [ [ SharedPDFService.PartsTaxAmounts1(ROPrintData.TaxSummary, true, ROPrintData.ShowIGST, ROPrintData.ShowTaxColumn), SharedPDFService.GetBankDetials(ROPrintData.Entity.Bank, ROPrintData.Entity.PrBank, ROPrintData.Entity.UPIPhone), { columns: [{ text: '', width: moreDiscDetails ? 153 : 175 }, SharedPDFService.GrandTotal(ROPrintData, '0.00', ROPrintData.CustPartsTotalBeforeDisc, totalDisc, totalTax, ROPrintData.For, ROPrintData.FixedTotal, ROPrintData.CustTotalRoundedBy, ROPrintData.CustRoundedTotal, null, ROPrintData.Consolidate, null, moreDiscDetails, ROPrintData.Entity.DecimalsNumber)] } ], ] }, layout: PrintSharedService.LayOutStyle() }], SharedPDFService.GetTemsAndConditions(ROPrintData.Entity.Terms), InvoicePrintService.GetLandscapeSignatures(ROPrintData.Entity.CName, ROPrintData.Type, ROPrintData.For), ]; if (!TrUtils.IsNull(numberofCopies) && numberofCopies.length !== 0 && (index !== (numberofCopies.length - 1))) { CommonDetails.push({ text: '', pageBreak: 'after' }) } return CommonDetails; } static GetLandscapeSignatures(CName: any, For: any, Type: any) { return { columns: [{ stack: [ InvoicePrintService.CompanyName(CName), { columns: [InvoicePrintService.Authorizedsignature(), SharedPDFService.SurveyorSignature(For, Type), InvoicePrintService.CustomerSignature()] } ] }], }; } static Authorizedsignature() { return { style: 'Sign1', text: ['Authorized Signatory'], }; } static CustomerSignature() { return { style: 'Sign1', text: ['Customer Signature'], marginLeft: 90 }; } // ==================== HC-SPECIFIC METHODS ==================== static GetHCMarginsBasedOnPaperSize(size: any) { if (size === 'full') { return [25, 15, 15, 15]; } else { return [25, 15, 15, 435.945]; } } static GetHCWatermark(ROPrintData: any) { if (ROPrintData.IsProforma && ROPrintData.Entity.Wmark) { return { text: 'Not a final invoice', opacity: 0.2 }; } else { return ''; } } static GetHCHeaderDetails(ROPrintData: any, text: any, isotherIndustry: boolean) { return [ SharedPDFService.GetMainHeader(ROPrintData.Entity, ROPrintData.Image, ROPrintData.AColor, ROPrintData.HColor, text), InvoicePrintService.GetHCPrintType(ROPrintData.HeaderName, ROPrintData.Entity.RegNo), InvoicePrintService.HeaderAfterLine(), SharedPDFService.GetCustomerAndVehicleDetails(ROPrintData._id, ROPrintData.CrDate, ROPrintData.PrDate, ROPrintData.MOut, ROPrintData.MIn, ROPrintData.Product, ROPrintData.PrintType, ROPrintData.For, ROPrintData.SurName, ROPrintData.SurPhone, ROPrintData.Type, ROPrintData.SurEmail, ROPrintData.InsComp, ROPrintData.PolNo, ROPrintData.PolType, ROPrintData.Customer, ROPrintData.IsProforma, null, ROPrintData.Location, isotherIndustry, ROPrintData.BL, ROPrintData.ROCode, ROPrintData.TypeName, ROPrintData.AdmNo, ROPrintData.DoS, ROPrintData.Entity.PrCustBar), SharedPDFService.GetOwnerDetails(ROPrintData.Cust, ROPrintData.Type, ROPrintData.For), InvoicePrintService.CustomerAndVehicleDetailsAfterLine(), SharedPDFService.GetDisplayTable(), ]; } static GetHCPrintType(type: any, RegNo: any) { return { columns: [{ text: '', width: 120 }, { text: type, alignment: 'center', style: 'Receiptheader1' }, { text: 'Regn.No : ' + RegNo, alignment: 'right', width: 140, fontSize: 7 }] }; } static HeaderAfterLine() { return { canvas: [ { type: 'line', lineColor: 'grey', x1: 0, y1: 0, x2: 555, y2: 0, lineWidth: 1.5 } ] }; } static CustomerAndVehicleDetailsAfterLine() { return { canvas: [ { type: 'line', lineColor: 'grey', x1: 0, y1: 0, x2: 555, y2: 0, lineWidth: 1.5 } ] }; } static PrepareHCPartsTable(ROPrintData: any, isAuto: boolean) { let List: any = []; if (ROPrintData.Entity.Body === 1) { for (let i = 0; i < ROPrintData.PrintInfo.length; i++) { if (TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) { ROPrintData.PrintInfo[i].Text = ''; } List.push(ROPrintData.PrintInfo[i].Text, InvoicePrintService.GetHCLaborPartsTableForView(TrUtils.Stringify(ROPrintData.PrintInfo[i].Items), TrUtils.Stringify(ROPrintData.PrintInfo[i].Ops), false) ); } } else { if (ROPrintData.Entity.Body === 2) { for (let i = 0; i < ROPrintData.PrintInfo.length; i++) { if (TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) { ROPrintData.PrintInfo[i].Text = ''; } List.push(ROPrintData.PrintInfo[i].Text, InvoicePrintService.GetHCWithOutDiscountFieldTable(TrUtils.Stringify(ROPrintData.PrintInfo[i].Items), TrUtils.Stringify(ROPrintData.PrintInfo[i].Ops), ROPrintData.ShowTaxColumn, false, ROPrintData.Entity.Body, ROPrintData.ShowIGST, ROPrintData.ConsolidateGST, ROPrintData.ShowDiscountColumn, isAuto, ROPrintData.Entity.DecimalsNumber) ); } } else { if (ROPrintData.Summary) { List.push('', InvoicePrintService.GetHCLaborPartsTableForView(ROPrintData.Items, ROPrintData.Ops, false) ); } else { for (let i = 0; i < ROPrintData.PrintInfo.length; i++) { if (TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) { ROPrintData.PrintInfo[i].Text = ''; } List.push(ROPrintData.PrintInfo[i].Text, InvoicePrintService.GetHCWithOutDiscAndTaxFieldHeader(TrUtils.Stringify(ROPrintData.PrintInfo[i].Items), TrUtils.Stringify(ROPrintData.PrintInfo[i].Ops), ROPrintData.ShowTaxColumn, false, ROPrintData.Entity.Body, ROPrintData.ShowIGST, ROPrintData.ConsolidateGST, ROPrintData.ShowDiscountColumn, isAuto, ROPrintData.Entity.DecimalsNumber) ); } } } } return List; } static GetHCLaborPartsTableForView(Parts: any, Ops: any, PrintPartNo: any) { if (Parts.length !== 0 || Ops.length !== 0) { if (PrintPartNo) { return { style: 'tableExample', table: { widths: [25, 30, 170, 85, 15, 20, 50, 30, 30, 50], body: InvoicePrintService.BuildHCTableForCustomerLabor(Parts, Ops, PrintPartNo, false) }, layout: PrintSharedService.LayOutStyleanother() }; } else { return { style: 'tableExample', table: { widths: [25, 200, 55, 25, 55, 55, 40, 15, 50], body: InvoicePrintService.BuildHCTableForCustomerLabor(Parts, Ops, PrintPartNo, false) }, layout: PrintSharedService.LayOutStyleanother() }; } } else { let a: any = ''; return a; } } static GetHCWithOutDiscountFieldTable(Parts: any, Ops: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any, isAuto: boolean, DecimalsNumber: number) { if (Parts.length !== 0 || Ops.length !== 0) { if (PrintPartNo) { return { style: 'tableExample', marginLeft: 20, table: { widths: [25, 60, 155, 30, 50, 60, 30, 50], headerRows: 1, body: InvoicePrintService.BuildHCTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) }, layout: PrintSharedService.LayOutStyleanother() }; } else { return { style: 'tableExample', marginLeft: 20, table: { widths: [25, 215, 25, 50, 60, 45, 50], headerRows: 1, body: InvoicePrintService.BuildHCTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) }, layout: PrintSharedService.LayOutStyleanother() }; } } else { let a: any = ''; return a; } } static BuildHCTableBodyForLaborAndParts(Parts: any, Labor: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any, isAuto: boolean, DecimalsNumber: number) { var body: any = []; let columns: any = PrintSharedService.GetWithOutDiscountFieldHeader(PrintPartNo, ShowTaxColumn, Body, ShowIGST, ShowDiscountColumn); for (let i = 0; i < columns.length; i++) { body.push(columns[i]); } columns = columns[1]; let DummyOps: any = []; if (Parts.length !== 0) { if (isAuto) { let Qty: number = 0; let CGSTAMT: number = 0; let SGSTAMT: number = 0; let IGSTAMT: number = 0; let Taxable: number = 0; let FinalTotal: number = 0; Parts.forEach((part: any) => { Qty = Qty + part.Qty; CGSTAMT = CGSTAMT + part.CGSTAmt; SGSTAMT = SGSTAMT + part.SGSTAmt; IGSTAMT = IGSTAMT + part.IGSTAmt; Taxable = Taxable + part.AfterPartDisc; FinalTotal = FinalTotal + part.AfterPartTax; }); let dpartadding1: any = {}; dpartadding1.SNo = ''; dpartadding1.Desc = 'Medications Total'; dpartadding1.QtyAndUoM = TrUtils.FixedTo(Qty, DecimalsNumber); dpartadding1.bold = true; dpartadding1.UnPr = TrUtils.FixedTo(Taxable, DecimalsNumber); dpartadding1.SGSTAmt = TrUtils.FixedTo(SGSTAMT, DecimalsNumber); dpartadding1.IGSTAmt = TrUtils.FixedTo(IGSTAMT, DecimalsNumber); dpartadding1.CGSTAmt = TrUtils.FixedTo(CGSTAMT, DecimalsNumber); dpartadding1.TCode = ShowTaxColumn ? 114 : undefined; dpartadding1.LineTotal = TrUtils.FixPriceValue(FinalTotal, DecimalsNumber); Parts.push({ SNo: '' }); Parts.push(dpartadding1); } let dummypartadding1: any = {}; dummypartadding1.SNo = ''; dummypartadding1.Desc = ' '; dummypartadding1.Qty = ''; dummypartadding1.UnPr = ''; dummypartadding1.LineTotal = ''; } let SNo: number = 1; Parts.forEach((part: any) => { var dataRow: any = []; columns.forEach((column: any) => { if ( (!TrUtils.IsNull(part[column.Field])) || (column.text === 'Line Total')) { if (((column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt' || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc') && TrUtils.CheckInvalidSelect(part.TCode))) { part[column.Field] === ''; dataRow.push({ text: part[column.Field].toString(), alignment: 'center' }); } else { if (column.text === 'Line Total' || column.Field === 'UnPr' || column.Field === 'HSN' || column.Field === 'QtyAndUoM' || column.text === 'Tax' || column.Field === 'Disc' || column.Field === 'Perc' || column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt' || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc') { if (column.Field === 'Disc') { if (column.type === 'percentage') { if (!TrUtils.IsEmpty(part[column.Field])) { dataRow.push({ text: part[column.Field].toString(), noWrap: true, alignment: 'right' }); } else { dataRow.push({ text: '', noWrap: true }); } } else { if (!TrUtils.IsNull(part[column.Field])) { dataRow.push({ text: TrUtils.FixPriceValue(part[column.Field]).toString(), alignment: 'right', noWrap: true }); } else { dataRow.push({ text: '', noWrap: true }); } } } else { if (!TrUtils.IsNull(part[column.Field])) { dataRow.push({ text: part[column.Field].toString(), bold: part.bold, alignment: 'right', nowrap: true }); } else { dataRow.push({ text: '', noWrap: true }); } } } else { if (column.Field === 'Desc') { let DescData: any = []; DescData.push({ text: part[column.Field].toString(), bold: part.bold }); if (!TrUtils.IsEmpty(part['EDesc'])) { DescData.push({ text: part['EDesc'].toString(), color: 'grey' }); } dataRow.push({ stack: DescData }); } else { dataRow.push({ text: part[column.Field].toString() }); } } } } else { if (column.Field === 'SNo') { part[column.Field] = SNo; SNo = SNo + 1; } else { if (TrUtils.IsNull(part[column.Field])) { part[column.Field] = ''; } } dataRow.push({ text: part[column.Field].toString(), alignment: 'center' }); } }); body.push(dataRow); }); SNo = 1; if (Labor.length !== 0 && Parts.length !== 0) { if (isAuto) { let CGSTAMT: number = 0; let SGSTAMT: number = 0; let IGSTAMT: number = 0; let Taxable: number = 0; let FinalTotal: number = 0; Labor.forEach((operation: any) => { CGSTAMT = CGSTAMT + operation.CGSTAmt; SGSTAMT = SGSTAMT + operation.SGSTAmt; IGSTAMT = IGSTAMT + operation.IGSTAmt; Taxable = Taxable + operation.AfterLaborDisc; FinalTotal = FinalTotal + operation.AfterLaborTax; }); let dpartadding1: any = {}; dpartadding1.SNo = ''; dpartadding1.Desc = 'Procedures Total'; dpartadding1.UnPr = TrUtils.FixedTo(Taxable, DecimalsNumber); dpartadding1.SGSTAmt = TrUtils.FixedTo(SGSTAMT, DecimalsNumber); dpartadding1.IGSTAmt = TrUtils.FixedTo(IGSTAMT, DecimalsNumber); dpartadding1.CGSTAmt = TrUtils.FixedTo(CGSTAMT, DecimalsNumber); dpartadding1.TCode = ShowTaxColumn ? 114 : undefined; dpartadding1.bold = true; dpartadding1.LineTotal = TrUtils.FixPriceValue(FinalTotal, DecimalsNumber); Labor.push({ SNo: '' }); Labor.push(dpartadding1); } let dummypartadding1: any = {}; dummypartadding1.SNo = ''; dummypartadding1.Desc = ' '; dummypartadding1.Qty = ''; dummypartadding1.UnPr = ''; dummypartadding1.LineTotal = ''; Labor.unshift(dummypartadding1); } if (Body === 2) { for (let i = 0; i < Labor.length; i++) { Labor[i].UnPr = ''; } } Labor.forEach((Ops: any) => { var dataRow: any = []; columns.forEach((column: any) => { if ((!TrUtils.IsNull(Ops[column.Field])) || (column.text === 'Line Total')) { if (Ops[column.Field] === 'Procedures') { dataRow.push({ text: Ops[column.Field].toString(), marginLeft: 50, style: 'InlineHeader' }); } else { if (((column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt' || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc') && TrUtils.CheckInvalidSelect(Ops.TCode))) { Ops[column.Field] = ''; dataRow.push({ text: Ops[column.Field].toString(), alignment: 'center' }); } else { if (column.text === 'Line Total' || column.Field === 'Price' || column.Field === 'HSN' || column.text === 'Tax' || column.Field === 'UnPr' || column.Field === 'QtyAndUoM' || column.Field === 'Disc' || column.Field === 'Perc' || column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt' || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc') { if (column.Field === 'Disc') { if (column.type === 'percentage') { if (!TrUtils.IsEmpty(Ops[column.Field])) { dataRow.push({ text: Ops[column.Field].toString(), alignment: 'right', noWrap: true }); } else { dataRow.push({ text: '', noWrap: true }); } } else { if (!TrUtils.IsNull(Ops[column.Field])) { dataRow.push({ text: TrUtils.FixPriceValue(Ops[column.Field]).toString(), alignment: 'right', noWrap: true }); } else { dataRow.push({ text: '', noWrap: true }); } } } else { if (!TrUtils.IsNull(Ops[column.Field])) { dataRow.push({ text: Ops[column.Field].toString(), alignment: 'right', nowrap: true, bold: Ops.bold }); } else { dataRow.push({ text: '', noWrap: true }); } } } else { if (column.Field === 'Desc') { let DescData: any = []; DescData.push({ text: Ops[column.Field].toString(), bold: Ops.bold }); if (!TrUtils.IsEmpty(Ops['EDesc'])) { DescData.push({ text: Ops['EDesc'].toString(), color: 'grey' }); } dataRow.push({ stack: DescData }); } else { dataRow.push({ text: Ops[column.Field].toString(), bold: Ops.bold }); } } } } } else { if (column.Field === 'SNo') { Ops[column.Field] = SNo; SNo = SNo + 1; } else { if (TrUtils.IsNull(Ops[column.Field])) { Ops[column.Field] = ''; } } dataRow.push({ text: Ops[column.Field].toString(), alignment: 'center' }); } }); body.push(dataRow); }); return body; } static GetHCWithOutDiscAndTaxFieldHeader(Parts: any, Ops: any, ShowTaxColumn: any, PrintPartNo: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any, isAuto: boolean, DecimalsNumber: number) { if (Parts.length !== 0 || Ops.length !== 0) { if (ShowTaxColumn) { return InvoicePrintService.GetHCTaxDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber); } else { if (ConsolidateGST) { return InvoicePrintService.GetHCConsolidateDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber); } else { return InvoicePrintService.GetHCNoTaxDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber); } } } else { let a: any = ''; return a; } } static GetHCTaxTableWidths(PrintPartNo: any, ShowIGST: any, ShowDiscountColumn: any) { if (PrintPartNo) { if (ShowIGST) { if (ShowDiscountColumn) { return [22, 50, 143, 35, 25, 40, 17, 35, 17, 35, 45]; } else { return [22, 50, 207, 37, 25, 40, 17, 35, 51]; } } else { if (ShowDiscountColumn) { return [22, 40, 90, 35, 22, 40, 17, 34, 17, 32, 17, 32, 48]; } else { return [22, 50, 135, 40, 22, 40, 17, 32, 17, 32, 54]; } } } else { if (ShowIGST) { if (ShowDiscountColumn) { return [22, 200, 40, 25, 40, 17, 35, 17, 35, 41]; } else { return [22, 255, 40, 25, 40, 20, 40, 50]; } } else { if (ShowDiscountColumn) { return [22, 135, 34, 22, 40, 17, 34, 17, 35, 17, 35, 45]; } else { return [22, 195, 35, 22, 40, 17, 35, 17, 35, 50]; } } } } static GetHCTaxDataTable(Parts: any, Ops: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any, isAuto: boolean, DecimalsNumber: number) { return { style: 'tableExample', table: { widths: InvoicePrintService.GetHCTaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn), body: InvoicePrintService.BuildHCTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) }, layout: PrintSharedService.LayOutStyle1() }; } static GetHCConsolidateDataTable(Parts: any, Ops: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any, isAuto: boolean, DecimalsNumber: number) { if (PrintPartNo) { return { style: 'tableExample', table: { widths: [25, 70, 263, 25, 60, 80, 10, 40], body: InvoicePrintService.BuildHCTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) }, layout: PrintSharedService.LayOutStyle1() }; } else { return { style: 'tableExample', table: { widths: [25, 295, 50, 80, 80, 10, 40], body: InvoicePrintService.BuildHCTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) }, layout: PrintSharedService.LayOutStyle1() }; } } static GetHCNoTaxDataTable(Parts: any, Ops: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any, isAuto: boolean, DecimalsNumber: number) { return { style: 'tableExample', table: { widths: PrintSharedService.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo), body: InvoicePrintService.BuildHCTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) }, layout: PrintSharedService.LayOutStyle1() }; } static BuildHCTableForCustomerLabor(Parts: any, Ops: any, PrintPartNo: any, customerorInsurance: any) { var body: any = []; let columns: any; columns = InvoicePrintService.GetHCSummaryHeaders(PrintPartNo); body.push(columns); if (Parts.length !== 0) { let dummypartadding1: any = {}; dummypartadding1.SNo = ''; dummypartadding1.Desc = ' '; dummypartadding1.Qty = ''; dummypartadding1.UnPr = ''; dummypartadding1.Price = ''; dummypartadding1.DiscountedPrice = ''; dummypartadding1.LineTotal = ''; dummypartadding1.QtyAndUoM = ''; dummypartadding1.HSN = ''; dummypartadding1.MPN = ''; } let SNo: number = 1; Parts.forEach((part: any) => { var dataRow: any = []; columns.forEach((column: any) => { if (!TrUtils.IsNull(part[column.Field]) || column.text === 'Line Total') { if (column.text === 'Line Total' || column.Field === 'QtyAndUoM' || column.Field === 'CustPrice' || column.Field === 'InsPrice' || column.Field === 'DiscountedPrice' || column.Field === 'TaxAmount' || column.Field === 'UnPr') { if (column.Field === 'Disc Amt') { dataRow.push({ text: part[column.Field].toString(), alignment: 'right', noWrap: true }); } else { dataRow.push({ text: part[column.Field].toString(), alignment: 'right', nowrap: true }); } } else { if (column.Field === 'Desc') { let DescData: any = []; DescData.push(part[column.Field].toString()); if (!TrUtils.IsEmpty(part['EDesc'])) { DescData.push({ text: part['EDesc'].toString(), color: 'grey' }); } dataRow.push({ stack: DescData }); } else { dataRow.push({ text: part[column.Field].toString() }); } } } else { if (column.Field === 'SNo') { part[column.Field] = SNo; SNo = SNo + 1; } else { if (TrUtils.IsNull(part[column.Field])) { part[column.Field] = ''; } } dataRow.push({ text: part[column.Field].toString(), alignment: 'center' }); } }); body.push(dataRow); }); SNo = 1; if (Ops.length !== 0 && Parts.length !== 0) { let dummypartadding1: any = {}; dummypartadding1.SNo = ''; dummypartadding1.Desc = ' '; dummypartadding1.Qty = ''; dummypartadding1.UnPr = ''; dummypartadding1.Price = ''; dummypartadding1.DiscountedPrice = ''; dummypartadding1.LineTotal = ''; dummypartadding1.QtyAndUoM = ''; dummypartadding1.HSN = ''; Ops.unshift(dummypartadding1); } Ops.forEach((labor: any) => { var dataRow: any = []; columns.forEach((column: any) => { if (!TrUtils.IsNull(labor[column.Field]) || column.text === 'Line Total') { if (labor[column.Field] === 'Procedures') { dataRow.push({ text: labor[column.Field].toString(), marginLeft: 50, style: 'InlineHeader' }); } else { if (column.text === 'Line Total' || column.Field === 'QtyAndUoM' || column.Field === 'DiscountedPrice' || column.Field === 'TaxAmount' || column.Field === 'UnPr' || column.Field === 'CustPrice' || column.Field === 'InsPrice') { if (column.Field === 'Disc Amt') { dataRow.push({ text: labor[column.Field].toString(), alignment: 'right', noWrap: true }); } else { dataRow.push({ text: labor[column.Field].toString(), alignment: 'right', nowrap: true }); } } else { if (column.Field === 'Desc') { let DescData: any = []; DescData.push(labor[column.Field].toString()); if (!TrUtils.IsEmpty(labor['EDesc'])) { DescData.push({ text: labor['EDesc'].toString(), color: 'grey' }); } dataRow.push({ stack: DescData }); } else { dataRow.push({ text: labor[column.Field].toString() }); } } } } else { if (column.Field === 'SNo') { labor[column.Field] = SNo; SNo = SNo + 1; } else { if (TrUtils.IsNull(labor[column.Field])) { labor[column.Field] = ''; } } dataRow.push({ text: labor[column.Field].toString(), alignment: 'center' }); } }); body.push(dataRow); }); return body; } static GetHCSummaryHeaders(permission: boolean) { let headersNames: any = [{ text: 'Description', style: 'tableheader', Field: 'Desc' }, { text: 'HSN / SAC', style: 'tableheader', Field: 'SAC' }, { text: 'Qty', style: 'tableheader', Field: 'QtyAndUoM' }, { text: 'Ins. Amt', style: 'tableheader', Field: 'AssPr' }, { text: 'Cust. Amt', style: 'tableheader', Field: 'Pr' }, { text: 'Disc.(Rs)', style: 'tableheader', Field: 'DiscountedPrice' }, { text: 'Tax %', style: 'tableheader', Field: 'TaxAmount' }, { text: 'Line Total', style: 'tableheader', Field: 'LineTotal' }]; if (permission) { let sno = { text: 'S.No.', style: 'tableheader', Field: 'SNo' }; let MPN = { text: 'Part No', style: 'tableheader', Field: 'MPN' }; headersNames.unshift(sno, MPN); } else { let sno = { text: 'S.No.', style: 'tableheader', Field: 'SNo' }; headersNames.unshift(sno); } return headersNames; } static GetHCTotalDetails(ROPrintData: any, index: any, numberofCopies: any, withPass: boolean, isAuto: boolean, moreDiscDetails: boolean) { let CommonDetails = [ SharedPDFService.GetFinalTotalDetails1(ROPrintData, ROPrintData.CustLaborTotalAfterDisc, ROPrintData.CustLaborDiscTotal, ROPrintData.CustLaborCGST, ROPrintData.CustLaborSGST, ROPrintData.CustLaborIGST, ROPrintData.CustPartIGST, ROPrintData.ShowIGST, ROPrintData.ShowTaxColumn, ROPrintData.CustPartsTotalAfterDisc, ROPrintData.CustPartsDiscTotal, ROPrintData.CustPartCGST, ROPrintData.CustPartSGST, ROPrintData.CustTaxGroupDataByPerc, ROPrintData.ShowAccParts, ROPrintData.CustLaborAfterTax, ROPrintData.CustPartAfterTax, ROPrintData.FixedDisc, ROPrintData.For, ROPrintData.FixedTotal, ROPrintData.CustTotalRoundedBy, ROPrintData.CustRoundedTotal, ROPrintData.ShowTaxColumn, ROPrintData.ShowTaxColumn, TrUtils.isTaxable(ROPrintData.Settings?.Tax), ROPrintData.CustLaborITax, ROPrintData.CustPartITax, ROPrintData.Consolidate, ROPrintData.From, ROPrintData.Adj, ROPrintData.CustTaxGroupDataByPerc, ROPrintData.STotal, isAuto, moreDiscDetails), InvoicePrintService.GetNumberInWords(ROPrintData.CustRoundedTotal), InvoicePrintService.InvoiceDueStatus(ROPrintData.Type, ROPrintData.Paid, ROPrintData.Due, ROPrintData.Sts, ROPrintData.isCountersale, ROPrintData.Entity.DecimalsNumber), SharedPDFService.GetTemsAndConditions(ROPrintData.Entity.Terms), SharedPDFService.GetBankDetials(ROPrintData.Entity.Bank, ROPrintData.Entity.PrBank, ROPrintData.Entity.UPIPhone), SharedPDFService.GetHCInvSignatures(ROPrintData.Entity.CName, ROPrintData.isCountersale), ]; if (ROPrintData.Type !== 'Invoice') { CommonDetails.splice(2, 0, SharedPDFService.GetUnderLine()); } if (!TrUtils.IsNull(numberofCopies) && numberofCopies.length !== 0 && (index !== (numberofCopies.length - 1))) { CommonDetails.push({ text: '', pageBreak: 'after' }) } return CommonDetails; } // ==================== STANDARD-SPECIFIC METHODS ==================== static GetStandardWatermark(ROPrintData: any, isAuto: any) { if (isAuto && ROPrintData.IsProforma && ROPrintData.Entity.Wmark) { return { text: 'Not a final invoice', opacity: 0.2 }; } else { return ''; } } static GetStandardHeaderDetails(ROPrintData: any, text: any, isotherIndustry: boolean) { return [ SharedPDFService.GetMainHeader(ROPrintData.Entity, ROPrintData.Image, ROPrintData.AColor, ROPrintData.HColor, text), SharedPDFService.GetPrintType(ROPrintData.HeaderName), SharedPDFService.HeaderAfterLine(), SharedPDFService.GetCustomerAndVehicleDetails(ROPrintData._id, ROPrintData.CrDate, ROPrintData.PrDate, ROPrintData.MOut, ROPrintData.MIn, ROPrintData.Product, ROPrintData.PrintType, ROPrintData.For, ROPrintData.SurName, ROPrintData.SurPhone, ROPrintData.Type, ROPrintData.SurEmail, ROPrintData.InsComp, ROPrintData.PolNo, ROPrintData.PolType, ROPrintData.Customer, ROPrintData.IsProforma, ROPrintData.Settings, ROPrintData.Location, isotherIndustry, ROPrintData.BL, ROPrintData.ROCode, ROPrintData.TypeName, ROPrintData.AdmNo, ROPrintData.DoS), SharedPDFService.GetOwnerDetails(ROPrintData.Cust, ROPrintData.Type, ROPrintData.For), SharedPDFService.CustomerAndVehicleDetailsAfterLine(), SharedPDFService.GetDisplayTable(), ]; } static PrepareStandardPartsTable(ROPrintData: any, isAuto: boolean) { let List: any = []; if (ROPrintData.Entity.Body === 1) { for (let i = 0; i < ROPrintData.PrintInfo.length; i++) { if (TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) { ROPrintData.PrintInfo[i].Text = ''; } List.push(ROPrintData.PrintInfo[i].Text, InvoicePrintService.GetStandardLaborPartsTableForView(TrUtils.Stringify(ROPrintData.PrintInfo[i].Items), TrUtils.Stringify(ROPrintData.PrintInfo[i].Ops), ROPrintData.Entity.MPN) ); } } else { if (ROPrintData.Entity.Body === 2) { for (let i = 0; i < ROPrintData.PrintInfo.length; i++) { if (TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) { ROPrintData.PrintInfo[i].Text = ''; } List.push(ROPrintData.PrintInfo[i].Text, InvoicePrintService.GetStandardWithOutDiscountFieldTable(TrUtils.Stringify(ROPrintData.PrintInfo[i].Items), TrUtils.Stringify(ROPrintData.PrintInfo[i].Ops), ROPrintData.ShowTaxColumn, ROPrintData.Entity.MPN, ROPrintData.Entity.Body, ROPrintData.ShowIGST, ROPrintData.ConsolidateGST, ROPrintData.ShowDiscountColumn, isAuto, ROPrintData.Entity.DecimalsNumber) ); } } else { if (ROPrintData.Summary) { List.push('', InvoicePrintService.GetStandardLaborPartsTableForView(ROPrintData.Items, ROPrintData.Ops, ROPrintData.Entity.MPN) ); } else { for (let i = 0; i < ROPrintData.PrintInfo.length; i++) { if (TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) { ROPrintData.PrintInfo[i].Text = ''; } List.push(ROPrintData.PrintInfo[i].Text, InvoicePrintService.GetStandardWithOutDiscAndTaxFieldHeader(TrUtils.Stringify(ROPrintData.PrintInfo[i].Items), TrUtils.Stringify(ROPrintData.PrintInfo[i].Ops), ROPrintData.ShowTaxColumn, ROPrintData.Entity.MPN, ROPrintData.Entity.Body, ROPrintData.ShowIGST, ROPrintData.ConsolidateGST, ROPrintData.ShowDiscountColumn, isAuto, ROPrintData.Entity.DecimalsNumber) ); } } } } return List; } static GetStandardLaborPartsTableForView(Parts: any, Ops: any, PrintPartNo: any) { if (Parts.length !== 0 || Ops.length !== 0) { if (PrintPartNo) { return { style: 'tableExample', table: { widths: [25, 30, 170, 85, 15, 20, 50, 30, 30, 50], body: InvoicePrintService.BuildStandardTableForCustomerLabor(Parts, Ops, PrintPartNo, false) }, layout: PrintSharedService.LayOutStyleanother() }; } else { return { style: 'tableExample', table: { widths: [25, 200, 55, 25, 55, 55, 40, 15, 50], body: InvoicePrintService.BuildStandardTableForCustomerLabor(Parts, Ops, PrintPartNo, false) }, layout: PrintSharedService.LayOutStyleanother() }; } } else { let a: any = ''; return a; } } static GetStandardWithOutDiscountFieldTable(Parts: any, Ops: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any, isAuto: boolean, DecimalsNumber: number) { if (Parts.length !== 0 || Ops.length !== 0) { if (PrintPartNo) { return { style: 'tableExample', marginLeft: 20, table: { widths: [25, 60, 155, 30, 50, 60, 30, 50], headerRows: 1, body: InvoicePrintService.BuildStandardTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) }, layout: PrintSharedService.LayOutStyleanother() }; } else { return { style: 'tableExample', marginLeft: 20, table: { widths: [25, 215, 25, 50, 60, 45, 50], headerRows: 1, body: InvoicePrintService.BuildStandardTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) }, layout: PrintSharedService.LayOutStyleanother() }; } } else { let a: any = ''; return a; } } static BuildStandardTableBodyForLaborAndParts(Parts: any, Labor: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any, isAuto: boolean, DecimalsNumber: number) { var body: any = []; let columns: any = PrintSharedService.GetWithOutDiscountFieldHeader(PrintPartNo, ShowTaxColumn, Body, ShowIGST, ShowDiscountColumn); for (let i = 0; i < columns.length; i++) { body.push(columns[i]); } columns = columns[1]; let DummyOps: any = []; if (Parts.length !== 0) { if (isAuto) { let Qty: number = 0; let CGSTAMT: number = 0; let SGSTAMT: number = 0; let IGSTAMT: number = 0; let Taxable: number = 0; let FinalTotal: number = 0; Parts.forEach((part: any) => { Qty = Add(Qty, TrUtils.FixedTo(part.Qty, DecimalsNumber)); CGSTAMT = Add(CGSTAMT, TrUtils.FixedTo(part.CGSTAmt, DecimalsNumber)); SGSTAMT = Add(SGSTAMT, TrUtils.FixedTo(part.SGSTAmt, DecimalsNumber)); IGSTAMT = Add(IGSTAMT, TrUtils.FixedTo(part.IGSTAmt, DecimalsNumber)); Taxable = Add(Taxable, TrUtils.FixedTo(part.AfterPartDisc, DecimalsNumber)); FinalTotal = Add(FinalTotal, TrUtils.FixedTo(part.AfterPartTax, DecimalsNumber)); }); let dpartadding1: any = {}; dpartadding1.SNo = ''; dpartadding1.Desc = 'Spare Total'; dpartadding1.QtyAndUoM = TrUtils.FixedTo(Qty, DecimalsNumber); dpartadding1.bold = true; dpartadding1.UnPr = TrUtils.FixedTo(Taxable, DecimalsNumber); dpartadding1.SGSTAmt = TrUtils.FixedTo(SGSTAMT, DecimalsNumber); dpartadding1.IGSTAmt = TrUtils.FixedTo(IGSTAMT, DecimalsNumber); dpartadding1.CGSTAmt = TrUtils.FixedTo(CGSTAMT, DecimalsNumber); dpartadding1.TCode = ShowTaxColumn ? 114 : undefined; dpartadding1.LineTotal = TrUtils.FixPriceValue(FinalTotal, DecimalsNumber); Parts.push({ SNo: '' }); Parts.push(dpartadding1); } let dummypartadding1: any = {}; dummypartadding1.SNo = ''; dummypartadding1.Desc = 'Spare Parts'; dummypartadding1.Qty = ''; dummypartadding1.UnPr = ''; dummypartadding1.LineTotal = ''; Parts.unshift(dummypartadding1); } let SNo: number = 1; Parts.forEach((part: any) => { var dataRow: any = []; columns.forEach((column: any) => { if ( (!TrUtils.IsFixedZero(part[column.Field]) && !TrUtils.IsNull(part[column.Field])) || (column.text === 'Line Total')) { if (part[column.Field] === 'Spare Parts') { dataRow.push({ text: part[column.Field].toString(), marginLeft: 50, style: 'InlineHeader' }); } else { if (((column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt' || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc') && TrUtils.CheckInvalidSelect(part.TCode))) { part[column.Field] = ''; dataRow.push({ text: part[column.Field].toString(), alignment: 'center' }); } else { if (column.text === 'Line Total' || column.Field === 'UnPr' || column.Field === 'QtyAndUoM' || column.text === 'Tax' || column.Field === 'Disc' || column.Field === 'Perc' || column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt' || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc') { if (column.Field === 'Disc') { if (column.type === 'percentage') { if (!TrUtils.IsEmpty(part[column.Field])) { dataRow.push({ text: part[column.Field].toString(), noWrap: true, alignment: 'center' }); } else { dataRow.push({ text: '', noWrap: true }); } } else { if (!TrUtils.IsNull(part[column.Field])) { dataRow.push({ text: part[column.Field].toString(), noWrap: true, alignment: 'right' }); } else { dataRow.push({ text: '', noWrap: true }); } } } else { if (!TrUtils.IsNull(part[column.Field])) { dataRow.push({ text: part[column.Field].toString(), bold: part.bold, alignment: 'right', nowrap: true }); } else { dataRow.push({ text: '', noWrap: true }); } } } else { if (column.Field === 'Desc') { let DescData: any = []; DescData.push({ text: part[column.Field].toString(), bold: part.bold }); if (!TrUtils.IsEmpty(part['EDesc'])) { DescData.push({ text: part['EDesc'].toString(), color: 'grey' }); } dataRow.push({ stack: DescData }); } else { dataRow.push({ text: part[column.Field].toString() }); } } } } } else { if (column.Field === 'SNo') { part[column.Field] = SNo; SNo = SNo + 1; } else { if (TrUtils.IsNull(part[column.Field])) { part[column.Field] = ''; } } dataRow.push({ text: part[column.Field].toString(), alignment: 'center' }); } }); body.push(dataRow); }); SNo = 1; if (Labor.length !== 0) { if (isAuto) { let CGSTAMT: number = 0; let SGSTAMT: number = 0; let IGSTAMT: number = 0; let Taxable: number = 0; let FinalTotal: number = 0; Labor.forEach((operation: any) => { CGSTAMT = Add(CGSTAMT, TrUtils.FixedTo(operation.CGSTAmt, DecimalsNumber)); SGSTAMT = Add(SGSTAMT, TrUtils.FixedTo(operation.SGSTAmt, DecimalsNumber)); IGSTAMT = Add(IGSTAMT, TrUtils.FixedTo(operation.IGSTAmt, DecimalsNumber)); Taxable = Add(Taxable, TrUtils.FixedTo(operation.AfterLaborDisc, DecimalsNumber)); FinalTotal = Add(FinalTotal, TrUtils.FixedTo(operation.AfterLaborTax, DecimalsNumber)); }); let dpartadding1: any = {}; dpartadding1.SNo = ''; dpartadding1.Desc = 'Labor Total'; dpartadding1.UnPr = TrUtils.FixedTo(Taxable, DecimalsNumber); dpartadding1.SGSTAmt = TrUtils.FixedTo(SGSTAMT, DecimalsNumber); dpartadding1.IGSTAmt = TrUtils.FixedTo(IGSTAMT, DecimalsNumber); dpartadding1.CGSTAmt = TrUtils.FixedTo(CGSTAMT, DecimalsNumber); dpartadding1.TCode = ShowTaxColumn ? 114 : undefined; dpartadding1.bold = true; dpartadding1.LineTotal = TrUtils.FixPriceValue(FinalTotal, DecimalsNumber); Labor.push({ SNo: '' }); Labor.push(dpartadding1); } let dummypartadding1: any = {}; dummypartadding1.SNo = ''; dummypartadding1.Desc = 'Labor'; dummypartadding1.Qty = ''; dummypartadding1.UnPr = ''; dummypartadding1.LineTotal = ''; Labor.unshift(dummypartadding1); } if (Body === 2) { for (let i = 0; i < Labor.length; i++) { Labor[i].UnPr = ''; } } Labor.forEach((Ops: any) => { var dataRow: any = []; columns.forEach((column: any) => { if ((!TrUtils.IsFixedZero(Ops[column.Field]) && !TrUtils.IsNull(Ops[column.Field])) || (column.text === 'Line Total')) { if (Ops[column.Field] === 'Labor') { dataRow.push({ text: Ops[column.Field].toString(), marginLeft: 50, style: 'InlineHeader' }); } else { if (((column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt' || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc') && TrUtils.CheckInvalidSelect(Ops.TCode))) { Ops[column.Field] = ''; dataRow.push({ text: Ops[column.Field].toString(), alignment: 'center' }); } else { if (column.text === 'Line Total' || column.Field === 'Price' || column.text === 'Tax' || column.Field === 'UnPr' || column.Field === 'QtyAndUoM' || column.Field === 'Disc' || column.Field === 'Perc' || column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt' || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc') { if (column.Field === 'Disc') { if (column.type === 'percentage') { if (!TrUtils.IsEmpty(Ops[column.Field])) { dataRow.push({ text: Ops[column.Field].toString(), noWrap: true, alignment: 'center' }); } else { dataRow.push({ text: '', noWrap: true }); } } else { if (!TrUtils.IsNull(Ops[column.Field])) { dataRow.push({ text: Ops[column.Field].toString(), noWrap: true, alignment: 'right' }); } else { dataRow.push({ text: '', noWrap: true }); } } } else { if (!TrUtils.IsNull(Ops[column.Field])) { dataRow.push({ text: Ops[column.Field].toString(), alignment: 'right', nowrap: true, bold: Ops.bold }); } else { dataRow.push({ text: '', noWrap: true }); } } } else { dataRow.push({ text: Ops[column.Field].toString(), bold: Ops.bold }); } } } } else { if (column.Field === 'SNo') { Ops[column.Field] = SNo; SNo = SNo + 1; } else { if (TrUtils.IsNull(Ops[column.Field])) { Ops[column.Field] = ''; } } dataRow.push({ text: Ops[column.Field].toString(), alignment: 'center' }); } }); body.push(dataRow); }); return body; } static GetStandardWithOutDiscAndTaxFieldHeader(Parts: any, Ops: any, ShowTaxColumn: any, PrintPartNo: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any, isAuto: boolean, DecimalsNumber: number) { if (Parts.length !== 0 || Ops.length !== 0) { if (ShowTaxColumn) { return InvoicePrintService.GetStandardTaxDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber); } else { if (ConsolidateGST) { return InvoicePrintService.GetStandardConsolidateDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber); } else { return InvoicePrintService.GetStandardNoTaxDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber); } } } else { let a: any = ''; return a; } } static GetStandardTaxDataTable(Parts: any, Ops: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any, isAuto: boolean, DecimalsNumber: number) { return { style: 'tableExample', table: { widths: PrintSharedService.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn), body: InvoicePrintService.BuildStandardTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) }, layout: PrintSharedService.LayOutStyle() }; } static GetStandardConsolidateDataTable(Parts: any, Ops: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any, isAuto: boolean, DecimalsNumber: number) { if (PrintPartNo) { return { style: 'tableExample', table: { widths: [25, 70, 263, 25, 60, 80, 10, 40], body: InvoicePrintService.BuildStandardTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) }, layout: PrintSharedService.LayOutStyle() }; } else { return { style: 'tableExample', table: { widths: [25, 295, 50, 80, 80, 10, 40], body: InvoicePrintService.BuildStandardTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) }, layout: PrintSharedService.LayOutStyle() }; } } static GetStandardNoTaxDataTable(Parts: any, Ops: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any, isAuto: boolean, DecimalsNumber: number) { return { style: 'tableExample', table: { widths: PrintSharedService.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo), body: InvoicePrintService.BuildStandardTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) }, layout: PrintSharedService.LayOutStyle() }; } static BuildStandardTableForCustomerLabor(Parts: any, Ops: any, PrintPartNo: any, customerorInsurance: any) { var body: any = []; let columns: any; columns = InvoicePrintService.GetStandardSummaryHeaders(PrintPartNo); body.push(columns); if (Parts.length !== 0) { let dummypartadding1: any = {}; dummypartadding1.SNo = ''; dummypartadding1.Desc = 'Spare Parts'; dummypartadding1.Qty = ''; dummypartadding1.UnPr = ''; dummypartadding1.Price = ''; dummypartadding1.DiscountedPrice = ''; dummypartadding1.LineTotal = ''; dummypartadding1.QtyAndUoM = ''; dummypartadding1.HSN = ''; dummypartadding1.MPN = ''; Parts.unshift(dummypartadding1); } let SNo: number = 1; Parts.forEach((part: any) => { var dataRow: any = []; columns.forEach((column: any) => { if (!TrUtils.IsFixedZero(part[column.Field]) && !TrUtils.IsNull(part[column.Field]) || column.text === 'Line Total') { if (part[column.Field] === 'Spare Parts') { dataRow.push({ text: part[column.Field].toString(), marginLeft: 50, style: 'InlineHeader' }); } else { if (column.text === 'Line Total' || column.Field === 'QtyAndUoM' || column.Field === 'CustPrice' || column.Field === 'InsPrice' || column.Field === 'DiscountedPrice' || column.Field === 'TaxAmount' || column.Field === 'UnPr') { if (column.Field === 'Disc Amt') { dataRow.push({ text: part[column.Field].toString(), alignment: 'right', noWrap: true }); } else { dataRow.push({ text: part[column.Field].toString(), alignment: 'right', nowrap: true }); } } else { if (column.Field === 'Desc') { let DescData: any = []; DescData.push(part[column.Field].toString()); if (!TrUtils.IsEmpty(part['EDesc'])) { DescData.push({ text: part['EDesc'].toString(), color: 'grey' }); } dataRow.push({ stack: DescData }); } else { dataRow.push({ text: part[column.Field].toString() }); } } } } else { if (column.Field === 'SNo') { part[column.Field] = SNo; SNo = SNo + 1; } else { if (TrUtils.IsNull(part[column.Field])) { part[column.Field] = ''; } } dataRow.push({ text: part[column.Field].toString(), alignment: 'center' }); } }); body.push(dataRow); }); SNo = 1; if (Ops.length !== 0) { let dummypartadding1: any = {}; dummypartadding1.SNo = ''; dummypartadding1.Desc = 'Labor'; dummypartadding1.Qty = ''; dummypartadding1.UnPr = ''; dummypartadding1.Price = ''; dummypartadding1.DiscountedPrice = ''; dummypartadding1.LineTotal = ''; dummypartadding1.QtyAndUoM = ''; dummypartadding1.HSN = ''; Ops.unshift(dummypartadding1); } Ops.forEach((labor: any) => { var dataRow: any = []; columns.forEach((column: any) => { if (!TrUtils.IsFixedZero(labor[column.Field]) && !TrUtils.IsNull(labor[column.Field]) || column.text === 'Line Total') { if (labor[column.Field] === 'Labor') { dataRow.push({ text: labor[column.Field].toString(), marginLeft: 50, style: 'InlineHeader' }); } else { if (column.text === 'Line Total' || column.Field === 'QtyAndUoM' || column.Field === 'DiscountedPrice' || column.Field === 'TaxAmount' || column.Field === 'UnPr' || column.Field === 'CustPrice' || column.Field === 'InsPrice') { if (column.Field === 'Disc Amt') { dataRow.push({ text: labor[column.Field].toString(), alignment: 'right', noWrap: true }); } else { dataRow.push({ text: labor[column.Field].toString(), alignment: 'right', nowrap: true }); } } else { dataRow.push({ text: labor[column.Field].toString() }); } } } else { if (column.Field === 'SNo') { labor[column.Field] = SNo; SNo = SNo + 1; } else { if (TrUtils.IsNull(labor[column.Field])) { labor[column.Field] = ''; } } dataRow.push({ text: labor[column.Field].toString(), alignment: 'center' }); } }); body.push(dataRow); }); return body; } static GetStandardSummaryHeaders(permission: boolean) { let headersNames: any = [{ text: 'Description', style: 'tableheader', Field: 'Desc' }, { text: 'HSN / SAC', style: 'tableheader', Field: 'SAC' }, { text: 'Qty', style: 'tableheader', Field: 'QtyAndUoM' }, { text: 'Ins. Amt', style: 'tableheader', Field: 'AssPr' }, { text: 'Cust. Amt', style: 'tableheader', Field: 'Pr' }, { text: 'Disc.(Rs)', style: 'tableheader', Field: 'DiscountedPrice' }, { text: 'Tax %', style: 'tableheader', Field: 'TaxAmount' }, { text: 'Line Total', style: 'tableheader', Field: 'LineTotal' }]; if (permission) { let sno = { text: 'S.No.', style: 'tableheader', Field: 'SNo' }; let MPN = { text: 'Part No', style: 'tableheader', Field: 'MPN' }; headersNames.unshift(sno, MPN); } else { let sno = { text: 'S.No.', style: 'tableheader', Field: 'SNo' }; headersNames.unshift(sno); } return headersNames; } static GetStandardTotalDetails(ROPrintData: any, index: any, numberofCopies: any, withPass: boolean, isAuto: boolean, moreDiscDetails: boolean) { let CommonDetails = [ SharedPDFService.GetFinalTotalDetails1(ROPrintData, ROPrintData.CustLaborTotalAfterDisc, ROPrintData.CustLaborDiscTotal, ROPrintData.CustLaborCGST, ROPrintData.CustLaborSGST, ROPrintData.CustLaborIGST, ROPrintData.CustPartIGST, ROPrintData.ShowIGST, ROPrintData.ShowTaxColumn, ROPrintData.CustPartsTotalAfterDisc, ROPrintData.CustPartsDiscTotal, ROPrintData.CustPartCGST, ROPrintData.CustPartSGST, ROPrintData.TaxSummary, ROPrintData.ShowAccParts, ROPrintData.CustLaborAfterTax, ROPrintData.CustPartAfterTax, ROPrintData.FixedDisc, ROPrintData.For, ROPrintData.FixedTotal, ROPrintData.CustTotalRoundedBy, ROPrintData.CustRoundedTotal, ROPrintData.ShowTaxColumn, ROPrintData.ShowTaxColumn, TrUtils.isTaxable(ROPrintData.Settings.Tax), ROPrintData.CustLaborITax, ROPrintData.CustPartITax, ROPrintData.Consolidate, ROPrintData.From, ROPrintData.Adj, ROPrintData.TaxSummary, ROPrintData.STotal, isAuto, moreDiscDetails), InvoicePrintService.GetNumberInWords(ROPrintData.CustRoundedTotal), SharedPDFService.InvoiceDueStatus(ROPrintData.Type, ROPrintData.Paid, ROPrintData.Due, ROPrintData.Sts, ROPrintData.isCountersale, ROPrintData.Entity.DecimalsNumber), SharedPDFService.GetTemsAndConditions(ROPrintData.Entity.Terms), InvoicePrintService.GetBanckdetailswithQRCode(ROPrintData), SharedPDFService.GetUnderLine(), SharedPDFService.GetInvSignatures(ROPrintData.Entity.CName, ROPrintData.isCountersale), SharedPDFService.GetUnderLine1(withPass), InvoicePrintService.GetGatePass(withPass, ROPrintData) ]; if (ROPrintData.Type !== 'Invoice') { CommonDetails.splice(2, 0, SharedPDFService.GetUnderLine()); } if (!TrUtils.IsNull(numberofCopies) && numberofCopies.length !== 0 && (index !== (numberofCopies.length -1))) { CommonDetails.push({ text: '', pageBreak: 'after' }) } return CommonDetails; } static GetBanckdetailswithQRCode(ROPrintData: any) { return { columns: [SharedPDFService.GetBankDetials(ROPrintData.Entity.Bank, ROPrintData.Entity.PrBank, ROPrintData.Entity.UPIPhone), SharedPDFService.GetEntityDetails(ROPrintData.Entity)] } } static GetGatePass(isGatepass: boolean, ROPrintData: any) { if (isGatepass) { return { columns: [{ id: '567', text: [{ text: '', id: '1234' }], stack: [ { columns: [{ text: '' }, { text: 'Gate Pass', bold: true, fontSize: 9, alignment: 'center', marginTop: 5 }, { text: 'Date: ' + MyDate.ConvertUTCDateToReadable(MyDate.GetDateTimeNowInUTC(ROPrintData.Entity.User.TZ)), marginTop: 5, fontSize: 9, alignment: 'right' }] }, { text: ROPrintData.Entity.CName, alignment: 'center', bold: true, fontSize: 12, marginTop: 5, marginBottom: 5 }, { marginTop: 5, columns: [ { text: '', width: 60 }, InvoicePrintService.GetGatePassCustomerDetails(ROPrintData, false), InvoicePrintService.GetGatePassVehicleDetails(ROPrintData.Product, false) ] }, { text: 'Vehicle has been received from workshop and work done as per my satisfaction.', fontSize: 7, marginTop: 10, marginLeft: 60 }, { columns: [SharedPDFService.CustomerSignature(), { text: '' }, SharedPDFService.Accountantsignature()] } ] }], }; } else { return SharedPDFService.emptyObject(); } } static GetGatePassCustomerDetails(ROPrintData: any, isOtherIndustry: boolean) { let CustomerData = [ { name: 'Customer Name', value: ROPrintData.Customer.Name }, { name: 'Service Advisor', value: ROPrintData.Name }, ]; return SharedPDFService.GetVehicleDataTable(CustomerData); } static GetGatePassVehicleDetails(Vehicle: any, isOtherIndustry: boolean) { let vehicleData: any = []; if (isOtherIndustry) { vehicleData.push({ name: 'Serial No', value: SharedPDFService.CheckAndSetString(Vehicle.SNo) }); } let a: any = [ { name: 'Vehicle Model', value: SharedPDFService.CheckAndSetString(Vehicle.Model) }, ]; if (!isOtherIndustry) { a.unshift({ name: 'Regn. No', value: SharedPDFService.CheckAndSetString(Vehicle.RegNo) }); if (!TrUtils.IsEmpty(Vehicle.VIN)) { a.unshift({ name: 'Chassis No', value: SharedPDFService.CheckAndSetString(Vehicle.VIN) }); } } for (let i = 0; i < a.length; i++) { vehicleData.push(a[i]); } return SharedPDFService.GetVehicleDataTable(vehicleData); } }