@sachin9822/reports-lib 0.0.82 → 0.0.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,10 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Injectable, Component, ErrorHandler, NgModule } from '@angular/core';
3
+ import { __awaiter } from 'tslib';
3
4
  import * as i6 from '@angular/common';
4
5
  import { formatDate, CommonModule } from '@angular/common';
5
- import jsPDF from 'jspdf';
6
6
  import 'jspdf-autotable';
7
+ import jsPDF from 'jspdf';
7
8
  import * as ExcelJS from 'exceljs';
8
9
  import * as FileSaver from 'file-saver';
9
10
  import { throwError } from 'rxjs';
@@ -53,76 +54,203 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
53
54
  }], ctorParameters: function () { return []; } });
54
55
 
55
56
  class ExportService {
56
- constructor() { }
57
- exportToPdf(headers, rows, doc, startY, fileName) {
58
- const columnStyles = {};
59
- headers.forEach((_, i) => {
60
- columnStyles[i] = { cellWidth: 'auto' };
57
+ constructor() {
58
+ this.pdfFontSize = 10;
59
+ this.pdfLineHeight = 7;
60
+ this.pdfLeftMargin = 15;
61
+ this.loadImageAsBase64('assets/images/XMLogo.png').then(base64 => {
62
+ this.logoBase64 = base64;
61
63
  });
62
- doc.autoTable({
63
- head: [headers],
64
- body: rows,
65
- startY: startY,
66
- theme: 'grid',
67
- headStyles: {
68
- fillColor: [220, 220, 220],
69
- textColor: 0,
70
- fontStyle: 'bold',
71
- fontSize: 9,
72
- halign: 'center',
73
- },
74
- bodyStyles: {
75
- fontSize: 8,
76
- fillColor: [255, 255, 255],
77
- textColor: [0, 0, 0],
78
- },
79
- styles: {
80
- cellPadding: 2,
81
- overflow: 'linebreak',
82
- minCellHeight: 6,
83
- },
84
- columnStyles: columnStyles,
64
+ }
65
+ // ------------------------ Utility ------------------------
66
+ loadImageAsBase64(imagePath) {
67
+ return new Promise((resolve, reject) => {
68
+ const img = new Image();
69
+ img.crossOrigin = 'anonymous';
70
+ img.src = imagePath;
71
+ img.onload = () => {
72
+ const scale = 6;
73
+ const canvas = document.createElement('canvas');
74
+ canvas.width = img.width * scale;
75
+ canvas.height = img.height * scale;
76
+ const ctx = canvas.getContext('2d');
77
+ if (ctx) {
78
+ ctx.scale(scale, scale);
79
+ ctx.drawImage(img, 0, 0);
80
+ const base64 = canvas.toDataURL('image/png', 1.0); // 1.0 = highest quality
81
+ resolve(base64);
82
+ }
83
+ else {
84
+ reject('Failed to get canvas context.');
85
+ }
86
+ };
87
+ img.onerror = () => reject('Failed to load image: ' + imagePath);
85
88
  });
86
- doc.save(fileName);
87
89
  }
88
- exportToExcel(headers, rows, worksheet, workbook, fileName) {
89
- var _a, _b;
90
- // Add header row
91
- const headerRow = worksheet.addRow(headers);
92
- headerRow.font = { bold: true };
93
- headerRow.fill = {
94
- type: 'pattern',
95
- pattern: 'solid',
96
- fgColor: { argb: 'D9D9D9' }
97
- };
98
- headerRow.alignment = { vertical: 'middle', horizontal: 'center' };
99
- headerRow.border = {
100
- top: { style: 'thin' }, bottom: { style: 'thin' },
101
- left: { style: 'thin' }, right: { style: 'thin' }
102
- };
103
- const dataStartRow = worksheet.lastRow.number + 1;
104
- // Add data rows
105
- rows.forEach(rowData => {
106
- const dataRow = worksheet.addRow(rowData);
107
- dataRow.border = {
108
- top: { style: 'thin' }, bottom: { style: 'thin' },
109
- left: { style: 'thin' }, right: { style: 'thin' }
90
+ formatDate(value) {
91
+ const date = new Date(value);
92
+ return isNaN(date.getTime()) ? '' :
93
+ `${date.getDate().toString().padStart(2, '0')}/${(date.getMonth() + 1).toString().padStart(2, '0')}/${date.getFullYear()}`;
94
+ }
95
+ formatDateTime(date) {
96
+ return `${date.getDate().toString().padStart(2, '0')}/` +
97
+ `${(date.getMonth() + 1).toString().padStart(2, '0')}/` +
98
+ `${date.getFullYear()} ` +
99
+ `${date.getHours().toString().padStart(2, '0')}:` +
100
+ `${date.getMinutes().toString().padStart(2, '0')}`;
101
+ }
102
+ generateReportMetadata(metadata) {
103
+ return metadata.filter(([_, value]) => value !== undefined && value !== null);
104
+ }
105
+ prepareExportTable(data, columnDefs, options = {}) {
106
+ const { excludeFields = ['srno', 'serial', 'action'], currencyFields = [] } = options;
107
+ const filteredColumns = columnDefs.filter(col => col.field &&
108
+ !excludeFields.some(ex => col.field.toLowerCase().includes(ex)) &&
109
+ !excludeFields.some(ex => { var _a; return (_a = col.headerName) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(ex); }));
110
+ const headers = ['Sr No', ...filteredColumns.map(col => col.headerName || col.field)];
111
+ const rows = data.map((row, index) => {
112
+ const rowData = filteredColumns.map(col => {
113
+ var _a;
114
+ let value = row[col.field];
115
+ const fieldName = ((_a = col.field) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || '';
116
+ // Handle various date field names
117
+ if ((fieldName.includes('date') ||
118
+ fieldName.includes('businessdate')) &&
119
+ value) {
120
+ value = this.formatDate(value);
121
+ }
122
+ // Format currency fields
123
+ if (currencyFields.includes(col.field) && value != null) {
124
+ value = parseFloat(value).toFixed(3);
125
+ }
126
+ return value !== null && value !== void 0 ? value : '';
127
+ });
128
+ return [index + 1, ...rowData];
129
+ });
130
+ return { headers, rows };
131
+ }
132
+ // ------------------------ PDF Universal ------------------------
133
+ exportToPdfUniversal(title, metadata, headers, rows, fileName) {
134
+ return __awaiter(this, void 0, void 0, function* () {
135
+ const doc = new jsPDF({ orientation: 'landscape', unit: 'mm', format: [400, 210] });
136
+ const logoWidth = 38.4, logoHeight = 17.5, logoX = 15, logoY = 10;
137
+ const pageWidth = doc.internal.pageSize.width;
138
+ const titleY = 18;
139
+ if (this.logoBase64) {
140
+ doc.addImage(this.logoBase64, 'PNG', logoX, logoY, logoWidth, logoHeight);
141
+ }
142
+ doc.setFontSize(15);
143
+ doc.setFont('helvetica', 'bold');
144
+ doc.text(title, pageWidth / 2, titleY, { align: 'center' });
145
+ let currentY = titleY + 14;
146
+ doc.setFontSize(this.pdfFontSize);
147
+ metadata.forEach(([label, value], i) => {
148
+ const y = currentY + i * this.pdfLineHeight;
149
+ doc.setFont('helvetica', 'bold');
150
+ doc.text(label, this.pdfLeftMargin, y);
151
+ const labelWidth = doc.getTextWidth(label + ' ');
152
+ doc.setFont('helvetica', 'normal');
153
+ doc.text(value, this.pdfLeftMargin + labelWidth, y);
154
+ });
155
+ currentY += metadata.length * this.pdfLineHeight + 5;
156
+ const columnStyles = {};
157
+ headers.forEach((_, i) => columnStyles[i] = { cellWidth: 'auto' });
158
+ doc.autoTable({
159
+ head: [headers],
160
+ body: rows,
161
+ startY: currentY,
162
+ theme: 'grid',
163
+ headStyles: {
164
+ fillColor: [220, 220, 220], textColor: 0,
165
+ fontStyle: 'bold', fontSize: 9, halign: 'center',
166
+ },
167
+ bodyStyles: { fontSize: 8, fillColor: [255, 255, 255], textColor: [0, 0, 0] },
168
+ styles: { cellPadding: 2, overflow: 'linebreak', minCellHeight: 6 },
169
+ columnStyles
170
+ });
171
+ doc.save(fileName);
172
+ });
173
+ }
174
+ // ------------------------ Excel Universal ------------------------
175
+ exportToExcelUniversal(title, metadata, headers, rows, fileName) {
176
+ var _a;
177
+ const workbook = new ExcelJS.Workbook();
178
+ const worksheet = workbook.addWorksheet(title);
179
+ let currentRow = 1;
180
+ // Add image if available
181
+ if (this.logoBase64) {
182
+ const base64Data = this.logoBase64.replace(/^data:image\/\w+;base64,/, '');
183
+ const imageId = workbook.addImage({
184
+ base64: base64Data,
185
+ extension: 'png',
186
+ });
187
+ // Place image at top-left (e.g., A1:C4)
188
+ worksheet.addImage(imageId, {
189
+ tl: { col: 0, row: 0 },
190
+ ext: { width: 145, height: 66 },
191
+ editAs: 'oneCell'
192
+ });
193
+ }
194
+ // Add title aligned in middle horizontally (merged across all columns)
195
+ const titleRow = worksheet.getRow(currentRow);
196
+ titleRow.getCell(4).value = title;
197
+ titleRow.getCell(4).font = { bold: true, size: 16 };
198
+ titleRow.getCell(4).alignment = { vertical: 'middle', horizontal: 'left' };
199
+ const titleMergeEnd = String.fromCharCode(64 + headers.length);
200
+ worksheet.mergeCells(`D${currentRow}:${titleMergeEnd}${currentRow}`);
201
+ currentRow += 3; // Move past image space
202
+ // Add metadata
203
+ metadata.forEach(([label, value]) => {
204
+ const row = worksheet.getRow(currentRow++);
205
+ const cell = row.getCell(1);
206
+ cell.value = {
207
+ richText: [
208
+ { text: `${label}: `, font: { bold: true } },
209
+ { text: value !== null && value !== void 0 ? value : '', font: { bold: false } }
210
+ ]
211
+ };
212
+ worksheet.mergeCells(`A${row.number}:${String.fromCharCode(64 + headers.length)}${row.number}`);
213
+ });
214
+ worksheet.addRow([]);
215
+ currentRow++;
216
+ // Add table header row
217
+ const headerRow = worksheet.getRow(currentRow++);
218
+ headers.forEach((header, i) => {
219
+ const cell = headerRow.getCell(i + 1);
220
+ cell.value = header;
221
+ cell.font = { bold: true };
222
+ cell.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'D9D9D9' } };
223
+ cell.alignment = { vertical: 'middle', horizontal: 'center' };
224
+ cell.border = {
225
+ top: { style: 'thin' },
226
+ bottom: { style: 'thin' },
227
+ left: { style: 'thin' },
228
+ right: { style: 'thin' }
110
229
  };
111
230
  });
112
- const totalColumns = headers.length;
113
- // Auto-width for each column
114
- for (let i = 1; i <= totalColumns; i++) {
115
- let maxLength = 5;
116
- const headerVal = (_b = (_a = headerRow.getCell(i).value) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '';
117
- maxLength = Math.max(maxLength, headerVal.length);
231
+ const dataStartRow = currentRow;
232
+ rows.forEach(rowData => {
233
+ const row = worksheet.getRow(currentRow++);
234
+ rowData.forEach((value, i) => {
235
+ const cell = row.getCell(i + 1);
236
+ cell.value = value;
237
+ cell.border = {
238
+ top: { style: 'thin' },
239
+ bottom: { style: 'thin' },
240
+ left: { style: 'thin' },
241
+ right: { style: 'thin' }
242
+ };
243
+ });
244
+ });
245
+ // Auto column widths
246
+ for (let i = 1; i <= headers.length; i++) {
247
+ let maxLength = headers[i - 1].length;
118
248
  for (let rowNum = dataStartRow; rowNum <= worksheet.lastRow.number; rowNum++) {
119
- const cell = worksheet.getRow(rowNum).getCell(i);
120
- const val = cell.value ? cell.value.toString() : '';
249
+ const val = ((_a = worksheet.getRow(rowNum).getCell(i).value) === null || _a === void 0 ? void 0 : _a.toString()) || '';
121
250
  maxLength = Math.max(maxLength, val.length);
122
251
  }
123
252
  worksheet.getColumn(i).width = maxLength + 2;
124
253
  }
125
- // Export as Excel file
126
254
  workbook.xlsx.writeBuffer().then(buffer => {
127
255
  const blob = new Blob([buffer], {
128
256
  type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
@@ -130,11 +258,16 @@ class ExportService {
130
258
  FileSaver.saveAs(blob, fileName);
131
259
  });
132
260
  }
133
- exportToCsv(headers, rows, metadata = [], fileName) {
134
- // Combine metadata + blank line + headers + data
135
- const csvContent = [...metadata, [], headers, ...rows]
136
- .map(e => e.join(','))
137
- .join('\n');
261
+ // ------------------------ CSV Universal ------------------------
262
+ exportToCsvUniversal(title, metadata, headers, rows, fileName) {
263
+ const metaRows = metadata.map(([k, v]) => [`${k}: ${v}`]);
264
+ const csvContent = [
265
+ [title],
266
+ ...metaRows,
267
+ [],
268
+ headers,
269
+ ...rows.map(row => row.map(value => `"${value}"`))
270
+ ].map(e => e.join(',')).join('\n');
138
271
  this.downloadFile(csvContent, fileName, 'text/csv');
139
272
  }
140
273
  downloadFile(data, filename, type) {
@@ -161,13 +294,11 @@ class ReportService {
161
294
  this.http = http;
162
295
  this.errorHandler = errorHandler;
163
296
  this.injector = injector;
164
- this.systemReportUrl = '/api/v1/CompanyConfiguration/SystemReports';
165
297
  this.serviceUrl = "https://4xplus-local.xpressmoney.tech:8752";
166
- this.AccGlDetailsEnquiryReportUrl = "/api/v1/Report/AccGlDetailsEnquiryReport";
167
298
  }
168
299
  getAccGLDetailsReport(formattedDate, dateType, sysCompanyCode, sysUserId, companyName) {
169
300
  if (formattedDate) {
170
- const apiPath = `${this.serviceUrl}${this.AccGlDetailsEnquiryReportUrl}/GetAccGLFDetailsEnquiryReport/${formattedDate}/${dateType}/${sysCompanyCode}/${sysUserId}/${companyName}`;
301
+ const apiPath = `${this.serviceUrl}/api/v1/Report/AccGlDetailsEnquiryReport/GetAccGLFDetailsEnquiryReport/${formattedDate}/${dateType}/${sysCompanyCode}/${sysUserId}/${companyName}`;
171
302
  return this.http.get(apiPath);
172
303
  }
173
304
  else {
@@ -366,162 +497,55 @@ class AccGlDetailsEnquiryReportComponent {
366
497
  alert('Please select an export format.');
367
498
  }
368
499
  }
369
- // call common exports methods from export service
370
500
  exportToPdf() {
371
- if (!this.accGlDetailsEnquiryReportModel.journalVoucherEntries.length)
372
- return;
373
- const doc = new jsPDF({
374
- orientation: 'landscape',
375
- unit: 'mm',
376
- format: [400, 210]
377
- });
378
- const pageWidth = doc.internal.pageSize.width;
379
- const title = `${this.companyName} - General Ledger Account Details Enquiry`;
380
- doc.setFontSize(15);
381
- doc.setFont('helvetica', 'bold');
382
- doc.text(title, 15, 15);
383
- const infoY = 25;
384
- const leftMargin = 15;
385
- const lineHeight = 7;
386
- const infoLines = [
387
- [`Report User:`, this.reportUser],
388
- [`Report Time:`, this.reportTime],
389
- [`Search Criteria`, ''],
390
- [`${this.dateType == 'VD' ? 'Value Date' : 'Posting Date'}:`, this.currentReportFormattedDate],
391
- ];
392
- doc.setFontSize(10);
393
- infoLines.forEach(([label, value], i) => {
394
- const y = infoY + i * lineHeight;
395
- if (label === 'Search Criteria') {
396
- doc.setFont('helvetica', 'bold');
397
- doc.text(label, leftMargin, y);
398
- const textWidth = doc.getTextWidth(label);
399
- doc.setDrawColor(0);
400
- doc.setLineWidth(0.5);
401
- doc.line(leftMargin, y + 1, leftMargin + textWidth, y + 1);
402
- }
403
- else {
404
- doc.setFont('helvetica', 'bold');
405
- doc.text(label, leftMargin, y);
406
- const labelWidth = doc.getTextWidth(label + ' ');
407
- doc.setFont('helvetica', 'normal');
408
- doc.text(value, leftMargin + labelWidth, y);
409
- }
410
- });
411
- // Table headers and rows
412
- const filteredColumns = this.columnDefs.filter(col => {
413
- var _a, _b, _c;
414
- return !(((_a = col.headerName) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('sr. no')) ||
415
- ((_b = col.field) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes('srno')) ||
416
- ((_c = col.field) === null || _c === void 0 ? void 0 : _c.toLowerCase().includes('serial')));
417
- });
418
- const headers = ['Sr No', ...filteredColumns.map(col => col.headerName || col.field)];
419
- const rows = this.accGlDetailsEnquiryReportModel.journalVoucherEntries.map((row, index) => {
420
- const rowData = filteredColumns.map(col => {
421
- let value = row[col.field];
422
- if (col.field && col.field.toLowerCase().includes('date') && value) {
423
- value = this.formatDate({ value });
424
- }
425
- return value !== null && value !== void 0 ? value : '';
501
+ var _a;
502
+ return __awaiter(this, void 0, void 0, function* () {
503
+ if (!((_a = this.accGlDetailsEnquiryReportModel.journalVoucherEntries) === null || _a === void 0 ? void 0 : _a.length))
504
+ return;
505
+ const title = `${this.companyName} - General Ledger Account Details Enquiry`;
506
+ const metadata = this.exportService.generateReportMetadata([
507
+ ['Report User : ', this.reportUser],
508
+ ['Report Time : ', this.reportTime],
509
+ ['Search Criteria', ' - '],
510
+ [`${this.dateType == 'VD' ? 'Value Date' : 'Posting Date'}:`, this.currentReportFormattedDate]
511
+ ]);
512
+ const { headers, rows } = this.exportService.prepareExportTable(this.accGlDetailsEnquiryReportModel.journalVoucherEntries, this.columnDefs, {
513
+ currencyFields: ['localCredit', 'forexCredit', 'localDebit', 'forexDebit']
426
514
  });
427
- return [index + 1, ...rowData];
515
+ yield this.exportService.exportToPdfUniversal(title, metadata, headers, rows, 'ACC-GL-Details-Enquiry-Report.pdf');
428
516
  });
429
- const startY = infoY + infoLines.length * lineHeight + 5;
430
- const fileName = 'ACC-GL-Details-Enquiry-Report.pdf';
431
- // Call reusable service
432
- this.exportService.exportToPdf(headers, rows, doc, startY, fileName);
433
517
  }
434
518
  exportToExcel() {
435
- const data = this.accGlDetailsEnquiryReportModel.journalVoucherEntries;
436
- if (!data.length)
519
+ var _a;
520
+ if (!((_a = this.accGlDetailsEnquiryReportModel.journalVoucherEntries) === null || _a === void 0 ? void 0 : _a.length))
437
521
  return;
438
- const workbook = new ExcelJS.Workbook();
439
- const worksheet = workbook.addWorksheet('ACC-GL-Details-Enquiry-Report');
440
- const filteredColumnDefs = this.columnDefs.filter(col => { var _a, _b; return !(((_a = col.headerName) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('sr. no')) || ((_b = col.field) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes('sr. no'))); });
441
- const totalColumns = filteredColumnDefs.length + 1;
442
- // Title
443
- const titleRow = worksheet.addRow([`${this.companyName} - General Ledger Account Details Enquiry`]);
444
- titleRow.font = { bold: true, size: 14 };
445
- worksheet.mergeCells(`A${titleRow.number}:${String.fromCharCode(64 + totalColumns)}${titleRow.number}`);
446
- worksheet.addRow([]);
447
- // Metadata
448
- const meta = [
522
+ const title = `${this.companyName} - General Ledger Account Details Enquiry`;
523
+ const metadata = this.exportService.generateReportMetadata([
449
524
  ['Report User', this.reportUser],
450
525
  ['Report Time', this.reportTime],
451
- ['Search Criteria', ''],
452
- [`${this.dateType === 'VD' ? 'Value Date' : 'Posting Date'}`, this.currentReportFormattedDate]
453
- ];
454
- meta.forEach(([label, value]) => {
455
- const row = worksheet.addRow([]);
456
- const cell = row.getCell(1);
457
- const isSearchCriteria = label.toLowerCase().includes('search criteria');
458
- cell.value = {
459
- richText: [
460
- {
461
- text: `${label}: `,
462
- font: {
463
- bold: true,
464
- underline: isSearchCriteria ? true : undefined
465
- }
466
- },
467
- {
468
- text: value !== null && value !== void 0 ? value : '',
469
- font: { bold: false }
470
- }
471
- ]
472
- };
473
- worksheet.mergeCells(`A${row.number}:${String.fromCharCode(64 + totalColumns)}${row.number}`);
474
- });
475
- worksheet.addRow([]);
476
- // Prepare headers and rows
477
- const headers = ['Sr. No.', ...filteredColumnDefs.map(col => col.headerName || col.field)];
478
- const rows = data.map((row, index) => {
479
- const rowData = filteredColumnDefs.map(col => {
480
- var _a;
481
- let value = row[col.field];
482
- if (((_a = col.field) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('date')) && value) {
483
- value = this.formatDate({ value });
484
- }
485
- return value !== null && value !== void 0 ? value : '';
486
- });
487
- rowData.unshift(index + 1);
488
- return rowData;
526
+ ['Search Criteria', ' - '],
527
+ [`${this.dateType == 'VD' ? 'Value Date' : 'Posting Date'}`, this.currentReportFormattedDate]
528
+ ]);
529
+ const { headers, rows } = this.exportService.prepareExportTable(this.accGlDetailsEnquiryReportModel.journalVoucherEntries, this.columnDefs, {
530
+ currencyFields: ['localCredit', 'forexCredit', 'localDebit', 'forexDebit']
489
531
  });
490
- const fileName = 'ACC-GL-Details-Enquiry-Report.xlsx';
491
- // Call reusable service
492
- this.exportService.exportToExcel(headers, rows, worksheet, workbook, fileName);
532
+ this.exportService.exportToExcelUniversal(title, metadata, headers, rows, 'ACC-GL-Details-Enquiry-Report.xlsx');
493
533
  }
494
534
  exportToCsv() {
495
- if (!this.accGlDetailsEnquiryReportModel.journalVoucherEntries.length)
496
- return;
497
- let metadata;
498
- try {
499
- metadata = [
500
- ['Report Title', `${this.companyName} - General Ledger Account Details Enquiry`],
501
- ['Report User', this.reportUser],
502
- ['Report Time', this.reportTime],
503
- [`Search Criteria - ${this.dateType == 'VD' ? 'Value Date' : 'Posting Date'}`, this.currentReportFormattedDate]
504
- ];
505
- }
506
- catch (err) {
507
- window.alert(`Error while binding data: ${err}`);
535
+ var _a;
536
+ if (!((_a = this.accGlDetailsEnquiryReportModel.journalVoucherEntries) === null || _a === void 0 ? void 0 : _a.length))
508
537
  return;
509
- }
510
- const filteredColumnDefs = this.columnDefs.filter(col => { var _a, _b; return !(((_a = col.headerName) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('sr. no')) || ((_b = col.field) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes('sr. no'))); });
511
- const headers = ['Sr No', ...filteredColumnDefs.map(col => col.headerName || col.field)];
512
- const rows = this.accGlDetailsEnquiryReportModel.journalVoucherEntries.map((row, index) => {
513
- const rowData = filteredColumnDefs.map(col => {
514
- var _a;
515
- let value = row[col.field];
516
- if (((_a = col.field) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('date')) && value) {
517
- value = this.formatDate({ value });
518
- }
519
- return (value !== null && value !== void 0 ? value : '').toString();
520
- });
521
- return [(index + 1).toString(), ...rowData];
538
+ const title = `${this.companyName} - General Ledger Account Details Enquiry`;
539
+ const metadata = this.exportService.generateReportMetadata([
540
+ ['Report User', this.reportUser],
541
+ ['Report Time', this.reportTime],
542
+ ['Search Criteria', '- '],
543
+ [`${this.dateType == 'VD' ? 'Value Date' : 'Posting Date'}`, this.currentReportFormattedDate]
544
+ ]);
545
+ const { headers, rows } = this.exportService.prepareExportTable(this.accGlDetailsEnquiryReportModel.journalVoucherEntries, this.columnDefs, {
546
+ currencyFields: ['localCredit', 'forexCredit', 'localDebit', 'forexDebit']
522
547
  });
523
- const fileName = 'ACC-GL-Details-Enquiry-Report.csv';
524
- this.exportService.exportToCsv(headers, rows, metadata, fileName);
548
+ this.exportService.exportToCsvUniversal(title, metadata, headers, rows, 'ACC-GL-Details-Enquiry-Report.csv');
525
549
  }
526
550
  }
527
551
  AccGlDetailsEnquiryReportComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AccGlDetailsEnquiryReportComponent, deps: [{ token: ExportService }, { token: ReportService }, { token: i1.HttpClient }, { token: i4.DomSanitizer }, { token: i0.ErrorHandler }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component });