import { SharedPDFService } from "../../shared/shared-pdf.service"; import { TrUtils } from "../../utils/tr-utils"; export class HSNSummaryPDFService { static GetHSNSummaryPrint(InvoicesData: any, Entity: any, searchValue: any) { var dd = { info: { title: 'HSN Summary', }, 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: [ { text: '' + Entity.DName + '', style: ['header'] }, { text: 'HSN Summary', alignment: 'center', fontSize: 15, bold: true }, SharedPDFService.GetSearchValueDetails(searchValue), this.GetInvoiceDataTable(InvoicesData), ], styles: SharedPDFService.GetStyles() }; return dd; } static GetInvoiceDataTable(InvoicesData: any) { let Data: any = [] // InvoicesData.forEach((invoice: any) => { Data.push(this.GetItemsTable(InvoicesData)); // }); return Data; } static getTableWidths() { // if (isHC) { // return [25, '*', '*', '*', '*']; // } else { return [25, '*', '*', '*', '*', '*', '*', '*', '*']; // } } static GetItemsTable(InvoiceData: any) { // InvoicesData.forEach((InvoiceData: any) => { return { style: 'tableExample', marginTop: 3, marginBottom: 5, table: { widths: this.getTableWidths(), headerRows: 1, body: this.BuildTableBodyForLaborAndParts(InvoiceData) // body:[['fsdfsdf','asfafdas','asdasdas','asdasdasd','asddass']] }, layout: { hLineWidth: function (i: any, node: any) { return (i === 0 || i === 1 || i === node.table.body.length) ? 1 : 0.5; }, vLineWidth: function (i: any, node: any) { return (i === 0 || i === node.table.widths.length) ? 1 : 0.5; }, // hLineStyle: function (i, node) { // return (i === 0 || i === 1) ? { dash: { length: 5, space: 5 } } : null; // }, hLineColor: function (i: any, node: any) { return (i === 0 || i === 1 || i === node.table.body.length) ? 'gray' : 'lightgrey'; }, vLineColor: function (i: any, node: any) { return 'gray'; }, } }; // }); } static BuildTableBodyForLaborAndParts(InvoiceData: any) { let body: any = this.GetHeaderNames(); let Sno: number = 1; body.push([{ text: 'Items', colSpan: 9, bold:true, style: 'tableheader1', alignment: 'left' }, {}, {}, {}, {}, {}, {}, {}, {}]); InvoiceData.B2B?.Items?.forEach((item: any, index: any) => { let dataRow: any = []; Sno = Sno + index; dataRow.push({ text: Sno }); dataRow.push({ text: 'GST' }); dataRow.push({ text: item.HSN }); dataRow.push({ text: item.Quantity, alignment: 'right' }); // if(!isHC){ dataRow.push({ text: item.UoM }); dataRow.push({ text: TrUtils.FixPriceValue(item.TaxableValue), alignment: 'right' }); dataRow.push({ text: TrUtils.FixPriceValue(item.CGST), alignment: 'right' }); dataRow.push({ text: TrUtils.FixPriceValue(item.SGST), alignment: 'right' }); dataRow.push({ text: TrUtils.FixPriceValue(item.IGST), alignment: 'right' }); body.push(dataRow); }); InvoiceData.B2C?.Items?.forEach((item: any, index: any) => { let dataRow: any = []; Sno = Sno + index; dataRow.push({ text: Sno }); dataRow.push({ text: 'No GST' }); dataRow.push({ text: item.HSN }); dataRow.push({ text: item.Quantity, alignment: 'right' }); // if(!isHC){ dataRow.push({ text: item.UoM }); dataRow.push({ text: TrUtils.FixPriceValue(item.TaxableValue), alignment: 'right' }); dataRow.push({ text: TrUtils.FixPriceValue(item.CGST), alignment: 'right' }); dataRow.push({ text: TrUtils.FixPriceValue(item.SGST), alignment: 'right' }); dataRow.push({ text: TrUtils.FixPriceValue(item.IGST), alignment: 'right' }); body.push(dataRow); }); body.push([{ text: 'Services', bold:true, colSpan: 9, style: 'tableheader1', alignment: 'left' }, {}, {}, {}, {}, {}, {}, {}, {}]); InvoiceData.B2B?.Ops?.forEach((labor: any, index: any) => { let dataRow: any = []; Sno = Sno + index; dataRow.push({ text: Sno }); dataRow.push({ text: 'GST' }); dataRow.push({ text: labor.HSN }); dataRow.push({ text: labor.Quantity, alignment: 'right' }); // if(!isHC){ dataRow.push({ text: labor.UoM }); dataRow.push({ text: TrUtils.FixPriceValue(labor.TaxableValue), alignment: 'right' }); dataRow.push({ text: TrUtils.FixPriceValue(labor.CGST), alignment: 'right' }); dataRow.push({ text: TrUtils.FixPriceValue(labor.SGST), alignment: 'right' }); dataRow.push({ text: TrUtils.FixPriceValue(labor.IGST), alignment: 'right' }); body.push(dataRow); }); InvoiceData.B2C?.Ops?.forEach((labor: any, index: any) => { let dataRow: any = []; Sno = Sno + index; dataRow.push({ text: Sno }); dataRow.push({ text: 'No GST' }); dataRow.push({ text: labor.HSN }); dataRow.push({ text: labor.Quantity, alignment: 'right' }); // if(!isHC){ dataRow.push({ text: labor.UoM }); dataRow.push({ text: TrUtils.FixPriceValue(labor.TaxableValue), alignment: 'right' }); dataRow.push({ text: TrUtils.FixPriceValue(labor.CGST), alignment: 'right' }); dataRow.push({ text: TrUtils.FixPriceValue(labor.SGST), alignment: 'right' }); dataRow.push({ text: TrUtils.FixPriceValue(labor.IGST), alignment: 'right' }); body.push(dataRow); }); // }); return body; } static GetHeaderNames() { let HeadingNames: any; HeadingNames = [[{ text: 'S.No', style: 'tableheader1', Field: 'SNo', alignment: 'left', line: true }, { text: '', style: 'tableheader1', Field: 'GST', alignment: 'left' }, { text: 'HSN', style: 'tableheader1', Field: 'HSN', alignment: 'left' }, { text: 'Quantity', style: 'tableheader1', Field: 'Qty', alignment: 'right' }, { text: 'UoM', style: 'tableheader1', Field: 'UoM', alignment: 'left' }, { text: 'Taxable Amount', style: 'tableheader1', Field: 'Taxable', alignment: 'right' }, { text: 'CGST', style: 'tableheader1', Field: 'CGST', alignment: 'right' }, { text: 'SGST', style: 'tableheader1', Field: 'SGST', alignment: 'right' }, { text: 'IGST', style: 'tableheader1', Field: 'IGST', alignment: 'right' } ] ]; return HeadingNames; } }