import { Add } from "../../shared/math-operations"; import { SharedPDFService } from "../../shared/shared-pdf.service"; import { PrintSharedService } from "../../shared/shared-print.service"; import { MyDate } from "../../utils/my-date"; import { TrUtils } from "../../utils/tr-utils"; export class InvoiceLandscapePdfService { FontSize: number = 8; static GetInvoiceLandscapePrint(ROPrintData: any, numberofCopies: any, moreDiscDetails:boolean) { var contents = []; if (TrUtils.IsNull(numberofCopies) || numberofCopies.length === 0) { contents.push( this.CommonHeaderDetails(ROPrintData, null), this.PreparesparePartsTable(ROPrintData), this.CommonTotalDetails(ROPrintData, null, numberofCopies, moreDiscDetails) ); } else { numberofCopies.forEach((text: any, index: any) => { contents.push( this.CommonHeaderDetails(ROPrintData, text), this.PreparesparePartsTable(ROPrintData), this.CommonTotalDetails(ROPrintData, index, numberofCopies, 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 }; }, pageMargins: [10, 15, 10, 15], pageOrientation: 'landscape', 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 GetAddress(Entity: any) { return Entity.Adrs1 + ', ' + Entity.Adrs2 + ', '; } static GetPINandPhone(Entity: any) { return Entity.City + '-' + Entity.PIN + ', Cell : ' + Entity.Phone; } static GetHeaderInfo(InvoicePDFData: any) { let TaxInfo: any = []; if (!TrUtils.IsEmpty(InvoicePDFData.Entity.GSTIN)) { TaxInfo.push({ text: 'GSTIN : ' + InvoicePDFData.Entity.GSTIN, marginTop: 2, marginLeft: 5, alignment: 'left', fontSize: 9, width: 'auto' }, ); } // if (!TrUtils.IsEmpty(InvoicePDFData.Entity.PAN)) { // TaxInfo.push({ text: 'PAN : ' + InvoicePDFData.Entity.PAN, marginTop: 2, marginLeft: 5, alignment: 'left', fontSize: 9, width: 'auto' }, // ); // } if (!TrUtils.IsEmpty(InvoicePDFData.Entity.DLNo)) { TaxInfo.push({ text: 'D.L.NO : ' + InvoicePDFData.Entity.DLNo, marginTop: 2, marginLeft: 5, alignment: 'left', fontSize: 9, width: '*' }, ); } TaxInfo.push(this.GetBillofSupplyName(InvoicePDFData.Settings)); return TaxInfo; } static GetBillofSupplyName(Settings: any) { return { text: Settings.Tax === 'BS' ? 'Bill of Supply' : null, alignment: 'right', marginRight: 5, marginTop: 2, marginBottom: 3, fontSize: 9, width: 'auto' }; } static CommonHeaderDetails(ROPrintData: any, text: any) { return [ { text: ROPrintData?.HeaderName, alignment: 'center', bold: true, fontSize: 10 }, { text: text, color: 'grey', alignment: 'right', width: 100, marginTop: (text !== null) ? -11 : 0, fontSize: 10 }, { style: 'tableExample', table: { widths: ['*', '*', '*'], body: [ [ { stack: [ { text: ROPrintData.Entity.CName, alignment: 'center', bold: true, fontSize: 13 }, // this.GetAddresDetailsAndLogo(ROPrintData.Entity, ROPrintData.Image, ROPrintData.AColor, ROPrintData.HColor, text) { text: this.GetAddress(ROPrintData.Entity), alignment: 'center', style: ['headerstyle'] }, { text: this.GetPINandPhone(ROPrintData.Entity), alignment: 'center', style: ['headerstyle'] }, { stack: this.GetHeaderInfo(ROPrintData) }, ] }, SharedPDFService.GetCustomer(ROPrintData.Customer, ROPrintData.Type, ROPrintData.For, ROPrintData.Product, ROPrintData.Settings, 'Customer Name & Address', false) , SharedPDFService.GetVehicleDetails(ROPrintData.Type, ROPrintData._id, ROPrintData.CrDate, ROPrintData.PrDate, ROPrintData.MOut, ROPrintData.MIn, ROPrintData.Product, ROPrintData.PrintType, ROPrintData.IsProforma, ROPrintData.Settings, false, ROPrintData.BL, null, null, null, ROPrintData.DoS)], ] }, layout: PrintSharedService.LayOutStyle() }, // 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, null, false, ROPrintData.BL), // SharedPDFService.GetOwnerDetails(ROPrintData.Cust, ROPrintData.Type, ROPrintData.For), // SharedPDFService.CustomerAndVehicleDetailsAfterLine(), // SharedPDFService.GetDisplayTable(), ]; } static MainHeading(CName: any, Entity: any, Image: any, HColor: any, CopyName: any) { let headerstyle: string; let MainHeaderStyle: any = SharedPDFService.GetMainHeaderStyleForLeftAlignHeader(CName); // if (Header === 1) { headerstyle = 'header2'; // } else { // headerstyle = 'temp2header'; // } return SharedPDFService.HeaderAlignmentBasedOnCondition(CName, Image, HColor, headerstyle, MainHeaderStyle, Entity, CopyName); } static GetAddresDetailsAndLogo(Entity: any, Image: any, AColor: any, HColor: any, text: any) { let Details: any = [ { stack: [ { columns: [this.MainHeading(Entity.CName, Entity, Image, HColor, text)] }, { columns: [{ width: 150, margin: [0, 0, 0, 5], stack: SharedPDFService.GetHeader(Entity, HColor), color: AColor, style: 'header' }, SharedPDFService.GetEntityDetails(Entity)] } ] } ] if (!TrUtils.IsNull(Image)) { // Details.unshift({ text: '', width: 120 }); if (Entity.CName.length < 28) { Details[0].stack[0].columns.push({ text: '', width: 140 }); } if (!TrUtils.IsNull(text)) { Details[0].stack.unshift({ text: text, color: 'grey', alignment: 'right', width: 100, marginBottom: -15, fontSize: 10 }); } Details.unshift({ image: Image, width: 120, height: 80 }); } else { Details[0].stack[1].columns.unshift({ text: '', width: 130 }); if (!TrUtils.IsNull(text)) { Details[0].stack.unshift({ text: text, color: 'grey', alignment: 'right', width: 100, marginBottom: -15, fontSize: 10 }); } } return Details; } 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 PreparesparePartsTable(ROPrintData: any) { // console.log('ROPrintData', ROPrintData); 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].Items) // ); } } 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) { 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: PrintSharedService.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: PrintSharedService.LayOutStyleanother() }; } } else { let a: any = ''; return a; } } 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: 'Batch No', rowSpan: 2, style: 'tableheader', lineHeight: 1 }, { text: 'Expiry', rowSpan: 2, style: 'tableheader', lineHeight: 1 }, { text: 'Qty', style: 'tableheader', rowSpan: 2, lineHeight: 0.5 }, { text: 'Offer Qty', style: 'tableheader', rowSpan: 2, lineHeight: 1 }, { text: 'M.R.P', style: 'tableheader', rowSpan: 2, lineHeight: 0.5, alignment: 'center', }, { text: 'Unit Price', style: 'tableheader', rowSpan: 2, lineHeight: 0.5, alignment: 'center', }, { text: 'Line Total', rowSpan: 2, lineHeight: 0.5, style: 'tabFleheader' } ], [{ text: '', Field: 'SNo', lineHeight: 0.5 }, { text: '', Field: 'MPN', lineHeight: 0.5 }, { text: '', Field: 'Desc', lineHeight: 0.5 }, { text: 'HSN/SAC', Field: 'HSN', lineHeight: 0.5 }, { text: '', Field: 'Batch', lineHeight: 0.5 }, { text: 'Expiry', Field: 'ExDate', lineHeight: 0.5 }, { text: '', Field: 'QtyAndUoM', lineHeight: 0.5 }, { text: '', Field: 'OfQty', lineHeight: 0.5 }, { text: '', Field: 'MRP', lineHeight: 0.5 }, { text: '', Field: 'UnPr', lineHeight: 0.5 }, { text: 'Line Total', Field: 'LineTotal', lineHeight: 0.5 } ] ]; let Count: number = 10; if (ShowDiscountColumn) { headersNames[0].splice(Count, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 }); headersNames[1].splice(Count + 1, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }); Count = 12; } if (ShowIGST) { headersNames[0].splice(Count, 0, { text: 'IGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'IGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'IGSTAmt', type: 'amount', lineHeight: 0.5 }); } else { headersNames[0].splice(Count, 0, { text: 'CGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'CGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'CGSTAmt', type: 'amount', lineHeight: 0.7 }); headersNames[0].splice(Count + 2, 0, { text: 'SGST/UTGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 3, 0, {}); headersNames[1].splice(Count + 2, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'SGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 3, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'SGSTAmt', type: 'amount', lineHeight: 0.5 }); } } else { headersNames = [[{ text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.6 }, { text: 'Description', rowSpan: 2, style: 'tableheader', alignment: 'center', lineHeight: 0.6 }, { text: 'HSN/SAC', rowSpan: 2, style: 'tableheader', lineHeight: 1 }, { text: 'Batch No', rowSpan: 2, style: 'tableheader', lineHeight: 1 }, { text: 'Expiry', rowSpan: 2, style: 'tableheader', lineHeight: 1 }, { text: 'Qty', style: 'tableheader', rowSpan: 2, lineHeight: 0.6 }, { text: 'Offer Qty', style: 'tableheader', rowSpan: 2, lineHeight: 1 }, { text: 'M.R.P', style: 'tableheader', rowSpan: 2, lineHeight: 0.5, alignment: 'center', }, { text: 'Unit Price', style: 'tableheader', rowSpan: 2, alignment: 'center', lineHeight: 0.6 }, { text: 'Line Total', rowSpan: 2, style: 'tableheader', lineHeight: 0.6 } ], [{ text: '', Field: 'SNo', lineHeight: 0.5 }, { text: '', Field: 'Desc', lineHeight: 0.5 }, { text: 'HSN/SAC', Field: 'HSN', lineHeight: 0.5 }, { text: '', Field: 'Batch', lineHeight: 0.5 }, { text: 'Expiry', Field: 'ExDate', lineHeight: 0.5 }, { text: '', Field: 'QtyAndUoM', lineHeight: 0.5 }, { text: '', Field: 'OfQty', lineHeight: 0.5 }, { text: '', Field: 'MRP', lineHeight: 0.5 }, { text: '', Field: 'UnPr', lineHeight: 0.5 }, { text: 'Line Total', Field: 'LineTotal', lineHeight: 0.5 } ]]; let Count: number = 9; if (ShowDiscountColumn) { headersNames[0].splice(Count, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 }); headersNames[1].splice(Count + 1, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }); Count = 11; } if (ShowIGST) { headersNames[0].splice(Count, 0, { text: 'IGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'IGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'IGSTAmt', type: 'amount', lineHeight: 0.5 }); } else { headersNames[0].splice(Count, 0, { text: 'CGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'CGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'CGSTAmt', type: 'amount', lineHeight: 0.5 }); headersNames[0].splice(Count + 2, 0, { text: 'SGST/UTGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 3, 0, {}); headersNames[1].splice(Count + 2, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'SGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 3, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'SGSTAmt', type: 'amount', lineHeight: 0.5 }); } } return headersNames; } static GetWithOutDiscountFieldHeader2(permission: any, Body: any, ShowDiscountColumn: any) { let headersNames: any = [[ { text: 'Description', rowSpan: 2, style: 'tableheader', alignment: 'left', lineHeight: 0.5 }, { text: 'Batch No', rowSpan: 2, style: 'tableheader', lineHeight: 1 }, { text: 'Expiry', rowSpan: 2, style: 'tableheader', lineHeight: 1 }, { text: 'Qty', style: 'tableheader', rowSpan: 2, lineHeight: 0.5 }, { text: 'Offer Qty', style: 'tableheader', rowSpan: 2, lineHeight: 1 }, { text: 'M.R.P', style: 'tableheader', rowSpan: 2, lineHeight: 0.5, alignment: 'center', }, { text: 'Unit Price', style: 'tableheader', rowSpan: 2, lineHeight: 0.5, alignment: 'right', }, { text: 'Line Total', rowSpan: 2, lineHeight: 0.5, style: 'tableheader' } ], [ { text: '', Field: 'Desc', lineHeight: 0.5 }, { text: '', Field: 'Batch', lineHeight: 0.5 }, { text: 'Expiry', Field: 'ExDate', lineHeight: 0.5 }, { text: '', Field: 'QtyAndUoM', lineHeight: 0.5 }, { text: '', Field: 'OfQty', lineHeight: 0.5 }, { text: '', Field: 'MRP', lineHeight: 0.5 }, { text: '', Field: 'UnPr', lineHeight: 0.5 }, { text: 'Line Total', Field: 'LineTotal', lineHeight: 0.5 } ]]; if (permission) { let sno = { text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }; let MPN = { text: 'Part No', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }; let sno1 = { text: '', Field: 'SNo', lineHeight: 0.5 }; let MPN1 = { text: '', Field: 'MPN', lineHeight: 0.5 }; headersNames[0].unshift(sno, MPN); headersNames[1].unshift(sno1, MPN1); if (ShowDiscountColumn) { headersNames[0].splice(9, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 }); headersNames[0].splice(10, 0, {}); headersNames[1].splice(9, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 }); headersNames[1].splice(10, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }); } } else { let sno = { text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }; let sno1 = { text: '', Field: 'SNo', lineHeight: 0.5 }; headersNames[0].unshift(sno); headersNames[1].unshift(sno1); if (ShowDiscountColumn) { headersNames[0].splice(8, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 }); headersNames[0].splice(9, 0, {}); headersNames[1].splice(8, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 }); headersNames[1].splice(9, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }); } } return headersNames; } static GetWithOutDiscountFieldHeader(permission: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ShowDiscountColumn: any) { if (Body === 2) { let headersNames: any = [{ text: 'Description', style: 'tableheader', Field: 'Desc' }, { text: 'Qty', style: 'tableheader', Field: 'QtyAndUoM' }, { text: 'Unit Price', style: 'tableheader', Field: 'UnPr' }, { text: 'Labor Charges', style: 'tableheader', Field: 'Price' }, { text: 'Tax', style: 'tableheader', Field: 'TaxAmount' }, { text: 'Line Total', style: 'tableheader', Field: 'LineTotal' }]; if (permission) { let sno = { text: 'S.No.', style: 'tableheader', Field: 'SNo' }; let MPN = { text: 'Part No', style: 'tableheader', Field: 'MPN' }; headersNames.unshift(sno, MPN); } else { let sno = { text: 'S.No.', style: 'tableheader', Field: 'SNo' }; headersNames.unshift(sno); } return headersNames; } else { if (ShowTaxColumn) { return this.GetWithOutDiscountFieldHeader1(permission, Body, ShowIGST, ShowDiscountColumn); } else { return this.GetWithOutDiscountFieldHeader2(permission, Body, ShowDiscountColumn); } } } 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, ShowDiscountColumn); // if (ShowTaxColumn) { for (let i = 0; i < columns.length; i++) { body.push(columns[i]); } columns = columns[1]; // } else { // body.push(columns); // } // console.log('balaraju'); 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); if (Parts.length <= 15) { let Count: number = 18 - Parts.length; for (let i = 0; i < Count; i++) { Parts.push({}); } } else { let Count: number = 58 - Parts.length; for (let i = 0; i < Count; i++) { Parts.push({}); } } } let SNo: number = 1; Parts.forEach((part: any) => { // console.log('part', part); var dataRow: any = []; columns.forEach((column: any) => { if ( (!TrUtils.IsFixedZero(part[column.Field]) && !TrUtils.IsNull(part[column.Field])) || (column.text === 'Line Total' || column.text === 'Expiry')) { if (part[column.Field] === 'Spare Parts') { dataRow.push({ text: part[column.Field].toString(), marginLeft: 50, style: 'InlineHeader' }); } else { if (((column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt' || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc') && TrUtils.CheckInvalidSelect(part.TCode))) { part[column.Field] = ''; dataRow.push({ text: part[column.Field].toString(), alignment: 'center' }); } else { if (column.text === 'Line Total' || column.Field === 'UnPr' || column.Field === 'MRP' || column.Field === 'Batch' || column.Field === 'ExDate' || column.Field === 'QtyAndUoM' || column.text === 'Tax' || column.Field === 'Disc' || column.Field === 'CGSTAmt' || column.Field === 'SGSTAmt' || column.Field === 'CGSTPerc' || column.Field === 'SGSTPerc' || column.Field === 'IGSTAmt' || column.Field === 'IGSTPerc') { if (column.Field === 'Disc') { if (column.type === 'percentage') { if (!TrUtils.IsEmpty(part[column.Field])) { dataRow.push({ text: part[column.Field].toString(), noWrap: true }); } else { dataRow.push({ text: '', noWrap: true }); } } else { if (!TrUtils.IsZero(part[column.Field])) { dataRow.push({ text: part[column.Field].toString(), noWrap: true }); } else { dataRow.push({ text: '', noWrap: true }); } } } else { if (column.Field === 'Batch') { if (!TrUtils.IsNull(part[column.Field])) { dataRow.push({ text: part[column.Field].BN, nowrap: true }); } else { dataRow.push({ text: '', noWrap: true }); } } else if (column.Field === 'ExDate') { if (!TrUtils.IsNull(part['Batch'])) { dataRow.push({ text: MyDate.ConvertUTCDateToReadableExDate(part['Batch'].ExDt), nowrap: true }); } else { dataRow.push({ text: '', noWrap: true }); } } else { if (!TrUtils.IsZero(part[column.Field])) { dataRow.push({ text: part[column.Field].toString(), alignment: 'right', nowrap: true }); } else { dataRow.push({ text: '', noWrap: true }); } } } } else { // dataRow.push(part[column.Field].toString()); if (TrUtils.IsNull(part[column.Field])) { part[column.Field] = ''; } if (column.Field === 'Desc') { let DescData: any = []; DescData.push(part[column.Field].toString()); if (!TrUtils.IsEmpty(part['EDesc'])) { DescData.push({ text: part['EDesc'].toString(), color: 'grey' }); } dataRow.push({ stack: DescData }); } else { dataRow.push({ text: part[column.Field].toString() }); } } } } } else { if (column.Field === 'SNo' && !TrUtils.IsNull(part.Desc)) { part[column.Field] = SNo; SNo = SNo + 1; } else { part[column.Field] = ''; } dataRow.push({ text: part[column.Field].toString(), alignment: 'center' }); } }); body.push(dataRow); }); // 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 { // 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 === '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 (Ops.Perc && !TrUtils.IsZero(Ops[column.Field])) { // dataRow.push({ text: Ops[column.Field].toString(), noWrap: true }); // } else { // dataRow.push({ text: '', noWrap: true }); // } // } else { // if (!Ops.Perc && !TrUtils.IsZero(Ops[column.Field])) { // dataRow.push({ text: Ops[column.Field].toString(), 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(Ops[column.Field].toString()); // } // } // } // } else { // if (column.Field === 'SNo') { // Ops[column.Field] = SNo; // SNo = SNo + 1; // } else { // Ops[column.Field] = ''; // } // dataRow.push({ text: Ops[column.Field].toString(), alignment: 'center' }); // } // }); // body.push(dataRow); // }); return body; } 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 [24, 50, '*', 50, 35, 35, 30, 25, 40, 35, 20, 35, 20, 35, 45]; } else { return [24, 50, '*', 50, 35, 35, 30, 25, 40, 40, 20, 35, 51]; } } else { if (ShowDiscountColumn) { return [24, 45, '*', 50, 35, 35, 30, 22, 40, 40, 20, 34, 20, 32, 20, 32, 48]; } else { return [24, 45, '*', 50, 35, 35, 30, 22, 40, 40, 20, 32, 20, 32, 54]; } } } else { if (ShowIGST) { if (ShowDiscountColumn) { return [24, '*', 50, 41, 35, 30, 25, 40, 40, 20, 35, 20, 35, 41]; } else { return [24, '*', 50, 50, 35, 30, 25, 40, 40, 20, 40, 50]; } } else { if (ShowDiscountColumn) { return [24, '*', 50, 45, 35, 30, 22, 40, 40, 20, 34, 20, 35, 20, 35, 45]; } else { return [24, '*', 50, 50, 35, 30, 22, 40, 40, 20, 35, 20, 35, 50]; } } } } static TaxDataTable(Parts: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any) { if (PrintPartNo) { if (ShowIGST) { return { style: 'tableExample', marginTop: -6, table: { widths: this.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn), // headerRows: 2, body: this.BuildTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } else { return { style: 'tableExample', marginTop: -6, 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', marginTop: -6, 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', marginTop: -6, table: { widths: this.TaxTableWidths(PrintPartNo, ShowIGST, ShowDiscountColumn), // headerRows: 2, body: this.BuildTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } } } static LayOutStyle() { return { hLineWidth: function (i: any, node: any) { return (i === 0 || i === 1 || i === 2) ? 0.7 : 0; }, vLineWidth: function (i: any, node: any) { return (i === 0 || i === 1 || i === 2) ? 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) { 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 = 'lightgray'; } return color; }, }; } static ConsolidateDataTable(Parts: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any) { if (PrintPartNo) { return { style: 'tableExample', marginTop: -6, table: { widths: this.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo), // headerRows: 1, body: this.BuildTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } else { return { style: 'tableExample', marginTop: -6, table: { widths: this.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo), // headerRows: 1, body: this.BuildTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } } static WidthForInsuranceOrNot(ShowDiscountColumn: any, PrintPartNo: boolean) { // console.log('ShowDiscountColumn', ShowDiscountColumn); if (PrintPartNo) { if (ShowDiscountColumn) { return [24, 70, '*', 45, 45, 25, 25, 60, 60, 45, 45, 50]; } else { return [25, 70, '*', 45, 45, 35, 35, 60, 60, 80]; } } else { if (ShowDiscountColumn) { return [25, '*', 50, 50, 50, 50, 70, 70, 70, 70, 70]; } else { return [25, '*', 45, 45, 40, 40, 60, 60, 80]; } } } static NoTaxDataTable(Parts: any, PrintPartNo: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ConsolidateGST: any, ShowDiscountColumn: any) { if (PrintPartNo) { return { style: 'tableExample', marginTop: -6, 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', marginTop: -6, table: { widths: this.WidthForInsuranceOrNot(ShowDiscountColumn, PrintPartNo), // headerRows: 1, body: this.BuildTableBodyForLaborAndParts(Parts, PrintPartNo, ShowTaxColumn, Body, ShowIGST, ConsolidateGST, ShowDiscountColumn) }, layout: PrintSharedService.LayOutStyle() }; } } static CommonTotalDetails(ROPrintData: any, index: any, numberofCopies: any, moreDiscDetails:boolean) { let CommonDetails = [ // SharedPDFService.GetFinalTotalDetails('0.00', '0.00', '0.00', // '0.00', '0.00', '0.00', ROPrintData.ShowIGST, ROPrintData.ShowTaxColumn, // ROPrintData.CustPartsTotalBeforeDisc, ROPrintData.CustPartsDiscTotal, ROPrintData.CustPartCGST, // ROPrintData.CustPartSGST, ROPrintData.CustTaxGroupData, ROPrintData.ShowAccParts, // '0.00', ROPrintData.CustPartAfterTax, ROPrintData.FixedDisc, ROPrintData.For, // ROPrintData.FixedTotal, ROPrintData.CustTotalRoundedBy, ROPrintData.CustRoundedTotal, // ROPrintData.ShowTaxColumn, ROPrintData.ShowTaxColumn, // TrUtils.isTaxable(ROPrintData.Settings.Tax), '0.00', // ROPrintData.CustPartITax, ROPrintData.Consolidate, ROPrintData.From, null), this.TotalDetails(ROPrintData, moreDiscDetails, ROPrintData.Entity.DecimalsNumber), // SharedPDFService.InvoiceDueStatus(ROPrintData.Type, ROPrintData.Paid, ROPrintData.Due, ROPrintData.Sts), SharedPDFService.GetTemsAndConditions(ROPrintData.Entity.Terms), // SharedPDFService.GetUnderLine(), this.GetSignatures(ROPrintData.Entity.CName, ROPrintData.Type, ROPrintData.For), ]; // 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 GetSignatures(CName: any, For: any, Type: any) { return { columns: [{ stack: [ this.CompanyName(CName), { columns: [this.Authorizedsignature(), SharedPDFService.SurveyorSignature(For, Type), this.CustomerSignature()] } ] }], }; } static CompanyName(CName: any) { return { style: 'forCompany1', text: ['For ', { text: CName, bold: 'true' }], }; } static Authorizedsignature() { return { style: 'Sign1', text: ['Authorized Signatory'], }; } static CustomerSignature() { return { style: 'Sign1', text: ['Customer Signature'], marginLeft: 90 }; } static TotalDetails(ROPrintData: any, moreDiscDetails:boolean, DecimalsNumber: number) { let totalDisc: any; let totalTax: any; if (!ROPrintData.Consolidate) { totalTax = TrUtils.FixPriceValue(Add(Number(ROPrintData.CustLaborITax), Number(ROPrintData.CustPartITax), DecimalsNumber)); if (TrUtils.isTaxable(ROPrintData.Settings.Tax)) { totalDisc = TrUtils.FixPriceValue(Add(Number(ROPrintData.CustLaborDiscTotal), Number(ROPrintData.CustPartsDiscTotal), DecimalsNumber)); } else { totalDisc = TrUtils.FixPriceValue(Add(Number(ROPrintData.CustLaborDiscTotal), Number(ROPrintData.CustPartsDiscTotal), DecimalsNumber)); } } return [ { style: 'tableExample', marginTop: -6, table: { widths: ['*', '*', '*'], heights: [105, 105, 105], body: [ [ SharedPDFService.PartsTaxAmounts1(ROPrintData.TaxSummary, true, ROPrintData.ShowIGST, ROPrintData.ShowTaxColumn), // SharedPDFService.GetTaxOnParts(ROPrintData.CustPartsTotalBeforeDisc, ROPrintData.CustPartsDiscTotal, ROPrintData.CustPartCGST, // ROPrintData.CustPartSGST, ROPrintData.ShowAccParts, ROPrintData.CustPartIGST, ROPrintData.ShowIGST, ROPrintData.ShowTaxColumn, // ROPrintData.ShowTaxColumn, ROPrintData.From), SharedPDFService.GetBankDetials(ROPrintData.Entity.Bank, ROPrintData.Entity.PrBank, ROPrintData.Entity.UPIPhone), { columns: [{ text: '', width: moreDiscDetails?153:175 }, SharedPDFService.GrandTotal(ROPrintData,'0.00', ROPrintData.CustPartsTotalBeforeDisc, totalDisc, totalTax, ROPrintData.For, ROPrintData.FixedTotal, ROPrintData.CustTotalRoundedBy, ROPrintData.CustRoundedTotal, null, ROPrintData.Consolidate, null, moreDiscDetails, ROPrintData.Entity.DecimalsNumber)] } // SharedPDFService.GetCustomer(ROPrintData.Customer, ROPrintData.Type, ROPrintData.For, // ROPrintData.Product, ROPrintData.Settings, 'Customer Name & Address', false) // , SharedPDFService.GetVehicleDetails(ROPrintData.Type, ROPrintData._id, ROPrintData.CrDate, ROPrintData.PrDate, // ROPrintData.MOut, ROPrintData.MIn, ROPrintData.Product, ROPrintData.PrintType, ROPrintData.IsProforma, ROPrintData.Settings, false, ROPrintData.BL) ], ] }, layout: PrintSharedService.LayOutStyle() }, // 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, null, false, ROPrintData.BL), // SharedPDFService.GetOwnerDetails(ROPrintData.Cust, ROPrintData.Type, ROPrintData.For), // SharedPDFService.CustomerAndVehicleDetailsAfterLine(), // SharedPDFService.GetDisplayTable(), ]; } }