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'; export class SharedInvoiceprintService { FontSize: number = 8; static GetInvoicePrint(ROPrintData: any, numberofCopies: any, isotherIndustry: boolean, withPass: boolean, isAuto: boolean, moreDiscDetails:boolean) { var contents = []; if (TrUtils.IsNull(numberofCopies) || numberofCopies.length === 0) { contents.push( this.CommonHeaderDetails(ROPrintData, null, isotherIndustry), this.PreparesparePartsTable(ROPrintData, isAuto), this.CommonTotalDetails(ROPrintData, null, numberofCopies, withPass, moreDiscDetails) ); } else { numberofCopies.forEach((text: any, index: any) => { contents.push( this.CommonHeaderDetails(ROPrintData, text, isotherIndustry), this.PreparesparePartsTable(ROPrintData, isAuto), this.CommonTotalDetails(ROPrintData, index, numberofCopies, withPass, moreDiscDetails) ); }); } 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 }; }, 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; } 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 CommonHeaderDetails(ROPrintData: any, text: any, isotherIndustry: boolean) { return [ this.GetMainHeaderDetails(ROPrintData.Entity, ROPrintData.HeaderName, ROPrintData.Image, ROPrintData.HColor, ROPrintData.AColor, text), 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,null, ROPrintData.DoS), SharedPDFService.GetOwnerDetails(ROPrintData.Cust, ROPrintData.Type, ROPrintData.For), 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('TAX INVOICE'), SharedPDFService.HeaderAfterLine() ]; } static PreparesparePartsTable(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, this.GetLaborPartsTableForView(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, this.WithOutDiscountFieldTable(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('', this.GetLaborPartsTableForView(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, this.GetWithOutDiscAndTaxFieldHeader(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 GetLaborPartsTableForView(Parts: any, Ops: any, PrintPartNo: any) { if (Parts.length !== 0 || Ops.length !== 0) { if (PrintPartNo) { return { style: 'tableExample', // marginLeft: 20, table: { widths: [25, 30, 170, 85, 15, 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, 15, 50], // headerRows: 2, body: this.buildTableForCustomerLabor(Parts, Ops, PrintPartNo, false) }, layout: PrintSharedService.LayOutStyleanother() }; } } else { let a: any = ''; return a; } } static WithOutDiscountFieldTable(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: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) }, layout: PrintSharedService.LayOutStyleanother() }; } else { // console.log(PrintSharedService.GetWithOutDiscountFieldHeaderSharedInv(PrintPartNo, ShowTaxColumn, Body)); return { style: 'tableExample', marginLeft: 20, table: { widths: [25, 215, 25, 50, 60, 45, 50], headerRows: 1, body: PrintSharedService.GetWithOutDiscountFieldHeaderSharedInv(PrintPartNo, ShowTaxColumn, Body) }, 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, isAuto: boolean, DecimalsNumber: number) { var body: any = []; let columns: any = PrintSharedService.GetWithOutDiscountFieldHeaderSharedInv(PrintPartNo, ShowTaxColumn, Body); body = columns; 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 = '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[0].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 === 'Shared' || column.Field === 'Tax' || 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 }); } else { dataRow.push({ text: '', noWrap: true }); } } else { if (!TrUtils.IsNull(part[column.Field])) { dataRow.push({ text: part[column.Field].toString(), 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 { // dataRow.push(part[column.Field].toString()); 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) { // let Qty: number = 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) => { // console.log('operation', operation); // Qty = Qty + operation.Qty; 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 = 'Labor Total'; // dpartadding1.QtyAndUoM = Qty; 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); // 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[0].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.Field === 'Shared' || column.Field === 'Tax' || 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 }); } else { dataRow.push({ text: '', noWrap: true }); } } else { if (!TrUtils.IsNull(Ops[column.Field])) { dataRow.push({ text: Ops[column.Field].toString(), 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 GetWithOutDiscAndTaxFieldHeader(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 this.TaxDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber); } else { if (ConsolidateGST) { return this.ConsolidateDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber); } else { return this.NoTaxDataTable(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber); } } } else { let a: any = ''; return a; } } static TaxDataTable(Parts: any, Ops: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any, isAuto: boolean, DecimalsNumber: number) { if (PrintPartNo) { // if (ShowIGST) { // return { // style: 'tableExample', // table: { // widths: PrintSharedService.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn), // // headerRows: 2, // body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto) // }, // layout: PrintSharedService.LayOutStyle() // }; // } else { return { style: 'tableExample', table: { widths: [25, 50, 150, 40, 25, 50, 70, 50, 40], // headerRows: 2, body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) }, layout: PrintSharedService.LayOutStyle() }; // } } else { // if (ShowIGST) { // return { // style: 'tableExample', // table: { // widths: PrintSharedService.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn), // // headerRows: 2, // body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto) // }, // layout: PrintSharedService.LayOutStyle() // }; // } else { return { style: 'tableExample', table: { widths: [25, 170,40, 40, 50, 70, 60, 50], // headerRows: 2, body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) }, layout: PrintSharedService.LayOutStyle() }; // } } } static ConsolidateDataTable(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], // headerRows: 1, body: this.BuildTableBodyForLaborAndParts(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], // headerRows: 1, body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) }, layout: PrintSharedService.LayOutStyle() }; } } static NoTaxDataTable(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: PrintSharedService.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo), // headerRows: 1, body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) }, layout: PrintSharedService.LayOutStyle() }; } else { return { style: 'tableExample', table: { widths: PrintSharedService.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo), // headerRows: 1, body: this.BuildTableBodyForLaborAndParts(Parts, Ops, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn, isAuto, DecimalsNumber) }, layout: PrintSharedService.LayOutStyle() }; } } static buildTableForCustomerLabor(Parts: any, Ops: any, PrintPartNo: any, customerorInsurance: any) { var body: any = []; let columns: any; columns = this.getSummaryHeaders(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 { // 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 === 'Shared' || column.Field === 'Tax' || 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 === 'Shared' || column.Field === 'Tax' || 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: '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 CommonTotalDetails(ROPrintData: any, index: any, numberofCopies: any, withPass: boolean, moreDiscDetails:boolean) { // console.log('ROPrintData', ROPrintData); let CommonDetails = [ SharedPDFService.GetFinalTotalDetails(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.STotal,moreDiscDetails), this.GetNumberInWords(ROPrintData.CustRoundedTotal), SharedPDFService.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.GetUnderLine(), SharedPDFService.GetInvSignatures(ROPrintData.Entity.CName, ROPrintData.isCountersale), // this.PageBrake(ROPrintData, withPass), SharedPDFService.GetUnderLine1(withPass), this.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 GetNumberInWords(TotalAmount:any) { var rupee = SharedPDFService.convertNumberToWords(TotalAmount); // console.log('rupee', rupee); return { columns: [{ text: 'In Words :', fontSize: 9, width: 45 }, { text: rupee, bold: true, fontSize: 9, width: '*' }] } } static GetGatePass(isGatepass: boolean, ROPrintData: any) { // console.log('ROPrintData', ROPrintData); 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: [ // { // stack: [{ text: 'Customer Name :' + ROPrintData.Customer.Name, fontSize: 9 }, { text: 'Service Advisor :', fontSize: 9, marginBottom: 10 }, // { text: 'Vehicle has been received from workshop and work done as per my satisfaction.', fontSize: 6 }] // } { text: '', width: 60 }, this.GetCustomerDetails(ROPrintData, false) , this.GetVehicleDetails(ROPrintData.Product, false) // { // stack: [{ text: 'Chassis No :' + ROPrintData.Product.VIN, fontSize: 9 }, // { text: 'Vehicle No :' + ROPrintData.Product.RegNo, fontSize: 9 }, { text: 'Vehicle Model :' + ROPrintData.Product.Model, fontSize: 9 }, { text: 'Repair Order No :', fontSize: 9 }] // } ] }, { 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 GetCustomerDetails(ROPrintData: any, isOtherIndustry: boolean) { let CustomerData = [ { name: 'Customer Name', value: ROPrintData.Customer.Name }, { name: 'Service Advisor', value: ROPrintData.Name }, ]; return SharedPDFService.GetVehicleDataTable(CustomerData); } static GetVehicleDetails(Vehicle: any, isOtherIndustry: boolean) { let vehicleData: any; vehicleData = [ ]; 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); } }