import { MyDate } from '../utils/my-date'; import { TrUtils } from '../utils/tr-utils'; export class PrintSharedService { static GetEntityHeaderStyles(PDFData: any, Entity: any, image: any) { PDFData.Image = image; PDFData.HColor = Entity.Entity.Settings.Common.PrOptions.NameClr; PDFData.AColor = Entity.Entity.Settings.Common.PrOptions.AdrsClr; return PDFData; } static GetFormattedEntityDataForPrint(argEntityData: any, RecordType: string, OriginalData: any) { let EntityData: any = TrUtils.Stringify(argEntityData); let tempEntity: any = !TrUtils.IsNull(EntityData.Entity) ? EntityData.Entity : EntityData; if (!TrUtils.IsNull(tempEntity.Address) && tempEntity.Address.length !== 0) { tempEntity.Address = TrUtils.Stringify(tempEntity.Address[0]); } if (TrUtils.IsNull(EntityData.User.TZ)) { EntityData.User.TZ = 'Asia/Calcutta'; } // MyDate.UserTimeZone = EntityData.User.TZ; let Entity: any = {}; Entity.User = EntityData.User; Entity.DecimalsNumber = 2; if (TrUtils.IsNull(tempEntity.Settings.Common)) { tempEntity.Settings.Common = {}; } if (TrUtils.IsNull(tempEntity.Settings.Common.Tax)) { tempEntity.Settings.Common.Tax = {}; } if (TrUtils.IsNull(tempEntity.Settings.Acc)) { tempEntity.Settings.Acc = {}; } if (!TrUtils.IsNull(tempEntity.Settings.Acc) && !TrUtils.IsNull(tempEntity.Settings.Acc.Banks)) { let Bank = tempEntity.Settings.Acc.Banks.filter((bank: any) => { return bank.Def; }); Entity.Bank = Bank[0]; Entity.PrBank = tempEntity.Settings.Acc.PrBnk; Entity.PrUPI = tempEntity.Settings.Acc.PrUPI; Entity.PrCustBar = tempEntity.Settings.Acc.PrCustBar; Entity.UPI = tempEntity.Settings.Acc.UPI; Entity.UPIPhone = tempEntity.Settings.Acc.UPIPhone; } if (TrUtils.IsNull(tempEntity.Settings.Common.Tax.GSTIN)) { Entity.GSTIN = ''; } else { Entity.GSTIN = tempEntity.Settings.Common.Tax.GSTIN; } if (TrUtils.IsNull(tempEntity.Settings.Common.DLNo)) { Entity.DLNo = ''; } else { Entity.DLNo = tempEntity.Settings.Common.DLNo; } if (TrUtils.IsNull(tempEntity.Settings.Common.RegNo)) { Entity.RegNo = ''; } else { Entity.RegNo = tempEntity.Settings.Common.RegNo; } if (!TrUtils.IsNull(tempEntity.Settings.Common.Tax)) { Entity.TaxIds = tempEntity.Settings.Common.Tax.TaxIds; } if (TrUtils.IsNull(tempEntity.Settings.Common.Tax.GSTType)) { Entity.GSTType = ''; } else { Entity.GSTType = tempEntity.Settings.Common.Tax.GSTType; } if (TrUtils.IsNull(tempEntity.Settings.Common.Tax.TIN)) { Entity.TIN = ''; } else { Entity.TIN = tempEntity.Settings.Common.Tax.TIN; } if (TrUtils.IsNull(tempEntity.Settings.Common.Tax.CIN)) { Entity.CIN = ''; } else { Entity.CIN = tempEntity.Settings.Common.Tax.CIN; } if (TrUtils.IsNull(tempEntity.Settings.Common.Tax.GST)) { Entity.GST = ''; } else { Entity.GST = tempEntity.Settings.Common.Tax.GST; } if (TrUtils.IsNull(tempEntity.Settings.Common.Tax.CST)) { Entity.CST = ''; } else { Entity.CST = tempEntity.Settings.Common.Tax.CST; } if (TrUtils.IsNull(tempEntity.Settings.Common.Tax.PAN)) { Entity.PAN = ''; } else { Entity.PAN = tempEntity.Settings.Common.Tax.PAN; } if (!TrUtils.IsNull(tempEntity.Phone2) && !TrUtils.IsNull(tempEntity.Phone2.No)) { Entity.Phone2 = tempEntity.Phone2.No; } else { Entity.Phone2 = ''; } Entity.CName = tempEntity.DName; Entity.TLine = tempEntity.TagLine; Entity.Adrs1 = tempEntity.Address.A1; Entity.Adrs2 = tempEntity.Address.A2; Entity.City = tempEntity.Address.Ct; Entity.State = tempEntity.Address.St; Entity.PIN = tempEntity.Address.Pin; let Email = this.GetEntityEmailDetails(tempEntity); if (!TrUtils.IsEmpty(Email)) { Entity.Email = Email; } Entity.Phone = this.GetEntityContactDetails(tempEntity); if (TrUtils.IsNull(tempEntity.Settings.Common.PrOptions)) { tempEntity.Settings.Common.PrOptions = {}; } // if (RecordType === "Work Order" || RecordType === "Estimate") { if (TrUtils.IsNull(tempEntity.Settings.Service)) { tempEntity.Settings.Service = {}; } if (TrUtils.IsNull(tempEntity.Settings.Service.PrMPN)) { tempEntity.Settings.Service.PrMPN = false; } Entity.MPN = tempEntity.Settings.Service.PrMPN; if (TrUtils.IsNull(tempEntity.Settings.Acc)) { tempEntity.Settings.Acc = {}; } if (TrUtils.IsNull(tempEntity.Settings.Acc.Round)) { tempEntity.Settings.Service.Round = false; } Entity.Round = tempEntity.Settings.Acc.Round; // }else{ // Entity.MPN = false; // } if (TrUtils.IsNull(tempEntity.Settings.Common.PrOptions.Header)) { tempEntity.Settings.Common.PrOptions.Header = 1; } if (TrUtils.IsNull(tempEntity.Settings.Common.PrOptions.Wmark)) { tempEntity.Settings.Common.PrOptions.Wmark = false; } if (TrUtils.IsNull(tempEntity.Settings.Common.PrOptions.Body)) { tempEntity.Settings.PrOptions.Body = 1; } Entity.Header = tempEntity.Settings.Common.PrOptions.Header; Entity.Wmark = tempEntity.Settings.Common.PrOptions.Wmark; Entity.PrLogo = tempEntity.Settings.Common.PrOptions.PrLogo; Entity.FootText = tempEntity.Settings.Common.PrOptions.FootText; Entity.Body = 3; if (RecordType === "Invoice") { Entity.Terms = TrUtils.IsEmpty(OriginalData.TC) ? EntityData.Entity.Settings.Acc.ITerms : OriginalData.TC; } else if (RecordType === "Work Order") { Entity.Terms = TrUtils.IsEmpty(OriginalData.TC) ? EntityData.Entity.Settings.Service.WTerms : OriginalData.TC; } else if (RecordType === "Estimate") { Entity.Terms = TrUtils.IsEmpty(OriginalData.TC) ? EntityData.Entity.Settings.Service.ETerms : OriginalData.TC; // Entity.Terms = "Estimate Terms"; } else if (RecordType === "SalesOrder") { Entity.Terms = TrUtils.IsEmpty(OriginalData.TC) ? "Sales Order Terms" : OriginalData.TC; } else if (RecordType === "Sales Estimate") { Entity.Terms = TrUtils.IsEmpty(OriginalData.TC) ? "Estimate Terms" : OriginalData.TC; } else { Entity.Terms = ""; } return Entity; } static GetEntityContactDetails(EntityInfo: any) { let Phone: string = ''; // console.log('EntityInfo', TrUtils.Stringify(EntityInfo)); if (!TrUtils.IsNull(EntityInfo.Phone1) && !TrUtils.IsNull(EntityInfo.Phone1.No)) { if (EntityInfo.Phone1.PrHead) { Phone += EntityInfo.Phone1.No; } } if (!TrUtils.IsNull(EntityInfo.Phone2) && !TrUtils.IsNull(EntityInfo.Phone2.No)) { if (EntityInfo.Phone2.PrHead) { Phone += ' , ' + EntityInfo.Phone2.No; } } if (!TrUtils.IsNull(EntityInfo.Phone3) && !TrUtils.IsNull(EntityInfo.Phone3.No)) { if (EntityInfo.Phone3.PrHead) { Phone += ' , ' + EntityInfo.Phone3.No; } } return Phone; } static GetEntityEmailDetails(EntityInfo: any) { let Email: string = ''; if (!TrUtils.IsEmpty(EntityInfo.EMail1) && !TrUtils.IsEmpty(EntityInfo.EMail1.Email)) { if (EntityInfo.EMail1.PrHead) { Email += EntityInfo.EMail1.Email; } } if (!TrUtils.IsEmpty(EntityInfo.EMail2) && !TrUtils.IsEmpty(EntityInfo.EMail2.Email)) { if (EntityInfo.EMail2.PrHead) { Email += ' , ' + EntityInfo.EMail2.Email; } } return Email; } static GetVehicleFromServiceAndFormatData(originalvehicledata: any) { let Vehicle: any = TrUtils.Stringify(originalvehicledata); let FormattedVehicleData = this.GetVehicleDataForPrint(Vehicle); return FormattedVehicleData; } static GetVehicleDataForPrint(vehicle: any) { let Vehicle: any = {}; Vehicle.RegNo = vehicle.RegNo; Vehicle.SNo = vehicle.SNo; Vehicle.Make = vehicle.Make; Vehicle.Model = vehicle.Model; Vehicle.Var = vehicle.Var; if (!TrUtils.IsNull(vehicle.VIN)) { Vehicle.VIN = vehicle.VIN; } else { Vehicle.VIN = ''; } if (!TrUtils.IsEmpty(vehicle.EngNo)) { Vehicle.EngNo = vehicle.EngNo; } else { Vehicle.EngNo = ''; } if (!TrUtils.IsEmpty(vehicle.DDate)) { Vehicle.DDate = MyDate.ConvertUTCDateToReadable(vehicle.DDate); } else { Vehicle.DDate = ''; } return Vehicle; } static GetCustomerFromServiceAndFormatData(originalcustomerdata: any) { let Customer: any = TrUtils.Stringify(originalcustomerdata); let FormattedCustData: any = this.GetCustomerDataForROEstPrint(Customer); return FormattedCustData; } static GetCustomerDataForROEstPrint(customer: any) { let Customer: any = { Name: customer.Sltn + ' ' + customer.Name, GSTIN: customer.GSTIN, TaxId: customer.TaxId, Ph: customer.Ph, Cons: [ { Type: 'M', No: customer.Ph } ], Adrs: this.GetAddress(customer.Adrs) } if (!TrUtils.IsNull(customer.Adrs)) { Customer.Pin = customer.Adrs.Pin; } return Customer; } static GetAddress(Address: any) { let Adrs: any[] = []; if (!TrUtils.IsNull(Address)) { if (!TrUtils.IsEmpty(Address.A1)) { Adrs.push(this.AddingComaAsaLastLetter(Address.A1)); } if (!TrUtils.IsEmpty(Address.A2)) { Adrs.push(this.AddingComaAsaLastLetter(Address.A2)); } if (!TrUtils.IsEmpty(Address.Ct)) { Adrs.push(this.AddingComaAsaLastLetter(Address.Ct)); } // if (!TrUtils.IsEmpty(Address.Pin)) { // Adrs.push(Address.Pin); // } } return Adrs; } static AddingComaAsaLastLetter(Stmt: string) { // console.log(Stmt, Stmt.slice(-1)); // console.log(Stmt.slice(-1) !== ','); if (!TrUtils.IsNull(Stmt) && Stmt.slice(-1) !== ',') { Stmt = Stmt + ', '; } else { Stmt = Stmt + ' '; } return Stmt; } static GetCustomerDataForTechnicianPrint(customer: any) { let Customer = { Name: customer.Sltn + ' ' + customer.Name, GSTIN: customer.GSTIN, Adrs: this.GetAddress(customer.Adrs) } return Customer; } static GetCGSTValueBasedOnTaxCode(TCode: any, argTaxCodes: any) { if (TrUtils.IsNull(TCode)) { return 0; } let TaxCodes: any = TrUtils.Stringify(argTaxCodes); let TCodeIndex: any = TaxCodes.findIndex((TaxCode: any) => { return TaxCode._id === Number(TCode); }); if (TCodeIndex !== -1) { if (TrUtils.IsNull(TaxCodes[TCodeIndex].CGST)) { return 0; } else { return TrUtils.FixedTo(TaxCodes[TCodeIndex].CGST); } } else { return 0; } } static GetSGSTValueBasedOnTaxCode(TCode: any, argTaxCodes: any) { if (TrUtils.IsNull(TCode)) { return 0; } let TaxCodes: any = TrUtils.Stringify(argTaxCodes); let TCodeIndex: any = TaxCodes.findIndex((TaxCode: any) => { return TaxCode._id === Number(TCode); }); if (TCodeIndex !== -1) { if (TrUtils.IsNull(TaxCodes[TCodeIndex].SGST)) { return 0; } else { return TrUtils.FixedTo(TaxCodes[TCodeIndex].SGST); } } else { return 0; } } static GetIGSTValueBasedOnTaxCode(TCode: any, argTaxCodes: any) { if (TrUtils.IsNull(TCode)) { return 0; } let TaxCodes: any = TrUtils.Stringify(argTaxCodes); let TCodeIndex: any = TaxCodes.findIndex((TaxCode: any) => { return TaxCode._id === Number(TCode); }); if (TCodeIndex !== -1) { if (TrUtils.IsNull(TaxCodes[TCodeIndex].IGST)) { return 0; } else { return TrUtils.FixedTo(TaxCodes[TCodeIndex].IGST); } } else { return 0; } } static CheckItemIndexWithDisc(RecordInfo: any) { let DiscItem: number = RecordInfo.PrintInfo.findIndex((PrintInfo: any) => { let LaborDiscItem: number = -1; if (!TrUtils.IsNull(PrintInfo.Ops)) { LaborDiscItem = PrintInfo.Ops.findIndex((Labor: any) => { if (!TrUtils.IsZero(Labor.Disc)) { return Labor; } }); } let PartDiscItem: number = -1; if (!TrUtils.IsNull(PrintInfo.Parts)) { PartDiscItem = PrintInfo.Parts.findIndex((Part: any) => { if (!TrUtils.IsZero(Part.Disc)) { return Part; } }); } else if (!TrUtils.IsNull(PrintInfo.Items)) { PartDiscItem = PrintInfo.Items.findIndex((Item: any) => { return !TrUtils.IsZero(Item.Disc); }); } if (LaborDiscItem !== -1 || PartDiscItem !== -1) { return PrintInfo; } }); return DiscItem; } static GetWithOutDiscountFieldHeader(permission: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ShowDiscountColumn: any) { if (Body === 2) { let headersNames: any = [{ text: 'Description', style: 'tableheader', Field: 'Desc' }, { text: 'Qty', style: 'tableheader', Field: 'QtyAndUoM' }, { text: 'Unit Price', style: 'tableheader', Field: 'UnPr', Field1: 'UnCo' }, { text: 'Labor Charges', style: 'tableheader', Field: 'Price' }, { text: 'Tax', style: 'tableheader', Field: 'TaxAmount' }, { text: 'Line Total', style: 'tableheader', Field: 'LineTotal' }]; if (permission) { let sno = { text: 'S.No.', style: 'tableheader', Field: 'SNo' }; let MPN = { text: 'Part No', style: 'tableheader', Field: 'MPN' }; headersNames.unshift(sno, MPN); } else { let sno = { text: 'S.No.', style: 'tableheader', Field: 'SNo' }; headersNames.unshift(sno); } return headersNames; } else { if (ShowTaxColumn) { return this.GetWithOutDiscountFieldHeader1(permission, Body, ShowIGST, ShowDiscountColumn); } else { return this.GetWithOutDiscountFieldHeader2(permission, Body, ShowDiscountColumn); } } } static GetWithOutDiscountFieldHeader1(permission: any, Body: any, ShowIGST: any, ShowDiscountColumn: any) { let headersNames: any; if (permission) { headersNames = [[{ text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }, { text: 'Part No', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }, { text: 'Description', rowSpan: 2, style: 'tableheader', alignment: 'center', lineHeight: 0.5 }, { text: 'HSN/SAC', rowSpan: 2, style: 'tableheader', lineHeight: 1 }, { text: 'Qty', style: 'tableheader', rowSpan: 2, lineHeight: 0.5 }, { text: 'Unit Price', style: 'tableheader', rowSpan: 2, lineHeight: 0.5, alignment: 'center', }, { text: 'Line Total', rowSpan: 2, lineHeight: 0.5, style: 'tabFleheader' } ], [{ text: '', Field: 'SNo', lineHeight: 0.5 }, { text: '', Field: 'MPN', lineHeight: 0.5 }, { text: '', Field: 'Desc', lineHeight: 0.5 }, { text: 'HSN/SAC', Field: 'HSN', lineHeight: 0.5 }, { text: '', Field: 'QtyAndUoM', lineHeight: 0.5 }, { text: 'Unit Price', Field: 'UnPr', Field1: 'UnCo', lineHeight: 0.5 }, { text: 'Line Total', Field: 'LineTotal', lineHeight: 0.5 } ] ]; let Count: number = 6; if (ShowDiscountColumn) { headersNames[0].splice(Count, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 }); headersNames[1].splice(Count + 1, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }); Count = 8; } if (ShowIGST) { headersNames[0].splice(Count, 0, { text: 'IGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'IGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'IGSTAmt', type: 'amount', lineHeight: 0.5 }); } else { headersNames[0].splice(Count, 0, { text: 'CGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'CGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'CGSTAmt', type: 'amount', lineHeight: 0.7 }); headersNames[0].splice(Count + 2, 0, { text: 'SGST/UTGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 3, 0, {}); headersNames[1].splice(Count + 2, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'SGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 3, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'SGSTAmt', type: 'amount', lineHeight: 0.5 }); } } else { headersNames = [[{ text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.6 }, { text: 'Description', rowSpan: 2, style: 'tableheader', alignment: 'center', lineHeight: 0.6 }, { text: 'HSN/SAC', rowSpan: 2, style: 'tableheader', lineHeight: 1 }, { text: 'Qty', style: 'tableheader', rowSpan: 2, lineHeight: 0.6 }, { text: 'Unit Price', style: 'tableheader', rowSpan: 2, alignment: 'center', lineHeight: 0.6 }, { text: 'Line Total', rowSpan: 2, style: 'tableheader', lineHeight: 0.6 } ], [{ text: '', Field: 'SNo', lineHeight: 0.5 }, { text: '', Field: 'Desc', lineHeight: 0.5 }, { text: 'HSN/SAC', Field: 'HSN', lineHeight: 0.5 }, { text: '', Field: 'QtyAndUoM', lineHeight: 0.5 }, { text: 'Unit Price', Field: 'UnPr', Field1: 'UnCo', lineHeight: 0.5 }, { text: 'Line Total', Field: 'LineTotal', lineHeight: 0.5 } ]]; let Count: number = 5; if (ShowDiscountColumn) { headersNames[0].splice(Count, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 }); headersNames[1].splice(Count + 1, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }); Count = 7; } if (ShowIGST) { headersNames[0].splice(Count, 0, { text: 'IGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'IGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'IGSTAmt', type: 'amount', lineHeight: 0.5 }); } else { headersNames[0].splice(Count, 0, { text: 'CGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'CGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'CGSTAmt', type: 'amount', lineHeight: 0.5 }); headersNames[0].splice(Count + 2, 0, { text: 'SGST/UTGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 3, 0, {}); headersNames[1].splice(Count + 2, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'SGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 3, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'SGSTAmt', type: 'amount', lineHeight: 0.5 }); } } return headersNames; } static GetWithOutDiscountFieldHeaderSharedInv(permission: any, Body: any, ShowDiscountColumn: any) { let headersNames: any = [[ { text: 'Description', style: 'tableheader', alignment: 'center', lineHeight: 0.5, Field: 'Desc' }, { text: 'HSN/SAC', Field: 'HSN', style: 'tableheader', lineHeight: 1 }, { text: 'Qty', style: 'tableheader', lineHeight: 0.5, Field: 'QtyAndUoM' }, { text: 'Unit Price', style: 'tableheader', lineHeight: 0.5, alignment: 'right', Field: 'Shared' }, { text: 'Taxable Amount', style: 'tableheader', lineHeight: 0.5, alignment: 'right', Field: 'UnPr', Field1: 'UnCo' }, { text: 'Tax Amount', style: 'tableheader', lineHeight: 0.5, alignment: 'right', Field: 'Tax' }, { text: 'Line Total', lineHeight: 0.5, style: 'tableheader', Field: 'LineTotal' } ]]; if (permission) { let sno = { text: 'S.No.', style: 'tableheader', lineHeight: 0.5, Field: 'SNo' }; let MPN = { text: 'Part No', style: 'tableheader', lineHeight: 0.5, Field: 'MPN' }; headersNames[0].unshift(sno, MPN); } else { let sno = { text: 'S.No.', style: 'tableheader', lineHeight: 0.5, Field: 'SNo' }; headersNames[0].unshift(sno); } return headersNames; } static GetWithOutDiscountFieldHeader2(permission: any, Body: any, ShowDiscountColumn: any) { let headersNames: any = [[ { text: 'Description', rowSpan: 2, style: 'tableheader', alignment: 'center', lineHeight: 0.5 }, { text: 'Qty', style: 'tableheader', rowSpan: 2, lineHeight: 0.5 }, { text: 'Unit Price', style: 'tableheader', rowSpan: 2, lineHeight: 0.5, alignment: 'right', }, { text: 'Line Total', rowSpan: 2, lineHeight: 0.5, style: 'tableheader' } ], [ { text: '', Field: 'Desc', lineHeight: 0.5 }, { text: '', Field: 'QtyAndUoM', lineHeight: 0.5 }, { text: 'Unit Price', Field: 'UnPr', Field1: 'UnCo', lineHeight: 0.5 }, { text: 'Line Total', Field: 'LineTotal', lineHeight: 0.5 } ]]; if (permission) { let sno = { text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }; let MPN = { text: 'Part No', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }; let sno1 = { text: '', Field: 'SNo', lineHeight: 0.5 }; let MPN1 = { text: '', Field: 'MPN', lineHeight: 0.5 }; headersNames[0].unshift(sno, MPN); headersNames[1].unshift(sno1, MPN1); if (ShowDiscountColumn) { headersNames[0].splice(5, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 }); headersNames[0].splice(6, 0, {}); headersNames[1].splice(5, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 }); headersNames[1].splice(6, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }); } } else { let sno = { text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }; let sno1 = { text: '', Field: 'SNo', lineHeight: 0.5 }; headersNames[0].unshift(sno); headersNames[1].unshift(sno1); if (ShowDiscountColumn) { headersNames[0].splice(4, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 }); headersNames[0].splice(5, 0, {}); headersNames[1].splice(4, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 }); headersNames[1].splice(5, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }); } } return headersNames; } static GetReceiptWithOutDiscountFieldHeader(permission: any, ShowTaxColumn: any, Body: any, ShowIGST: any, ShowDiscountColumn: any) { if (Body === 2) { let headersNames: any = [{ text: 'Description', style: 'tableheader', Field: 'Desc' }, { text: 'Qty', style: 'tableheader', Field: 'QtyAndUoM' }, { text: 'Unit Price', style: 'tableheader', Field: 'UnPr', Field1: 'UnCo' }, { text: 'Labor Charges', style: 'tableheader', Field: 'Price' }, { text: 'Tax', style: 'tableheader', Field: 'TaxAmount' }, { text: 'Line Total', style: 'tableheader', Field: 'LineTotal' }]; if (permission) { let sno = { text: 'S.No.', style: 'tableheader', Field: 'SNo' }; let MPN = { text: 'Part No', style: 'tableheader', Field: 'MPN' }; headersNames.unshift(sno, MPN); } else { let sno = { text: 'S.No.', style: 'tableheader', Field: 'SNo' }; headersNames.unshift(sno); } return headersNames; } else { if (ShowTaxColumn) { return this.GetReceiptWithOutDiscountFieldHeader1(permission, Body, ShowIGST, ShowDiscountColumn); } else { return this.GetReceiptWithOutDiscountFieldHeader2(permission, Body, ShowDiscountColumn); } } } static GetReceiptWithOutDiscountFieldHeader1(permission: any, Body: any, ShowIGST: any, ShowDiscountColumn: any) { let headersNames: any; if (permission) { headersNames = [[{ text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }, { text: 'Part No', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }, { text: 'Description', rowSpan: 2, style: 'tableheader', alignment: 'center', lineHeight: 0.5 }, { text: 'HSN/SAC', rowSpan: 2, style: 'tableheader', lineHeight: 1 }, { text: 'Batch', rowSpan: 2, style: 'tableheader', alignment: 'center', lineHeight: 0.5 }, { text: 'Exp.Date', 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: 'center', }, { text: 'Line Total', rowSpan: 2, lineHeight: 0.5, style: 'tabFleheader' } ], [{ text: '', Field: 'SNo', lineHeight: 0.5 }, { text: '', Field: 'MPN', lineHeight: 0.5 }, { text: '', Field: 'Desc', lineHeight: 0.5 }, { text: 'HSN/SAC', Field: 'HSN', lineHeight: 0.5 }, { text: '', lineHeight: 0.5, Field: 'Batch' }, { text: '', Field: 'ExDt', lineHeight: 0.5 }, { text: '', Field: 'QtyAndUoM', lineHeight: 0.5 }, { text: 'Unit Price', Field: 'UnPr', Field1: 'UnCo', lineHeight: 0.5 }, { text: 'Line Total', Field: 'LineTotal', lineHeight: 0.5 } ] ]; let Count: number = 8; if (ShowDiscountColumn) { headersNames[0].splice(Count, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 }); headersNames[1].splice(Count + 1, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }); Count = 10; } if (ShowIGST) { headersNames[0].splice(Count, 0, { text: 'IGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'IGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'IGSTAmt', type: 'amount', lineHeight: 0.5 }); } else { headersNames[0].splice(Count, 0, { text: 'CGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'CGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'CGSTAmt', type: 'amount', lineHeight: 0.7 }); headersNames[0].splice(Count + 2, 0, { text: 'SGST/UTGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 3, 0, {}); headersNames[1].splice(Count + 2, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'SGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 3, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'SGSTAmt', type: 'amount', lineHeight: 0.5 }); } } else { headersNames = [[{ text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.6 }, { text: 'Description', rowSpan: 2, style: 'tableheader', alignment: 'center', lineHeight: 0.6 }, { text: 'HSN/SAC', rowSpan: 2, style: 'tableheader', lineHeight: 1 }, { text: 'Qty', style: 'tableheader', rowSpan: 2, lineHeight: 0.6 }, { text: 'Unit Price', style: 'tableheader', rowSpan: 2, alignment: 'center', lineHeight: 0.6 }, { text: 'Line Total', rowSpan: 2, style: 'tableheader', lineHeight: 0.6 } ], [{ text: '', Field: 'SNo', lineHeight: 0.5 }, { text: '', Field: 'Desc', lineHeight: 0.5 }, { text: 'HSN/SAC', Field: 'HSN', lineHeight: 0.5 }, { text: '', Field: 'QtyAndUoM', lineHeight: 0.5 }, { text: 'Unit Price', Field: 'UnPr', Field1: 'UnCo', lineHeight: 0.5 }, { text: 'Line Total', Field: 'LineTotal', lineHeight: 0.5 } ]]; let Count: number = 7; if (ShowDiscountColumn) { headersNames[0].splice(Count, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 }); headersNames[1].splice(Count + 1, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }); Count = 9; } if (ShowIGST) { headersNames[0].splice(Count, 0, { text: 'IGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'IGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'IGSTAmt', type: 'amount', lineHeight: 0.5 }); } else { headersNames[0].splice(Count, 0, { text: 'CGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 1, 0, {}); headersNames[1].splice(Count, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'CGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 1, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'CGSTAmt', type: 'amount', lineHeight: 0.5 }); headersNames[0].splice(Count + 2, 0, { text: 'SGST/UTGST', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.8 }); headersNames[0].splice(Count + 3, 0, {}); headersNames[1].splice(Count + 2, 0, { text: 'Rate %', alignment: 'center', style: 'tableheader', Field: 'SGSTPerc', type: 'percentage', lineHeight: 0.8 }); headersNames[1].splice(Count + 3, 0, { text: 'Amount', alignment: 'center', style: 'tableheader', Field: 'SGSTAmt', type: 'amount', lineHeight: 0.5 }); } } return headersNames; } static GetReceiptWithOutDiscountFieldHeader2(permission: any, Body: any, ShowDiscountColumn: any) { let headersNames: any = [[ { text: 'Description', rowSpan: 2, style: 'tableheader', alignment: 'center', lineHeight: 0.5 }, { text: 'Qty', style: 'tableheader', rowSpan: 2, lineHeight: 0.5 }, { text: 'Unit Price', style: 'tableheader', rowSpan: 2, lineHeight: 0.5, alignment: 'right', }, { text: 'Line Total', rowSpan: 2, lineHeight: 0.5, style: 'tableheader' } ], [ { text: '', Field: 'Desc', lineHeight: 0.5 }, { text: '', Field: 'QtyAndUoM', lineHeight: 0.5 }, { text: 'Unit Price', Field: 'UnPr', Field1: 'UnCo', lineHeight: 0.5 }, { text: 'Line Total', Field: 'LineTotal', lineHeight: 0.5 } ]]; if (permission) { let sno = { text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }; let MPN = { text: 'Part No', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }; let sno1 = { text: '', Field: 'SNo', lineHeight: 0.5 }; let MPN1 = { text: '', Field: 'MPN', lineHeight: 0.5 }; headersNames[0].unshift(sno, MPN); headersNames[1].unshift(sno1, MPN1); if (ShowDiscountColumn) { headersNames[0].splice(5, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 }); headersNames[0].splice(6, 0, {}); headersNames[1].splice(5, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 }); headersNames[1].splice(6, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }); } } else { let sno = { text: 'S.No.', rowSpan: 2, style: 'tableheader', lineHeight: 0.5 }; let sno1 = { text: '', Field: 'SNo', lineHeight: 0.5 }; headersNames[0].unshift(sno); headersNames[1].unshift(sno1); if (ShowDiscountColumn) { headersNames[0].splice(4, 0, { text: 'Discount', style: 'tableheader', colSpan: 2, alignment: 'center', lineHeight: 0.5 }); headersNames[0].splice(5, 0, {}); headersNames[1].splice(4, 0, { text: '%', alignment: 'center', style: 'tableheader', Field: 'Perc', type: 'percentage', lineHeight: 0.5 }); headersNames[1].splice(5, 0, { text: 'Rs', alignment: 'center', style: 'tableheader', Field: 'Disc', type: 'amount', lineHeight: 0.5 }); } } return headersNames; } static TaxReceiptTableWidths(PrintPartNo: any, ShowIGST: any, ShowDiscountColumn: any) { // console.log(PrintPartNo, ShowIGST, ShowDiscountColumn); if (PrintPartNo) { if (ShowIGST) { if (ShowDiscountColumn) { return [24, 50, 160, 37, 50, 30, 25, 40, 17, 33, 17, 33, 45]; } else { return [24, 50, 222, 37, 25, 40, 17, 35, 51, 50, 50]; } } else { if (ShowDiscountColumn) { return [24, 45, 100, 35, 50, 30, 22, 40, 17, 34, 17, 32, 17, 32, 48,]; } else { return [20, 40, 90, 35, 50, 38, 22, 40, 17, 32, 17, 32, 36]; } } } else { if (ShowIGST) { if (ShowDiscountColumn) { return [24, 215, 40, 25, 40, 17, 35, 17, 35, 41, 50, 50]; } else { return [24, 270, 40, 25, 40, 20, 40, 50, 50, 50]; } } else { if (ShowDiscountColumn) { return [24, 155, 35, 22, 40, 17, 34, 17, 32, 17, 32, 45, 50, 50]; } else { return [24, 216, 35, 22, 40, 17, 32, 17, 32, 50, 50, 50]; } } } } static TaxTableWidths(PrintPartNo: any, ShowIGST: any, ShowDiscountColumn: any) { if (PrintPartNo) { if (ShowIGST) { if (ShowDiscountColumn) { return [24, 50, 158, 35, 25, 40, 17, 35, 17, 35, 45]; } else { return [24, 50, 222, 37, 25, 40, 17, 35, 51]; } } else { if (ShowDiscountColumn) { return [24, 45, 100, 35, 22, 40, 17, 34, 17, 32, 17, 32, 48]; } else { return [24, 50, 150, 40, 22, 40, 17, 32, 17, 32, 54]; } } } else { if (ShowIGST) { if (ShowDiscountColumn) { return [24, 215, 40, 25, 40, 17, 35, 17, 35, 41]; } else { return [24, 270, 40, 25, 40, 20, 40, 50]; } } else { if (ShowDiscountColumn) { return [24, '*', 40, 30, 40, 17, 34, 17, 35, 17, 35, 45]; } else { return [24, '*', 45, 30, 40, 17, 35, 17, 35, 50]; } } } } static WidthForInsuranceOrNot(ShowDiscountColumn: any, PrintPartNo: boolean) { if (PrintPartNo) { if (ShowDiscountColumn) { return [24, 70, 200, 25, 60, 38, 38, 50]; } else { return [25, 70, 250, 35, 60, 80]; } } else { if (ShowDiscountColumn) { return [25, 210, 40, 75, 40, 40, 80]; } else { return [25, 308, 52, 65, 80]; } } } static LayOutStyle1() { 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) { let color; if (i === 0 || i === node.table.body.length) { color = 'grey'; } else { if (i === 1 || i === 2) { color = 'gray'; } else { color = '#f8f8f8'; } } return color; }, vLineColor: function (i: any, node: any) { let color; if (i === 0 || i === node.table.widths.length) { color = 'grey'; } else { color = 'lightgrey'; } return color; }, }; } static LayOutStyle() { 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) { let color; if (i === 0 || i === node.table.body.length) { color = 'black'; } else { if (i === 1) { color = 'gray'; } else { color = 'lightgray'; } } return color; }, vLineColor: function (i: any, node: any) { let color; if (i === 0 || i === node.table.widths.length) { color = 'black'; } else { color = 'lightgray'; } return color; }, }; } static LayOutStyleanother() { return { hLineWidth: function (i: any, node: any) { return (i === 0 || i === 1 || i === 2 || 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 === node.table.body.length) ? 'black' : 'gray'; }, vLineColor: function (i: any, node: any) { return (i === 0 || i === node.table.widths.length) ? 'black' : 'gray'; } }; } }