import { ROTypeEnum } from '../enums/code-enums'; import { ROStatusEnum } from '../enums/enums'; import { SharedPDFService } from '../shared/shared-pdf.service'; import { PrintSharedService } from '../shared/shared-print.service'; import { TrUtils } from '../utils/tr-utils'; declare var pdfMake: any; export class RoprintService { static FontSize: number = 8; static PrintFile: any; static CommonHeaderDetails(ROPrintData: any, text: any, isOtherIndustry: boolean) { // console.log('ROPrintData', ROPrintData); return [ this.GetMainHeaderDetails(ROPrintData.Entity, ROPrintData.HeaderName, ROPrintData.Image, ROPrintData.HColor, ROPrintData.AColor, text), // this.GetHeaderDetails(ROPrintData.HeaderName, ROPrintData.Entity, ROPrintData.Image), // SharedPDFService.HeaderAfterLine() SharedPDFService.GetCustomerAndVehicleDetails(ROPrintData._id, ROPrintData.CrDate, ROPrintData.PrDate, ROPrintData.MOut, ROPrintData.MIn, ROPrintData.Vehicle, ROPrintData.Type, ROPrintData.Payee, ROPrintData.SurName, ROPrintData.SurPhone, ROPrintData.Type, ROPrintData.SurEmail, ROPrintData.InsComp, ROPrintData.PolNo, ROPrintData.PolType, ROPrintData.Customer, false, ROPrintData.Settings, ROPrintData.Location, isOtherIndustry, null, null,null,null, ROPrintData.DoS), SharedPDFService.CustomerAndVehicleDetailsAfterLine(), // SharedPDFService.GetDisplayTable() ]; } static GetMainHeaderDetails(Entity: any, HeaderName: any, Image: any, HColor: any, AColor: any, text: any) { return [ // SharedPDFService.MainHeading(Entity.CName, Entity.Header, Image, HColor, text), SharedPDFService.GetMainHeader(Entity, Image, AColor, HColor, text), SharedPDFService.GetPrintType(HeaderName), SharedPDFService.HeaderAfterLine() ]; } static CommonTotalDetails(ROPrintData: any, index: any, numberofCopies: any) { let CommonDetails = [ SharedPDFService.GetFinalTotalDetails(ROPrintData,ROPrintData.CustLaborTotalBeforeDisc, ROPrintData.CustLaborDiscTotal, ROPrintData.CustLaborCGST, ROPrintData.CustLaborSGST, ROPrintData.CustLaborIGST, ROPrintData.CustPartIGST, ROPrintData.ShowIGST, ROPrintData.ShowTaxColumn, ROPrintData.CustPartsTotalBeforeDisc, ROPrintData.CustPartsDiscTotal, ROPrintData.CustPartCGST, ROPrintData.CustPartSGST, ROPrintData.CustTaxGroupData, ROPrintData.ShowAccParts, ROPrintData.CustLaborAfterTax, ROPrintData.CustPartAfterTax, ROPrintData.FixedDisc, ROPrintData.Payee, ROPrintData.FixedTotal, ROPrintData.CustTotalRoundedBy, ROPrintData.CustRoundedTotal, ROPrintData.ShowDetailedLaborTaxInfo, ROPrintData.ShowDetailedPartTaxInfo, TrUtils.isTaxable(ROPrintData.Settings.Tax), ROPrintData.CustLaborITax, ROPrintData.CustPartITax, ROPrintData.Consolidate, ROPrintData.From, null,null,false), // SharedPDFService.InvoiceDueStatus(ROPrintData.Type, ROPrintData.Paid, ROPrintData.Due, ROPrintData.Sts, false, ROPrintData.Entity.DecimalsNumber), SharedPDFService.GetTemsAndConditions(ROPrintData.Entity.Terms), SharedPDFService.GetUnderLine(), SharedPDFService.GetSignatures(ROPrintData.Entity.CName, ROPrintData.Type, ROPrintData.Payee), ]; if (ROPrintData.Type !== 'Invoice') { CommonDetails.splice(1, 0, SharedPDFService.GetUnderLine()); } if (!TrUtils.IsNull(numberofCopies) && numberofCopies.length !== 0 && (index !== (numberofCopies.length - 1))) { CommonDetails.push({ text: '', pageBreak: 'after' }) } return CommonDetails; } static CommonInsTotalDetails(ROPrintData: any, index: any, numberofCopies: any) { let CommonDetails = [ SharedPDFService.GetFinalTotalDetails(ROPrintData,ROPrintData.InsLaborTotalBeforeDisc, ROPrintData.InsLaborDiscTotal, ROPrintData.InsLaborCGST, ROPrintData.InsLaborSGST, ROPrintData.InsLaborIGST, ROPrintData.InsPartIGST, ROPrintData.ShowIGST, ROPrintData.ShowTaxColumn, ROPrintData.InsPartsTotalBeforeDisc, ROPrintData.InsPartsDiscTotal, ROPrintData.InsPartCGST, ROPrintData.InsPartSGST, ROPrintData.InsTaxGroupData, ROPrintData.ShowAccParts, ROPrintData.InsLaborTotalAfterTax, ROPrintData.InsPartsTotalAfterTax, ROPrintData.FixedDisc, ROPrintData.Payee, ROPrintData.FixedInsTotal, ROPrintData.InsTotalRoundedBy, ROPrintData.InsRoundedTotal, ROPrintData.ShowDetailedLaborTaxInfo, ROPrintData.ShowDetailedPartTaxInfo, TrUtils.isTaxable(ROPrintData.Settings.Tax), ROPrintData.InsLaborITax, ROPrintData.InsPartITax, ROPrintData.Consolidate, ROPrintData.From, null,null,false), // SharedPDFService.InvoiceDueStatus(ROPrintData.Type, ROPrintData.Paid, ROPrintData.Due, ROPrintData.Sts, false, ROPrintData.Entity.DecimalsNumber), SharedPDFService.GetTemsAndConditions(ROPrintData.Entity.Terms), SharedPDFService.GetUnderLine(), SharedPDFService.GetSignatures(ROPrintData.Entity.CName, ROPrintData.Type, ROPrintData.Payee), ]; if (ROPrintData.Type !== 'Invoice') { CommonDetails.splice(1, 0, SharedPDFService.GetUnderLine()); } if (!TrUtils.IsNull(numberofCopies) && numberofCopies.length !== 0 && (index !== (numberofCopies.length - 1))) { CommonDetails.push({ text: '', pageBreak: 'after' }) } return CommonDetails; } // Customer Only Print Method static GetCustomerPrint(ROPrintData: any, numberofCopies: any, isOtherIndustry: boolean) { var contents = []; if (TrUtils.IsNull(numberofCopies) || numberofCopies.length === 0) { contents.push( this.CommonHeaderDetails(ROPrintData, null, isOtherIndustry), this.CustomersparePartsTable(ROPrintData), this.CommonTotalDetails(ROPrintData, null, numberofCopies) ); } else { numberofCopies.forEach((text: any, index: any) => { contents.push( this.CommonHeaderDetails(ROPrintData, text, isOtherIndustry), this.CustomersparePartsTable(ROPrintData), this.CommonTotalDetails(ROPrintData, index, numberofCopies) ); }); } var dd = { info: { title: this.GetFileName(ROPrintData), }, header: function (currentPage: any, pageCount: any, pageSize: any) { return { text: currentPage.toString() + ' of ' + pageCount, alignment: 'right', marginRight: 7, fontSize: 8, marginTop: 2 }; }, background: function (currentPage: any, pageSize: any) { return SharedPDFService.GetWatermarkImage(ROPrintData.Image, pageSize, ROPrintData.Entity.Wmark); }, pageMargins: [10, 25, 10, 15], content: contents, styles: SharedPDFService.GetStyles() }; return dd; } static GetHeaderDetails(HeaderName: any, Entity: any, Image: any) { return { columns: [{ stack: [{ image: Image, width: 150, marginBottom: 15 }, { text: HeaderName, fontSize: 20 }] }, { stack: this.CompanyDetails(Entity), }], marginLeft: 20, marginRight: 20, marginTop: 15, marginBottom: 5 } } static CompanyDetails(Entity: any) { const gstin = this.GetEntityGSTIN(Entity); let Details: any = [ { text: Entity.CName, alignment: 'right', lineHeight: 1.5, fontSize: 8 }, { text: Entity.Adrs1 + ',', alignment: 'right', color: 'gray', lineHeight: 1.5, fontSize: 8 }, { text: '' + Entity.City + SharedPDFService.getPinCode(Entity.PIN) + ', ' + 'Ph: ' + Entity.Phone, alignment: 'right', color: 'gray', lineHeight: 1.5, fontSize: 8 }, { text: '' + SharedPDFService.GetEmail(Entity.Email) + '', alignment: 'right', color: 'gray', lineHeight: 1.5, fontSize: 8 }, { text: 'GSTIN : ' + gstin, alignment: 'right', color: 'gray', lineHeight: 1.5, fontSize: 8 }, { text: 'PAN No : ' + Entity.PAN, alignment: 'right', color: 'gray', lineHeight: 1.5, fontSize: 8 }] if (!TrUtils.IsEmpty(Entity.Adrs2)) { Details.splice(2, 0, { text: Entity.Adrs2 + '', alignment: 'right', color: 'gray', lineHeight: 1.5, fontSize: 8 }); } return Details; } static GetEntityGSTIN(Entity: any) { if (!TrUtils.IsNull(Entity) && Array.isArray(Entity.TaxIds)) { const gstinEntry = Entity.TaxIds.find((taxId: any) => { const label = (taxId?.Label || taxId?.label || '').toString().trim().toUpperCase(); const value = taxId?.Value || taxId?.value; return label === 'GSTIN' && !TrUtils.IsEmpty(value); }); if (!TrUtils.IsNull(gstinEntry)) { return gstinEntry.Value || gstinEntry.value; } } return TrUtils.IsNull(Entity?.GSTIN) ? '' : Entity.GSTIN; } static GetFileName(ROPrintData: any) { let fileName: string = ROPrintData.HeaderName; if (!TrUtils.IsEmpty(ROPrintData.Vehicle.RegNo)) { fileName = fileName + '-' + ROPrintData.Vehicle.RegNo } return fileName; } static CustomersparePartsTable(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 = ''; } List.push(ROPrintData.PrintInfo[i].Text, this.GetLaborPartsTableForView(TrUtils.Stringify(ROPrintData.PrintInfo[i].Parts), TrUtils.Stringify(ROPrintData.PrintInfo[i].Ops), ROPrintData.Entity.MPN), this.GetCustomerIndPartsTable(ROPrintData.PrintInfo[i].Colli, ROPrintData.PrintInfo[i].Type, ROPrintData.PrintInfo[i].Sts, ROPrintData.Entity.MPN, ROPrintData.ShowTaxColumn) ); } } 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, this.WithOutDiscountFieldTable(TrUtils.Stringify(ROPrintData.PrintInfo[i].Parts), TrUtils.Stringify(ROPrintData.PrintInfo[i].Ops), ROPrintData.ShowTaxColumn, ROPrintData.Entity.MPN, ROPrintData.Entity.Body, ROPrintData.ShowIGST, ROPrintData.ConsolidateGST, ROPrintData.ShowDiscountColumn), this.GetCustomerIndPartsTable(ROPrintData.PrintInfo[i].Colli, ROPrintData.PrintInfo[i].Type, ROPrintData.PrintInfo[i].Sts, ROPrintData.Entity.MPN, ROPrintData.ShowTaxColumn), ); } } else { if (ROPrintData.Summary) { List.push('', this.GetLaborPartsTableForView(ROPrintData.Parts, ROPrintData.Ops, ROPrintData.Entity.MPN) // this.GetCustomerIndPartsTable(null, ROPrintData.Type, ROPrintData.Sts, // ROPrintData.Entity.MPN, ROPrintData.ShowTaxColumn) ); } else { console.log('new', ROPrintData.PrintInfo); for (let i = 0; i < ROPrintData.PrintInfo.length; i++) { const printInfo = ROPrintData.PrintInfo[i]; const hasText = !TrUtils.IsEmpty(printInfo.Text) && ('' + printInfo.Text).trim() !== ''; const hasPartsOrOps = (!TrUtils.IsNull(printInfo.Parts) && printInfo.Parts.length > 0) || (!TrUtils.IsNull(printInfo.Ops) && printInfo.Ops.length > 0); const hasColli = !TrUtils.IsNull(printInfo.Colli) && printInfo.Colli.length > 0; if (hasText) { List.push(printInfo.Text); } if (hasPartsOrOps) { List.push( this.GetWithOutDiscAndTaxFieldHeader(TrUtils.Stringify(printInfo.Parts), TrUtils.Stringify(printInfo.Ops), ROPrintData.ShowTaxColumn, ROPrintData.Entity.MPN, ROPrintData.Entity.Body, ROPrintData.ShowIGST, ROPrintData.ConsolidateGST, ROPrintData.ShowDiscountColumn) ); } if (hasColli) { List.push( this.GetCustomerIndPartsTable(printInfo.Colli, printInfo.Type, printInfo.Sts, ROPrintData.Entity.MPN, ROPrintData.ShowTaxColumn) ); } } } } } return List; } static GetCustomerIndPartsTable(Colli: any, Type: any, Status: any, PrintPartNo: any, ShowTaxColumn: any) { let Table: any = {}; if (!TrUtils.IsNull(Colli) && Colli.length !== 0) { let Approved: boolean = (Status === ROStatusEnum.New || Status === ROStatusEnum.WtngForAppr) ? false : true; let isRepairOrder: boolean = (Type === ROTypeEnum.RepairOrder) ? true : false; Table = this.CustomerAccidentalPartsTableAfterApproval(Colli, ShowTaxColumn, PrintPartNo, Approved, isRepairOrder); return Table; } else { return Table; } } static GetInsurancePrint(ROPrintData: any, numberofCopies: any, isOtherIndustry: boolean) { var contents = []; if (TrUtils.IsNull(numberofCopies) || numberofCopies.length === 0) { contents.push( this.CommonHeaderDetails(ROPrintData, null, isOtherIndustry), this.InsurancesparePartsTable(ROPrintData), this.CommonInsTotalDetails(ROPrintData, null, numberofCopies) ); } else { numberofCopies.forEach((text: any, index: any) => { contents.push( this.CommonHeaderDetails(ROPrintData, text, isOtherIndustry), this.InsurancesparePartsTable(ROPrintData), this.CommonInsTotalDetails(ROPrintData, index, numberofCopies) ); }); } var dd = { info: { title: this.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, 25, 10, 15], content: contents, styles: SharedPDFService.GetStyles() }; // if (!TrUtils.IsNull(win)) { // pdfMake.createPdf(dd).open({}, win); // } else { // pdfMake.createPdf(dd).open(); // } return dd; // this.PrintFile = TrUtils.Stringify(dd); // pdfMake.createPdf(dd).getDataUrl(function (outDoc: any) { // document.getElementById('pdf').setAttribute('src', outDoc); // }); } // Insurance Only Print Method static InsurancesparePartsTable(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 = ''; } List.push(ROPrintData.PrintInfo[i].Text, this.GetLaborPartsTableForView(TrUtils.Stringify(ROPrintData.PrintInfo[i].Parts), TrUtils.Stringify(ROPrintData.PrintInfo[i].Ops), ROPrintData.Entity.MPN), this.GetInsuranceIndPartsTable(ROPrintData.PrintInfo[i], ROPrintData.Entity.MPN, ROPrintData.ShowTaxColumn) ); } } 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, this.WithOutDiscountFieldTable(TrUtils.Stringify(ROPrintData.PrintInfo[i].Parts), TrUtils.Stringify(ROPrintData.PrintInfo[i].Ops), ROPrintData.ShowTaxColumn, ROPrintData.Entity.MPN, ROPrintData.Entity.Body, ROPrintData.ShowIGST, ROPrintData.ConsolidateGST, ROPrintData.ShowDiscountColumn), this.GetInsuranceIndPartsTable(ROPrintData.PrintInfo[i], ROPrintData.Entity.MPN, ROPrintData.ShowTaxColumn) ); } } else { if (ROPrintData.Summary) { List.push('', this.GetLaborPartsTableForView(ROPrintData.Parts, ROPrintData.Ops, ROPrintData.Entity.MPN) // this.GetCustomerIndPartsTable(null, ROPrintData.Type, ROPrintData.Sts, // ROPrintData.Entity.MPN, ROPrintData.ShowTaxColumn) ); } else { for (let i = 0; i < ROPrintData.PrintInfo.length; i++) { const printInfo = ROPrintData.PrintInfo[i]; const hasText = !TrUtils.IsNull(printInfo.Text) && ('' + printInfo.Text).trim() !== ''; const hasPartsOrOps = (!TrUtils.IsNull(printInfo.Parts) && printInfo.Parts.length > 0) || (!TrUtils.IsNull(printInfo.Ops) && printInfo.Ops.length > 0); const hasColli = !TrUtils.IsNull(printInfo.Colli) && printInfo.Colli.length > 0; if (hasText) { List.push(printInfo.Text); } if (hasPartsOrOps) { List.push( this.GetWithOutDiscAndTaxFieldHeader(TrUtils.Stringify(printInfo.Parts), TrUtils.Stringify(printInfo.Ops), ROPrintData.ShowTaxColumn, ROPrintData.Entity.MPN, ROPrintData.Entity.Body, ROPrintData.ShowIGST, ROPrintData.ConsolidateGST, ROPrintData.ShowDiscountColumn) ); } if (hasColli) { List.push( this.GetInsuranceIndPartsTable(printInfo, ROPrintData.Entity.MPN, ROPrintData.ShowTaxColumn) ); } } } } } return List; } static GetInsuranceIndPartsTable(PrintInfo: any, PrintPartNo: any, ShowTaxColumn: any) { let Table: any = {}; if (!TrUtils.IsNull(PrintInfo.Colli) && PrintInfo.Colli.length !== 0) { if (PrintInfo.Sts === ROStatusEnum.New || PrintInfo.Sts === ROStatusEnum.WtngForAppr) { Table = this.GetTableForApproval(PrintInfo.Colli, PrintPartNo, ShowTaxColumn); } else { Table = this.InsuranceAccidentalPartsTableAfterApproval(PrintInfo.Colli, ShowTaxColumn, PrintPartNo); } return Table; } else { return Table; } } // Insurance & Customer Print Method static GetInsuranceAndCustomerPrint(ROPrintData: any, numberofCopies: any, isOtherIndustry: boolean) { var contents = []; if (TrUtils.IsNull(numberofCopies) || numberofCopies.length === 0) { contents.push( this.CommonHeaderDetails(ROPrintData, null, isOtherIndustry), this.InsuranceAndCustomersparePartsTable(ROPrintData), this.CommonInsTotalDetails(ROPrintData, null, numberofCopies) ); } else { numberofCopies.forEach((text: any, index: any) => { contents.push( this.CommonHeaderDetails(ROPrintData, text, isOtherIndustry), this.InsuranceAndCustomersparePartsTable(ROPrintData), this.CommonInsTotalDetails(ROPrintData, index, numberofCopies) ); }); } var dd = { info: { title: this.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, 25, 10, 15], content: contents, styles: SharedPDFService.GetStyles() }; // if (!TrUtils.IsNull(win)) { // pdfMake.createPdf(dd).open({}, win); // } else { // pdfMake.createPdf(dd).open(); // } return dd; // this.PrintFile = TrUtils.Stringify(dd); // pdfMake.createPdf(dd).getDataUrl(function (outDoc: any) { // document.getElementById('pdf').setAttribute('src', outDoc); // }); } static InsuranceAndCustomersparePartsTable(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 = ''; } List.push(ROPrintData.PrintInfo[i].Text, this.GetLaborPartsTableForView(TrUtils.Stringify(ROPrintData.PrintInfo[i].Parts), TrUtils.Stringify(ROPrintData.PrintInfo[i].Ops), ROPrintData.Entity.MPN), this.GetInsuranceAndCustomerIndPartsTable(ROPrintData.PrintInfo[i], ROPrintData.Entity.MPN, ROPrintData.ShowTaxColumn) ); } } 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, this.WithOutDiscountFieldTable(TrUtils.Stringify(ROPrintData.PrintInfo[i].Parts), TrUtils.Stringify(ROPrintData.PrintInfo[i].Ops), ROPrintData.ShowTaxColumn, ROPrintData.Entity.MPN, ROPrintData.Entity.Body, ROPrintData.ShowIGST, ROPrintData.ConsolidateGST, ROPrintData.ShowDiscountColumn), this.GetInsuranceAndCustomerIndPartsTable(ROPrintData.PrintInfo[i], ROPrintData.Entity.MPN, ROPrintData.ShowTaxColumn) ); } } else { if (ROPrintData.Summary) { List.push('', this.GetInsuranceOrCustomerLaborPartsTableForView(TrUtils.Stringify(ROPrintData.Parts), TrUtils.Stringify(ROPrintData.Ops), ROPrintData.Entity.MPN)); } else { for (let i = 0; i < ROPrintData.PrintInfo.length; i++) { const printInfo = ROPrintData.PrintInfo[i]; const hasText = !TrUtils.IsNull(printInfo.Text) && ('' + printInfo.Text).trim() !== ''; const hasPartsOrOps = (!TrUtils.IsNull(printInfo.Parts) && printInfo.Parts.length > 0) || (!TrUtils.IsNull(printInfo.Ops) && printInfo.Ops.length > 0); const hasColli = !TrUtils.IsNull(printInfo.Colli) && printInfo.Colli.length > 0; if (hasText) { List.push(printInfo.Text); } if (hasPartsOrOps) { List.push( this.GetWithOutDiscAndTaxFieldHeader(TrUtils.Stringify(printInfo.Parts), TrUtils.Stringify(printInfo.Ops), ROPrintData.ShowTaxColumn, ROPrintData.Entity.MPN, ROPrintData.Entity.Body, ROPrintData.ShowIGST, ROPrintData.ConsolidateGST, ROPrintData.ShowDiscountColumn) ); } if (hasColli) { List.push( this.GetInsuranceAndCustomerIndPartsTable(printInfo, ROPrintData.Entity.MPN, ROPrintData.ShowTaxColumn) ); } } } } } return List; } static GetInsuranceAndCustomerIndPartsTable(PrintInfo: any, PrintPartNo: any, ShowTaxColumn: any) { let Table: any = {}; if (!TrUtils.IsNull(PrintInfo.Colli) && PrintInfo.Colli.length !== 0) { Table = this.GetTableAsCombinedColForCustAndIns(PrintInfo.Colli, PrintPartNo, ShowTaxColumn); return Table; } else { return Table; } } // Insurance | Customer Print Method static GetInsuranceOrCustomerPrint(ROPrintData: any, numberofCopies: any, isOtherIndustry: boolean) { var contents = []; if (TrUtils.IsNull(numberofCopies) || numberofCopies.length === 0) { contents.push( this.CommonHeaderDetails(ROPrintData, null, isOtherIndustry), this.InsuranceOrCustomersparePartsTable(ROPrintData), this.CommonInsTotalDetails(ROPrintData, null, numberofCopies) ); } else { numberofCopies.forEach((text: any, index: any) => { contents.push( this.CommonHeaderDetails(ROPrintData, text, isOtherIndustry), this.InsuranceOrCustomersparePartsTable(ROPrintData), this.CommonInsTotalDetails(ROPrintData, index, numberofCopies) ); }); } var dd = { info: { title: this.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, 25, 10, 15], content: contents, styles: SharedPDFService.GetStyles() }; // if (!TrUtils.IsNull(win)) { // pdfMake.createPdf(dd).open({}, win); // } else { // pdfMake.createPdf(dd).open(); // } return dd; // this.PrintFile = TrUtils.Stringify(dd); // pdfMake.createPdf(dd).getDataUrl(function (outDoc: any) { // document.getElementById('pdf').setAttribute('src', outDoc); // }); } static InsuranceOrCustomersparePartsTable(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 = ''; } List.push(ROPrintData.PrintInfo[i].Text, this.GetLaborPartsTableForView(ROPrintData.PrintInfo[i].Parts, ROPrintData.PrintInfo[i].Ops, ROPrintData.Entity.MPN), this.GetInsuranceOrCustomerIndPartsTable(ROPrintData.PrintInfo[i], ROPrintData.Entity.MPN, ROPrintData.ShowTaxColumn) ); } } 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, this.WithOutDiscountFieldTable(ROPrintData.PrintInfo[i].Parts, ROPrintData.PrintInfo[i].Ops, ROPrintData.ShowTaxColumn, ROPrintData.Entity.MPN, ROPrintData.Entity.Body, ROPrintData.ShowIGST, ROPrintData.ConsolidateGST, ROPrintData.ShowDiscountColumn), this.GetInsuranceOrCustomerIndPartsTable(ROPrintData.PrintInfo[i], ROPrintData.Entity.MPN, ROPrintData.ShowTaxColumn) ); } } else { if (ROPrintData.Summary) { List.push('', this.GetInsuranceOrCustomerLaborPartsTableForView(ROPrintData.Parts, ROPrintData.Ops, ROPrintData.Entity.MPN)); } else { for (let i = 0; i < ROPrintData.PrintInfo.length; i++) { const printInfo = ROPrintData.PrintInfo[i]; const hasText = !TrUtils.IsNull(printInfo.Text) && ('' + printInfo.Text).trim() !== ''; const hasPartsOrOps = (!TrUtils.IsNull(printInfo.Parts) && printInfo.Parts.length > 0) || (!TrUtils.IsNull(printInfo.Ops) && printInfo.Ops.length > 0); const hasColli = !TrUtils.IsNull(printInfo.Colli) && printInfo.Colli.length > 0; if (hasText) { List.push(printInfo.Text); } if (hasPartsOrOps) { List.push( this.GetWithOutDiscAndTaxFieldHeader(printInfo.Parts, printInfo.Ops, ROPrintData.ShowTaxColumn, ROPrintData.Entity.MPN, ROPrintData.Entity.Body, ROPrintData.ShowIGS, ROPrintData.ConsolidateGST, ROPrintData.ShowDiscountColumn) ); } if (hasColli) { List.push( this.GetInsuranceOrCustomerIndPartsTable(printInfo, ROPrintData.Entity.MPN, ROPrintData.ShowTaxColumn) ); } } } } } return List; } static GetInsuranceOrCustomerIndPartsTable(PrintInfo: any, PrintPartNo: any, ShowTaxColumn: any) { let Table: any = {}; if (!TrUtils.IsNull(PrintInfo.Colli) && PrintInfo.Colli.length !== 0) { Table = this.GetTableAsSeparateColForCustAndIns(PrintInfo.Colli, PrintPartNo, ShowTaxColumn); return Table; } else { return Table; } } static GetLaborPartsTableForView(Parts: any, Ops: any, PrintPartNo: any) { if (Parts.length !== 0 || Ops.length !== 0) { if (PrintPartNo) { return { style: 'tableExample', // marginLeft: 20, table: { widths: [25, 85, 170, 20, 50, 30, 30, 50], // headerRows: 2, body: this.buildTableForCustomerLabor(Parts, Ops, PrintPartNo, false) }, layout: PrintSharedService.LayOutStyleanother() }; } else { return { style: 'tableExample', // marginLeft: 20, table: { widths: [25, 200, 55, 25, 55, 55, 40, 50], // headerRows: 2, body: this.buildTableForCustomerLabor(Parts, Ops, PrintPartNo, false) }, layout: PrintSharedService.LayOutStyleanother() }; } } else { let a: any = ''; return a; } } static GetInsuranceOrCustomerLaborPartsTableForView(Parts: any, Ops: any, PrintPartNo: any) { if (Parts.length !== 0 || Ops.length !== 0) { if (PrintPartNo) { return { style: 'tableExample', // marginLeft: 20, table: { widths: [25, 85, 170, 20, 50, 30, 30, 50], // headerRows: 2, body: this.buildTableForCustomerLabor(Parts, Ops, PrintPartNo, true) }, layout: PrintSharedService.LayOutStyleanother() }; } else { return { style: 'tableExample', // marginLeft: 20, table: { widths: [25, 185, 45, 20, 50, 50, 40, 30, 50], // headerRows: 2, body: this.buildTableForCustomerLabor(Parts, Ops, PrintPartNo, true) }, layout: PrintSharedService.LayOutStyleanother() }; } } else { let a: any = ''; return a; } } static buildTableBody(Parts: any, Ops: any, PrintPartNo: any) { var body: any = []; let columns: any = SharedPDFService.GetHeaders(PrintPartNo); // body.push(columns); for (let i = 0; i < columns.length; i++) { body.push(columns[i]); } let DummyOps: any = []; if (Parts.length !== 0) { 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[1].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 { // tslint:disable-next-line:max-line-length if (column.text === 'Line Total' || column.Field === 'QtyAndUoM' || column.Field === 'Disc' || column.Field === 'UnPr') { if (column.Field === 'Disc') { if (column.type === 'percentage') { if (!TrUtils.IsEmpty(part.Perc)) { dataRow.push({ text: part.Perc.toString(), alignment: 'right', 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 { 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 { part[column.Field] = ''; } dataRow.push({ text: part[column.Field].toString(), alignment: 'center' }); } }); body.push(dataRow); }); if (Ops.length !== 0) { let dummypartadding1: any = {}; dummypartadding1.SNo = ''; dummypartadding1.Desc = 'Labor'; dummypartadding1.Qty = ''; dummypartadding1.UnPr = ''; dummypartadding1.LineTotal = ''; Ops.unshift(dummypartadding1); } Ops.forEach((labor: any) => { var dataRow: any = []; columns[1].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 === 'Disc' || column.Field === 'UnPr') { if (column.Field === 'Disc') { if (column.type === 'percentage') { if (!TrUtils.IsEmpty(labor.Perc)) { dataRow.push({ text: labor.Perc.toString(), alignment: 'right', noWrap: true }); } else { dataRow.push({ text: '', noWrap: true }); } } else { if (!TrUtils.IsZero(labor[column.Field])) { dataRow.push({ text: labor[column.Field].toString(), alignment: 'right', noWrap: true }); } else { dataRow.push({ text: '', noWrap: true }); } } } else { dataRow.push({ text: labor[column.Field].toString(), alignment: 'right', nowrap: true }); } } else { dataRow.push(labor[column.Field].toString()); } } } else { if (column.Field === 'SNo') { labor[column.Field] = SNo; SNo = SNo + 1; } else { labor[column.Field] = ''; } dataRow.push({ text: labor[column.Field].toString(), alignment: 'center' }); } }); body.push(dataRow); }); return body; } static GetTableForApproval(Colli: any, PrintPartNo: any, ShowTaxColumn: any) { if (ShowTaxColumn) { return { style: 'tableExample', marginTop: 7, lineHeight: 1, dontBreakRows: true, table: { widths: [10, 94, 28, 20, 34, 35, 34, 35, 34, 35, 34, 35, 35], // headerRows: 3, body: this.GetApprovalTableHeaderBody(Colli, PrintPartNo, ShowTaxColumn) }, layout: this.threeLayOutStyle() }; } else { return { style: 'tableExample', marginTop: 7, lineHeight: 1, dontBreakRows: true, table: { widths: [10, 130, 20, 34, 35, 34, 35, 34, 35, 34, 35, 35], // headerRows: 3, body: this.GetApprovalTableHeaderBody(Colli, PrintPartNo, ShowTaxColumn) }, layout: this.threeLayOutStyle() }; } } static GetApprovalTableHeaderBody(Colli: any, PrintPartNo: any, ShowTaxColumn: any) { var body: any = []; let SNo: number = 1; let columns: any = this.GetTableHeadersForApproval(PrintPartNo, ShowTaxColumn); for (let i = 0; i < columns.length; i++) { body.push(columns[i]); } Colli.forEach((part: any) => { var dataRow: any = []; columns[2].forEach((column: any) => { if (!TrUtils.IsNull(column.Parent)) { if (column.Field === 'AssPr') { dataRow.push({ text: '', alignment: 'center' }); } else { if (!TrUtils.IsNull(part[column.Parent]) && !TrUtils.IsFixedZero(part[column.Parent][column.Field]) && !TrUtils.IsNull(part[column.Parent][column.Field])) { dataRow.push({ text: part[column.Parent][column.Field].toString(), alignment: 'right', fontSize: 7, nowrap: true }); } else { dataRow.push({ text: '', alignment: 'center' }); } } } else { if (!TrUtils.IsFixedZero(part[column.Field]) && !TrUtils.IsNull(part[column.Field])) { if (column.Field === 'SNo' || column.Field === 'Desc' || column.text === 'Description/PartNo') { // dataRow.push(part[column.Field].toString()); 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 { dataRow.push({ text: part[column.Field].toString(), alignment: 'right', fontSize: 7, nowrap: true }); } } else { if (column.Field === 'SNo') { 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 GetTableHeadersForApproval(PrintPartNo: any, ShowTaxColumn: any) { let headersNames: any[] = [ [{ text: 'S. No.', rowSpan: 3, style: ['tableheader', 'withOutApp'], lineHeight: 1 }, { text: 'Qty', style: ['tableheader', 'withOutApp'], rowSpan: 3 }, { text: 'Unit Price', style: ['tableheader', 'withOutApp'], rowSpan: 2, colSpan: 2 }, {}, { text: 'Labor charges', style: ['tableheader', 'withOutApp'], colSpan: 6 }, {}, {}, {}, {}, {}, { text: 'Line Total', rowSpan: 3, style: 'tableheader', alignment: 'center', lineHeight: 1 }], [{}, {}, {}, {}, {}, { text: 'R&R/Labor', colSpan: 2, style: ['tableheader', 'withOutApp'] }, {}, { text: 'Denting', colSpan: 2, style: ['tableheader', 'withOutApp'] }, {}, { text: 'Painting', colSpan: 2, style: ['tableheader', 'withOutApp'] }, {}, {}], [{ text: '', Field: 'SNo', lineHeight: 0.5 }, { text: '', Field: 'Desc', lineHeight: 0.5 }, { text: '', Field: 'QtyAndUoM', Parent: 'PartData', lineHeight: 0.5 }, { text: 'Estimate', fontSize: this.FontSize, style: ['tableheader', 'withOutApp'], Parent: 'PartData', Field: 'EstPr', }, { text: 'Assessed', fontSize: this.FontSize, style: ['tableheader', 'withOutApp'], Parent: 'PartData', Field: 'AssPr', }, { text: 'Estimate', fontSize: this.FontSize, style: ['tableheader', 'withOutApp'], Parent: 'RRFData', Field: 'EstPr', }, { text: 'Assessed', fontSize: this.FontSize, style: ['tableheader', 'withOutApp'], Parent: 'RRFData', Field: 'AssPr', }, { text: 'Estimate', fontSize: this.FontSize, style: ['tableheader', 'withOutApp'], Parent: 'DtngData', Field: 'EstPr', }, { text: 'Assessed', fontSize: this.FontSize, style: ['tableheader', 'withOutApp'], Parent: 'DtngData', Field: 'AssPr', }, { text: 'Estimate', fontSize: this.FontSize, style: ['tableheader', 'withOutApp'], Parent: 'PtngData', Field: 'EstPr', }, { text: 'Assessed', fontSize: this.FontSize, style: ['tableheader', 'withOutApp'], Parent: 'PtngData', Field: 'AssPr', }, { text: '', Field: 'LineTotal', lineHeight: 1, alignment: 'center' }] ]; if (PrintPartNo) { headersNames[0].splice(1, 0, { text: 'Description/PartNo', rowSpan: 3, style: ['tableheader', 'withOutApp'] }); } else { headersNames[0].splice(1, 0, { text: 'Description', rowSpan: 3, style: ['tableheader', 'withOutApp'] }); } if (ShowTaxColumn) { headersNames[0].splice(2, 0, { text: 'HSN', style: ['tableheader', 'withOutApp'], rowSpan: 3 }); headersNames[1].splice(2, 0, {}); headersNames[2].splice(2, 0, { text: '', Parent: 'PartData', Field: 'HSN', lineHeight: 0.5 }); } return headersNames; } static GetTableAsSeparateColForCustAndIns(Colli: any, PrintPartNo: any, ShowTaxColumn: any) { if (ShowTaxColumn) { return { style: 'tableExample', marginTop: 7, lineHeight: 1, table: { widths: [10, 96, 28, 20, 34, 33, 34, 33, 34, 33, 34, 33, 40], // headerRows: 3, body: this.GetApprovedCustInsTableHeaderBody(Colli, PrintPartNo, ShowTaxColumn) }, layout: PrintSharedService.LayOutStyle() }; } else { return { style: 'tableExample', marginTop: 7, lineHeight: 1, table: { widths: [10, 130, 20, 34, 33, 34, 33, 34, 33, 34, 33, 40], // headerRows: 3, body: this.GetApprovedCustInsTableHeaderBody(Colli, PrintPartNo, ShowTaxColumn) }, layout: PrintSharedService.LayOutStyle() }; } } static GetApprovedCustInsTableHeaderBody(Parts: any, PrintPartNo: any, ShowTaxColumn: any) { var body: any = []; let SNo: number = 1; let columns = this.GetTableHeadersForCustAndIns(PrintPartNo, ShowTaxColumn); for (let i = 0; i < columns.length; i++) { body.push(columns[i]); } Parts.forEach((part: any) => { var dataRow: any = []; columns[2].forEach((column: any) => { if (!TrUtils.IsNull(column.Parent)) { if (!TrUtils.IsNull(part[column.Parent]) && !TrUtils.IsFixedZero(part[column.Parent][column.Field]) && !TrUtils.IsNull(part[column.Parent][column.Field])) { dataRow.push({ text: part[column.Parent][column.Field].toString(), alignment: 'right', fontSize: 7, nowrap: true }); } else { dataRow.push({ text: '', alignment: 'center' }); } } else { if (!TrUtils.IsFixedZero(part[column.Field]) && !TrUtils.IsNull(part[column.Field])) { if (column.Field === 'SNo' || column.Field === 'Desc' || column.text === 'Description/PartNo') { // dataRow.push(part[column.Field].toString()); 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 { dataRow.push({ text: part[column.Field].toString(), alignment: 'right', fontSize: 7, nowrap: true }); } } else { if (column.Field === 'SNo') { 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 GetTableHeadersForCustAndIns(PrintPartNo: any, ShowTaxColumn: any) { let headersNames: any[] = [ [{ text: 'S. No.', rowSpan: 3, style: ['tableheader', 'withOutApp'], lineHeight: 1 }, { text: 'Qty', style: ['tableheader', 'withOutApp'], rowSpan: 3 }, { text: 'Unit Price', style: ['tableheader', 'withOutApp'], rowSpan: 2, colSpan: 2, }, {}, { text: 'Labor charges', style: ['tableheader', 'withOutApp'], colSpan: 6 }, {}, {}, {}, {}, {}, { text: 'Line Total', rowSpan: 3, style: 'tableheader', alignment: 'center', lineHeight: 1 }], [{}, {}, {}, {}, {}, { text: 'R&R/Labor', colSpan: 2, style: ['tableheader', 'withOutApp'] }, {}, { text: 'Denting', colSpan: 2, style: ['tableheader', 'withOutApp'] }, {}, { text: 'Painting', colSpan: 2, style: ['tableheader', 'withOutApp'] }, {}, {}], [{ text: '', Field: 'SNo' }, { text: '', Field: 'Desc' }, { text: '', Field: 'QtyAndUoM', Parent: 'PartData' }, { text: 'Assessed', fontSize: this.FontSize, style: ['tableheader', 'withOutApp'], Field: 'AssPr', Parent: 'PartData' }, { text: 'Customer', fontSize: this.FontSize, style: ['tableheader', 'withOutApp'], Field: 'UnPr', Parent: 'PartData', lineHeight: 1 }, { text: 'Assessed', fontSize: this.FontSize, style: ['tableheader', 'withOutApp'], Field: 'AssPr', Parent: 'RRFData' }, { text: 'Customer', fontSize: this.FontSize, style: ['tableheader', 'withOutApp'], Field: 'NetAmt', Parent: 'RRFData', lineHeight: 1 }, { text: 'Assessed', fontSize: this.FontSize, style: ['tableheader', 'withOutApp'], Field: 'AssPr', Parent: 'DtngData' }, { text: 'Customer', fontSize: this.FontSize, style: ['tableheader', 'withOutApp'], Field: 'NetAmt', Parent: 'DtngData', lineHeight: 1 }, { text: 'Assessed', fontSize: this.FontSize, style: ['tableheader', 'withOutApp'], Parent: 'PtngData', Field: 'AssPr' }, { text: 'Customer', fontSize: this.FontSize, style: ['tableheader', 'withOutApp'], Field: 'NetAmt', Parent: 'PtngData', lineHeight: 1 }, { text: '', Field: 'LineTotal' }] ]; if (PrintPartNo) { headersNames[0].splice(1, 0, { text: 'Description/PartNo', rowSpan: 3, style: ['tableheader', 'withOutApp'] }); } else { headersNames[0].splice(1, 0, { text: 'Description', rowSpan: 3, style: ['tableheader', 'withOutApp'] }); } if (ShowTaxColumn) { headersNames[0].splice(2, 0, { text: 'HSN', style: ['tableheader', 'withOutApp'], rowSpan: 3 }); headersNames[1].splice(2, 0, {}); headersNames[2].splice(2, 0, { text: '', Parent: 'PartData', Field: 'HSN' }); } return headersNames; } static GetTableAsCombinedColForCustAndIns(Colli: any, PrintPartNo: any, ShowTaxColumn: any) { if (ShowTaxColumn) { return { style: 'tableExample', lineHeight: 1, marginTop: 7, // marginLeft: 20, table: { // widths: [15, 179, 35, 25, 45, 49, 49, 49, 49], widths: [24, 180, 35, 25, 45, 45, 45, 45, 45], // headerRows: 2, body: this.GetCombinedCustAndInsTableBodyAndHeaders(Colli, PrintPartNo, ShowTaxColumn) }, layout: PrintSharedService.LayOutStyle() }; } else { { return { style: 'tableExample', lineHeight: 1, marginTop: 7, // marginLeft: 20, table: { // widths: [15, 179, 35, 25, 45, 49, 49, 49, 49], widths: [25, 220, 25, 45, 45, 45, 45, 45], // headerRows: 2, body: this.GetCombinedCustAndInsTableBodyAndHeaders(Colli, PrintPartNo, ShowTaxColumn) }, layout: PrintSharedService.LayOutStyle() }; } } } static GetCombinedCustAndInsTableBodyAndHeaders(Colli: any, PrintPartNo: any, ShowTaxColumn: any) { let SNo: number = 1; let body: any[] = []; let columns: any[] = this.GetCombinedCustAndInsColumns(PrintPartNo, ShowTaxColumn); for (let i = 0; i < columns.length; i++) { body.push(columns[i]); } Colli.forEach((part: any) => { var dataRow: any = []; columns[1].forEach((column: any) => { if (!TrUtils.IsNull(column.Parent)) { if (!TrUtils.IsNull(part[column.Parent]) && !TrUtils.IsFixedZero(part[column.Parent][column.Field]) && !TrUtils.IsNull(part[column.Parent][column.Field])) { dataRow.push({ text: part[column.Parent][column.Field].toString(), alignment: 'right', nowrap: true }); } else { dataRow.push({ text: '', alignment: 'center' }); } } else { if (!TrUtils.IsFixedZero(part[column.Field]) && !TrUtils.IsNull(part[column.Field])) { if (column.Field === 'SNo' || column.Field === 'Desc' || column.text === 'Description/PartNo') { // dataRow.push(part[column.Field].toString()); 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 { dataRow.push({ text: part[column.Field].toString(), alignment: 'right', nowrap: true }); } } else { if (column.Field === 'SNo') { 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 GetCombinedCustAndInsColumns(PrintPartNo: any, ShowTaxColumn: any) { let headersNames: any = [ [{ text: 'S.No.', rowSpan: 2, style: ['tableheader', 'withApp'] }, { text: 'Qty', style: ['tableheader', 'withApp'], rowSpan: 2, }, { text: 'Unit Price', style: ['tableheader', 'withApp'], rowSpan: 2, lineHeight: 1 }, { text: 'Labor charges', style: ['tableheader', 'withApp'], colSpan: 3, }, {}, {}, { text: 'Line Total', rowSpan: 2, style: ['tableheader', 'withApp'] } ], [{ text: '', Field: 'SNo' }, { text: '', Field: 'Desc' }, { text: '', Field: 'QtyAndUoM', Parent: 'PartData' }, { text: '', Field: 'AssPr', Parent: 'PartData' }, { text: 'R&R/Labor', fontSize: this.FontSize, style: ['tableheader', 'withApp'], Field: 'AssPr', Parent: 'RRFData' }, { text: 'Denting', fontSize: this.FontSize, style: ['tableheader', 'withApp'], Field: 'AssPr', Parent: 'DtngData' }, { text: 'Painting', fontSize: this.FontSize, style: ['tableheader', 'withApp'], Field: 'AssPr', Parent: 'PtngData' }, { text: '', Field: 'LineTotal', style: ['tableheader', 'withApp'] } ] ]; if (PrintPartNo) { headersNames[0].splice(1, 0, { text: 'Description/PartNo', rowSpan: 2, style: ['tableheader', 'withOutApp'] }); } else { headersNames[0].splice(1, 0, { text: 'Description', rowSpan: 2, style: ['tableheader', 'withOutApp'] }); } if (ShowTaxColumn) { headersNames[0].splice(2, 0, { text: 'HSN', style: ['tableheader', 'withApp'], rowSpan: 2, }); headersNames[1].splice(2, 0, { text: '', Parent: 'PartData', Field: 'HSN' }); } return headersNames; } static CustomerAccidentalPartsTableAfterApproval(Colli: any, ShowTaxColumn: any, PrintPartNo: boolean, Approved: boolean, isRepairOrder: boolean) { if (ShowTaxColumn) { return { style: 'tableExample', marginTop: 7, lineHeight: 1, // marginLeft: 20, table: { // widths: [15, 174, 35, 25, 49, 49, 49, 49, 49], widths: [24, 185, 35, 25, 45, 45, 45, 45, 45], // headerRows: 2, body: this.GetCustomerAccidentalPartsTableBodyData(Colli, ShowTaxColumn, PrintPartNo, Approved, isRepairOrder) }, layout: PrintSharedService.LayOutStyle() }; } else { return { style: 'tableExample', marginTop: 7, lineHeight: 1, // marginLeft: 20, table: { // widths: [15, 174, 35, 25, 49, 49, 49, 49, 49], widths: [25, 220, 25, 45, 45, 45, 45, 45], // headerRows: 2, body: this.GetCustomerAccidentalPartsTableBodyData(Colli, ShowTaxColumn, PrintPartNo, Approved, isRepairOrder) }, layout: PrintSharedService.LayOutStyle() }; } } static InsuranceAccidentalPartsTableAfterApproval(Colli: any, ShowTaxColumn: any, PrintPartNo: boolean) { if (ShowTaxColumn) { return { style: 'tableExample', marginTop: 7, // lineHeight: 1, // marginLeft: 20, table: { widths: [24, 185, 35, 25, 45, 45, 45, 45, 45], // headerRows: 2, body: this.GetInsuranceAccidentalPartsTableBodyData(Colli, ShowTaxColumn, PrintPartNo) }, layout: PrintSharedService.LayOutStyle() }; } else { return { style: 'tableExample', marginTop: 7, // lineHeight: 1, // marginLeft: 20, table: { widths: [25, 220, 25, 45, 45, 45, 45, 45], // headerRows: 2, body: this.GetInsuranceAccidentalPartsTableBodyData(Colli, ShowTaxColumn, PrintPartNo) }, layout: PrintSharedService.LayOutStyle() }; } } static GetCustomerAccidentalPartsTableBodyData(Parts: any, ShowTaxColumn: any, PrintPartNo: boolean, Approved: boolean, isRepairOrder: boolean) { let columns: any = this.GetCustomerAccidentalPartsHeaders(ShowTaxColumn, PrintPartNo, Approved, isRepairOrder); var body: any = []; for (let i = 0; i < columns.length; i++) { body.push(columns[i]); } let SNo: number = 1; Parts.forEach((part: any) => { var dataRow: any = []; columns[1].forEach((column: any) => { if (!TrUtils.IsNull(column.Parent)) { if (!TrUtils.IsNull(part[column.Parent]) && !TrUtils.IsFixedZero(part[column.Parent][column.Field]) && !TrUtils.IsNull(part[column.Parent][column.Field])) { dataRow.push({ text: part[column.Parent][column.Field].toString(), alignment: 'right', nowrap: true }); } else { dataRow.push({ text: '', alignment: 'center' }); } } else { if (!TrUtils.IsFixedZero(part[column.Field]) && !TrUtils.IsNull(part[column.Field])) { if (column.Field === 'SNo' || column.Field === 'Desc' || column.text === 'Description/PartNo') { // dataRow.push(part[column.Field].toString()); 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 { dataRow.push({ text: part[column.Field].toString(), alignment: 'right', nowrap: true }); } } else { if (column.Field === 'SNo') { 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 GetInsuranceAccidentalPartsTableBodyData(Parts: any, ShowTaxColumn: any, PrintPartNo: boolean) { let columns: any = this.GetInsuranceAccidentalPartsHeaders(ShowTaxColumn, PrintPartNo); var body: any = []; for (let i = 0; i < columns.length; i++) { body.push(columns[i]); } let SNo: number = 1; Parts.forEach((part: any) => { var dataRow: any = []; columns[1].forEach((column: any) => { if (!TrUtils.IsNull(column.Parent)) { if (!TrUtils.IsNull(part[column.Parent]) && !TrUtils.IsFixedZero(part[column.Parent][column.Field]) && !TrUtils.IsNull(part[column.Parent][column.Field])) { dataRow.push({ text: part[column.Parent][column.Field].toString(), alignment: 'right', nowrap: true }); } else { dataRow.push({ text: '', alignment: 'center' }); } } else { if (!TrUtils.IsFixedZero(part[column.Field]) && !TrUtils.IsNull(part[column.Field])) { if (column.Field === 'SNo' || column.Field === 'Desc' || column.text === 'Description/PartNo') { // dataRow.push(part[column.Field].toString()); 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 { dataRow.push({ text: part[column.Field].toString(), alignment: 'right', nowrap: true }); } } else { if (column.Field === 'SNo') { 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 GetInsuranceAccidentalPartsHeaders(ShowTaxColumn: any, PrintPartNo: boolean) { let headersNames: any = [ [{ text: 'S.No.', rowSpan: 2, style: ['tableheader', 'withApp'] }, { text: 'Qty', style: ['tableheader', 'withApp'], rowSpan: 2, }, { text: 'Unit Price', style: ['tableheader', 'withApp'], rowSpan: 2, }, { text: 'Labor charges ', style: ['tableheader', 'withApp'], colSpan: 3, }, {}, {}, { text: 'Line Total', rowSpan: 2, style: ['tableheader', 'withApp'] } ], [{ text: '', Field: 'SNo' }, { text: '', Field: 'Desc' }, { text: '', Field: 'QtyAndUoM', Parent: 'PartData' }, { text: '', Parent: 'PartData', Field: 'AssPr' }, { text: 'R&R/Labor', fontSize: this.FontSize, style: ['tableheader', 'withApp'], Parent: 'RRFData', Field: 'AssPr' }, { text: 'Denting', fontSize: this.FontSize, style: ['tableheader', 'withApp'], Parent: 'DtngData', Field: 'AssPr' }, { text: 'Painting', fontSize: this.FontSize, style: ['tableheader', 'withApp'], Parent: 'PtngData', Field: 'AssPr' }, { text: '', Field: 'LineTotal', style: ['tableheader', 'withApp'] } ] ]; if (PrintPartNo) { headersNames[0].splice(1, 0, { text: 'Description/PartNo', rowSpan: 2, style: ['tableheader', 'withApp'] }); } else { headersNames[0].splice(1, 0, { text: 'Description', rowSpan: 2, style: ['tableheader', 'withApp'] }); } if (ShowTaxColumn) { headersNames[0].splice(2, 0, { text: 'HSN', rowSpan: 2, style: ['tableheader', 'withApp'] }); headersNames[1].splice(2, 0, { text: '', Parent: 'PartData', Field: 'HSN' }); } return headersNames; } static GetCustomerAccidentalPartsHeaders(ShowTaxColumn: any, PrintPartNo: boolean, Approved: boolean, isRepairOrder: boolean) { let headersNames: any = []; if (Approved || isRepairOrder) { headersNames = [ [{ text: 'S.No.', rowSpan: 2, style: ['tableheader', 'withApp'], alignment: 'center' }, { text: 'Qty', style: ['tableheader', 'withApp'], rowSpan: 2, alignment: 'center' }, { text: 'Unit Price', style: ['tableheader', 'withApp'], rowSpan: 2, alignment: 'center' }, { text: 'Labor charges ', style: ['tableheader', 'withApp'], colSpan: 3, alignment: 'center' }, {}, {}, { text: 'Line Total', rowSpan: 2, alignment: 'center', style: ['tableheader', 'withApp'] } ], [{ text: '', Field: 'SNo' }, { text: '', Field: 'Desc' }, { text: '', Parent: 'PartData', Field: 'QtyAndUoM' }, { text: '', Parent: 'PartData', Field: 'UnPr' }, { text: 'R&R/Labor', fontSize: this.FontSize, style: ['tableheader', 'withApp'], Parent: 'RRFData', Field: 'UnPr' }, { text: 'Denting', fontSize: this.FontSize, Parent: 'DtngData', style: ['tableheader', 'withApp'], Field: 'UnPr' }, { text: 'Painting', fontSize: this.FontSize, Parent: 'PtngData', style: ['tableheader', 'withApp'], Field: 'UnPr', alignment: 'center' }, { text: '', Field: 'LineTotal' } ] ]; } else { headersNames = [ [{ text: 'S.No.', rowSpan: 2, style: ['tableheader', 'withApp'], alignment: 'center' }, { text: 'Qty', style: ['tableheader', 'withApp'], rowSpan: 2, alignment: 'center' }, { text: 'Unit Price', style: ['tableheader', 'withApp'], rowSpan: 2, alignment: 'center' }, { text: 'Labor charges ', style: ['tableheader', 'withApp'], colSpan: 3, alignment: 'center' }, {}, {}, { text: 'Line Total', rowSpan: 2, alignment: 'center', style: ['tableheader', 'withApp'] } ], [{ text: '', Field: 'SNo' }, { text: '', Field: 'Desc' }, { text: '', Parent: 'PartData', Field: 'QtyAndUoM' }, { text: '', Parent: 'PartData', Field: 'EstPr' }, { text: 'R&R/Labor', fontSize: this.FontSize, style: ['tableheader', 'withApp'], Parent: 'RRFData', Field: 'EstPr' }, { text: 'Denting', fontSize: this.FontSize, style: ['tableheader', 'withApp'], Parent: 'DtngData', Field: 'EstPr' }, { text: 'Painting', fontSize: this.FontSize, style: ['tableheader', 'withApp'], Parent: 'PtngData', Field: 'EstPr', alignment: 'center' }, { text: '', Field: 'LineTotal' } ] ]; } if (PrintPartNo) { headersNames[0].splice(1, 0, { text: 'Description/PartNo', rowSpan: 2, style: ['tableheader', 'withApp'] }); } else { headersNames[0].splice(1, 0, { text: 'Description', rowSpan: 2, style: ['tableheader', 'withApp'] }); } if (ShowTaxColumn) { headersNames[0].splice(2, 0, { text: 'HSN', rowSpan: 2, style: ['tableheader', 'withApp'], alignment: 'center' }); headersNames[1].splice(2, 0, { text: '', Parent: 'PartData', Field: 'HSN' }); } return headersNames; } static threeLayOutStyle() { return { hLineWidth: function (i: any, node: any) { return (i === 0 || i === node.table.body.length) ? 0.7 : 0.7; }, vLineWidth: function (i: any, node: any) { return (i === 0 || i === node.table.widths.length) ? 0.7 : 0.7; }, hLineColor: function (i: any, node: any) { let color; if (i === 0 || i === node.table.body.length) { color = 'black'; } else { if (i === 1 || i === 2 || i === 3) { color = 'gray'; } else { color = 'lightgray'; } } return color; }, vLineColor: function (i: any, node: any) { let color; if (i === 0 || i === node.table.widths.length) { color = 'black'; } else { color = 'gray'; } return color; }, }; } static WithOutDiscountFieldTable(Parts: any, Ops: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any) { if (Parts.length !== 0 || Ops.length !== 0) { if (PrintPartNo) { return { style: 'tableExample', marginLeft: 20, table: { widths: [25, 60, 160, 25, 50, 60, 30, 50], headerRows: 1, body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyleanother() }; } else { return { style: 'tableExample', marginLeft: 20, table: { widths: [25, 215, 25, 50, 60, 45, 50], headerRows: 1, body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyleanother() }; } } else { let a: any = ''; return a; } } static BuildTableBodyForLaborAndParts(Parts: any, Labor: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any) { var body: any = []; let columns: any = PrintSharedService.GetWithOutDiscountFieldHeader(PrintPartNo, ShowTaxColumn, Body, ShowIGST, ShowDiscountColumn); // if (ShowTaxColumn) { for (let i = 0; i < columns.length; i++) { body.push(columns[i]); } columns = columns[1]; // } else { // body.push(columns); // } let DummyOps: any = []; if (Parts.length !== 0) { 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 { console.log(part.TCode); 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.Perc)) { dataRow.push({ text: part.Perc.toString(), alignment: 'right', 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 { dataRow.push({ text: part[column.Field].toString(), alignment: 'right', nowrap: true }); } } else { // dataRow.push(part[column.Field].toString()); 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 (Labor.length !== 0) { let dummypartadding1: any = {}; dummypartadding1.SNo = ''; dummypartadding1.Desc = 'Labor'; dummypartadding1.Qty = ''; dummypartadding1.UnPr = ''; dummypartadding1.LineTotal = ''; Labor.unshift(dummypartadding1); // DummyOps.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 { console.log(Ops.TCode); 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.Perc)) { dataRow.push({ text: Ops.Perc.toString(), alignment: 'right', noWrap: true }); } else { dataRow.push({ text: '', noWrap: true }); } } else { if (!TrUtils.IsZero(Ops[column.Field])) { dataRow.push({ text: Ops[column.Field].toString(), alignment: 'right', noWrap: true }); } else { dataRow.push({ text: '', noWrap: true }); } } } else { dataRow.push({ text: Ops[column.Field].toString(), alignment: 'right', nowrap: true }); } } else { dataRow.push(Ops[column.Field].toString()); } } } } 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 GetWithOutDiscAndTaxFieldHeader(Parts: any, Ops: any, ShowTaxColumn: any, PrintPartNo: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any) { if (Parts.length !== 0 || Ops.length !== 0) { console.log('ShowTaxColumn', ShowTaxColumn); if (ShowTaxColumn) { return this.TaxDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn); } else { if (ConsolidateGST) { return this.ConsolidateDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn); } else { return this.NoTaxDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn); } } } else { let a: any = ''; return a; } } static TaxDataTable(Parts: any, Ops: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any) { if (PrintPartNo) { if (ShowIGST) { return { style: 'tableExample', marginTop:7, table: { widths: PrintSharedService.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn), // headerRows: 2, body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } else { return { style: 'tableExample', marginTop:7, table: { widths: PrintSharedService.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn), // headerRows: 2, body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } } else { if (ShowIGST) { return { style: 'tableExample', marginTop:7, table: { widths: PrintSharedService.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn), // headerRows: 2, body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } else { return { style: 'tableExample', marginTop:7, table: { widths: PrintSharedService.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn), // headerRows: 2, body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } } } static ConsolidateDataTable(Parts: any, Ops: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any) { if (PrintPartNo) { return { style: 'tableExample', marginTop:7, table: { widths: [25, 65, 273, 25, 60, 75, 10, 40], // headerRows: 1, body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } else { return { style: 'tableExample', marginTop:7, table: { widths: [25, 290, 50, 80, 80, 10, 40], // headerRows: 1, body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } } static NoTaxDataTable(Parts: any, Ops: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any) { if (PrintPartNo) { return { style: 'tableExample', marginTop:7, table: { widths: PrintSharedService.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo), // headerRows: 1, body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } else { return { style: 'tableExample', marginTop:7, table: { widths: PrintSharedService.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo), // headerRows: 1, body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } } static buildTableForCustomerLabor(Parts: any, Ops: any, PrintPartNo: any, customerorInsurance: any) { var body: any = []; let columns: any; columns = this.getSummaryHeaders(PrintPartNo); // console.log(columns); 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 { // tslint:disable-next-line:max-line-length 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 { // dataRow.push({ text: part[column.Field].toString() }); 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 getSummaryHeaders(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: 'Rate / Unit', style: 'tableheader', Field: 'UnPr' }, { text: 'Ins. Amt', style: 'tableheader', Field: 'InsPrice' }, { text: 'Cust. Amt', style: 'tableheader', Field: 'CustPrice' }, { 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; } }