import JsBarcode from "jsbarcode"; import { PayTypeEnum } from "../enums/enums"; import { MyDate } from '../utils/my-date'; import { TrUtils } from '../utils/tr-utils'; import { Add } from "./math-operations"; declare var pdfMake: any; declare var document: any; export class SharedPDFService { static BodySize: number = 8; static TableHeaders: number = 9; static SubHeaderSize: number = 9; static TermsandCond: number = 6; static MainHeading(CName: any, Entity: any, Image: any, HColor: any, CopyName: any) { let headerstyle: string; let MainHeaderStyle: any = this.GetMainHeaderStyleForLeftAlignHeader(CName); if (Entity.Header.Position === 'Center') { headerstyle = 'header'; } else { headerstyle = 'temp2header'; } return this.HeaderAlignmentBasedOnCondition(CName, Image, HColor, headerstyle, MainHeaderStyle, Entity, CopyName); } static HeaderAlignmentBasedOnCondition(CName: any, Image: any, HColor: any, headerstyle: any, MainHeaderStyle: any, Entity: any, CopyName: any) { let HeaderDetails: any = []; // HeaderDetails.push({ text: 'Original', color: 'grey', alignment: 'right' }); if (!TrUtils.IsNull(Image) && Entity.Header.ShowLogo) { if (Entity.Header.Position === 'Center') { HeaderDetails.push({ text: '' + CName + '', style: [headerstyle, MainHeaderStyle], color: HColor, alignment: this.GetLeftMArgin(CName) }) } else { HeaderDetails.push({ text: '' + CName + '', style: [headerstyle, MainHeaderStyle], color: HColor, alignment: 'left', margin: [10, 0, 0, 0] }) } } else { HeaderDetails.push({ text: '' + CName + '', style: [headerstyle, MainHeaderStyle], color: HColor }) } // if (!TrUtils.IsNull(CopyName)) { // HeaderDetails.push({ text: CopyName, color: 'grey', alignment: 'right', width: 100, marginTop: -15, fontSize: 10 }); // } return HeaderDetails; } static GetLeftMArgin(WorkShopName: any) { if (WorkShopName.length < 28) { return 'center'; } else { return 'left'; } } static GetMainHeader(Entity: any, Image: any, AColor: any, HColor: any, text: any) { if (Entity.Header.Position === 'Center') { return { columns: this.GetAddresDetailsAndLogo(Entity, Image, AColor, HColor, text) }; } else { return { columns: this.GetLeftAlignmentHeader(Entity, Image, AColor, HColor, text) }; } } static GetConsultationMainHeader(Entity: any, Image: any, AColor: any, HColor: any, text: any) { return { columns: this.GetConsultationLeftAlignmentHeader(Entity, Image, AColor, HColor, text), width: '60%' }; } static ConsultationMainHeading(CName: any, Entity: any, Image: any, HColor: any, CopyName: any) { let headerstyle: string; let MainHeaderStyle: any = { fontSize: 15, bold: true, }; // if (Entity.Header === 1) { // headerstyle = 'header'; // } else { headerstyle = 'temp2header'; // } return this.ConsultHeaderAlignmentBasedOnCondition(CName, Image, HColor, headerstyle, MainHeaderStyle, Entity, CopyName); } static ConsultHeaderAlignmentBasedOnCondition(CName: any, Image: any, HColor: any, headerstyle: any, MainHeaderStyle: any, Entity: any, CopyName: any) { let HeaderDetails: any = []; // HeaderDetails.push({ text: 'Original', color: 'grey', alignment: 'right' }); if (!TrUtils.IsNull(Image) && Entity.Header.ShowLogo) { // if (Entity.Header.Position === 'Center') { // HeaderDetails.push({ text: '' + CName + '', style: [headerstyle, MainHeaderStyle], color: HColor, alignment: this.GetLeftMArgin(CName) }) // } else { HeaderDetails.push({ text: '' + CName + '', style: [headerstyle, MainHeaderStyle], color: HColor, alignment: 'left', margin: [10, 0, 0, 0] }) // } } else { HeaderDetails.push({ text: '' + CName + '', style: [headerstyle, MainHeaderStyle], color: HColor }) } // if (!TrUtils.IsNull(CopyName)) { // HeaderDetails.push({ text: CopyName, color: 'grey', alignment: 'right', width: 100, marginTop: -15, fontSize: 10 }); // } return HeaderDetails; } static GetConsultationLeftAlignmentHeader(Entity: any, Image: any, AColor: any, HColor: any, text: any) { let Details: any = [ { stack: [{ columns: [this.ConsultationMainHeading(Entity.CName, Entity, Image, HColor, text)], marginTop: 15 }, { columns: [ this.GetEntityDetails(Entity)] } ] }]; if (!TrUtils.IsNull(Image) && Entity.Header.ShowLogo) { Details[0].stack[1].columns.unshift({ width: 290, margin: [10, 0, 0, 5], stack: this.GetHeader(Entity, HColor), color: AColor, style: 'temp2header' }); 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({ width: 420, margin: [0, 0, 0, 5], stack: this.GetHeader(Entity, HColor), color: AColor, style: 'temp2header' }); if (!TrUtils.IsNull(text)) { Details[0].stack.unshift({ text: text, color: 'grey', alignment: 'right', width: 100, marginBottom: -15, fontSize: 10 }); } } return Details; } static GetWatermarkImage(Image: any, pageSize: any, Wmark: boolean) { if (!TrUtils.IsNull(Image) && Wmark) { return { margun: [10, 15, 10, 15], image: Image, width: pageSize.width, alignment: 'center', height: pageSize.height, opacity: 0.04, } } else { return this.emptyObject(); } } static GetLeftAlignmentHeader(Entity: any, Image: any, AColor: any, HColor: any, text: any) { let Details: any = [ { stack: [{ columns: [this.MainHeading(Entity.CName, Entity, Image, HColor, text)] }, { columns: [ this.emptyObject()] } ] }]; if (!TrUtils.IsNull(Image) && Entity.Header.ShowLogo) { Details[0].stack[1].columns.unshift({ width: 290, margin: [10, 0, 0, 5], stack: this.GetHeader(Entity, HColor), color: AColor, style: 'temp2header' }); 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({ width: 420, margin: [0, 0, 0, 5], stack: this.GetHeader(Entity, HColor), color: AColor, style: 'temp2header' }); if (!TrUtils.IsNull(text)) { Details[0].stack.unshift({ text: text, color: 'grey', alignment: 'right', width: 100, marginBottom: -15, fontSize: 10 }); } } return Details; } 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: 300, margin: [0, 0, 0, 5], stack: this.GetHeader(Entity, HColor), color: AColor, style: 'header' }, this.emptyObject()] } ] } ] if (!TrUtils.IsNull(Image) && Entity.Header.ShowLogo) { // Details.unshift({ text: '', width: 120 }); if (Entity.CName.length < 28) { Details[0].stack[0].columns.push({ text: '', width: 150 }); } if (!TrUtils.IsNull(text)) { Details[0].stack.unshift({ text: text, color: 'grey', alignment: 'right', width: 100, marginBottom: -15, fontSize: 7 }); } 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: 7 }); } } return Details; } static GetHeader(Entity: any, HColor: string) { let headerstyle: string; if (Entity.Header.Position === 'Center') { headerstyle = 'ws_adrs_center'; } else { headerstyle = 'ws_adrs_left'; } let SubHeader: any = [ { text: '' + Entity.Adrs1 + '', style: [headerstyle] }, { text: '' + Entity.City + this.getPinCode(Entity.PIN) + ', ' + 'Ph: ' + Entity.Phone, style: headerstyle }, { text: '' + this.GetEmail(Entity.Email) + '', style: headerstyle }, // { text: 'GSTIN:' + Entity.GSTIN + ', ' + 'PAN: ' + Entity.PAN, style: headerstyle }, ]; if (!TrUtils.IsEmpty(Entity.Adrs2)) { SubHeader.splice(1, 0, { text: '' + Entity.Adrs2 + '', style: [headerstyle] }); } if (!TrUtils.IsEmpty(Entity.TLine)) { SubHeader.unshift({ text: this.GetTagLine(Entity.TLine), fontSize: 10, bold: true, color: HColor, margin: [0, 0, 0, 2] }); } if (!TrUtils.IsEmpty(Entity.GSTIN) || !TrUtils.IsEmpty(Entity.PAN)) { let Data: any = ''; if (!TrUtils.IsEmpty(Entity.GSTIN)) { Data = 'GSTIN:' + Entity.GSTIN; } if (!TrUtils.IsEmpty(Entity.GSTIN) && !TrUtils.IsEmpty(Entity.PAN)) { Data = Data + ', '; } if (!TrUtils.IsEmpty(Entity.PAN)) { Data = Data + 'PAN:' + Entity.PAN; } SubHeader.push({ text: Data, style: headerstyle, fontSize: this.TermsandCond }); } if (Entity.GSTType === 2) { SubHeader.push({ text: '* under composition scheme', fontSize: this.TermsandCond }); } return SubHeader; } static GetMainHeaderStyleForLeftAlignHeader(WorkShopName: string) { var wsname_fontSize: any; if (TrUtils.IsNull(WorkShopName)) { WorkShopName = ''; } switch (true) { case (WorkShopName.length < 30): wsname_fontSize = 20; break; case (WorkShopName.length < 35): wsname_fontSize = 20; break; case (WorkShopName.length < 50): wsname_fontSize = 17; break; default: wsname_fontSize = 14; } var HeaderSize: any = { fontSize: wsname_fontSize, bold: true, }; return HeaderSize; } static GetEntityDetails(Entity: any) { let SetData: any = []; if (Entity.PrUPI && !Entity.IsProforma && !TrUtils.IsEmpty(Entity.UPI)) { SetData.push({ qr: Entity.UPI, fit: '125', marginLeft: 150 }); SetData.push({ text: 'Scan To Pay', fontSize: this.TermsandCond, marginLeft: 151, bold: true, marginTop: 2 }); // SetData.push({ text: 'UPI Number: ' + Entity.UPIPhone, fontSize: 9, marginLeft: 151, bold: true, marginTop: 5 }); if (!TrUtils.IsNull(Entity.UPIPhone)) { SetData.push({ text: 'UPI Number: ' + Entity.UPIPhone, fontSize: 9, marginLeft: 151, bold: true, marginTop: 5 }); } } // SetData.push({ columns: [this.GetEntityTax(Entity)] }) return { lineHeight: 0.7, stack: SetData }; } static GetEntityTax(Entity: any) { let EntityData: any = []; if (!TrUtils.IsEmpty(Entity.GSTIN)) { EntityData.push({ name: 'GSTIN', value: Entity.GSTIN }); } if (!TrUtils.IsEmpty(Entity.PAN)) { EntityData.push({ name: 'PAN No', value: Entity.PAN }); } if (EntityData.length !== 0) { return this.GetEntityeDataTable(EntityData, Entity); } else { return this.emptyObject(); } } static GetEntityeDataTable(EntityFields: any, Entity: any) { return { lineHeight: 0.7, marginTop: 5, marginLeft: 10, fontSize: this.TermsandCond, // fontSize: this.SubHeaderSize, table: { body: [ [{ table: { fontSize: this.TermsandCond, widths: ['auto', 'auto', '*'], body: this.EntityTableDataDetails(EntityFields, Entity) }, layout: 'noBorders', }] ] }, layout: 'noBorders', }; } static EntityTableDataDetails(EntityFields: any, Entity: any) { var body: any = []; EntityFields.forEach((row: any) => { if (!TrUtils.IsFixedZero(row.value) && !TrUtils.IsEmpty(row.value)) { var dataRow: any = []; dataRow.push({ text: (row.name).toString(), noWrap: true, fontSize: 8 }); dataRow.push(':'); dataRow.push({ text: (row.value).toString(), noWrap: true, fontSize: 9 }); body.push(dataRow); if (row.name === 'GSTIN' && Entity.GSTType === 2) { let data: any = []; data.push({ text: '* under composition scheme', colSpan: 3, fontSize: 7, marginLeft: 10 }, {}, {}); body.push(data); } } // else { // var a: any = []; // a.push({ text: '', lineHeight: 0.1 }); // a.push({ text: '', lineHeight: 0.1 }); // a.push({ text: '', lineHeight: 0.1 }); // body.push(a); // } }); return body; } static GetTagLine(TLine: any) { if (!TrUtils.IsEmpty(TLine)) { return TLine; } else { let TagLine: any = ''; return TagLine; } } static GetEmail(email: any) { let Email: any = ''; if (!TrUtils.IsNull(email)) { return 'Email: ' + email; } else { return Email; } } static getPinCode(pin: any) { let code: any = ''; if (!TrUtils.IsNull(pin)) { return ' - ' + pin; } else { return code; } } static GetPrintType(type: any) { return { // marginLeft: 10, columns: [{ text: '', width: 120 }, { text: type, alignment: 'center' }, { text: '', width: 140 } ], style: 'Receiptheader1' }; } static GetNewUnderLine(orientation: 'portrait' | 'landscape' = 'portrait') { const lineWidth = orientation === 'landscape' ? 820 : 575; return { marginTop: 10, canvas: [ { type: 'line', color: 'grey', x1: 0, y1: 0, x2: lineWidth, y2: 0, lineWidth: 0.9 } ] }; } static GetNewUnderLine1(withPass: boolean, orientation: 'portrait' | 'landscape' = 'portrait') { if (withPass) { const lineWidth = orientation === 'landscape' ? 820 : 575; return { marginTop: 10, canvas: [ { type: 'line', color: 'grey', x1: 0, y1: 0, x2: lineWidth, y2: 0, dash: { length: 5, space: 10 }, lineWidth: 0.9 } ] }; } else { return this.emptyObject(); } } static GetNewMainHeader(Entity: any, Image: any, AColor: any, HColor: any, text: any, orientation: 'portrait' | 'landscape' = 'portrait') { if (Entity.Header.Position === 'Center') { return { columns: this.GetNewAddresDetailsAndLogo(Entity, Image, AColor, HColor, text, orientation) }; } else { return { columns: this.GetNewLeftAlignmentHeader(Entity, Image, AColor, HColor, text, orientation) }; } } static GetNewLeftAlignmentHeader(Entity: any, Image: any, AColor: any, HColor: any, text: any, orientation: 'portrait' | 'landscape' = 'portrait') { const headerWidth = orientation === 'landscape' ? 420 : 290; const noImageWidth = orientation === 'landscape' ? 550 : 420; let Details: any = [ { stack: [{ columns: [this.MainHeading(Entity.CName, Entity, Image, HColor, text)] }, { columns: [ this.emptyObject()] } ] }]; if (!TrUtils.IsNull(Image) && Entity.Header.ShowLogo) { Details[0].stack[1].columns.unshift({ width: headerWidth, margin: [10, 0, 0, 5], stack: this.GetHeader(Entity, HColor), color: AColor, style: 'temp2header' }); 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({ width: noImageWidth, margin: [0, 0, 0, 5], stack: this.GetHeader(Entity, HColor), color: AColor, style: 'temp2header' }); if (!TrUtils.IsNull(text)) { Details[0].stack.unshift({ text: text, color: 'grey', alignment: 'right', width: 100, marginBottom: -15, fontSize: 10 }); } } return Details; } static GetNewAddresDetailsAndLogo(Entity: any, Image: any, AColor: any, HColor: any, text: any, orientation: 'portrait' | 'landscape' = 'portrait') { const logoWidth = 120; const logoHeight = 80; const headerStyle = this.GetMainHeaderStyleForLeftAlignHeader(Entity.CName || ''); const extras: any[] = []; if (!TrUtils.IsNull(Entity.PageCount)) { extras.push({ text: 'Page: ' + Entity.PageCount, color: 'grey', alignment: 'center', fontSize: this.TermsandCond, margin: [0, 1, 0, 0] }); } if (!TrUtils.IsEmpty(Entity.Extra1)) { extras.push({ text: Entity.Extra1, color: 'grey', alignment: 'center', fontSize: this.TermsandCond, margin: [0, 1, 0, 0] }); } if (!TrUtils.IsEmpty(Entity.Extra2)) { extras.push({ text: Entity.Extra2, color: 'grey', alignment: 'center', fontSize: this.TermsandCond, margin: [0, 1, 0, 0] }); } const centerStack: any[] = [ { text: '' + (Entity.CName || '') + '', color: HColor, fontSize: headerStyle.fontSize, bold: true, alignment: 'center' }, { stack: this.GetHeader(Entity, HColor), color: AColor, style: 'header', alignment: 'center', margin: [0, 0, 0, 2] } ]; if (!TrUtils.IsNull(text)) { centerStack.push({ text: text, color: 'grey', alignment: 'center', fontSize: 7, margin: [0, 0, 0, 1] }); } extras.forEach((row: any) => centerStack.push(row)); let Details: any = [ !TrUtils.IsNull(Image) && Entity.Header.ShowLogo ? { image: Image, width: logoWidth, height: logoHeight } : { text: '', width: logoWidth }, { width: '*', stack: centerStack }, { text: '', width: logoWidth } ]; return Details; } static GetUnderLine() { return { marginTop: 10, canvas: [ { type: 'line', color: 'grey', x1: 0, y1: 0, x2: 575, y2: 0, lineWidth: 0.9 } ] }; } static GetUnderLine1(withPass: boolean) { if (withPass) { return { marginTop: 10, canvas: [ { type: 'line', color: 'grey', x1: 0, y1: 0, x2: 575, y2: 0, dash: { length: 5, space: 10 }, lineWidth: 0.9 } ] }; } else { return this.emptyObject(); } } static GetLightUnderLine(width: number, color: string) { return { canvas: [ { type: 'line', color: color, x1: 0, y1: 0, x2: width, y2: 0, lineWidth: 0.3 } ] }; } static HeaderAfterLine() { return { canvas: [ { type: 'line', lineColor: 'grey', x1: 0, y1: 0, x2: 575, y2: 0, lineWidth: 1.5 } ] }; } static HeaderAfterLine2() { return { canvas: [ { type: 'line', lineColor: 'grey', x1: 0, y1: 0, x2: 545, y2: 0, lineWidth: 1.5 } ] }; } static HeaderAfterLine1() { return { canvas: [ { type: 'line', lineColor: 'grey', x1: 0, y1: 0, x2: 545, y2: 0, lineWidth: 1.5 } ] }; } static CustomerAndVehicleDetailsAfterLine() { return { canvas: [ { type: 'line', lineColor: 'grey', x1: 0, y1: 0, x2: 575, y2: 0, lineWidth: 1 } ] }; } static convertImgToBase64URL(url: any, callback: any, outputFormat: any) { var canvas = document.createElement('CANVAS'), ctx = canvas.getContext('2d'), img = new Image; img.crossOrigin = 'Anonymous'; img.onload = function () { var dataURL; canvas.height = img.height; canvas.width = img.width; ctx.drawImage(img, 0, 0); dataURL = canvas.toDataURL(outputFormat); callback(dataURL); canvas = null; }; img.onerror = outputFormat; img.src = url; } static GetShowLine(ROData: any) { if (ROData.Parts.length !== 0 || ROData.Ops.length !== 0) { return this.GetUnderLine(); } else { return this.emptyObject(); } } static GetTemsAndConditions(Terms: any) { if (!TrUtils.IsNull(Terms)) { return { text: '' + Terms + '', marginTop: 5, marginBottom: 5, fontSize: this.TermsandCond, alignment: 'justify' }; } else { return this.emptyObject(); } } static GetSearchValueDetails(searchValue: any) { let showSearch: any = []; for (const key in searchValue) { if (!TrUtils.IsNull(searchValue[key]) && !TrUtils.CheckInvalidSelect(searchValue[key]) && key !== 'Date' && key !== 'CustCntrlId' && key !== 'DescCntrlId' && key !== 'ManfCntrlId' && key !== 'VenCntrlId') { showSearch.push({ name: (key === 'StDate') ? 'Start Date' : (key === 'EnDate') ? 'End Date' : (key === 'CustCntrl') ? 'Customer' : (key === 'DescCntrl') ? 'Item' : (key === 'ManfCntrl') ? 'Manufacturer' : (key === 'VenCntrl') ? 'Vendor' : key, value: (key === 'StDate') ? MyDate.ConvertUTCDateToReadable(searchValue[key]) : (key === 'EnDate') ? MyDate.ConvertUTCDateToReadable(searchValue[key]) : searchValue[key], }); } // console.log('showSearch', showSearch); // console.log(`${key}: ${searchValue[key]}`); } return { style: ['columnheader', 'TotalsStyles'], lineHeight: 1, fontSize: this.SubHeaderSize, marginBottom: 5, table: { body: this.GetBankDataTable(showSearch, false) }, layout: 'noBorders', }; } static GetBankDetials(Bankinfo: any, isPrint: boolean, UPIPhone: string) { if (isPrint && !TrUtils.IsNull(Bankinfo)) { let AccountFields = []; let BANK = { name: 'BANK', value: Bankinfo.Name }; let Acc = { name: 'A/C NO', value: Bankinfo.ACNo }; let AccHolderName = { name: 'Account Holder Name', value: Bankinfo.ACName }; let Branch = { name: 'Branch', value: TrUtils.IsNull(Bankinfo.Bran) ? '' : Bankinfo.Bran }; let IFSC = { name: 'IFSC NO', value: Bankinfo.IFSC }; // let UPIPh = { name: 'Phone Pay / Google Pay', value: UPIPhone }; // let TotalPartsAmount = { name: 'Final Labor Amount', value: this.LabourtotalAmount(ROPrintData.LaborInsTotal) }; AccountFields.push(BANK); // if (!TrUtils.IsNull(ROPrintData.OverAllLaborDiscount) && ROPrintData.OverAllLaborDiscount !== 0) { AccountFields.push(Acc); AccountFields.push(AccHolderName); // } AccountFields.push(Branch); AccountFields.push(IFSC); // if (!TrUtils.IsNull(UPIPhone)) { // AccountFields.push(UPIPh); // } // AccountFields.push(TotalPartsAmount); return { style: ['columnheader', 'TotalsStyles'], lineHeight: 1, fontSize: this.SubHeaderSize, marginBottom: 5, table: { body: this.GetBankDataTable(AccountFields, true) }, layout: 'noBorders', }; } else { return this.emptyObject(); } } static GetBankDataTable(data: any, isBank: boolean) { var body: any = []; if (isBank) { body = [[{ text: 'Bank Details', bold: true, colSpan: 3 }, {}, {}]];; } data.forEach((row: any) => { // if ((!TrUtils.IsFixedZero(row.value) && !TrUtils.IsNull(row.value)) || row.name === 'Total') { var dataRow: any = []; dataRow.push({ text: (row.name).toString(), noWrap: true }); dataRow.push(':'); dataRow.push({ text: (row.value).toString(), noWrap: true, }); body.push(dataRow); // } // else { // var a: any = []; // a.push({ text: '', lineHeight: 0.1 }); // a.push({ text: '', lineHeight: 0.1 }); // a.push({ text: '', lineHeight: 0.1 }); // body.push(a); // } }); return body; } //Not Use This Function any where static LaborTotalTable(ROPrintData: any) { let AccountFields = []; if (ROPrintData.For === PayTypeEnum.Insurance) { let LaborTotal = { name: 'Labor Total', value: ROPrintData.BasicLaborTotal }; let Disc = { name: 'Labor Discount', value: ROPrintData.OverAllLaborDiscount }; let VAT = { name: 'Service Tax', value: ROPrintData.OverAllLaborTaxAmount }; // let TotalPartsAmount = { name: 'Final Labor Amount', value: this.LabourtotalAmount(ROPrintData.LaborInsTotal) }; AccountFields.push(LaborTotal); // if (!TrUtils.IsNull(ROPrintData.OverAllLaborDiscount) && ROPrintData.OverAllLaborDiscount !== 0) { AccountFields.push(Disc); // } AccountFields.push(VAT); // AccountFields.push(TotalPartsAmount); } else { let LaborTotal = { name: 'Labor Total', value: ROPrintData.BasicLaborTotal }; let Disc = { name: 'Labor Discount', value: ROPrintData.OverAllLaborDiscount }; let VAT = { name: 'Service Tax ', value: ROPrintData.OverAllLaborTaxAmount }; // let TotalPartsAmount = { name: 'Final Labor Amount', value: this.LabourtotalAmount(ROPrintData.LaborTotal) } AccountFields.push(LaborTotal); // if (!TrUtils.IsNull(ROPrintData.OverAllLaborDiscount) && ROPrintData.OverAllLaborDiscount !== 0) { AccountFields.push(Disc); // } AccountFields.push(VAT); // AccountFields.push(TotalPartsAmount); } return { style: ['columnheader', 'TotalsStyles'], lineHeight: 1, fontSize: this.SubHeaderSize, marginBottom: 5, table: { body: this.GetDataTable(AccountFields, true) }, layout: 'noBorders', }; } //Not Use This Function any where static PartsTotalTables(ROPrintData: any) { let AccountFields = []; if (ROPrintData.For === PayTypeEnum.Insurance) { let PartsTotal = { name: 'Parts Total', value: ROPrintData.BasicPartsTotal }; let Disc = { name: 'Parts Discount', value: ROPrintData.OverAllPartsDiscount }; let VAT = { name: 'Parts Tax', value: ROPrintData.OverAllPartsTaxAmount }; // let TotalPartsAmount = { name: 'Final Parts Amount', value: this.PartstotalAmount(ROPrintData.PartsInsTotal)}; AccountFields.push(PartsTotal); AccountFields.push(Disc); AccountFields.push(VAT); // AccountFields.push(TotalPartsAmount); } else { let PartsTotal = { name: 'Parts Total', value: ROPrintData.BasicPartsTotal }; let Disc = { name: 'Parts Discount', value: ROPrintData.OverAllPartsDiscount }; let VAT = { name: 'Parts Tax', value: ROPrintData.OverAllPartsTaxAmount }; // let TotalPartsAmount = { name: 'Final Parts Amount', value: this.PartstotalAmount(ROPrintData.PartsTotal) } AccountFields.push(PartsTotal); AccountFields.push(Disc); AccountFields.push(VAT); // AccountFields.push(TotalPartsAmount); } return { style: ['columnheader', 'TotalsStyles'], lineHeight: 1, fontSize: this.SubHeaderSize, marginBottom: 5, table: { body: this.GetDataTable(AccountFields, true) }, layout: 'noBorders', }; } static GetDataTable(data: any, istotal: boolean) { var body: any = []; data.forEach((row: any) => { // if ((!TrUtils.IsFixedZero(row.value) && !TrUtils.IsNull(row.value)) || row.name === 'Total') { if (TrUtils.IsNull(row.value)) { row.value = ''; } var dataRow: any = []; if (row.name === 'Labor' || row.name === 'Parts') { dataRow.push({ text: [{ text: row.name, bold: 'true' }, ' Total(Before Tax)'] }); } else { dataRow.push({ text: (row.name).toString(), noWrap: true }); } dataRow.push(':'); if (row.name === 'Vehicle') { dataRow.push({ text: (row.value).toString(), width: 'auto', lineHeight: 1 }); } else { if (istotal) { dataRow.push({ text: (row.value).toString(), noWrap: true, alignment: 'right' }); } else { dataRow.push({ text: (row.value).toString(), noWrap: true, bold: row.bold }); } } body.push(dataRow); // } // else { // var a: any = []; // a.push({ text: '', lineHeight: 0.1 }); // a.push({ text: '', lineHeight: 0.1 }); // a.push({ text: '', lineHeight: 0.1 }); // body.push(a); // } }); return body; } static GetCustomerAndVehicleDetails(Id: any, CrDate: any, PrDate: any, MOut: any, MIn: any, Vehicle: any, PrintType: any, For: any, SurName: any, SurPhone: any, Type: any, SurEmail: any, InsComp: any, PolNo: any, PolType: any, Customer: any, IsProforma: boolean, Settings: any, Location: any, isOtherIndustry: boolean, BL: any, ROCode: any, TypeName: any, AdmNo: any, DoS: any, PrCustBar: boolean = false) { return { style: 'textcust', marginLeft: 5, columns: [ this.GetCustomer(Customer, Type, For, Vehicle, Settings, 'Bill To', isOtherIndustry), this.GetInsurence(For, SurName, SurPhone, Type, SurEmail, InsComp, PolNo, PolType, Location, isOtherIndustry, Customer.Code, PrCustBar), this.GetVehicle(Type, Id, CrDate, PrDate, MOut, MIn, Vehicle, PrintType, For, IsProforma, Settings, isOtherIndustry, BL, ROCode, TypeName, AdmNo, DoS) ], }; } static GetNewCustomerAndVehicleDetails(Id: any, CrDate: any, PrDate: any, MOut: any, MIn: any, Vehicle: any, PrintType: any, For: any, SurName: any, SurPhone: any, Type: any, SurEmail: any, InsComp: any, PolNo: any, PolType: any, Customer: any, IsProforma: boolean, Settings: any, Location: any, isOtherIndustry: boolean, BL: any, ROCode: any, TypeName: any, AdmNo: any, DoS: any, PrCustBar: boolean = false, orientation: 'portrait' | 'landscape' = 'portrait') { return { style: 'textcust', marginLeft: 5, columns: [ this.GetNewCustomer(Customer, Type, For, Vehicle, Settings, 'Bill To', isOtherIndustry, orientation), this.GetNewInsurence(For, SurName, SurPhone, Type, SurEmail, InsComp, PolNo, PolType, Location, isOtherIndustry, Customer.Code, PrCustBar, orientation), this.GetNewVehicle(Type, Id, CrDate, PrDate, MOut, MIn, Vehicle, PrintType, For, IsProforma, Settings, isOtherIndustry, BL, ROCode, TypeName, AdmNo, DoS, orientation) ], }; } static GetNewCustomer(Customer: any, Type: any, For: any, Vehicle: any, Settings: any, Headding: any, isOtherIndustry: boolean, orientation: 'portrait' | 'landscape' = 'portrait') { const insuranceWidth = orientation === 'landscape' ? 220 : 170; const normalWidth = orientation === 'landscape' ? 280 : 230; if (For === PayTypeEnum.Insurance || isOtherIndustry) { return { stack: [this.GetCustomerDetails(Customer, Type, Vehicle, Settings, Headding)], width: insuranceWidth, marginLeft: 2 }; } else { return { stack: [this.GetCustomerDetails(Customer, Type, Vehicle, Settings, Headding)], width: normalWidth, marginLeft: 4 }; } } static GetNewInsurence(For: any, SurName: any, SurPhone: any, Type: any, SurEmail: any, InsComp: any, PolNo: any, PolType: any, Location: any, isOtherIndustry: boolean, Code: any = null, PrCustBar: boolean = false, orientation: 'portrait' | 'landscape' = 'portrait') { const insuranceWidth = orientation === 'landscape' ? 260 : 210; const emptyWidth = orientation === 'landscape' ? 100 : 70; if (isOtherIndustry || ((For === PayTypeEnum.Insurance) && Type !== 'Invoice')) { return { stack: [this.GetInsurenceDetails(For, SurName, SurPhone, SurEmail, InsComp, PolNo, PolType, Type, Location, isOtherIndustry)], width: insuranceWidth, marginRight: 2 }; } else if (!TrUtils.IsNull(Code)) { return { stack: [this.GetBarCode(Code, PrCustBar)], width: insuranceWidth, marginRight: 2 }; } else { return { text: '', width: emptyWidth }; } } static GetNewVehicle(Type: any, Id: any, CrDate: any, PrDate: any, MOut: any, MIn: any, Vehicle: any, PrintType: any, For: any, IsProforma: boolean, Settings: any, isOtherIndustry: boolean, BL: any, ROCode: any, TypeName: any, AdmNo: any, DoS: any, orientation: 'portrait' | 'landscape' = 'portrait') { const insuranceWidth = orientation === 'landscape' ? 250 : 200; const normalWidth = orientation === 'landscape' ? 300 : 250; if (For === PayTypeEnum.Insurance) { return { stack: [this.GetVehicleDetails(Type, Id, CrDate, PrDate, MOut, MIn, Vehicle, PrintType, IsProforma, Settings, isOtherIndustry, BL, ROCode, TypeName, AdmNo, DoS)], width: insuranceWidth }; } else { return { stack: [this.GetVehicleDetails(Type, Id, CrDate, PrDate, MOut, MIn, Vehicle, PrintType, IsProforma, Settings, isOtherIndustry, BL, ROCode, TypeName, AdmNo, DoS)], width: normalWidth }; } } static GetReceiptCustomerAndVehicleDetails(Id: any, CrDate: any, PrDate: any, MOut: any, MIn: any, Vehicle: any, PrintType: any, For: any, SurName: any, SurPhone: any, Type: any, SurEmail: any, InsComp: any, PolNo: any, PolType: any, Customer: any, IsProforma: boolean, Settings: any, Location: any, isOtherIndustry: boolean) { return { style: 'textcust', marginLeft: 5, columns: [ this.GetReceiptCustomer(Customer, Type, For, Vehicle, Settings, 'Patient Name & Address', isOtherIndustry), this.GetInsurence(For, SurName, SurPhone, Type, SurEmail, InsComp, PolNo, PolType, Location, isOtherIndustry), this.GetReceiptVehicle(Type, Id, CrDate, PrDate, MOut, MIn, Vehicle, PrintType, For, IsProforma, Settings, isOtherIndustry) ], }; } static GetSOCustomerAndOthDetails(Id: any, CrDate: any, PrDate: any, PrintType: any, For: any, SurName: any, SurPhone: any, Type: any, SurEmail: any, Shipment: any, PolNo: any, PolType: any, Customer: any, DoS: any, RefNo: any, IsPackage: any, PackId: any, PackedDate: any, ShipId: any, ShippedDate: any) { return { style: 'textcust', marginLeft: 5, stack: [{ columns: [{ text: 'SO# : ' + this.CheckAndSetString(Id) }, { text: 'Date : ' + this.CheckAndSetString(CrDate) }, { text: 'Place Of Supply : ' + this.GetStateName(DoS) }] }, this.CustomerDetails(Customer, Type, For, null, null, Shipment)], }; } static CustomerDetails(Customer: any, Type: any, For: any, Vehicle: any, Settings: any, Shipment: any) { return { columns: [ this.GetCustomerSO(Customer, Type, For, null, null, 'Bill To'), this.GetCustomerSO(Shipment, Type, For, null, null, 'Ship To'), // this.GetInsurence(For, SurName, SurPhone, Type, SurEmail, InsComp, PolNo, PolType), // this.GetOtherDtails(Type, Id, CrDate, PrDate, PrintType, Settings, RefNo, IsPackage, PackId, PackedDate, ShipId, ShippedDate) ], marginTop: 10 } } static GetCustomerSO(Customer: any, Type: any, For: any, Vehicle: any, Settings: any, Headding: any) { return { stack: [this.GetCustomerDetails(Customer, Type, Vehicle, Settings, Headding)], width: 300, marginLeft: 4 }; } static GetOwnerDetails(Customer: any, Type: any, For: any) { if (For === PayTypeEnum.Insurance && Type === 'Invoice') { return { style: 'colum1', stack: [this.GetUnderLine(), { columns: [{ text: 'Owner Details : ', style: 'hed', width: 70 }, { text: Customer.Name }, { text: this.GetAddress(Customer), }, this.GetCustPhoneNumber(Customer, Type), this.GetCustomerGSTIN(Customer)], margin: [0, 5, 0, 5], } ] } } else { return this.emptyObject(); } } static GetReceiptCustomer(Customer: any, Type: any, For: any, Vehicle: any, Settings: any, Headding: any, isOtherIndustry: boolean) { return { stack: [this.GetReceiptCustomerDetails(Customer, Type, Vehicle, Settings, Headding)], width: 170, marginLeft: 2 }; } static GetReceiptCustomerDetails(Customer: any, Type: any, Vehicle: any, Settings: any, CustHeader: string) { if (TrUtils.IsNull(Customer)) { return this.emptyObject(); } return { style: 'colum1', stack: [{ text: CustHeader + ':', style: 'hed' }, { text: Customer.Name, marginTop: 2 }, { text: this.GetAddress(Customer), marginTop: 3 }, this.GetCustPhoneNumber(Customer, Type), this.GetCustomerGSTIN(Customer), { text: 'Doctor : ' + Customer.Doctor, marginTop: 2 },] }; } static GetCustomer(Customer: any, Type: any, For: any, Vehicle: any, Settings: any, Headding: any, isOtherIndustry: boolean) { if (For === PayTypeEnum.Insurance || isOtherIndustry) { return { stack: [this.GetCustomerDetails(Customer, Type, Vehicle, Settings, Headding)], width: 170, marginLeft: 2 }; } else { return { stack: [this.GetCustomerDetails(Customer, Type, Vehicle, Settings, Headding)], width: 230, marginLeft: 4 }; } } static GetInsurence(For: any, SurName: any, SurPhone: any, Type: any, SurEmail: any, InsComp: any, PolNo: any, PolType: any, Location: any, isOtherIndustry: boolean, Code: any = null, PrCustBar: boolean = false) { if (isOtherIndustry || ((For === PayTypeEnum.Insurance) && Type !== 'Invoice')) { return { stack: [this.GetInsurenceDetails(For, SurName, SurPhone, SurEmail, InsComp, PolNo, PolType, Type, Location, isOtherIndustry)], width: 210, marginRight: 2 }; } else if (!TrUtils.IsNull(Code)) { return { stack: [this.GetBarCode(Code, PrCustBar)], width: 210, marginRight: 2 }; } else { return { text: '', width: 70 }; } } static GetBarCode(code: string, PrCustBar: boolean) { if (!TrUtils.IsNull(code) && PrCustBar) { return { svg: this.textToSvgBarcode(code).svg } } else { return {}; } } static textToSvgBarcode(text: string): any { const svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg"); JsBarcode(svgElement, text, { format: "CODE128", width: 1.25, height: 20, margin: 0, marginTop: 8, displayValue: true, fontSize: 7, textMargin: 0, fontOptions: 'bold' }); return { svg: svgElement.outerHTML }; } static GetVehicle(Type: any, Id: any, CrDate: any, PrDate: any, MOut: any, MIn: any, Vehicle: any, PrintType: any, For: any, IsProforma: boolean, Settings: any, isOtherIndustry: boolean, BL: any, ROCode: any, TypeName: any, AdmNo: any, DoS: any) { if (For === PayTypeEnum.Insurance) { return { stack: [this.GetVehicleDetails(Type, Id, CrDate, PrDate, MOut, MIn, Vehicle, PrintType, IsProforma, Settings, isOtherIndustry, BL, ROCode, TypeName, AdmNo, DoS)], width: 200 }; } else { return { stack: [this.GetVehicleDetails(Type, Id, CrDate, PrDate, MOut, MIn, Vehicle, PrintType, IsProforma, Settings, isOtherIndustry, BL, ROCode, TypeName, AdmNo, DoS)], width: 250 }; } } static GetReceiptVehicle(Type: any, Id: any, CrDate: any, PrDate: any, MOut: any, MIn: any, Vehicle: any, PrintType: any, For: any, IsProforma: boolean, Settings: any, isOtherIndustry: boolean) { // if (For === PayTypeEnum.Insurance) { // return { stack: [this.GetVehicleDetails(Type, Id, CrDate, PrDate, MOut, MIn, Vehicle, PrintType, IsProforma, Settings, isOtherIndustry)], width: 200 }; // } else { return { stack: [this.GetReceiptVehicleDetails(Type, Id, CrDate, PrDate, MOut, MIn, Vehicle, PrintType, IsProforma, Settings, isOtherIndustry)], width: 250 }; // } } static GetReceiptVehicleDetails(Type: any, Id: any, CrDate: any, PrDate: any, MOut: any, MIn: any, Vehicle: any, PrintType: any, IsProforma: boolean, Settings: any, isOtherIndustry: boolean) { let id: any; let vehicleData: any; vehicleData = [ { name: 'Bill#', value: this.CheckAndSetString(Id) }, { name: 'Date', value: this.CheckAndSetString(CrDate) } ]; return this.GetVehicleDataTable(vehicleData); } static GetInsurenceDetails(For: any, SurName: any, SurPhone: any, SurEmail: any, InsComp: any, PolNo: any, PolType: any, Type: any, Location: any, isOtherIndustry: boolean) { let InsuranceFields = [ { name: 'Name', value: SurName }, { name: 'Phone', value: SurPhone }, { name: 'Email', value: SurEmail } ]; if (!isOtherIndustry && For === PayTypeEnum.Insurance) { return { columns: [ { stack: [ this.GetInsuranceDetailsTable(InsuranceFields, SurName, SurPhone, SurEmail, InsComp, PolNo, PolType), // this.getServeyorEmail(RepairOrder), ] } ] }; } else if (isOtherIndustry) { let Head: any = (Type !== 'Invoice' && Type !== 'SalesReceipt') ? 'Service Location' : 'Ship To'; return { columns: [ { stack: [ this.GetCustomerDetails(Location, 'Sales Order', null, null, Head), ] } ] }; } else { return this.emptyObject(); } } static GetInsuranceDetailsTable(InsuranceFields: any, SurName: any, SurPhone: any, SurEmail: any, InsComp: any, PolNo: any, PolType: any) { var List: any = []; if (TrUtils.CheckInvalidSelect(PolType)) { PolType = null; } List.push(this.InsCompany(InsComp), { text: InsComp, marginTop: 5 }, this.GetPolicyInfo(PolNo, PolType), this.GetSurveyor(SurName, SurPhone, SurEmail), this.GetInsuranceDetails(InsuranceFields)); return List; } static GetPolicyInfo(PolNo: any, PolType: any) { let isFieldThere: boolean = false; let InsuranceFields = [ { name: 'Policy No', value: PolNo }, { name: 'Policy Type', value: PolType }, ]; for (let i = 0; i < InsuranceFields.length; i++) { if (!TrUtils.IsEmpty(InsuranceFields[i].value)) { isFieldThere = true; } } if (isFieldThere) { return { fontSize: this.BodySize, lineHeight: 0.7, table: { body: this.GetInsuranceTable(InsuranceFields) }, layout: 'noBorders', }; } else { return this.emptyObject(); } } static GetSurveyor(SurName: any, SurPhone: any, SurEmail: any) { if (SurName || SurEmail || SurName) { return { text: 'Surveyor :', bold: true, fontSize: this.SubHeaderSize, marginTop: 2 }; } else { return this.emptyObject(); } } static emptyObject() { let a: any = {}; return a; } static InsCompany(InsComp: any) { if (InsComp) { return { text: 'Insurance Company :', bold: true, fontSize: this.SubHeaderSize }; } else { return this.emptyObject(); } } static GetInsuranceDetails(data: any) { return { fontSize: this.BodySize, lineHeight: 0.7, // widths:['*','*',10], table: { body: this.GetInsuranceTable(data) }, layout: 'noBorders', }; } static GetInsuranceTable(data: any) { var body: any = []; data.forEach((row: any) => { if (!TrUtils.IsEmpty(row.value)) { var dataRow: any = []; dataRow.push({ text: (row.name).toString(), noWrap: true }); dataRow.push(':'); dataRow.push({ text: (row.value).toString(), lineHeight: 0.8 }); body.push(dataRow); } else { var a: any = []; a.push(''); a.push(''); a.push(''); body.push(a); } }); return body; } static GetCustomerDetails(Customer: any, Type: any, Vehicle: any, Settings: any, CustHeader: string) { if (TrUtils.IsNull(Customer)) { return this.emptyObject(); } let Data: any = [{ text: CustHeader + ':', fontSize: 7 }, { text: Customer.Code, fontSize: 11, bold: true }, { text: Customer.Name, fontSize: 10 }, { text: this.GetAddress(Customer), marginTop: 2 }, this.GetCustPhoneNumber(Customer, Type), this.GetCustomerGSTIN(Customer), this.GetCustomerDLNo(Customer), , this.GetCustomerName(Customer.CustName)] .filter(item => { if (item === null || item === undefined) { return false; } if (typeof item === 'string') { return item.trim() !== ''; } if (typeof item === 'object') { if (Object.keys(item).length === 0) { return false; } if (Object.prototype.hasOwnProperty.call(item, 'text')) { return !TrUtils.IsEmpty(item.text); } } return true; }) // if(!TrUtils.IsNull(Customer.CustName)){ // Data.splice(1,0,{ text: Customer.CustName, marginTop: 2 }); // Data.splice(2,0,{ text: 'Bill To :', style: 'hed', marginTop: 2 }); // } return { style: 'colum1', stack: Data }; } static GetNameAndAddress(RepairOrder: any) { if (RepairOrder.Type === 'Invoice' || RepairOrder.Type === 'SalesReceipt') { if (RepairOrder.AsInsuranceBilling) { return 'Insurance Company Name & Address:'; } else { return 'Customer Name & Address:'; } } else { if (RepairOrder.Type === 'Sales Order') { return 'Location:'; } else { return 'Customer Name & Address:'; } } } static GetCustomerName(Customer: any) { if (!TrUtils.IsEmpty(Customer)) { let GSTIN = { columns: [{ text: 'Customer Name :', width: 65, bold: true }, { text: Customer }] }; return GSTIN; } else { return this.emptyObject(); } } static GetCustomerGSTIN(Customer: any) { const customerTaxId = TrUtils.IsEmpty(Customer?.TaxId?.Value) ? Customer?.GSTIN : Customer.TaxId.Value; if (!TrUtils.IsEmpty(customerTaxId)) { let GSTIN = { columns: [{ text: Customer?.TaxId?.Label ||'GSTIN :', width: 33, style: 'hed' }, { text: customerTaxId, marginTop: 1.5 }] }; return GSTIN; } else { return this.emptyObject(); } } static GetCustomerDLNo(Customer: any) { if (!TrUtils.IsEmpty(Customer.DLNo)) { let GSTIN = { columns: [{ text: 'DL No :', width: 33, style: 'hed' }, { text: Customer.DLNo, marginTop: 1.5 }] }; return GSTIN; } else { return this.emptyObject(); } } // static GetPlaceofSupply(Vehicle: any, Settings: any) { // if (!TrUtils.IsNull(Vehicle) && !TrUtils.IsNull(Settings) && Settings.Tax === 'TI' && // !TrUtils.IsNull(Settings.PoS) && !TrUtils.IsEmpty(Settings.PoS.Name)) { // let PoS = { columns: [{ text: 'Place Of Supply :', width: 75, style: 'hed' }, { text: this.GetStateName(Settings.PoS), marginTop: 1.5 }] }; // return PoS; // } else { // return this.emptyObject(); // } // } static GetCustPhoneNumber(Customer: any, Type: any) { if (Type !== 'Technician Copy') { var contact = this.GetFormatContact(Customer); if (contact.length !== 0) { return { columns: [{ text: 'Phone', width: 'auto', style: 'hed' }, { text: contact, width: '*' }] }; } else { return this.emptyObject(); } } else { return this.emptyObject(); } } static GetAddress(Customer: any) { var Address = this.GetFormatAddress(Customer); if (Address.length !== 5) { return Address; } else { let a: any = ''; return a; } } static GetVehicleDetails(Type: any, Id: any, CrDate: any, PrDate: any, MOut: any, MIn: any, Vehicle: any, PrintType: any, IsProforma: boolean, Settings: any, isOtherIndustry: boolean, BL: any, ROCode: any, TypeName: any, AdmNo: any, DoS: any) { let id: any; let vehicleData: any; if (Type === 'Work Order' || Type === 'Technician Copy') { id = 'WO#'; } else if (Type === 'SalesOrder') { id = 'SO#'; } else if (Type === 'Sales Estimate') { id = 'Estimate#'; } else if (Type === 'Debit Notes') { id = 'Debit Note#'; } else if (Type === 'Credit Notes') { id = 'Credit Note#'; } else if (Type === 'Delivery Challan') { id = 'Delivery Challan#'; } else if (Type === 'Invoice' || Type === 'Tax Invoice' || Type === 'SalesReceipt') { id = 'Invoice#'; } else { id = 'Estimate#'; } if (PrintType === 'Parts Order' || TrUtils.IsNull(Vehicle)) { vehicleData = [ { name: id, value: this.CheckAndSetString(Id), bold: true }, { name: 'Date', value: this.CheckAndSetString(CrDate) } ]; if (!TrUtils.IsNull(AdmNo)) { vehicleData.push({ name: 'Admission No', value: AdmNo }); } if (!TrUtils.IsNull(Settings) && Settings.Tax === 'TI' && !TrUtils.IsNull(DoS) && !TrUtils.IsEmpty(DoS.Name)) { vehicleData.push({ name: 'Place Of Supply', value: this.GetStateName(DoS) }); } if (Type === 'Delivery Challan' || isOtherIndustry) { if (Type === 'Delivery Challan') { vehicleData.push({ name: 'Challan Type', value: '' }); } else { vehicleData.push({ name: 'Ref. No', value: BL?.RefNo }); } vehicleData.push({ name: 'Carrier Name/Agent', value: BL?.Cour }); vehicleData.push({ name: 'Bill of Lading/LR-RR No', value: BL?.No }); vehicleData.push({ name: 'Motor Vehicle No ', value: BL?.VNo }); vehicleData.push({ name: 'E-Way Bill No', value: BL?.EWay }); } } else { vehicleData = [ { name: id, value: this.CheckAndSetString(Id) }, { name: 'Date', value: this.CheckAndSetString(CrDate) } ]; if (!TrUtils.IsNull(PrDate) && Type !== 'Invoice' && Type !== 'Estimate' && Type !== 'Supplementary Estimate' && Type !== 'Tax Invoice') { vehicleData.push({ name: 'Delivery Date', value: this.CheckAndSetString(PrDate) }); } // if (!TrUtils.IsNull(Settings) && Settings.Tax === 'TI' && !TrUtils.IsNull(Settings.PoS) && !TrUtils.IsEmpty(Settings.PoS.Name)) { // vehicleData.push({ name: 'Place Of Supply', value: this.GetStateName(Settings.PoS) }); // } if (isOtherIndustry) { vehicleData.push({ name: 'Serial No', value: this.CheckAndSetString(Vehicle.SNo) }); } else { vehicleData.push({ name: 'Regn. No', value: this.CheckAndSetString(Vehicle.RegNo) }); if (Type === 'Invoice' && !IsProforma) { vehicleData.push({ name: 'Mileage', value: this.CheckAndSetString(MOut) }); } else { vehicleData.push({ name: 'Mileage', value: this.CheckAndSetString(MIn) }); } if (Type === 'Invoice' && !TrUtils.IsNull(TypeName)) { vehicleData.push({ name: 'RO Type', value: TypeName }); } if (Type === 'Invoice' && !TrUtils.IsNull(ROCode)) { vehicleData.push({ name: 'RO#', value: ROCode }); } } let Product: string; let ProdType: string = 'Equipment'; Product = this.CheckAndSetString(Vehicle.Make) + ' ' + this.CheckAndSetString(Vehicle.Model); if (!isOtherIndustry) { ProdType = 'Vehicle'; Product = Product + ' ' + this.CheckAndSetString(Vehicle.Var); } let a: any = [ { name: ProdType, value: Product }, ]; if (!isOtherIndustry) { if (!TrUtils.IsEmpty(Vehicle.VIN)) { a.push({ name: 'Chassis No', value: this.CheckAndSetString(Vehicle.VIN) }); } if (!TrUtils.IsEmpty(Vehicle.EngNo)) { a.push({ name: 'Engine No', value: this.CheckAndSetString(Vehicle.EngNo) }); } } for (let i = 0; i < a.length; i++) { vehicleData.push(a[i]); } } return this.GetVehicleDataTable(vehicleData); } static GetStateName(PlaceofSupply: any) { if (TrUtils.IsNull(PlaceofSupply)) { return '' } let supplyName: any = PlaceofSupply.Name + ' (' + PlaceofSupply.GCode + ')'; return supplyName; } static GetOtherDtails(Type: any, Id: any, CrDate: any, PrDate: any, PrintType: any, Settings: any, RefNo: any, IsPackage: any, PackId: any, PackedDate: any, ShipId: any, ShippedDate: any) { let id: any; let vehicleData: any; if (Type === 'SalesOrder') { id = 'SO#'; } else { id = 'Estimate#'; } if (PrintType === 'Parts Order') { vehicleData = [ { name: id, value: this.CheckAndSetString(Id) }, { name: 'Date', value: this.CheckAndSetString(CrDate) } ]; } else { vehicleData = [ { name: id, value: this.CheckAndSetString(Id) }, { name: 'Date', value: this.CheckAndSetString(CrDate) } ]; if (!TrUtils.IsNull(Settings) && Settings.Tax === 'TI' && !TrUtils.IsNull(Settings.PoS) && !TrUtils.IsEmpty(Settings.PoS.Name)) { vehicleData.push({ name: 'Place Of Supply', value: this.GetStateName(Settings.PoS) }); } if (!TrUtils.IsNull(RefNo)) { vehicleData.push({ name: 'Reference#', value: RefNo }); } if (IsPackage) { if (!TrUtils.IsNull(PackId)) { vehicleData.push({ name: 'Package#', value: PackId }); } if (!TrUtils.IsNull(PackedDate)) { vehicleData.push({ name: 'Packed Date', value: this.CheckAndSetString(PackedDate) }); } } else { if (!TrUtils.IsNull(ShipId)) { vehicleData.push({ name: 'Shipment#', value: ShipId }); } if (!TrUtils.IsNull(ShippedDate)) { vehicleData.push({ name: 'Shipped Date', value: this.CheckAndSetString(ShippedDate) }); } } // if (!TrUtils.IsNull(PrDate) && Type !== 'Invoice' && Type !== 'Tax Invoice') { // vehicleData.push({ name: 'Delivery Date', value: this.CheckAndSetString(PrDate) }); // } } return this.GetVehicleDataTable(vehicleData); } static CheckAndSetString(Value: any) { if (TrUtils.IsNull(Value)) { Value = ''; } return Value; } static GetVehicleDataTable(vehicleData: any) { return { lineHeight: 0.7, fontSize: this.BodySize, table: { body: this.GetDataTable(vehicleData, false) }, layout: 'noBorders', }; } static GetFormatContact(CustomerObj: any) { var contactnew = ''; if (!TrUtils.IsNull(CustomerObj.Cons)) { CustomerObj.Cons.forEach((Contact: any) => { contactnew = contactnew + '(' + Contact.Type + '):' + Contact.No + '\n'; }); } return contactnew; } static GetFormatAddress(CustomerObj: any) { var Addressnew = ''; if (!TrUtils.IsNull(CustomerObj.Adrs)) { CustomerObj.Adrs.forEach((Adrs: any) => { Addressnew = Addressnew + Adrs + '\n'; }); } return Addressnew; } static GetDisplayTable() { return { text: '', fontSize: 10, bold: true, margin: [0, 0, 0, 5] }; } static GetHeaders(PrintPartNumber: any) { let headersNames: any; if (PrintPartNumber) { 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: 'Qty', style: 'tableheader', rowSpan: 2, lineHeight: 0.5 }, { text: 'Unit Price', style: 'tableheader', rowSpan: 2, lineHeight: 0.5, alignment: 'right', }, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 }, {}, { 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: '', Field: 'QtyAndUoM', lineHeight: 0.5 }, { text: 'Unit Price', Field: 'UnPr', Field1: 'UnCo', lineHeight: 0.5 }, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'percentage', lineHeight: 0.5 }, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }, { text: 'Line Total', Field: 'LineTotal', 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: 'Qty', style: 'tableheader', rowSpan: 2, lineHeight: 0.6 }, { text: 'Unit Price', style: 'tableheader', rowSpan: 2, alignment: 'right', lineHeight: 0.6 }, { text: 'Discount', style: 'tableheader', colSpan: 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: '', Field: 'QtyAndUoM', lineHeight: 0.5 }, { text: 'Unit Price', Field: 'UnPr', Field1: 'UnCo', lineHeight: 0.5 }, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'percentage', lineHeight: 0.5 }, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }, { text: 'Line Total', Field: 'LineTotal', lineHeight: 0.5 } ]]; } return headersNames; } static PartsTaxAmounts1(PartsTaxInfo: any, ShowAccParts: any, ShowIGST: any, ShowTaxColumn: any) { if (ShowTaxColumn && !TrUtils.IsNull(PartsTaxInfo) && PartsTaxInfo.length > 0) { return { stack: [this.AllHSNPartCGSTTaxListTable1(PartsTaxInfo, ShowAccParts, ShowIGST, ShowTaxColumn)] }; } else { return ''; } } static PartsTaxAmounts(PartsTaxInfo: any, ShowAccParts: any, ShowIGST: any, ShowTaxColumn: any) { if (ShowTaxColumn && !TrUtils.IsNull(PartsTaxInfo) && PartsTaxInfo.length > 0) { return { stack: [this.AllHSNPartCGSTTaxListTable(PartsTaxInfo, ShowAccParts, ShowIGST, ShowTaxColumn)] }; } else { return ''; } } static AllHSNPartCGSTTaxListTable1(PartsTaxInfo: any, ShowAccParts: any, ShowIGST: any, ShowTaxColumn: any) { if (ShowIGST) { return { style: 'tableExample', table: { widths: [25, 60, 50], headerRows: 1, body: this.CreateHSNTaxTable1(PartsTaxInfo, ShowAccParts, ShowIGST, ShowTaxColumn) }, layout: this.HeaderLineStyle(), }; } else { return { style: 'tableExample', table: { widths: [25, 60, 40, 40], headerRows: 1, body: this.CreateHSNTaxTable1(PartsTaxInfo, ShowAccParts, ShowIGST, ShowTaxColumn) }, layout: this.HeaderLineStyle(), }; } } static AllHSNPartCGSTTaxListTable(PartsTaxInfo: any, ShowAccParts: any, ShowIGST: any, ShowTaxColumn: any) { if (ShowIGST) { return { style: 'tableExample', table: { widths: [40, 'auto', 50], headerRows: 1, body: this.CreateHSNTaxTable(PartsTaxInfo, ShowAccParts, ShowIGST, ShowTaxColumn) }, layout: this.HeaderLineStyle(), }; } else { return { style: 'tableExample', table: { widths: [50, 65, 50, 50], headerRows: 1, body: this.CreateHSNTaxTable(PartsTaxInfo, ShowAccParts, ShowIGST, ShowTaxColumn) }, layout: this.HeaderLineStyle(), }; } } static AllPartCGSTTaxListTable(PartsTaxInfo: any, ShowAccParts: any, ShowTaxColumn: any) { return { style: 'tableExample', table: { widths: [20, 60, 40, 40], body: this.ALLPartsCGSTTaxListTable(PartsTaxInfo, ShowAccParts, ShowTaxColumn) }, layout: this.HeaderLineStyle(), }; } static HeaderLineStyle() { return { hLineWidth: function (i: any, node: any) { return (i === 1) ? 0.1 : 0; }, vLineWidth: function (i: any, node: any) { return (i === 0 || i === node.table.widths.length) ? 0 : 0; }, hLineColor: function (i: any, node: any) { let color; if (i === 0 || i === node.table.body.length) { color = 'black'; } else { if (i === 1) { color = 'lightgray'; } else { color = 'lightgray'; } } return color; }, }; } static CreateHeadingAllPartCGSTTaxList() { let HeaderNames = [{ text: 'GST(%)', style: 'tableheader', fontSize: 6, lineHeight: 0.3, Field: 'CombinedTaxPercentage' }, // { text: 'SGST', style: 'tableheader', fontSize: 6,lineHeight:0.3, Field: 'SGST' }, { text: 'Count', style: 'tableheader', fontSize: 6, lineHeight: 0.3, Field: 'PartsCount' }, { text: 'Taxble Value', style: 'tableheader', alignment: 'right', fontSize: 6, lineHeight: 0.3, Field: 'TotalTaxableAmount' }, { text: 'Amount', style: 'tableheader', alignment: 'right', fontSize: 6, lineHeight: 0.3, Field: 'TotalTaxAmount' }, ]; return HeaderNames; } static ALLPartsCGSTTaxListTable(PartsTaxInfo: any, ShowAccParts: any, ShowTaxColumn: any) { if (!TrUtils.IsNull(PartsTaxInfo) && PartsTaxInfo.length !== 0 && ShowAccParts && ShowTaxColumn) { var body: any = []; let columns: any = this.CreateHeadingAllPartCGSTTaxList(); body.push(columns); PartsTaxInfo.forEach((part: any) => { var dataRow: any = []; columns.forEach((column: any) => { if (!TrUtils.IsNull(part[column.Field]) && !TrUtils.IsNull(part[column.Field])) { if (column.Field === 'TotalTaxAmount' || column.Field === 'TotalTaxableAmount') { dataRow.push({ text: part[column.Field].toString(), alignment: 'right', nowrap: true }); } else { dataRow.push({ text: part[column.Field].toString(), alignment: 'center', nowrap: true }); } } else { part[column.Field] = ''; dataRow.push({ text: part[column.Field].toString(), alignment: 'center' }); } }); body.push(dataRow); }); return body; } else { return [{}]; } } static CreateHeadingAllHSNTaxList(ShowIGST: any) { let HeaderNames = [{ text: 'HSN', style: 'tableheader', fontSize: 6, lineHeight: 0.3, Field: 'HSN' }, // { text: 'CGST', style: 'tableheader', fontSize: 6, lineHeight: 0.3, Field: 'CGST' }, // { text: 'SGST', style: 'tableheader', fontSize: 6, lineHeight: 0.3, Field: 'SGST' }, // { text: 'Count', style: 'tableheader', fontSize: 6, lineHeight: 0.3, Field: 'PartsCount' }, { text: 'Taxable Value', style: 'tableheader', fontSize: 6, lineHeight: 0.3, Field: 'TotalTaxableAmount' }, { text: 'Amount', style: 'tableheader', fontSize: 6, lineHeight: 0.3, Field: 'TotalTaxAmount' }, ]; if (ShowIGST) { HeaderNames.splice(1, 0, { text: 'IGST', style: 'tableheader', fontSize: 6, lineHeight: 0.3, Field: 'IGST' }) } else { HeaderNames.splice(1, 0, { text: 'CGST', style: 'tableheader', fontSize: 6, lineHeight: 0.3, Field: 'CGST' }) HeaderNames.splice(2, 0, { text: 'SGST', style: 'tableheader', fontSize: 6, lineHeight: 0.3, Field: 'SGST' }) } return HeaderNames; } static CreateHeadingAllTaxList(ShowIGST: any) { let HeaderNames = [ // { text: 'CGST', style: 'tableheader', fontSize: 6, lineHeight: 0.3, Field: 'CGST' }, // { text: 'SGST', style: 'tableheader', fontSize: 6, lineHeight: 0.3, Field: 'SGST' }, // { text: 'Count', style: 'tableheader', fontSize: 6, lineHeight: 0.3, Field: 'PartsCount' }, { text: 'Tax Rate', style: 'tableheader2', fontSize: 6, lineHeight: 0.3, Field: 'CombinedTaxPercentage', alignment: 'left' }, { text: 'Taxable Amount', style: 'tableheader2', fontSize: 6, lineHeight: 0.3, Field: 'TotalTaxableAmount', alignment: 'right' }, // { text: 'Tax Amount', style: 'tableheader2', fontSize: 6, lineHeight: 0.3, Field: 'TotalTaxAmount' }, ]; if (ShowIGST) { // HeaderNames.splice(1, 0, { text: 'IGST(%)', style: 'tableheader2', fontSize: 6, lineHeight: 0.3, Field: 'IGST' }); HeaderNames.splice(2, 0, { text: 'IGST(Rs.)', style: 'tableheader2', fontSize: 6, lineHeight: 0.3, Field: 'IGSTAmt', alignment: 'right' }); } else { // HeaderNames.splice(1, 0, { text: 'CGST(%)', style: 'tableheader2', fontSize: 6, lineHeight: 0.3, Field: 'CGST' }); HeaderNames.splice(2, 0, { text: 'CGST(Rs.)', style: 'tableheader2', fontSize: 6, lineHeight: 0.3, Field: 'CGSTAmt', alignment: 'right' }); // HeaderNames.splice(3, 0, { text: 'SGST(%)', style: 'tableheader2', fontSize: 6, lineHeight: 0.3, Field: 'CGST' }); HeaderNames.splice(3, 0, { text: 'SGST(Rs.)', style: 'tableheader2', fontSize: 6, lineHeight: 0.3, Field: 'SGSTAmt', alignment: 'right' }); } return HeaderNames; } static CreateHSNTaxTable1(PartsTaxInfo: any, ShowAccParts: any, ShowIGST: any, ShowTaxColumn: any) { if (!TrUtils.IsNull(PartsTaxInfo) && PartsTaxInfo.length !== 0 && ShowAccParts && ShowTaxColumn) { var body: any = []; let columns: any = this.CreateHeadingAllTaxList(ShowIGST); body.push(columns); PartsTaxInfo.forEach((part: any) => { var dataRow: any = []; columns.forEach((column: any) => { if (!TrUtils.IsFixedZero(part[column.Field]) && !TrUtils.IsNull(part[column.Field]) || column.Field === 'SGST' || column.Field === 'CGST' || column.Field === 'SGSTAmt' || column.Field === 'CGSTAmt' || column.Field === 'TotalTaxableAmount') { if (column.Field === 'TotalTaxableAmount' || column.Field === 'SGSTAmt' || column.Field === 'CGSTAmt' || column.Field === 'IGSTAmt') { dataRow.push({ text: TrUtils.FixPriceValue(part[column.Field]), alignment: 'right', opacity: 0.7, nowrap: true, fontSize: 6 }); } else if (column.Field === 'CombinedTaxPercentage') { dataRow.push({ text: part[column.Field].toString() + '%', alignment: 'left', opacity: 0.7, nowrap: true, fontSize: 6 }); } else { dataRow.push({ text: part[column.Field].toString(), alignment: 'left', opacity: 0.7, nowrap: true, fontSize: 6 }); } } else { part[column.Field] = ''; dataRow.push({ text: part[column.Field].toString(), alignment: 'left', opacity: 0.7, fontSize: 6 }); } }); body.push(dataRow); }); return body; } else { return [{}]; } } static CreateHSNTaxTable(PartsTaxInfo: any, ShowAccParts: any, ShowIGST: any, ShowTaxColumn: any) { if (!TrUtils.IsNull(PartsTaxInfo) && PartsTaxInfo.length !== 0 && ShowAccParts && ShowTaxColumn) { var body: any = []; let columns: any = this.CreateHeadingAllHSNTaxList(ShowIGST); body.push(columns); PartsTaxInfo.forEach((part: any) => { var dataRow: any = []; columns.forEach((column: any) => { if (!TrUtils.IsFixedZero(part[column.Field]) && !TrUtils.IsNull(part[column.Field]) || column.Field === 'SGST' || column.Field === 'CGST' || column.Field === 'TotalTaxAmount') { if (column.Field === 'SGSTLaborAmt') { dataRow.push({ text: part[column.Field].toString(), alignment: 'right', nowrap: true }); } else { dataRow.push({ text: part[column.Field].toString(), alignment: 'center', nowrap: true }); } } else { part[column.Field] = ''; dataRow.push({ text: part[column.Field].toString(), alignment: 'center' }); } }); body.push(dataRow); }); return body; } else { return [{}]; } } // static GetHCFinalTotalDetails(RecordData: any, BasicLaborTotal: any, OverAllMainLaborDiscount: any, LCGST: any, LSGST: any, LIGST: any, PIGST: any, ShowIGST: any, ShowTaxColumn: any, // BasicPartsTotal: any, OverAllMainPartsDiscount: any, PCGST: any, PSGST: any, PartsTaxInfo: any, // ShowAccParts: any, LaborAfterGST: any, PartsAfterGST: any, OverAllRecordDiscount: any, For: any, // OverAllRecordTotal: any, Rounded: any, GrandTotal: any, ShowDetailedLaborTaxInfo: any, // ShowDetailedPartTaxInfo: any, istaxable: boolean, LaborTotalTax: any, PartTotalTax: any, Consolidate: boolean, From: string, Adj: any, STotal: any, moreDiscDetails: boolean) { // let totalDisc: any; // let totalTax: any; // if (!Consolidate) { // totalTax = TrUtils.FixPriceValue(Number(LaborTotalTax) + Number(PartTotalTax)); // if (istaxable) { // totalDisc = TrUtils.FixPriceValue(Number(OverAllMainLaborDiscount) + Number(OverAllMainPartsDiscount)); // } else { // totalDisc = TrUtils.FixPriceValue(Number(OverAllMainLaborDiscount) + Number(OverAllMainPartsDiscount) + Number(OverAllRecordDiscount)); // } // } // return { // columns: [ // // this.GetTaxOnLabor(BasicLaborTotal, OverAllMainLaborDiscount, LCGST, // // LSGST, LIGST, ShowIGST, ShowTaxColumn, ShowDetailedLaborTaxInfo), // { text: '', width: 225 }, // // { // // stack: [ // // this.GetTaxOnParts(BasicPartsTotal, OverAllMainPartsDiscount, PCGST, // // PSGST, ShowAccParts, PIGST, ShowIGST, ShowTaxColumn, ShowDetailedPartTaxInfo, From), // // this.PartsTaxAmounts(PartsTaxInfo, ShowAccParts, ShowIGST, // // ShowTaxColumn) // // ] // // }, // { text: '', width: 230 }, // // this.GrandTotal(LaborAfterGST, PartsAfterGST, totalDisc, For, OverAllRecordTotal, Rounded, GrandTotal) // this.GrandTotal(RecordData, BasicLaborTotal, BasicPartsTotal, totalDisc, totalTax, For, OverAllRecordTotal, Rounded, GrandTotal, Adj, Consolidate, STotal, moreDiscDetails) // ] // // columnGap: 40 // , marginLeft: 10 // }; // } static GetFinalTotalDetails1(RecordData: any, BasicLaborTotal: any, OverAllMainLaborDiscount: any, LCGST: any, LSGST: any, LIGST: any, PIGST: any, ShowIGST: any, ShowTaxColumn: any, BasicPartsTotal: any, OverAllMainPartsDiscount: any, PCGST: any, PSGST: any, PartsTaxInfo: any, ShowAccParts: any, LaborAfterGST: any, PartsAfterGST: any, OverAllRecordDiscount: any, For: any, OverAllRecordTotal: any, Rounded: any, GrandTotal: any, ShowDetailedLaborTaxInfo: any, ShowDetailedPartTaxInfo: any, istaxable: boolean, LaborTotalTax: any, PartTotalTax: any, Consolidate: boolean, From: string, Adj: any, CustLaborTaxGroupDataByPerc: any, STotal: any, isAuto: boolean, moreDiscDetails: boolean) { let totalDisc: any; let totalTax: any; if (!Consolidate) { totalTax = TrUtils.FixPriceValue(Add(Number(LaborTotalTax), Number(PartTotalTax)), RecordData.Entity.DecimalsNumber); if (istaxable) { totalDisc = TrUtils.FixPriceValue(Add(Number(OverAllMainLaborDiscount), Number(OverAllMainPartsDiscount)), RecordData.Entity.DecimalsNumber); } else { totalDisc = TrUtils.FixPriceValue(Add(Number(OverAllMainLaborDiscount), Number(OverAllMainPartsDiscount)), RecordData.Entity.DecimalsNumber); } } // let serviceName: string; // let itemName: string; // if (isAuto) { // serviceName = 'Labor Tax'; // itemName = 'Parts Tax'; // } else { // serviceName = 'Service Tax'; // itemName = 'Items Tax'; // } return { columns: [ // this.GetTaxOnLabor(BasicLaborTotal, OverAllMainLaborDiscount, LCGST, // LSGST, LIGST, ShowIGST, ShowTaxColumn, ShowDetailedLaborTaxInfo), // { text: '', width: 10 }, { stack: [ // this.GetTaxOnParts(BasicPartsTotal, OverAllMainPartsDiscount, PCGST, // PSGST, ShowAccParts, PIGST, ShowIGST, ShowTaxColumn, ShowDetailedPartTaxInfo, From), // { text: (istaxable && CustLaborTaxGroupDataByPerc.length !== 0) ? serviceName : '', fontSize: 7, opacity: 0.8 }, this.PartsTaxAmounts1(CustLaborTaxGroupDataByPerc, ShowAccParts, ShowIGST, ShowTaxColumn), // { text: (istaxable && PartsTaxInfo.length !== 0) ? itemName : '', fontSize: 7, opacity: 0.8 }, // this.PartsTaxAmounts1(PartsTaxInfo, ShowAccParts, ShowIGST, // ShowTaxColumn) this.GetNotes(RecordData) ] }, // { text: '', width: 60 }, // this.GrandTotal(LaborAfterGST, PartsAfterGST, totalDisc, For, OverAllRecordTotal, Rounded, GrandTotal) this.GrandTotal1(RecordData, BasicLaborTotal, BasicPartsTotal, totalDisc, totalTax, For, OverAllRecordTotal, Rounded, GrandTotal, Adj, Consolidate, STotal, moreDiscDetails) ] // columnGap: 40 // , marginLeft: 10 }; } static GetNotes(RecordData: any) { console.log('RecordData.Notes shared', RecordData.Notes); if (!TrUtils.IsNull(RecordData.Notes)) { return { stack: [ { text: 'Notes:', bold: true, fontSize: 9, margin: [0, 5, 0, 0] }, { text: RecordData.Notes, fontSize: 7, margin: [0, 2, 0, 5], italics: true, opacity: 0.7 } ], margin: [0, 5, 0, 0] } } else { return ''; } } static GrandTotal1(RecordData: any, LaborAfterGST: any, PartsAfterGST: any, OverAllRecordDiscount: any, totalTax: any, For: any, OverAllRecordTotal: any, Rounded: any, GrandTotal: any, Adj: any, Consolidate: any, STotal: any, moreDiscDetails: boolean) { let AccountFields = [ // { name: 'Labor Total', value: LaborAfterGST }, // { name: 'Part Total', value: PartsAfterGST }, // { name: 'Total Disc.', value: OverAllRecordDiscount }, ]; if (moreDiscDetails) { if (!TrUtils.IsZero(RecordData.PDisc)) { AccountFields.push({ name: 'Items Discount', value: TrUtils.FixPriceValue(RecordData.PDisc, RecordData.Entity.DecimalsNumber) }); } if (!TrUtils.IsZero(RecordData.LDisc)) { AccountFields.push({ name: 'Services Discount', value: TrUtils.FixPriceValue(RecordData.LDisc, RecordData.Entity.DecimalsNumber) }); } if (!TrUtils.IsZero(RecordData.Disc)) { AccountFields.push({ name: 'Overall Discount', value: TrUtils.FixPriceValue(RecordData.Disc, RecordData.Entity.DecimalsNumber) }); } } else { AccountFields.push({ name: 'Discount', value: OverAllRecordDiscount }); } if (!Consolidate) { AccountFields.unshift({ name: 'SubTotal', value: TrUtils.FixPriceValue(STotal, RecordData.Entity.DecimalsNumber) }); } if (!TrUtils.IsEmpty(totalTax)) { AccountFields.push({ name: 'Total Tax', value: totalTax }); } if (!TrUtils.IsEmpty(Adj)) { if (Adj > 0) { Adj = '+' + TrUtils.FixPriceValue(Adj, RecordData.Entity.DecimalsNumber); } AccountFields.push({ name: 'Adjust', value: Adj }); } if (For === PayTypeEnum.Insurance) { let total = { name: 'Total', value: OverAllRecordTotal }; let Rounding = { name: 'Rounding', value: Rounded }; if (Rounding.value > 0) { Rounding.value = '+' + Rounding.value; } let FinalTotal = { name: 'Final Total', value: GrandTotal }; AccountFields.push(total); AccountFields.push(Rounding); if (!TrUtils.IsFixedZero(Rounded)) { AccountFields.push(FinalTotal); } } else { let total = { name: 'Total', value: OverAllRecordTotal }; let Rounding = { name: 'Rounding', value: Rounded }; let FinalTotal = { name: 'Final Total', value: GrandTotal }; if (Rounding.value > 0) { Rounding.value = '+' + Rounding.value; } AccountFields.push(total); AccountFields.push(Rounding); if (!TrUtils.IsFixedZero(Rounded)) { AccountFields.push(FinalTotal); } } return { style: ['columnheader', 'TotalsStyles'], lineHeight: 0.7, marginBottom: 5, width: 'auto', table: { body: this.GrandTotalTable(AccountFields) }, layout: 'noBorders' // layout: { // hLineWidth: function (i: any, node: any) { // return (i === 0) ? 1 : 0; // }, // vLineWidth: function (i: any, node: any) { // return (i === 0 || i === node.table.body.length) ? 0 : 0; // } // }, }; } static GetFinalTotalDetails(RecordData: any, BasicLaborTotal: any, OverAllMainLaborDiscount: any, LCGST: any, LSGST: any, LIGST: any, PIGST: any, ShowIGST: any, ShowTaxColumn: any, BasicPartsTotal: any, OverAllMainPartsDiscount: any, PCGST: any, PSGST: any, PartsTaxInfo: any, ShowAccParts: any, LaborAfterGST: any, PartsAfterGST: any, OverAllRecordDiscount: any, For: any, OverAllRecordTotal: any, Rounded: any, GrandTotal: any, ShowDetailedLaborTaxInfo: any, ShowDetailedPartTaxInfo: any, istaxable: boolean, LaborTotalTax: any, PartTotalTax: any, Consolidate: boolean, From: string, Adj: any, STotal: any, moreDiscDetails: boolean) { let totalDisc: any; let totalTax: any; if (!Consolidate) { totalTax = TrUtils.FixPriceValue(Add(Number(LaborTotalTax), Number(PartTotalTax)), RecordData.Entity.DecimalsNumber); if (istaxable) { totalDisc = TrUtils.FixPriceValue(Add(Number(OverAllMainLaborDiscount), Number(OverAllMainPartsDiscount)), RecordData.Entity.DecimalsNumber); } else { totalDisc = TrUtils.FixPriceValue(Add(Number(OverAllMainLaborDiscount), Number(OverAllMainPartsDiscount)), RecordData.Entity.DecimalsNumber); } } return { columns: [ this.GetTaxOnLabor(BasicLaborTotal, OverAllMainLaborDiscount, LCGST, LSGST, LIGST, ShowIGST, ShowTaxColumn, ShowDetailedLaborTaxInfo, Consolidate), { text: '', width: 10 }, { stack: [ this.GetTaxOnParts(BasicPartsTotal, OverAllMainPartsDiscount, PCGST, PSGST, ShowAccParts, PIGST, ShowIGST, ShowTaxColumn, ShowDetailedPartTaxInfo, From, Consolidate), this.PartsTaxAmounts1(PartsTaxInfo, ShowAccParts, ShowIGST, ShowTaxColumn) ] }, { text: '', width: moreDiscDetails ? 40 : 60 }, // this.GrandTotal(LaborAfterGST, PartsAfterGST, totalDisc, For, OverAllRecordTotal, Rounded, GrandTotal) this.GrandTotal(RecordData, BasicLaborTotal, BasicPartsTotal, totalDisc, totalTax, For, OverAllRecordTotal, Rounded, GrandTotal, Adj, Consolidate, STotal, moreDiscDetails, RecordData.Entity.DecimalsNumber) ] // columnGap: 40 , marginLeft: 10 }; } static GetDebitTotalDetails(RecordData: any, BasicLaborTotal: any, OverAllMainLaborDiscount: any, LCGST: any, LSGST: any, LIGST: any, PIGST: any, ShowIGST: any, ShowTaxColumn: any, BasicPartsTotal: any, OverAllMainPartsDiscount: any, PCGST: any, PSGST: any, PartsTaxInfo: any, ShowAccParts: any, LaborAfterGST: any, PartsAfterGST: any, OverAllRecordDiscount: any, For: any, OverAllRecordTotal: any, Rounded: any, GrandTotal: any, ShowDetailedLaborTaxInfo: any, ShowDetailedPartTaxInfo: any, istaxable: boolean, LaborTotalTax: any, PartTotalTax: any, Consolidate: boolean, From: string, moreDiscDetails: boolean) { let totalDisc: any; let totalTax: any; if (!Consolidate) { totalTax = TrUtils.FixPriceValue(Number(PartTotalTax), RecordData.Entity.DecimalsNumber); if (istaxable) { totalDisc = TrUtils.FixPriceValue(Number(OverAllMainPartsDiscount), RecordData.Entity.DecimalsNumber); } else { totalDisc = TrUtils.FixPriceValue(Number(OverAllMainPartsDiscount), RecordData.Entity.DecimalsNumber); } } return { columns: [ // this.GetTaxOnLabor(BasicLaborTotal, OverAllMainLaborDiscount, LCGST, // LSGST, LIGST, ShowIGST, ShowTaxColumn, ShowDetailedLaborTaxInfo), { text: '', width: 100 }, { stack: [ this.GetTaxOnParts(BasicPartsTotal, OverAllMainPartsDiscount, PCGST, PSGST, ShowAccParts, PIGST, ShowIGST, ShowTaxColumn, ShowDetailedPartTaxInfo, From, Consolidate), this.PartsTaxAmounts(PartsTaxInfo, ShowAccParts, ShowIGST, ShowTaxColumn) ] }, { text: '', width: 100 }, { text: '', width: 80 }, this.DebitGrandTotal(RecordData, BasicLaborTotal, BasicPartsTotal, totalDisc, totalTax, For, OverAllRecordTotal, Rounded, GrandTotal, moreDiscDetails, RecordData.Entity.DecimalsNumber) ] // columnGap: 40 , marginLeft: 10 }; } static DebitGrandTotal(RecordData: any, LaborAfterGST: any, PartsAfterGST: any, OverAllRecordDiscount: any, totalTax: any, For: any, OverAllRecordTotal: any, Rounded: any, GrandTotal: any, moreDiscDetails: boolean, DecimalsNumber: number) { let AccountFields = [ // { name: 'Labor Total', value: LaborAfterGST }, // { name: 'Part Total', value: PartsAfterGST }, { name: 'SubTotal', value: TrUtils.FixPriceValue(TrUtils.SetValueToZeroIfNull(Number(PartsAfterGST)), DecimalsNumber) }, ]; if (moreDiscDetails) { AccountFields.push({ name: 'Overall Discount', value: TrUtils.FixPriceValue(RecordData.Disc, DecimalsNumber) }); } else { AccountFields.push({ name: 'Discount', value: OverAllRecordDiscount }); } if (!TrUtils.IsEmpty(totalTax)) { AccountFields.push({ name: 'Total Tax', value: totalTax }); } if (For === PayTypeEnum.Insurance) { let total = { name: 'Total', value: OverAllRecordTotal }; let Rounding = { name: 'Rounding', value: Rounded }; if (Rounding.value > 0) { Rounding.value = '+' + Rounding.value; } let FinalTotal = { name: 'Final Total', value: GrandTotal }; AccountFields.push(total); AccountFields.push(Rounding); if (!TrUtils.IsFixedZero(Rounded)) { AccountFields.push(FinalTotal); } } else { let total = { name: 'Total', value: OverAllRecordTotal }; let Rounding = { name: 'Rounding', value: Rounded }; let FinalTotal = { name: 'Final Total', value: GrandTotal }; if (Rounding.value > 0) { Rounding.value = '+' + Rounding.value; } AccountFields.push(total); AccountFields.push(Rounding); if (!TrUtils.IsFixedZero(Rounded)) { AccountFields.push(FinalTotal); } } return { style: ['columnheader', 'TotalsStyles'], lineHeight: 0.7, marginBottom: 5, fontSize: 7, table: { body: this.GrandTotalTable(AccountFields) }, layout: 'noBorders' // layout: { // hLineWidth: function (i: any, node: any) { // return (i === 0) ? 1 : 0; // }, // vLineWidth: function (i: any, node: any) { // return (i === 0 || i === node.table.body.length) ? 0 : 0; // } // }, }; } static GetPOTotalDetails(ROPrintData: any, moreDiscDetails: boolean) { return { columns: [ { stack: [ this.GetTaxOnParts(ROPrintData.BasicPartsTotal, ROPrintData.OverAllMainPartsDiscount, ROPrintData.PCGST, ROPrintData.PSGST, ROPrintData.PIGST, ROPrintData.ShowIGST, ROPrintData.ShowAccParts, ROPrintData.ShowTaxColumn, ROPrintData.ShowDetailedPartTaxInfo, ROPrintData.Type, ROPrintData.Consolidate), this.PartsTaxAmounts(ROPrintData.PartsTaxInfo, ROPrintData.ShowAccParts, ROPrintData.ShowIGST, ROPrintData.ShowTaxColumn) ] }, { text: '', width: 200 }, this.GrandTotal(ROPrintData, ROPrintData.LaborAfterGST, ROPrintData.PartsAfterGST, ROPrintData.OverAllRecordDiscount, null, ROPrintData.For, ROPrintData.OverAllRecordTotal, ROPrintData.Rounded, ROPrintData.GrandTotal, ROPrintData.Adj, ROPrintData.Consolidate, null, moreDiscDetails, ROPrintData.Entity.DecimalsNumber)] // columnGap: 40 , marginLeft: 10 }; } static GetTaxOnParts(BasicPartsTotal: any, OverAllMainPartsDiscount: any, PCGST: any, PSGST: any, ShowAccParts: any, PIGST: any, ShowIGST: any, ShowTaxColumn: any, ShowDetailedPartTaxInfo: any, From: string, Consolidate: boolean) { let istheretax = false; let PartsTotal = []; // if (!TrUtils.IsFixedZero(OverAllMainPartsDiscount)) { // PartsTotal.push({ name: 'Discount On Parts', value: OverAllMainPartsDiscount }); // } if (!Consolidate) { if (!TrUtils.IsFixedZero(BasicPartsTotal) && (From !== 'Countersale')) { PartsTotal.unshift({ name: 'Parts Total', value: BasicPartsTotal }); } } if (!ShowAccParts && ShowTaxColumn && ShowDetailedPartTaxInfo) { if (From === 'Sales' || From === 'Countersale') { if (ShowIGST) { PartsTotal.push({ name: 'IGST', value: PIGST }); } else { PartsTotal.push({ name: 'CGST', value: PCGST }); PartsTotal.push({ name: 'SGST', value: PSGST }); } } else { if (ShowIGST) { PartsTotal.push({ name: 'IGST On Parts', value: PIGST }); } else { PartsTotal.push({ name: 'CGST On Parts', value: PCGST }); PartsTotal.push({ name: 'SGST On Parts', value: PSGST }); } } } if (PartsTotal.length !== 0) { return { style: ['columnheader', 'TotalsStyles'], lineHeight: 0.7, fontSize: 7, marginBottom: 5, table: { body: this.GetDataTable(PartsTotal, true) }, layout: 'noBorders', }; } else { return this.emptyObject(); } } static GetTaxOnLabor(BasicLaborTotal: any, OverAllMainLaborDiscount: any, LCGST: any, LSGST: any, LIGST: any, ShowIGST: any, ShowTaxColumn: any, ShowDetailedLaborTaxInfo: any, Consolidate: boolean) { let istheretax = false; let LaborTotal = []; // if (!TrUtils.IsFixedZero(OverAllMainLaborDiscount)) { // LaborTotal.push({ name: 'Discount On Labor', value: OverAllMainLaborDiscount }); // } //consolidate and no-tax i want show labor discount if (!Consolidate) { if (!TrUtils.IsFixedZero(BasicLaborTotal)) { LaborTotal.unshift({ name: 'Labor Total', value: BasicLaborTotal }); } } if (ShowTaxColumn && ShowDetailedLaborTaxInfo && (!TrUtils.IsFixedZero(LIGST) || (!TrUtils.IsFixedZero(LCGST) || !TrUtils.IsFixedZero(LSGST)))) { if (ShowIGST) { LaborTotal.push({ name: 'IGST On Labor', value: LIGST }); } else { LaborTotal.push({ name: 'CGST On Labor', value: LCGST }); LaborTotal.push({ name: 'SGST On Labor', value: LSGST }); } } if (LaborTotal.length !== 0) { return { style: ['columnheader', 'TotalsStyles'], lineHeight: 0.7, fontSize: 7, marginBottom: 5, table: { body: this.GetDataTable(LaborTotal, true) }, layout: 'noBorders', }; } else { return this.emptyObject(); } } static GrandTotal(RecordData: any, LaborAfterGST: any, PartsAfterGST: any, OverAllRecordDiscount: any, totalTax: any, For: any, OverAllRecordTotal: any, Rounded: any, GrandTotal: any, Adj: any, Consolidate: any, subTotal: any, moreDiscDetails: boolean, DecimalsNumber: number) { let AccountFields = [ // { name: 'Labor Total', value: LaborAfterGST }, // { name: 'Part Total', value: PartsAfterGST }, ]; if (moreDiscDetails) { if (!TrUtils.IsZero(RecordData.PDisc)) { AccountFields.push({ name: 'Items Discount', value: TrUtils.FixPriceValue(RecordData.PDisc, DecimalsNumber) }); } if (!TrUtils.IsZero(RecordData.LDisc)) { AccountFields.push({ name: 'Services Discount', value: TrUtils.FixPriceValue(RecordData.LDisc, DecimalsNumber) }); } if (!TrUtils.IsZero(RecordData.Disc)) { AccountFields.push({ name: 'Overall Discount', value: TrUtils.FixPriceValue(RecordData.Disc, DecimalsNumber) }); } } else { AccountFields.push({ name: 'Discount', value: OverAllRecordDiscount }); } if (!Consolidate && !TrUtils.IsNull(subTotal)) { AccountFields.unshift({ name: 'SubTotal', value: TrUtils.FixPriceValue(TrUtils.SetValueToZeroIfNull(Number(subTotal)), DecimalsNumber) }); } else { if (!Consolidate) { AccountFields.unshift({ name: 'SubTotal', value: TrUtils.FixPriceValue(Add(TrUtils.SetValueToZeroIfNull(Number(LaborAfterGST)), TrUtils.SetValueToZeroIfNull(Number(PartsAfterGST))), DecimalsNumber) }); } else { console.log('Test', TrUtils.FixPriceValue(Add(TrUtils.SetValueToZeroIfNull(Number(LaborAfterGST)), TrUtils.SetValueToZeroIfNull(Number(PartsAfterGST)), TrUtils.SetValueToZeroIfNull(Number(totalTax))), DecimalsNumber)); AccountFields.unshift({ name: 'SubTotal', value: TrUtils.FixPriceValue(Add(TrUtils.SetValueToZeroIfNull(Number(LaborAfterGST)), TrUtils.SetValueToZeroIfNull(Number(PartsAfterGST)), TrUtils.SetValueToZeroIfNull(Number(totalTax))), DecimalsNumber) }); } } if (!TrUtils.IsEmpty(totalTax) && !Consolidate) { AccountFields.push({ name: 'Total Tax', value: totalTax }); } if (!TrUtils.IsEmpty(Adj)) { if (Adj > 0) { Adj = '+' + TrUtils.FixPriceValue(Adj, DecimalsNumber); } AccountFields.push({ name: 'Adjust', value: Adj }); } if (For === PayTypeEnum.Insurance) { let total = { name: 'Total', value: OverAllRecordTotal }; let Rounding = { name: 'Rounding', value: Rounded }; if (Rounding.value > 0) { Rounding.value = '+' + Rounding.value; } let FinalTotal = { name: 'Final Total', value: GrandTotal }; AccountFields.push(total); AccountFields.push(Rounding); if (!TrUtils.IsFixedZero(Rounded)) { AccountFields.push(FinalTotal); } } else { let total = { name: 'Total', value: OverAllRecordTotal }; let Rounding = { name: 'Rounding', value: Rounded }; let FinalTotal = { name: 'Final Total', value: GrandTotal }; if (Rounding.value > 0) { Rounding.value = '+' + Rounding.value; } AccountFields.push(total); AccountFields.push(Rounding); if (!TrUtils.IsFixedZero(Rounded)) { AccountFields.push(FinalTotal); } } return { style: ['columnheader', 'TotalsStyles'], lineHeight: 0.7, marginBottom: 5, width: 'auto', table: { body: this.GrandTotalTable(AccountFields) }, layout: 'noBorders' // layout: { // hLineWidth: function (i: any, node: any) { // return (i === 0) ? 1 : 0; // }, // vLineWidth: function (i: any, node: any) { // return (i === 0 || i === node.table.body.length) ? 0 : 0; // } // }, }; } static SalesGrandTotal(LaborAfterGST: any, PartsAfterGST: any, OverAllRecordDiscount: any, For: any, OverAllRecordTotal: any, Rounded: any, GrandTotal: any) { let AccountFields = [ // { name: 'Labor Total', value: LaborAfterGST }, // { name: 'Part Total', value: PartsAfterGST }, { name: 'Disc.', value: OverAllRecordDiscount }]; if (For === PayTypeEnum.Insurance) { let total = { name: 'Total', value: OverAllRecordTotal }; let Rounding = { name: 'Rounding', value: Rounded }; if (Rounding.value > 0) { Rounding.value = '+' + Rounding.value; } let FinalTotal = { name: 'Final Total', value: GrandTotal }; AccountFields.push(total); AccountFields.push(Rounding); if (!TrUtils.IsFixedZero(Rounded)) { AccountFields.push(FinalTotal); } } else { let total = { name: 'Total', value: OverAllRecordTotal }; let Rounding = { name: 'Rounding', value: Rounded }; let FinalTotal = { name: 'Final Total', value: GrandTotal }; if (Rounding.value > 0) { Rounding.value = '+' + Rounding.value; } AccountFields.push(total); AccountFields.push(Rounding); if (!TrUtils.IsFixedZero(Rounded)) { AccountFields.push(FinalTotal); } } return { style: ['columnheader', 'TotalsStyles'], lineHeight: 0.7, marginBottom: 5, table: { body: this.GrandTotalTable(AccountFields) }, layout: 'noBorders' }; } static GrandTotalTable(data: any) { var body: any = []; data.forEach((row: any) => { if (!TrUtils.IsFixedZero(row.value) || row.name === 'Total') { var dataRow: any = []; dataRow.push({ text: (row.name).toString(), noWrap: true }); dataRow.push(':'); if (!TrUtils.IsNull(row.value)) { dataRow.push({ text: (row.value).toString(), noWrap: true, alignment: 'right' }); } else { dataRow.push({ text: '', noWrap: true, alignment: 'right' }); } body.push(dataRow); } }); return body; } static InvoiceDueStatus(Type: any, Paid: any, Due: any, Status: any, isCounter: boolean, DecimalsNumber: number) { if (Type === 'Invoice' && !isCounter) { return { // lineHeight: 0.7, fontSize: this.TableHeaders, marginTop: 3, marginBottom: 5, table: { widths: ['*', 'auto'], body: [[{ text: 'Paid : Rs.' + TrUtils.FixPriceValue(Paid, DecimalsNumber), marginLeft: 20 }, { text: 'Due : Rs.' + TrUtils.FixPriceValue(Due, DecimalsNumber), marginRight: 20 }]] }, layout: this.LayOutLineStyle(), }; } else { return this.emptyObject(); } } static DebitDueStatus(Type: any, Paid: any, Due: any, Status: any) { // if (Type === 'Invoice') { return { // lineHeight: 0.7, fontSize: this.TableHeaders, marginTop: 10, marginBottom: 5, table: { widths: ['*', 'auto'], body: [[{ text: 'Paid : Rs.' + Paid, marginLeft: 20 }, { text: 'Due : Rs.' + Due, marginRight: 20 }]] }, layout: this.LayOutStyle(), }; // } else { // return this.emptyObject(); // } } static LayOutStyle() { return { hLineColor: function (i: any, node: any) { return (i === 0 || i === 1 || i === 2 || i === node.table.body.length) ? 'gray' : 'white'; }, vLineColor: function (i: any, node: any) { return (i === 0 || i === node.table.widths.length) ? 'gray' : 'white'; } }; } static LayOutLineStyle() { return { hLineWidth: function (i: any, node: any) { return (i === 0 || i === node.table.body.length) ? 0.7 : 0.7; }, vLineWidth: function (i: any, node: any) { return (i === 0 || i === node.table.widths.length) ? 0.7 : 0.7; }, hLineColor: function (i: any, node: any) { return (i === 0 || i === 1 || i === 2 || i === node.table.body.length) ? 'lightgray' : 'white'; }, vLineColor: function (i: any, node: any) { return (i === 0 || i === node.table.widths.length) ? 'lightgray' : 'white'; } }; } //Not use this function any where static LayOutStyle1() { return { hLineColor: function (i: any, node: any) { return (i === 0 || i === 1 || i === node.table.body.length) ? 'gray' : 'white'; }, vLineColor: function (i: any, node: any) { return (i === 0 || i === node.table.widths.length) ? 'gray' : 'white'; } }; } static GetImage(Image: any, PrLogo: boolean) { if (!TrUtils.IsNull(Image) && PrLogo) { return { image: Image, width: 120, height: 80 }; } else { return { text: '', width: 150, height: 100 }; } } static FooterContent(CnstData: any) { if (CnstData.Entity.Header.Position === 'Left') { if (!TrUtils.IsEmpty(CnstData.Entity.FootText)) { return { table: { widths: ['auto'], body: [ [{ text: CnstData.Entity.FootText, alignment: 'center', fontSize: 9 }] ] }, margin: [35, 0, 15, 10] } } else { return this.emptyObject(); } } else { return { stack: [{ text: CnstData.Doc?.Sltn + ' ' + CnstData.Doc?.Name, bold: true, alignment: 'right', marginBottom: 10 }, SharedPDFService.HeaderAfterLine1(), { columns: [this.GetEntityAddress(CnstData.Entity)] }], margin: [35, 0, 15, 10] } } } static GetEntityAddress(Entity: any) { let Addres: string = Entity.CName + ', ' + Entity.Adrs1; if (!TrUtils.IsEmpty(Entity.Adrs2)) { Addres = Addres + ',' + Entity.Adrs2; } Addres = Addres + ',' + Entity.City + SharedPDFService.getPinCode(Entity.PIN); return { style: 'tableExample', table: { widths: [80, '*'], body: [ [{ text: 'Address -', bold: true }, { text: Addres, marginLeft: -45 }], [{ text: 'For Appointments' }, { text: 'Call: ' + Entity.Phone + ', ' + this.GetEmail(Entity.Email), marginLeft: -12 }], ] }, layout: 'noBorders', } } static GetSignatures(CName: any, For: any, Type: any) { return { columns: [{ marginTop: 3, stack: [ { text: this.CompanyName(CName), alignment: 'right' }, { columns: [this.CustomerSignature(), this.SurveyorSignature(For, Type), this.Authorizedsignature()] } ] }], }; } static GetInvSignatures(CName: any, isCounterSale: boolean) { return { columns: [{ marginTop: 5, stack: [ { text: this.CompanyName(CName), alignment: 'right' }, { columns: [this.CustomerSignature(), this.SparesSignature(isCounterSale), this.Authorizedsignature()] } ] }], }; } static GetHCInvSignatures(CName: any, isCounterSale: boolean) { return { columns: [{ marginTop: 5, stack: [ { text: this.CompanyName(CName), alignment: 'right' }, { columns: [this.PatientSignature(), this.SparesSignature(isCounterSale), this.Authorizedsignature()] } ] }], }; } static SparesSignature(CounterSale: boolean) { if (CounterSale) { return { style: 'Sign', text: ['Parts Incharge Signature'], width: '*' }; } else { let Sur: any = []; return Sur; } } static CompanyName(CName: any) { return { text: [{ text: 'For ', fontSize: 9 }, { text: CName, bold: 'true', fontSize: 9 }], }; } static Authorizedsignature() { return { style: 'Sign', text: ['Authorised Signatory'], width: 'auto' }; } static Accountantsignature() { return { style: 'Sign', text: ['Accountant Signature'], width: '*' }; } static CustomerSignature() { return { style: 'Sign', text: ['Customer Signature'], width: '*' }; } static PatientSignature() { return { style: 'Sign', text: ['Patient / Guardian Signature'], width: '*' }; } static SurveyorSignature(For: any, Type: any) { if (For === PayTypeEnum.Insurance && Type === 'Estimate') { return { style: 'Sign', text: ['Surveyor Signature'], width: '*' }; } else { let Sur: any = []; return Sur; } } //Not Use this function any where static GetHeadersWithDiffDisc(ROData: any, PrintPartNumber: any) { let headersNames: any; if (PrintPartNumber) { 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: 'Qty', style: 'tableheader', rowSpan: 2, lineHeight: 0.5 }, { text: 'Unit Price', style: 'tableheader', rowSpan: 2, lineHeight: 0.5, alignment: 'right', }, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 }, {}, { 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: '', Field: 'QtyAndUoM', lineHeight: 0.5 }, { text: 'Unit Price', Field: 'UnPr', Field1: 'UnCo', lineHeight: 0.5 }, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'percentage', lineHeight: 0.5 }, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }, { text: 'Line Total', Field: 'LineTotal', lineHeight: 0.5 } ]]; } else { headersNames = [[{ text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }, { text: 'Description', rowSpan: 2, style: 'tableheader', alignment: 'center', lineHeight: 0.5 }, { text: 'Qty', style: 'tableheader', rowSpan: 2, lineHeight: 0.5 }, { text: 'Unit Price', style: 'tableheader', rowSpan: 2, alignment: 'right', lineHeight: 0.5 }, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 }, {}, { text: 'Line Total', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 } ], [{ text: '', Field: 'SNo', lineHeight: 0.5 }, { text: '', Field: 'Desc', lineHeight: 0.5 }, { text: '', Field: 'QtyAndUoM', lineHeight: 0.5 }, { text: 'Unit Price', Field: 'UnPr', Field1: 'UnCo', lineHeight: 0.5 }, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'percentage', lineHeight: 0.5 }, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }, { text: 'Line Total', Field: 'LineTotal', lineHeight: 0.5 } ]]; } return headersNames; } static GetStyles() { return { temp2header: { fontSize: 23, bold: true, alignment: 'left', // margin: [0, 10, 0, 0], }, tableheader1: { bold: true, fontFamily: 'Calibri', margin: [0, 2, 0, 2], alignment: 'center' }, header: { fontSize: 26, bold: true, alignment: 'center', // margin: [0, 10, 0, 0], }, // header2: { // fontSize: 13, // bold: true, // alignment: 'center', // // margin: [0, 10, 0, 0], // }, meetingHeader: { fontSize: 16, bold: true, // alignment: 'center', }, Receiptheader: { fontSize: 26, bold: true, alignment: 'center', margin: [0, 10, 0, 0], }, InlineHeader: { fontSize: this.TableHeaders, bold: true, alignment: 'center', // decoration: 'underline', margin: [100, 2, 0, 2], }, TaskHeading: { fontSize: 10, bold: true, margin: [30, 10, 0, 0], }, lettersSize: { fontSize: this.SubHeaderSize, margin: [30, 0, 0, 0], }, tablexample: { margin: [0, 5, 0, 0] }, hedstyl: { margin: [0, 0, 0, 0] }, header2: { fontSize: 12, bold: true, alignment: 'center', margin: [0, 0, 0, 0], }, header1: { fontSize: 18, bold: true, alignment: 'center', decoration: 'underline', margin: [0, 0, 0, 0] }, ws_adrs_center: { fontSize: this.BodySize, alignment: 'center', }, ws_adrs_center1: { fontSize: 10, alignment: 'center', }, ws_adrs_left: { fontSize: this.BodySize, alignment: 'left', }, ws_adrs_left1: { fontSize: 10, alignment: 'left', }, columnheader: { margin: [0, 5, 0, 0], }, tableExample: { margin: [0, 0.5, 0, 5], fontSize: this.BodySize }, tableExamplemargin: { margin: [25, 10, 20, 0], fontSize: this.BodySize }, textcust: { fontSize: this.BodySize, margin: [0, 2, 0, 2], }, column: { margin: [15, 0, 0, 0] }, tableheader: { bold: true, fontSize: this.TableHeaders, margin: [0, 1, 0, 5], alignment: 'center' }, tableheader2: { fontSize: this.TableHeaders, margin: [0, 1, 0, 5], alignment: 'center', // color: 'grey' opacity: 0.7 }, hed: { fontSize: this.SubHeaderSize, bold: true }, hed2: { fontSize: this.SubHeaderSize, // bold: true }, TotalsStyles: { marginTop: 15, lineHeight: 1.4, fontSize: this.BodySize, margin: [15, 0, 0, 0], }, colum1: { fontSize: this.BodySize, lineHeight: 1.2, }, colum2: { fontSize: this.BodySize, lineHeight: 1.4, margin: [10, 0, 0, 0], }, colum3: { lineHeight: 0.7 }, Receiptheader1: { fontSize: 10, bold: true, alignment: 'center', margin: [0, 0, 0, 3] }, Row1: { fontSize: this.TableHeaders, margin: [0, 5, 0, 5], }, rowdata: { margin: [0, 10, 0, 0], fontSize: this.TableHeaders }, forCompany: { margin: [0, 10, 30, 0], fontSize: 9 }, forCompany1: { margin: [0, 5, 15, 0], fontSize: 9 }, Rupees: { margin: [0, 40, 0, 0], fontSize: 10, }, Signature: { margin: [0, 40, 50, 0], alignment: 'right', fontSize: 10 }, withApp: { alignment: 'center', lineHeight: 0.7 }, withOutApp: { alignment: 'center', lineHeight: 0.5 }, Sign: { fontSize: this.BodySize, margin: [0, 20, 0, 5] }, Sign1: { fontSize: this.BodySize, margin: [0, 15, 0, 5] }, // 'html-font': { // fontSize: this.TermsandCond, // }, // 'html-ol': { // fontSize: this.TermsandCond, // }, 'margin-all': { margin: [0, 5, 0, 5], }, 'margin-top': { margin: [0, 5, 0, 0], }, 'margin-bottom': { margin: [0, 0, 0, 5], }, 'fontSize': { fontSize: this.TermsandCond, }, // 'html-u': { // fontSize: 16, // }, // 'html-b': { // }, // 'html-li': { // }, // 'html-span': { // fontSize: this.TermsandCond, // } }; } static convertNumberToWords(value: any) { var fraction = Math.round(this.frac(value) * 100); let f_text: any = ''; if (fraction > 0) { let paisa: any = (this.convert_number(fraction) === 'ONE') ? 'Paisa' : ' Paise'; f_text = 'And ' + this.convert_number(fraction) + paisa; } return this.convert_number(value) + ' Rupee(s) ' + f_text + ' Only'; } static frac(f: any) { return f % 1; } static convert_number(number: any) { if ((number < 0) || (number > 999999999)) { return 'NUMBER OUT OF RANGE!'; } var Gn = Math.floor(number / 10000000); /* Crore */ number -= Gn * 10000000; var kn = Math.floor(number / 100000); /* lakhs */ number -= kn * 100000; var Hn = Math.floor(number / 1000); /* thousand */ number -= Hn * 1000; var Dn = Math.floor(number / 100); /* Tens (deca) */ number = number % 100; /* Ones */ var tn = Math.floor(number / 10); var one = Math.floor(number % 10); var res = ''; if (Gn > 0) { res += (this.convert_number(Gn) + ' Crore'); } if (kn > 0) { res += (((res === '') ? '' : ' ') + this.convert_number(kn) + ' Lakh'); } if (Hn > 0) { res += (((res === '') ? '' : ' ') + this.convert_number(Hn) + ' Thousand'); } if (Dn) { res += (((res === '') ? '' : ' ') + this.convert_number(Dn) + ' Hundred'); } var ones = Array('', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen'); var tens = Array('', '', 'Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety'); if (tn > 0 || one > 0) { if (!(res === '')) { res += ' And '; } if (tn < 2) { res += ones[tn * 10 + one]; } else { res += tens[tn]; if (one > 0) { res += ('-' + ones[one]); } } } if (res === '') { res = 'Zero'; } return res; } }