import { PrintSharedService } from '../../shared/shared-print.service'; import { TrUtils } from '../../utils/tr-utils'; import { SharedPDFService } from '../../shared/shared-pdf.service'; export class DebitNotePdfService { FontSize: number = 8; static GetInvoicePrint(ROPrintData: any, win: any, moreDiscDetails:boolean) { 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, 15, 10, 15], content: [ this.CommonHeaderDetails(ROPrintData), this.PreparesparePartsTable(ROPrintData), this.CommonTotalDetails(ROPrintData, moreDiscDetails) ], 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) { return [ this.GetMainHeaderDetails(ROPrintData.Entity, ROPrintData.HeaderName, ROPrintData.Image, ROPrintData.HColor, ROPrintData.AColor), 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, null, false, null, null,null,null, ROPrintData.DoS), SharedPDFService.CustomerAndVehicleDetailsAfterLine(), SharedPDFService.GetDisplayTable(), ]; } static GetMainHeaderDetails(Entity: any, HeaderName: any, Image: any, HColor: any, AColor: any) { return [ // SharedPDFService.MainHeading(Entity.CName, Entity.Header, Image, HColor, null), SharedPDFService.GetMainHeader(Entity, Image, AColor, HColor, null), SharedPDFService.GetPrintType(HeaderName), SharedPDFService.HeaderAfterLine() ]; } static PreparesparePartsTable(ROPrintData: any) { let List: any = []; if (ROPrintData.Entity.Body === 1) { for (let i = 0; i < ROPrintData.PrintInfo.length; i++) { if (TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) { ROPrintData.PrintInfo[i].Text = ''; }; } } else { if (ROPrintData.Entity.Body === 2) { for (let i = 0; i < ROPrintData.PrintInfo.length; i++) { if (TrUtils.IsNull(ROPrintData.PrintInfo[i].Text)) { ROPrintData.PrintInfo[i].Text = ''; } List.push(ROPrintData.PrintInfo[i].Text, this.WithOutDiscountFieldTable(TrUtils.Stringify(ROPrintData.PrintInfo[i].Items), ROPrintData.ShowTaxColumn, ROPrintData.Entity.MPN, ROPrintData.Entity.Body, ROPrintData.ShowIGST, ROPrintData.ConsolidateGST, ROPrintData.ShowDiscountColumn) ); } } else { if (ROPrintData.Summary) { // List.push('', // this.GetLaborPartsTableForView(ROPrintData.Items) // ); } 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), ROPrintData.ShowTaxColumn, ROPrintData.Entity.MPN, ROPrintData.Entity.Body, ROPrintData.ShowIGST, ROPrintData.ConsolidateGST, ROPrintData.ShowDiscountColumn) ); } } } } return List; } static WithOutDiscountFieldTable(Parts: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any) { if (Parts.length !== 0) { return { style: 'tableExample', marginLeft: 20, table: { widths: [15, 215, 25, 100, 60, 60, 60], headerRows: 1, body: this.BuildTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyleanother() }; // if (PrintPartNo) { // return { // style: 'tableExample', // marginLeft: 20, // table: { // widths: [15, 67, 160, 25, 50, 60, 30, 53], // headerRows: 1, // body: this.BuildTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) // }, // layout: this.LayOutStyleanother() // }; // } else { // return { // style: 'tableExample', // marginLeft: 20, // table: { // widths: [15, 215, 25, 50, 60, 45, 60], // headerRows: 1, // body: this.BuildTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) // }, // layout: this.LayOutStyleanother() // }; // } } else { let a: any = ''; return a; } } static BuildTableBodyForLaborAndParts(Parts: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any) { var body: any = []; let columns: any = this.GetWithOutDiscountFieldHeader(PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn); // if (ShowTaxColumn) { for (let i = 0; i < columns.length; i++) { body.push(columns[i]); } columns = columns[1]; // } else { // body.push(columns); // } if (Parts.length !== 0) { let dummypartadding1: any = {}; dummypartadding1.SNo = ''; dummypartadding1.Desc = 'Spare Parts'; // dummypartadding1.Qty = ''; dummypartadding1.Pr = ''; dummypartadding1.LineTotal = ''; Parts.unshift(dummypartadding1); } let SNo: number = 1; Parts.forEach((part: any) => { var dataRow: any = []; columns.forEach((column: any) => { if ( (!TrUtils.IsFixedZero(part[column.Field]) && !TrUtils.IsNull(part[column.Field])) || (column.text === 'Line Total')) { if (part[column.Field] === 'Spare Parts') { dataRow.push({ text: part[column.Field].toString(), marginLeft: 50, style: 'InlineHeader' }); } else { if (((column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt' || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc') && TrUtils.CheckInvalidSelect(part.TCode))) { part[column.Field] = ''; dataRow.push({ text: part[column.Field].toString(), alignment: 'center' }); } else { if (column.Field === 'Pr' || column.Field === 'QtyAndUoM' || column.text === 'Tax' || column.Field === 'Disc' || column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt' || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc' || column.text === 'Line Total') { if (column.Field === 'Disc') { if (column.type === 'percentage') { if (!TrUtils.IsEmpty(part[column.Field])) { dataRow.push({ text: part[column.Field].toString(), noWrap: true }); } else { dataRow.push({ text: '', noWrap: true }); } } else { if (!TrUtils.IsZero(part[column.Field])) { dataRow.push({ text: part[column.Field].toString(), noWrap: true }); } else { dataRow.push({ text: '', noWrap: true }); } } } else { if (!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(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); }); return body; } static GetWithOutDiscountFieldHeader(permission: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any) { if (Body === 2) { let headersNames: any = [{ text: 'Description', style: 'tableheader', Field: 'Desc' }, // { text: 'Qty', style: 'tableheader', Field: 'QtyAndUoM' }, { text: 'Price', style: 'tableheader', Field: 'Pr' }, { text: 'Labor Charges', style: 'tableheader', Field: 'Price' }, { text: 'Tax', style: 'tableheader', Field: 'TaxAmount' }, { text: 'Line Total', style: 'tableheader', Field: 'LineTotal' }]; if (permission) { let sno = { text: 'S.No.', style: 'tableheader', Field: 'SNo' }; let MPN = { text: 'Part No', style: 'tableheader', Field: 'MPN' }; headersNames.unshift(sno, MPN); } else { let sno = { text: 'S.No.', style: 'tableheader', Field: 'SNo' }; headersNames.unshift(sno); } return headersNames; } else { if (ShowTaxColumn) { return this.GetWithOutDiscountFieldHeader1(permission, Body, ShowIGST, ShowDiscountColumn); } else { return this.GetWithOutDiscountFieldHeader2(permission, Body, ShowDiscountColumn); } } } static GetWithOutDiscountFieldHeader1(permission: any, Body: any, ShowIGST: any, ShowDiscountColumn: any) { let headersNames: any; if (permission) { headersNames = [[{ text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }, { text: 'Part No', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }, { text: 'Description', rowSpan: 2, style: 'tableheader', alignment: 'center', lineHeight: 0.5 }, // { text: 'HSN/SAC', rowSpan: 2, style: 'tableheader', lineHeight: 1 }, // { text: 'Qty', style: 'tableheader', rowSpan: 2, lineHeight: 0.5 }, { text: 'Price', style: 'tableheader', rowSpan: 2, lineHeight: 0.5, alignment: 'center', }, { text: 'Line Total', rowSpan: 2, lineHeight: 0.5, style: 'tableheader' } ], [{ text: '', Field: 'SNo', lineHeight: 0.5 }, { text: '', Field: 'MPN', lineHeight: 0.5 }, { text: '', Field: 'Desc', lineHeight: 0.5 }, // { text: 'HSN/SAC', Field: 'HSN', lineHeight: 0.5 }, // { text: '', Field: 'QtyAndUoM', lineHeight: 0.5 }, { text: '', Field: 'Pr', lineHeight: 0.5 }, { text: 'Line Total', Field: 'LineTotal', lineHeight: 0.5 } ]]; let Count: number = 4; if (ShowDiscountColumn) { headersNames[0].splice(Count, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 }); headersNames[1].splice(Count + 1, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }); Count = 6; } if (ShowIGST) { headersNames[0].splice(Count, 0, { text: 'IGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'IGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'IGSTAmt', type: 'amount', lineHeight: 0.5 }); } else { headersNames[0].splice(Count, 0, { text: 'CGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'CGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'CGSTAmt', type: 'amount', lineHeight: 0.5 }); headersNames[0].splice(Count + 2, 0, { text: 'SGST/UTGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 }); headersNames[0].splice(Count + 3, 0, {}); headersNames[1].splice(Count + 2, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'SGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 3, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'SGSTAmt', type: 'amount', lineHeight: 0.5 }); } } else { headersNames = [[{ text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.6 }, { text: 'Description', rowSpan: 2, style: 'tableheader', alignment: 'center', lineHeight: 0.6 }, // { text: 'HSN/SAC', rowSpan: 2, style: 'tableheader', lineHeight: 1 }, // { text: 'Qty', style: 'tableheader', rowSpan: 2, lineHeight: 0.6 }, { text: 'Price', style: 'tableheader', rowSpan: 2, alignment: 'center', lineHeight: 0.6 }, { text: 'Line Total', rowSpan: 2, style: 'tableheader', lineHeight: 0.6 } ], [{ text: '', Field: 'SNo', lineHeight: 0.5 }, { text: '', Field: 'Desc', lineHeight: 0.5 }, // { text: 'HSN/SAC', Field: 'HSN', lineHeight: 0.5 }, // { text: '', Field: 'QtyAndUoM', lineHeight: 0.5 }, { text: '', Field: 'Pr', lineHeight: 0.5 }, { text: 'Line Total', Field: 'LineTotal', lineHeight: 0.5 } ]]; let Count: number = 3; if (ShowDiscountColumn) { headersNames[0].splice(Count, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 }); headersNames[1].splice(Count + 1, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }); Count = 5; } if (ShowIGST) { headersNames[0].splice(Count, 0, { text: 'IGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'IGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'IGSTAmt', type: 'amount', lineHeight: 0.5 }); } else { headersNames[0].splice(Count, 0, { text: 'CGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'CGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'CGSTAmt', type: 'amount', lineHeight: 0.5 }); headersNames[0].splice(Count + 2, 0, { text: 'SGST/UTGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 }); headersNames[0].splice(Count + 3, 0, {}); headersNames[1].splice(Count + 2, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'SGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 3, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'SGSTAmt', type: 'amount', lineHeight: 0.5 }); } } return headersNames; } static GetWithOutDiscountFieldHeader2(permission: any, Body: any, ShowDiscountColumn: any) { let headersNames: any = [[ { text: 'Description', rowSpan: 2, style: 'tableheader', alignment: 'center', lineHeight: 0.5 }, // { text: 'Qty', style: 'tableheader', rowSpan: 2, lineHeight: 0.5 }, { text: 'Price', style: 'tableheader', rowSpan: 2, lineHeight: 0.5, alignment: 'right', }, { text: 'Line Total', rowSpan: 2, lineHeight: 0.5, style: 'tableheader' } ], [ { text: '', Field: 'Desc', lineHeight: 0.5 }, // { text: '', Field: 'QtyAndUoM', lineHeight: 0.5 }, { text: '', Field: 'Pr', lineHeight: 0.5 }, { text: 'Line Total', Field: 'LineTotal', lineHeight: 0.5 } ]]; if (permission) { let sno = { text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }; let MPN = { text: 'Part No', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }; let sno1 = { text: '', Field: 'SNo', lineHeight: 0.5 }; let MPN1 = { text: '', Field: 'MPN', lineHeight: 0.5 }; headersNames[0].unshift(sno, MPN); headersNames[1].unshift(sno1, MPN1); if (ShowDiscountColumn) { headersNames[0].splice(4, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 }); headersNames[0].splice(5, 0, {}); headersNames[1].splice(4, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 }); headersNames[1].splice(5, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }); } } else { let sno = { text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }; let sno1 = { text: '', Field: 'SNo', lineHeight: 0.5 }; headersNames[0].unshift(sno); headersNames[1].unshift(sno1); if (ShowDiscountColumn) { headersNames[0].splice(3, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 }); headersNames[0].splice(4, 0, {}); headersNames[1].splice(3, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 }); headersNames[1].splice(3, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }); } } return headersNames; } static GetWithOutDiscAndTaxFieldHeader(Parts: any, ShowTaxColumn: any, PrintPartNo: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any) { if (Parts.length !== 0) { if (ShowTaxColumn) { return this.TaxDataTable(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn); } else { if (ConsolidateGST) { return this.ConsolidateDataTable(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn); } else { return this.NoTaxDataTable(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn); } } } else { let a: any = ''; return a; } } static TaxTableWidths(PrintPartNo: any, ShowIGST: any, ShowDiscountColumn: any) { if (PrintPartNo) { if (ShowIGST) { if (ShowDiscountColumn) { return [15, 50, 160, 37, 25, 40, 17, 35, 17, 35, 50]; } else { return [15, 50, 222, 37, 25, 40, 17, 35, 55]; } } else { if (ShowDiscountColumn) { return [15, 50, 175, 40, 17, 34, 17, 34, 17, 34, 48]; } else { return [15, 50, 160, 35, 22, 40, 17, 34, 17, 34, 54]; } } } else { if (ShowIGST) { if (ShowDiscountColumn) { return [20, "*", 60, 17, 35, 17, 35, 60]; } else { return [20, '*', 40, 25, 40, 60]; } } else { if (ShowDiscountColumn) { return [15, 155, 40, 50, 34, 35, 40, 40, 40, 40]; // return [15, 155, 40, 40, 40, 60, 60, 60]; } else { return [15, 216, 35, 22, 40, 17, 34, 17, 34, 55]; } } } } static TaxDataTable(Parts: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any) { if (PrintPartNo) { if (ShowIGST) { return { style: 'tableExample', table: { widths: this.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn), // headerRows: 2, body: this.BuildTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } else { return { style: 'tableExample', table: { widths: this.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn), // headerRows: 2, body: this.BuildTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } } else { if (ShowIGST) { return { style: 'tableExample', table: { widths: this.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn), // headerRows: 2, body: this.BuildTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } else { return { style: 'tableExample', table: { widths: this.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn), // headerRows: 2, body: this.BuildTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } } } static ConsolidateDataTable(Parts: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any) { return { style: 'tableExample', table: { widths: [25, 350, 80, 80,], // headerRows: 1, body: this.BuildTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } static WidthForInsuranceOrNot(ShowDiscountColumn: any, PrintPartNo: boolean) { if (PrintPartNo) { if (ShowDiscountColumn) { return [15, 70, 240, 50, 40, 40, 60]; } else { return [25, 70, 285, 60, 80]; } } else { if (ShowDiscountColumn) { return [15, 230, 40, 70, 40, 40, 80]; } else { return [25, 325, 40, 60, 80]; } } } static NoTaxDataTable(Parts: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any) { if (PrintPartNo) { return { style: 'tableExample', table: { widths: this.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo), // headerRows: 1, body: this.BuildTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } else { return { style: 'tableExample', table: { widths: this.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo), // headerRows: 1, body: this.BuildTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } } static buildTableForCustomerLabor(Parts: 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.Pr = ''; 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.Field === 'CustPrice' || column.Field === 'InsPrice' || column.Field === 'DiscountedPrice' || column.Field === 'TaxAmount' || column.Field === 'Pr' || column.text === 'Line Total') { 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() }); } } } 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.Pr = ''; // 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 === 'Pr' || 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 { // 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: 'Pr' }, { 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, moreDiscDetails:boolean) { let CommonDetails = [ SharedPDFService.GetDebitTotalDetails(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.For, ROPrintData.FixedTotal, ROPrintData.CustTotalRoundedBy, ROPrintData.CustRoundedTotal, ROPrintData.ShowTaxColumn, ROPrintData.ShowTaxColumn, TrUtils.isTaxable(ROPrintData.Settings.Tax), ROPrintData.CustLaborITax, ROPrintData.CustPartITax, ROPrintData.Consolidate, ROPrintData.From,moreDiscDetails), SharedPDFService.DebitDueStatus(ROPrintData.Type, ROPrintData.Paid, ROPrintData.Due, ROPrintData.Sts), SharedPDFService.GetTemsAndConditions(ROPrintData.Entity.Terms), SharedPDFService.GetUnderLine(), SharedPDFService.GetSignatures(ROPrintData.Entity.CName, ROPrintData.Type, ROPrintData.For), ]; if (ROPrintData.Type !== 'Invoice') { CommonDetails.splice(2, 0, SharedPDFService.GetUnderLine()); } return CommonDetails; } }