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