import { MyDate } from "../../utils/my-date"; import { TrUtils } from "../../utils/tr-utils"; export class AdjustmentDrugPDFService { static GetPrint(ReOrderPointData: any, DatesDetails: any) { // console.log('ReOrderPointData', ReOrderPointData); let dd: any = { // info: { // title: this.GetFileName(ROPrintData), // }, info: { title: 'Adjustment Items', }, header: function (currentPage: any, pageCount: any, pageSize: any) { return { text: currentPage.toString() + ' of ' + pageCount, alignment: 'right', marginRight: 25, fontSize: 8, marginTop: 2 }; }, pageMargins: [25, 15, 25, 15], pageSize: 'A4', content: [ { text: ReOrderPointData.Entity.CName, style: ['headerstyle'], alignment: 'center', fontSize: 20 }, { text: 'Adjustment Items ', style: ['headerstyle'], alignment: 'center', fontSize: 12 }, { columns: [ { text: 'Date : ' + MyDate.ConvertUTCDateToReadable(DatesDetails.AdjDate), style: ['headerstyle'], alignment: 'left', fontSize: 10 }, { text: 'Reason : ' + ReOrderPointData.Reason, style: ['headerstyle'], alignment: 'right', fontSize: 10 }, ] }, this.GetItemsTable(ReOrderPointData.Items, ReOrderPointData.Entity.DecimalsNumber), this.GetSignatures(ReOrderPointData.Entity.CName, ReOrderPointData.Type, ReOrderPointData.For), ], styles: { headerstyle: { fontFamily: 'Calibri', fontSize: 9 }, Sign: { fontSize: 8, margin: [0, 30, 0, 5] }, forCompany: { // margin: [0, 10, 30, 0], marginRight: 5, marginTop: 10, fontSize: 9, alignment: 'right' }, tableheader: { bold: true, fontFamily: 'Calibri', margin: [0, 1, 0, 5], alignment: 'center' }, tableheader1: { bold: true, fontFamily: 'Calibri', margin: [0, 2, 0, 2], alignment: 'center' }, tableExample: { fontSize: 9 } } }; return dd; } // static GetDate(DatesDetails: any, UserTimeZone: any) { // if (DatesDetails.Date === 'CustomRange') { // return MyDate.GetWeekAndDate(DatesDetails.StDate, UserTimeZone) + ' - ' + MyDate.GetWeekAndDate(DatesDetails.EnDate, UserTimeZone); // } else { // return 'till ' + MyDate.GetWeekAndDate(DatesDetails.EnDate, UserTimeZone); // } // } static CustomerAndVehicleDetailsAfterLine() { return { canvas: [ { type: 'line', lineColor: 'gray', x1: 0, y1: 0, x2: 575, y2: 0, lineWidth: 1 } ] }; } static GetSignatures(CName: any, For: any, Type: any) { return { columns: [{ stack: [ this.CompanyName(CName), ] }], }; } static CompanyName(CName: any) { return { style: 'forCompany', text: ['For ', { text: CName, }], }; } static GetItemsTable(Items: any, DecimalsNumber: number) { return { style: 'tableExample', marginTop: 3, marginBottom: 5, table: { widths: [25, '*', 80, 80], headerRows: 1, body: this.BuildTableBodyForLaborAndParts(Items, DecimalsNumber) }, layout: { hLineWidth: function (i: any, node: any) { return (i === 0 || i === 1 || i === node.table.body.length) ? 1 : 0.5; }, vLineWidth: function (i: any, node: any) { return (i === 0 || i === node.table.widths.length) ? 1 : 0.5; }, hLineColor: function (i: any, node: any) { return (i === 0 || i === 1 || i === node.table.body.length) ? 'gray' : 'lightgrey'; }, vLineColor: function (i: any, node: any) { return 'gray'; }, } }; } static BuildTableBodyForLaborAndParts(Items: any, DecimalsNumber: number) { let body: any = this.GetHeaderNames(); // let Total: number = 0; Items.forEach((item: any, index: any) => { // Total = Total + (TrUtils.SetValueToZeroIfNull(item.Batch.Qty) * TrUtils.SetValueToZeroIfNull(item.Batch.Cost)); let dataRow: any = []; dataRow.push({ text: index + 1, alignment: 'center' }); dataRow.push({ text: item.Name }); dataRow.push({ text: TrUtils.IsNull(item.Batch) ? '' : item.Batch.BN, alignment: 'left', style: ['headerstyle'], }); // dataRow.push({ text: MyDate.ConvertUTCDateToReadableExDateTxt(item.Batch.ExDt), alignment: 'center', style: ['headerstyle'], }); dataRow.push({ text: item.Qty, alignment: 'right', style: ['headerstyle'], }); // dataRow.push({ text: TrUtils.FixPriceValue(item.Batch.Cost, DecimalsNumber), alignment: 'right', style: ['headerstyle'], }); // dataRow.push({ text: TrUtils.FixPriceValue(multiply(item.Batch.Qty, item.Batch.Cost), DecimalsNumber), alignment: 'right', style: ['headerstyle'], }); body.push(dataRow); }); // let Row: any = [{ text: 'Total', alignment: 'right', colSpan: 5, bold: true, fontSize: 12 }, {}, {}, {}, {}, { text: TrUtils.FixPriceValue(Total, DecimalsNumber), fontSize: 12, alignment: 'right', bold: true }]; // body.push(Row); return body; } static GetHeaderNames() { let HeadingNames: any; HeadingNames = [[{ text: 'S.No', style: 'tableheader1', Field: 'SNo', alignment: 'center', line: true }, { text: 'Name', style: 'tableheader1', Field: 'Name', alignment: 'left', line: true }, { text: 'Batch No.', style: 'tableheader1', Field: 'BatchNo', alignment: 'left' }, // { text: 'Expiry Date', style: 'tableheader1', Field: 'ExDate', alignment: 'center' }, { text: 'Quantity Adjusted ', style: 'tableheader1', Field: 'Qty', alignment: 'right' }, // { text: 'Rate', style: 'tableheader1', Field: 'Rate', alignment: 'right' }, // { text: 'Value', style: 'tableheader1', Field: 'Value', alignment: 'right' }, ]]; return HeadingNames; } }