@sachin9822/reports-lib 0.0.211 → 0.0.212

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.
Files changed (211) hide show
  1. package/karma.conf.js +44 -0
  2. package/ng-package.json +17 -0
  3. package/package.json +16 -31
  4. package/src/assets/images/BreadcrumbArrow.png +0 -0
  5. package/src/lib/assets/images/Search.svg +10 -0
  6. package/src/lib/assets/images/XMLogo.png +0 -0
  7. package/src/lib/components/acc-gl-details-enquiry-report/acc-gl-details-enquiry-report.component.html +27 -0
  8. package/src/lib/components/acc-gl-details-enquiry-report/acc-gl-details-enquiry-report.component.scss +46 -0
  9. package/src/lib/components/acc-gl-details-enquiry-report/acc-gl-details-enquiry-report.component.spec.ts +23 -0
  10. package/src/lib/components/acc-gl-details-enquiry-report/acc-gl-details-enquiry-report.component.ts +292 -0
  11. package/src/lib/components/accounting-report/accounting-report.component.html +64 -0
  12. package/src/lib/components/accounting-report/accounting-report.component.scss +24 -0
  13. package/src/lib/components/accounting-report/accounting-report.component.spec.ts +23 -0
  14. package/src/lib/components/accounting-report/accounting-report.component.ts +738 -0
  15. package/src/lib/components/branch-activity-receive-report/branch-activity-receive-report.component.html +46 -0
  16. package/src/lib/components/branch-activity-receive-report/branch-activity-receive-report.component.scss +2 -0
  17. package/src/lib/components/branch-activity-receive-report/branch-activity-receive-report.component.spec.ts +23 -0
  18. package/src/lib/components/branch-activity-receive-report/branch-activity-receive-report.component.ts +247 -0
  19. package/src/lib/components/branch-activity-send-report/branch-activity-send-report.component.html +46 -0
  20. package/src/lib/components/branch-activity-send-report/branch-activity-send-report.component.scss +3 -0
  21. package/src/lib/components/branch-activity-send-report/branch-activity-send-report.component.spec.ts +23 -0
  22. package/src/lib/components/branch-activity-send-report/branch-activity-send-report.component.ts +276 -0
  23. package/src/lib/components/branch-activity-send-summary-report/branch-activity-send-summary-report.component.html +51 -0
  24. package/src/lib/components/branch-activity-send-summary-report/branch-activity-send-summary-report.component.scss +7 -0
  25. package/src/lib/components/branch-activity-send-summary-report/branch-activity-send-summary-report.component.spec.ts +23 -0
  26. package/src/lib/components/branch-activity-send-summary-report/branch-activity-send-summary-report.component.ts +840 -0
  27. package/src/lib/components/cancellation-transaction-report/cancellation-transaction-report.component.html +68 -0
  28. package/src/lib/components/cancellation-transaction-report/cancellation-transaction-report.component.scss +65 -0
  29. package/src/lib/components/cancellation-transaction-report/cancellation-transaction-report.component.spec.ts +23 -0
  30. package/src/lib/components/cancellation-transaction-report/cancellation-transaction-report.component.ts +290 -0
  31. package/src/lib/components/credit-limit-status-enquiry-report/credit-limit-status-enquiry-report.component.html +25 -0
  32. package/src/lib/components/credit-limit-status-enquiry-report/credit-limit-status-enquiry-report.component.scss +1 -0
  33. package/src/lib/components/credit-limit-status-enquiry-report/credit-limit-status-enquiry-report.component.spec.ts +23 -0
  34. package/src/lib/components/credit-limit-status-enquiry-report/credit-limit-status-enquiry-report.component.ts +213 -0
  35. package/src/lib/components/funding-report/funding-report.component.html +49 -0
  36. package/src/lib/components/funding-report/funding-report.component.scss +1 -0
  37. package/src/lib/components/funding-report/funding-report.component.spec.ts +23 -0
  38. package/src/lib/components/funding-report/funding-report.component.ts +221 -0
  39. package/src/lib/components/revenue-per-transaction-report/revenue-per-transaction-report.component.html +26 -0
  40. package/src/lib/components/revenue-per-transaction-report/revenue-per-transaction-report.component.scss +1 -0
  41. package/src/lib/components/revenue-per-transaction-report/revenue-per-transaction-report.component.spec.ts +23 -0
  42. package/src/lib/components/revenue-per-transaction-report/revenue-per-transaction-report.component.ts +267 -0
  43. package/src/lib/components/statement-of-accounts-report/statement-of-accounts-report.component.html +95 -0
  44. package/src/lib/components/statement-of-accounts-report/statement-of-accounts-report.component.scss +54 -0
  45. package/src/lib/components/statement-of-accounts-report/statement-of-accounts-report.component.spec.ts +23 -0
  46. package/src/lib/components/statement-of-accounts-report/statement-of-accounts-report.component.ts +904 -0
  47. package/src/lib/components/transaction-enquiry-report/transaction-enquiry-report.component.html +49 -0
  48. package/src/lib/components/transaction-enquiry-report/transaction-enquiry-report.component.scss +2 -0
  49. package/src/lib/components/transaction-enquiry-report/transaction-enquiry-report.component.spec.ts +32 -0
  50. package/src/lib/components/transaction-enquiry-report/transaction-enquiry-report.component.ts +304 -0
  51. package/src/lib/components/transaction-monitoring-report/transaction-monitoring-report.component.html +46 -0
  52. package/src/lib/components/transaction-monitoring-report/transaction-monitoring-report.component.scss +7 -0
  53. package/src/lib/components/transaction-monitoring-report/transaction-monitoring-report.component.ts +343 -0
  54. package/src/lib/components/trial-balance-accounts-report/trial-balance-accounts-report.component.html +25 -0
  55. package/src/lib/components/trial-balance-accounts-report/trial-balance-accounts-report.component.scss +23 -0
  56. package/src/lib/components/trial-balance-accounts-report/trial-balance-accounts-report.component.spec.ts +23 -0
  57. package/src/lib/components/trial-balance-accounts-report/trial-balance-accounts-report.component.ts +745 -0
  58. package/src/lib/models/acc-gl-details-enquiry-report/accgl-details-enquiry-reportmodel.ts +10 -0
  59. package/src/lib/models/acc-gl-details-enquiry-report/journal-voucher-entry-model.ts +20 -0
  60. package/src/lib/models/accounting-report/accounting-report-branch-group.ts +7 -0
  61. package/src/lib/models/accounting-report/accounting-report-entry-model.ts +25 -0
  62. package/src/lib/models/accounting-report/accounting-report-model.ts +7 -0
  63. package/{lib/models/accounting-report/accounting-report-sub-group.d.ts → src/lib/models/accounting-report/accounting-report-sub-group.ts} +3 -2
  64. package/{lib/models/app-config.model.d.ts → src/lib/models/app-config.model.ts} +8 -7
  65. package/src/lib/models/branch-activity-receive-report/branch-activity-receive.model.ts +18 -0
  66. package/src/lib/models/branch-activity-report/branch-activity-send-report-request-domain-model.ts +16 -0
  67. package/src/lib/models/branch-activity-report/branch-activity-send-report.ts +26 -0
  68. package/src/lib/models/cancellation-transaction-report/cancellation-transaction.model.ts +65 -0
  69. package/src/lib/models/component-loading-states.ts +5 -0
  70. package/src/lib/models/credit-limit-status-enquiry-report/credit-limit-status-enquiry.model.ts +28 -0
  71. package/{lib/models/revenue-per-transaction-report/revenue-per-transaction.model.d.ts → src/lib/models/revenue-per-transaction-report/revenue-per-transaction.model.ts} +1 -1
  72. package/src/lib/models/statement-of-account-report/statement-of-accounts.model.ts +21 -0
  73. package/src/lib/models/transaction-enquiry-report/transaction-enquiry.model.ts +127 -0
  74. package/src/lib/models/transaction-monitoring-report/transaction-monitoring-report-request-domain-model.ts +16 -0
  75. package/src/lib/models/transaction-monitoring-report/transaction-monitoring-report.ts +29 -0
  76. package/src/lib/models/trial-balance-accounts-report/trial-balance-accounts.models.ts +46 -0
  77. package/src/lib/reports-lib-routing.module.ts +20 -0
  78. package/src/lib/reports-lib.component.spec.ts +23 -0
  79. package/src/lib/reports-lib.component.ts +20 -0
  80. package/src/lib/reports-lib.module.ts +102 -0
  81. package/src/lib/reports-lib.service.spec.ts +16 -0
  82. package/src/lib/reports-lib.service.ts +9 -0
  83. package/src/lib/services/config.service.ts +43 -0
  84. package/src/lib/services/report.service.spec.ts +16 -0
  85. package/src/lib/services/report.service.ts +463 -0
  86. package/src/lib/shared/export-generic.service.ts +557 -0
  87. package/src/lib/shared/export.service.spec.ts +16 -0
  88. package/src/lib/shared/export.service.ts +457 -0
  89. package/src/lib/shared/loader/loader.component.html +8 -0
  90. package/src/lib/shared/loader/loader.component.scss +52 -0
  91. package/src/lib/shared/loader/loader.component.ts +10 -0
  92. package/src/lib/shared/metadata/metadata.component.html +42 -0
  93. package/src/lib/shared/metadata/metadata.component.scss +95 -0
  94. package/src/lib/shared/metadata/metadata.component.spec.ts +23 -0
  95. package/src/lib/shared/metadata/metadata.component.ts +38 -0
  96. package/src/lib/shared/page-size-selector/page-size-selector.component.html +7 -0
  97. package/src/lib/shared/page-size-selector/page-size-selector.component.scss +42 -0
  98. package/src/lib/shared/page-size-selector/page-size-selector.component.spec.ts +23 -0
  99. package/src/lib/shared/page-size-selector/page-size-selector.component.ts +38 -0
  100. package/src/lib/shared/search-filter/search-filter.component.html +601 -0
  101. package/src/lib/shared/search-filter/search-filter.component.scss +203 -0
  102. package/src/lib/shared/search-filter/search-filter.component.spec.ts +23 -0
  103. package/src/lib/shared/search-filter/search-filter.component.ts +2387 -0
  104. package/src/lib/shared/shared.module.ts +13 -0
  105. package/{public-api.d.ts → src/public-api.ts} +17 -7
  106. package/src/styles/ag-grid-report-style.scss +71 -0
  107. package/src/styles/common-ag-grid-style.scss +146 -0
  108. package/src/styles/common-report-style.scss +395 -0
  109. package/src/styles/common-style.scss +615 -0
  110. package/src/test.ts +27 -0
  111. package/tsconfig.lib.json +15 -0
  112. package/tsconfig.lib.prod.json +10 -0
  113. package/tsconfig.spec.json +17 -0
  114. package/esm2020/lib/components/acc-gl-details-enquiry-report/acc-gl-details-enquiry-report.component.mjs +0 -240
  115. package/esm2020/lib/components/accounting-report/accounting-report.component.mjs +0 -596
  116. package/esm2020/lib/components/branch-activity-receive-report/branch-activity-receive-report.component.mjs +0 -218
  117. package/esm2020/lib/components/branch-activity-send-report/branch-activity-send-report.component.mjs +0 -243
  118. package/esm2020/lib/components/branch-activity-send-summary-report/branch-activity-send-summary-report.component.mjs +0 -700
  119. package/esm2020/lib/components/cancellation-transaction-report/cancellation-transaction-report.component.mjs +0 -255
  120. package/esm2020/lib/components/credit-limit-status-enquiry-report/credit-limit-status-enquiry-report.component.mjs +0 -192
  121. package/esm2020/lib/components/funding-report/funding-report.component.mjs +0 -198
  122. package/esm2020/lib/components/revenue-per-transaction-report/revenue-per-transaction-report.component.mjs +0 -244
  123. package/esm2020/lib/components/statement-of-accounts-report/statement-of-accounts-report.component.mjs +0 -776
  124. package/esm2020/lib/components/transaction-enquiry-report/transaction-enquiry-report.component.mjs +0 -266
  125. package/esm2020/lib/components/transaction-monitoring-report/transaction-monitoring-report.component.mjs +0 -311
  126. package/esm2020/lib/components/trial-balance-accounts-report/trial-balance-accounts-report.component.mjs +0 -631
  127. package/esm2020/lib/models/acc-gl-details-enquiry-report/accgl-details-enquiry-reportmodel.mjs +0 -2
  128. package/esm2020/lib/models/acc-gl-details-enquiry-report/journal-voucher-entry-model.mjs +0 -2
  129. package/esm2020/lib/models/accounting-report/accounting-report-branch-group.mjs +0 -2
  130. package/esm2020/lib/models/accounting-report/accounting-report-entry-model.mjs +0 -2
  131. package/esm2020/lib/models/accounting-report/accounting-report-model.mjs +0 -2
  132. package/esm2020/lib/models/accounting-report/accounting-report-sub-group.mjs +0 -2
  133. package/esm2020/lib/models/app-config.model.mjs +0 -2
  134. package/esm2020/lib/models/branch-activity-receive-report/branch-activity-receive.model.mjs +0 -2
  135. package/esm2020/lib/models/branch-activity-report/branch-activity-send-report-request-domain-model.mjs +0 -6
  136. package/esm2020/lib/models/branch-activity-report/branch-activity-send-report.mjs +0 -3
  137. package/esm2020/lib/models/cancellation-transaction-report/cancellation-transaction.model.mjs +0 -10
  138. package/esm2020/lib/models/component-loading-states.mjs +0 -7
  139. package/esm2020/lib/models/credit-limit-status-enquiry-report/credit-limit-status-enquiry.model.mjs +0 -5
  140. package/esm2020/lib/models/revenue-per-transaction-report/revenue-per-transaction.model.mjs +0 -2
  141. package/esm2020/lib/models/statement-of-account-report/statement-of-accounts.model.mjs +0 -2
  142. package/esm2020/lib/models/transaction-enquiry-report/transaction-enquiry.model.mjs +0 -8
  143. package/esm2020/lib/models/transaction-monitoring-report/transaction-monitoring-report-request-domain-model.mjs +0 -6
  144. package/esm2020/lib/models/transaction-monitoring-report/transaction-monitoring-report.mjs +0 -5
  145. package/esm2020/lib/models/trial-balance-accounts-report/trial-balance-accounts.models.mjs +0 -3
  146. package/esm2020/lib/reports-lib-routing.module.mjs +0 -24
  147. package/esm2020/lib/reports-lib.component.mjs +0 -22
  148. package/esm2020/lib/reports-lib.module.mjs +0 -172
  149. package/esm2020/lib/reports-lib.service.mjs +0 -14
  150. package/esm2020/lib/services/config.service.mjs +0 -39
  151. package/esm2020/lib/services/report.service.mjs +0 -374
  152. package/esm2020/lib/shared/export-generic.service.mjs +0 -443
  153. package/esm2020/lib/shared/export.service.mjs +0 -379
  154. package/esm2020/lib/shared/loader/loader.component.mjs +0 -11
  155. package/esm2020/lib/shared/metadata/metadata.component.mjs +0 -51
  156. package/esm2020/lib/shared/page-size-selector/page-size-selector.component.mjs +0 -44
  157. package/esm2020/lib/shared/search-filter/search-filter.component.mjs +0 -2134
  158. package/esm2020/lib/shared/shared.module.mjs +0 -21
  159. package/esm2020/public-api.mjs +0 -41
  160. package/esm2020/sachin9822-reports-lib.mjs +0 -5
  161. package/fesm2015/sachin9822-reports-lib.mjs +0 -8402
  162. package/fesm2015/sachin9822-reports-lib.mjs.map +0 -1
  163. package/fesm2020/sachin9822-reports-lib.mjs +0 -8384
  164. package/fesm2020/sachin9822-reports-lib.mjs.map +0 -1
  165. package/index.d.ts +0 -5
  166. package/lib/components/acc-gl-details-enquiry-report/acc-gl-details-enquiry-report.component.d.ts +0 -70
  167. package/lib/components/accounting-report/accounting-report.component.d.ts +0 -76
  168. package/lib/components/branch-activity-receive-report/branch-activity-receive-report.component.d.ts +0 -58
  169. package/lib/components/branch-activity-send-report/branch-activity-send-report.component.d.ts +0 -69
  170. package/lib/components/branch-activity-send-summary-report/branch-activity-send-summary-report.component.d.ts +0 -78
  171. package/lib/components/cancellation-transaction-report/cancellation-transaction-report.component.d.ts +0 -95
  172. package/lib/components/credit-limit-status-enquiry-report/credit-limit-status-enquiry-report.component.d.ts +0 -55
  173. package/lib/components/funding-report/funding-report.component.d.ts +0 -55
  174. package/lib/components/revenue-per-transaction-report/revenue-per-transaction-report.component.d.ts +0 -57
  175. package/lib/components/statement-of-accounts-report/statement-of-accounts-report.component.d.ts +0 -109
  176. package/lib/components/transaction-enquiry-report/transaction-enquiry-report.component.d.ts +0 -76
  177. package/lib/components/transaction-monitoring-report/transaction-monitoring-report.component.d.ts +0 -68
  178. package/lib/components/trial-balance-accounts-report/trial-balance-accounts-report.component.d.ts +0 -71
  179. package/lib/models/acc-gl-details-enquiry-report/accgl-details-enquiry-reportmodel.d.ts +0 -8
  180. package/lib/models/acc-gl-details-enquiry-report/journal-voucher-entry-model.d.ts +0 -18
  181. package/lib/models/accounting-report/accounting-report-branch-group.d.ts +0 -6
  182. package/lib/models/accounting-report/accounting-report-entry-model.d.ts +0 -24
  183. package/lib/models/accounting-report/accounting-report-model.d.ts +0 -6
  184. package/lib/models/branch-activity-receive-report/branch-activity-receive.model.d.ts +0 -18
  185. package/lib/models/branch-activity-report/branch-activity-send-report-request-domain-model.d.ts +0 -13
  186. package/lib/models/branch-activity-report/branch-activity-send-report.d.ts +0 -24
  187. package/lib/models/cancellation-transaction-report/cancellation-transaction.model.d.ts +0 -44
  188. package/lib/models/component-loading-states.d.ts +0 -5
  189. package/lib/models/credit-limit-status-enquiry-report/credit-limit-status-enquiry.model.d.ts +0 -26
  190. package/lib/models/statement-of-account-report/statement-of-accounts.model.d.ts +0 -18
  191. package/lib/models/transaction-enquiry-report/transaction-enquiry.model.d.ts +0 -113
  192. package/lib/models/transaction-monitoring-report/transaction-monitoring-report-request-domain-model.d.ts +0 -13
  193. package/lib/models/transaction-monitoring-report/transaction-monitoring-report.d.ts +0 -23
  194. package/lib/models/trial-balance-accounts-report/trial-balance-accounts.models.d.ts +0 -38
  195. package/lib/reports-lib-routing.module.d.ts +0 -7
  196. package/lib/reports-lib.component.d.ts +0 -8
  197. package/lib/reports-lib.module.d.ts +0 -33
  198. package/lib/reports-lib.service.d.ts +0 -6
  199. package/lib/services/config.service.d.ts +0 -20
  200. package/lib/services/report.service.d.ts +0 -80
  201. package/lib/shared/export-generic.service.d.ts +0 -50
  202. package/lib/shared/export.service.d.ts +0 -32
  203. package/lib/shared/loader/loader.component.d.ts +0 -5
  204. package/lib/shared/metadata/metadata.component.d.ts +0 -24
  205. package/lib/shared/page-size-selector/page-size-selector.component.d.ts +0 -15
  206. package/lib/shared/search-filter/search-filter.component.d.ts +0 -127
  207. package/lib/shared/shared.module.d.ts +0 -11
  208. /package/{lib → src}/assets/images/Search.svg +0 -0
  209. /package/{lib/assets/images/XMLogo.png → src/assets/images/XMCoral.png} +0 -0
  210. /package/{lib → src/lib}/assets/config/app-config.json +0 -0
  211. /package/{lib → src/lib}/assets/svg-loaders/blue-tail-spin.svg +0 -0
@@ -0,0 +1,457 @@
1
+ import { Injectable } from '@angular/core';
2
+ import jsPDF from 'jspdf';
3
+ import 'jspdf-autotable';
4
+ import * as ExcelJS from 'exceljs';
5
+ import * as FileSaver from 'file-saver';
6
+ import { formatDate } from '@angular/common';
7
+
8
+ declare module 'jspdf' {
9
+ interface jsPDF {
10
+ autoTable: (options: any) => jsPDF;
11
+ }
12
+ }
13
+
14
+ @Injectable({
15
+ providedIn: 'root'
16
+ })
17
+ export class ExportService {
18
+
19
+ private readonly pdfFontSize = 10;
20
+ private readonly pdfLineHeight = 7;
21
+ private readonly pdfLeftMargin = 15;
22
+ public logoBase64: string | undefined;
23
+
24
+ constructor() {
25
+ this.loadImageAsBase64('assets/reports-lib/assets/images/XMLogo.png').then(base64 => {
26
+ this.logoBase64 = base64;
27
+ });
28
+ }
29
+
30
+ // ------------------------ Utility ------------------------
31
+ private loadImageAsBase64(imagePath: string): Promise<string> {
32
+ return new Promise((resolve, reject) => {
33
+ const img = new Image();
34
+ img.crossOrigin = 'anonymous';
35
+ img.src = imagePath;
36
+
37
+ img.onload = () => {
38
+ const scale = 6;
39
+ const canvas = document.createElement('canvas');
40
+ canvas.width = img.width * scale;
41
+ canvas.height = img.height * scale;
42
+
43
+ const ctx = canvas.getContext('2d');
44
+ if (ctx) {
45
+ ctx.scale(scale, scale);
46
+ ctx.drawImage(img, 0, 0);
47
+ const base64 = canvas.toDataURL('image/png', 1.0); // 1.0 = highest quality
48
+ resolve(base64);
49
+ } else {
50
+ reject('Failed to get canvas context.');
51
+ }
52
+ };
53
+
54
+ img.onerror = () => reject('Failed to load image: ' + imagePath);
55
+ });
56
+ }
57
+
58
+ formatDate(value: any): string {
59
+ const date = new Date(value);
60
+ return isNaN(date.getTime()) ? '' :
61
+ `${date.getDate().toString().padStart(2, '0')}/${(date.getMonth() + 1).toString().padStart(2, '0')}/${date.getFullYear()}`;
62
+ }
63
+
64
+ formatDateTime(date: Date): string {
65
+ const day = date.getDate().toString().padStart(2, '0');
66
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
67
+ const year = date.getFullYear();
68
+
69
+ // 12-hour format
70
+ let hours = date.getHours();
71
+ const minutes = date.getMinutes().toString().padStart(2, '0');
72
+ const ampm = hours >= 12 ? 'PM' : 'AM';
73
+ hours = hours % 12;
74
+ hours = hours ? hours : 12; // the hour '0' should be '12'
75
+ const hoursStr = hours.toString().padStart(2, '0');
76
+
77
+ return `${day}/${month}/${year} ${hoursStr}:${minutes} ${ampm}`;
78
+ }
79
+
80
+ generateReportMetadata(metadata: [string, string][]): [string, string][] {
81
+ return metadata.filter(([_, value]) => value !== undefined && value !== null);
82
+ }
83
+
84
+ prepareExportTable(data: any[], columnDefs: any[], options: {
85
+ excludeFields?: string[],
86
+ currencyFields?: string[],
87
+ rateFields?: string[],
88
+ } = {}): { headers: string[], rows: any[][] } {
89
+ const { excludeFields = ['srno'], currencyFields = [], rateFields = [] } = options;
90
+
91
+ const filteredColumns = columnDefs.filter(col =>
92
+ col.field &&
93
+ !excludeFields.some(ex => col.field.toLowerCase().includes(ex)) &&
94
+ !excludeFields.some(ex => col.headerName?.toLowerCase().includes(ex))
95
+ );
96
+
97
+ const headers = ['Sr No', ...filteredColumns.map(col => col.headerName || col.field)];
98
+
99
+ const rows = data.map((row, index) => {
100
+ const rowData = filteredColumns.map(col => {
101
+ let value = row[col.field];
102
+ const fieldName = col.field?.toLowerCase() || '';
103
+
104
+ // Handle various date field names
105
+ if (fieldName.includes('transactiondateandtime') && value) {
106
+ value = formatDate(value, 'dd/MM/yyyy hh:mm a', 'en-US');
107
+ } else if ((fieldName.includes('date') || fieldName.includes('businessdate')) && value) {
108
+ // value = this.formatDate(value);
109
+ if (value instanceof Date || !/^\d{2}\/\d{2}\/\d{4}/.test(value)) {
110
+ value = this.formatDate(value);
111
+ }
112
+ }
113
+
114
+ // Format currency fields
115
+ if (currencyFields.includes(col.field) && value != null) {
116
+ value = parseFloat(value).toFixed(3);
117
+ }
118
+
119
+ if (rateFields.includes(col.field) && value != null) {
120
+ value = parseFloat(value).toFixed(8);
121
+ }
122
+
123
+ return value ?? '';
124
+ });
125
+ return [index + 1, ...rowData];
126
+ });
127
+ return { headers, rows };
128
+ }
129
+
130
+ // ------------------------ PDF Universal ------------------------
131
+ async exportToPdfUniversal(title: string, metadata: [string, string][], searchCriteria: [string, string][], headers: string[], rows: any[][], fileName: string): Promise<void> {
132
+ let doc;
133
+ doc = new jsPDF({ orientation: 'landscape', unit: 'mm', format: [400, 210] });
134
+
135
+ const logoWidth = 38.4, logoHeight = 17.5, logoX = 15, logoY = 10;
136
+ const pageWidth = doc.internal.pageSize.width;
137
+ const titleY = 18;
138
+ const marginLeft = 15;
139
+
140
+ if (this.logoBase64) {
141
+ doc.addImage(this.logoBase64, 'PNG', logoX, logoY, logoWidth, logoHeight);
142
+ }
143
+
144
+ doc.setFontSize(15);
145
+ doc.setFont('helvetica', 'bold');
146
+ doc.text(title, pageWidth / 2, titleY, { align: 'center' });
147
+
148
+ let currentY = titleY + 14;
149
+ doc.setFontSize(this.pdfFontSize);
150
+ metadata.forEach(([label, value], i) => {
151
+ const y = currentY + i * this.pdfLineHeight;
152
+ doc.setFont('helvetica', 'bold');
153
+ doc.text(label, this.pdfLeftMargin, y);
154
+ const labelWidth = doc.getTextWidth(label + ' ');
155
+ doc.setFont('helvetica', 'normal');
156
+ doc.text(value, this.pdfLeftMargin + labelWidth, y);
157
+ });
158
+ currentY += metadata.length * this.pdfLineHeight + 5;
159
+
160
+ // --- draw search criteria heading ---
161
+ doc.setFont('helvetica', 'bold');
162
+ doc.text('Search Criteria:-', marginLeft, currentY);
163
+ currentY += 8;
164
+
165
+ const rowHeightPerLine = 6;
166
+ const minGap = 2; // gap between key and value
167
+ const betweenColumnsGap = 15; // gap between left and right columns (you can tune this)
168
+ const pageContentWidth = doc.internal.pageSize.width - 2 * marginLeft;
169
+
170
+ // --- helper function to measure total width of a key-value pair ---
171
+ const measurePairWidth = (key: string, value: string): number => {
172
+ doc.setFont('helvetica', 'bold');
173
+ const keyWidth = doc.getTextWidth(key + ' ');
174
+ doc.setFont('helvetica', 'normal');
175
+ const valueWidth = doc.getTextWidth(value);
176
+ return keyWidth + minGap + valueWidth;
177
+ };
178
+
179
+ // --- calculate max width of left column pairs dynamically ---
180
+ let maxLeftPairWidth = 0;
181
+ for (let i = 0; i < searchCriteria.length; i += 2) {
182
+ if (searchCriteria[i]) {
183
+ const [key, value] = searchCriteria[i];
184
+ const width = measurePairWidth(key, value);
185
+ if (width > maxLeftPairWidth) maxLeftPairWidth = width;
186
+ }
187
+ }
188
+
189
+ // --- compute where right column should start ---
190
+ const leftColumnStart = marginLeft;
191
+ const rightColumnStart = leftColumnStart + maxLeftPairWidth + betweenColumnsGap;
192
+
193
+ // --- print search criteria dynamically ---
194
+ for (let i = 0; i < searchCriteria.length; i += 2) {
195
+ let maxLineCount = 1;
196
+
197
+ // Left column
198
+ if (searchCriteria[i]) {
199
+ const [key, value] = searchCriteria[i];
200
+ doc.setFont('helvetica', 'bold');
201
+ doc.text(key, leftColumnStart, currentY);
202
+
203
+ doc.setFont('helvetica', 'normal');
204
+ const keyWidth = doc.getTextWidth(key + ' ');
205
+ const valueX = leftColumnStart + keyWidth + minGap;
206
+ doc.text(value, valueX, currentY);
207
+ }
208
+
209
+ // Right column
210
+ if (searchCriteria[i + 1]) {
211
+ const [key, value] = searchCriteria[i + 1];
212
+ doc.setFont('helvetica', 'bold');
213
+ doc.text(key, rightColumnStart, currentY);
214
+
215
+ doc.setFont('helvetica', 'normal');
216
+ const keyWidth = doc.getTextWidth(key + ' ');
217
+ const valueX = rightColumnStart + keyWidth + minGap;
218
+ doc.text(value, valueX, currentY);
219
+ }
220
+
221
+ currentY += rowHeightPerLine;
222
+ }
223
+
224
+ const columnCount = headers.length;
225
+ const tableWidth = pageWidth - (this.pdfLeftMargin * 2);
226
+ const equalWidth = tableWidth / columnCount;
227
+
228
+ const columnStyles: { [key: number]: any } = {};
229
+ headers.forEach((_, i) => {
230
+ columnStyles[i] = { cellWidth: equalWidth };
231
+ });
232
+
233
+ doc.autoTable({
234
+ head: [headers],
235
+ body: rows,
236
+ startY: currentY,
237
+ theme: 'grid',
238
+ headStyles: {
239
+ fillColor: [220, 220, 220], textColor: 0,
240
+ fontStyle: 'bold', fontSize: 9, halign: 'center',
241
+ },
242
+ bodyStyles: { fontSize: 8, fillColor: [255, 255, 255], textColor: [0, 0, 0] },
243
+ styles: { cellPadding: 2, overflow: 'linebreak', minCellHeight: 6 },
244
+ columnStyles
245
+ });
246
+
247
+ const pageCount = doc.internal.getNumberOfPages();
248
+ for (let i = 1; i <= pageCount; i++) {
249
+ doc.setFont("helvetica", "bold");
250
+ doc.setPage(i);
251
+ doc.setFontSize(9);
252
+ doc.setTextColor(100);
253
+
254
+ const footerY = doc.internal.pageSize.height - 6;
255
+
256
+ doc.text(
257
+ `Page ${i} of ${pageCount}`,
258
+ pageWidth - 15,
259
+ footerY,
260
+ { align: 'right' }
261
+ );
262
+ }
263
+
264
+ doc.save(fileName);
265
+ }
266
+
267
+ // ------------------------ Excel Universal ------------------------
268
+ exportToExcelUniversal(title: string, metadata: [string, string][], searchCriteria: [string, string][], headers: string[], rows: any[][], fileName: string): void {
269
+ const workbook = new ExcelJS.Workbook();
270
+ const worksheet = workbook.addWorksheet(title);
271
+
272
+ let currentRow = 1;
273
+
274
+ // Add image if available
275
+ if (this.logoBase64) {
276
+ const base64Data = this.logoBase64.replace(/^data:image\/\w+;base64,/, '');
277
+ const imageId = workbook.addImage({
278
+ base64: base64Data,
279
+ extension: 'png',
280
+ });
281
+
282
+ // Place image at top-left (e.g., A1:C4)
283
+ worksheet.addImage(imageId, {
284
+ tl: { col: 0, row: 0 },
285
+ ext: { width: 145, height: 66 },
286
+ editAs: 'oneCell'
287
+ });
288
+ }
289
+
290
+ // Add title aligned in middle horizontally (merged across all columns)
291
+ const titleRow = worksheet.getRow(currentRow);
292
+ titleRow.getCell(4).value = title;
293
+ titleRow.getCell(4).font = { bold: true, size: 16 };
294
+ titleRow.getCell(4).alignment = { vertical: 'middle', horizontal: 'left' };
295
+
296
+ const titleMergeEnd = String.fromCharCode(64 + headers.length);
297
+ worksheet.mergeCells(`D${currentRow}:${titleMergeEnd}${currentRow}`);
298
+ currentRow += 3; // Move past image space
299
+
300
+ // Add metadata
301
+ metadata.forEach(([label, value]) => {
302
+ const row = worksheet.getRow(currentRow++);
303
+ const cell = row.getCell(1);
304
+ cell.value = {
305
+ richText: [
306
+ { text: `${label}: `, font: { bold: true } },
307
+ { text: value ?? '', font: { bold: false } }
308
+ ]
309
+ };
310
+ worksheet.mergeCells(`A${row.number}:${String.fromCharCode(64 + headers.length)}${row.number}`);
311
+ });
312
+
313
+ worksheet.addRow([]);
314
+ currentRow++;
315
+ //=========================================================
316
+ // --- search criteria heading ---
317
+ worksheet.mergeCells(currentRow, 1, currentRow, 6);
318
+ worksheet.getCell(currentRow, 1).value = 'Search Criteria:-';
319
+ worksheet.getCell(currentRow, 1).font = { bold: true };
320
+ currentRow += 2;
321
+
322
+ for (let i = 0; i < searchCriteria.length; i += 2) {
323
+ const left = searchCriteria[i];
324
+ const right = searchCriteria[i + 1]; // may be undefined
325
+ const row = worksheet.getRow(currentRow++);
326
+
327
+ // Left cell
328
+ worksheet.mergeCells(row.number, 1, row.number, 3);
329
+ row.getCell(1).value = {
330
+ richText: [
331
+ { text: (left?.[0] ?? '') + ' ', font: { bold: true } },
332
+ { text: left?.[1] ?? '' }
333
+ ]
334
+ };
335
+ row.getCell(1).alignment = { wrapText: true, vertical: 'middle' };
336
+
337
+ // Right cell (only if present)
338
+ if (right) {
339
+ worksheet.mergeCells(row.number, 4, row.number, 6);
340
+ row.getCell(4).value = {
341
+ richText: [
342
+ { text: (right?.[0] ?? '') + ' ', font: { bold: true } },
343
+ { text: right?.[1] ?? '' }
344
+ ]
345
+ };
346
+ row.getCell(4).alignment = { wrapText: true, vertical: 'middle' };
347
+ }
348
+ }
349
+ currentRow++;
350
+ //============================================================
351
+
352
+ // Add table header row
353
+ const headerRow = worksheet.getRow(currentRow++);
354
+ headers.forEach((header, i) => {
355
+ const cell = headerRow.getCell(i + 1);
356
+ cell.value = header;
357
+ cell.font = { bold: true };
358
+ cell.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'D9D9D9' } };
359
+ cell.alignment = { vertical: 'middle', horizontal: 'center' };
360
+ cell.border = {
361
+ top: { style: 'thin' },
362
+ bottom: { style: 'thin' },
363
+ left: { style: 'thin' },
364
+ right: { style: 'thin' }
365
+ };
366
+ });
367
+
368
+ const dataStartRow = currentRow;
369
+ rows.forEach(rowData => {
370
+ const row = worksheet.getRow(currentRow++);
371
+ rowData.forEach((value, i) => {
372
+ const cell = row.getCell(i + 1);
373
+ cell.value = value;
374
+ cell.border = {
375
+ top: { style: 'thin' },
376
+ bottom: { style: 'thin' },
377
+ left: { style: 'thin' },
378
+ right: { style: 'thin' }
379
+ };
380
+ });
381
+ });
382
+
383
+ // Auto column widths
384
+ for (let i = 1; i <= headers.length; i++) {
385
+ let maxLength = headers[i - 1].length;
386
+ for (let rowNum = dataStartRow; rowNum <= worksheet.lastRow!.number; rowNum++) {
387
+ const val = worksheet.getRow(rowNum).getCell(i).value?.toString() || '';
388
+ maxLength = Math.max(maxLength, val.length);
389
+ }
390
+ worksheet.getColumn(i).width = maxLength + 2;
391
+ }
392
+
393
+ workbook.xlsx.writeBuffer().then(buffer => {
394
+ const blob = new Blob([buffer], {
395
+ type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
396
+ });
397
+ FileSaver.saveAs(blob, fileName);
398
+ });
399
+ }
400
+
401
+
402
+ // ------------------------ CSV Universal ------------------------
403
+ exportToCsvUniversal(title: string, metadata: [string, string][], searchCriteria: [string, string][], headers: string[], rows: any[][], fileName: string): void {
404
+ const escapeCsv = (value: any) => {
405
+ if (value === null || value === undefined) return '';
406
+ const str = value.toString();
407
+ return str.includes(',') || str.includes('"') || str.includes('\n')
408
+ ? `"${str.replace(/"/g, '""')}"`
409
+ : str;
410
+ };
411
+
412
+ const metaRows = metadata.map(([k, v]) => [`${k} ${v}`]);
413
+
414
+ // --- Build search criteria section ---
415
+ const searchLines: string[] = [];
416
+ if (searchCriteria?.length) {
417
+ searchLines.push('Search Criteria:-');
418
+
419
+ const maxLeftLength = Math.max(...searchCriteria.map(([k, v]) => (k + ' ' + v).length));
420
+
421
+ for (let i = 0; i < searchCriteria.length; i += 2) {
422
+ const left = searchCriteria[i];
423
+ const right = searchCriteria[i + 1];
424
+
425
+ const leftText = left ? `${left[0]} ${left[1]}`.padEnd(maxLeftLength + 5, ' ') : '';
426
+ const rightText = right ? `${right[0]} ${right[1]}` : '';
427
+
428
+ searchLines.push(`"${leftText}${rightText}"`); // wrap in quotes for single CSV cell
429
+ }
430
+ searchLines.push(''); // blank line after criteria
431
+ }
432
+
433
+ // --- Combine all parts ---
434
+ const csvContent = [
435
+ [title].join(','),
436
+ ...metaRows.map(e => e.join(',')),
437
+ '',
438
+ ...searchLines, // ✅ this block is column-independent
439
+ headers.join(','),
440
+ ...rows.map(row => row.map(value => escapeCsv(value)).join(','))
441
+ ].join('\n');
442
+
443
+ this.downloadFile(csvContent, fileName, 'text/csv');
444
+ }
445
+
446
+ private downloadFile(data: string, filename: string, type: string): void {
447
+ const blob = new Blob([data], { type });
448
+ const link = document.createElement('a');
449
+ link.href = URL.createObjectURL(blob);
450
+ link.setAttribute('download', filename);
451
+ document.body.appendChild(link);
452
+ link.click();
453
+ document.body.removeChild(link);
454
+ }
455
+
456
+ }
457
+
@@ -0,0 +1,8 @@
1
+ <div class="loaderContainer">
2
+ <div class="loading">
3
+ <div class="loading-bar"></div>
4
+ <div class="loading-bar"></div>
5
+ <div class="loading-bar"></div>
6
+ <div class="loading-bar"></div>
7
+ </div>
8
+ </div>
@@ -0,0 +1,52 @@
1
+ $Grey: #8091a5;
2
+ .loaderContainer {
3
+ width: 100%;
4
+ height: 100%;
5
+ display: block;
6
+ position: absolute;
7
+ background: rgba(255, 255, 255, 0.75);
8
+ top: 0;
9
+ left: 0;
10
+ z-index: 10;
11
+ .loading {
12
+ position: absolute;
13
+ top: 50%;
14
+ left: 50%;
15
+ width: 30px;
16
+ .loading-bar {
17
+ display: inline-block;
18
+ width: 3px;
19
+ margin-right:2px;
20
+ height: 18px;
21
+ animation: loading 1s ease-in-out infinite;
22
+ &:nth-child(1) {
23
+ background-color: $Grey;
24
+ animation-delay: 0;
25
+ }
26
+ &:nth-child(2) {
27
+ background-color: $Grey;
28
+ animation-delay: 0.09s;
29
+ }
30
+ &:nth-child(3) {
31
+ background-color: $Grey;
32
+ animation-delay: 0.18s;
33
+ }
34
+ &:nth-child(4) {
35
+ background-color: $Grey;
36
+ animation-delay: 0.27s;
37
+ }
38
+ }
39
+ }
40
+ }
41
+
42
+ @keyframes loading {
43
+ 0% {
44
+ transform: scale(1);
45
+ }
46
+ 20% {
47
+ transform: scale(1, 2.2);
48
+ }
49
+ 40% {
50
+ transform: scale(1);
51
+ }
52
+ }
@@ -0,0 +1,10 @@
1
+ import { Component, Input } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'app-loader',
5
+ templateUrl: './loader.component.html',
6
+ styleUrls: ['./loader.component.scss']
7
+ })
8
+
9
+ export class LoaderComponent {
10
+ }
@@ -0,0 +1,42 @@
1
+ <section class="my-2">
2
+ <div class="title mb-3">
3
+ {{reportName}}
4
+ </div>
5
+ <div class="meta mb-2">
6
+ <div *ngIf="showmetaDataOne" class="data-holder">
7
+ <tbody>
8
+ <tr *ngFor="let item of metaDataOne | keyvalue:preserveOrder">
9
+ <td class="labl meta-td">{{item.key}}</td>
10
+ <td class="px-3 meta-td"><span class="info">: {{item.value}}</span></td>
11
+ </tr>
12
+ </tbody>
13
+ </div>
14
+ <div *ngIf="showmetaDataTwo" class="data-holder">
15
+ <tbody>
16
+ <tr *ngFor="let item of metaDataTwo | keyvalue:preserveOrder">
17
+ <td class="labl meta-td">{{item.key}}</td>
18
+ <td class="px-3 meta-td"><span class="info">: {{item.value}}</span></td>
19
+ </tr>
20
+ </tbody>
21
+ </div>
22
+ </div>
23
+ <div class="search-export">
24
+ <div class="searchBox">
25
+ <input type="text" [(ngModel)]="searchText" name="searchText" class="search-input"
26
+ (ngModelChange)="onSearch()" placeholder="Search..." autocomplete="off" />
27
+
28
+ <button type="button" class="btn btn-sm search-btn" (click)="onSearch()">
29
+ <img src="assets/images/Search.svg" alt="Search" class="search-icon" />
30
+ </button>
31
+ </div>
32
+
33
+ <div class="export">
34
+ <div class="exp-options">
35
+ <ng-select [items]="exportFormats" bindLabel="formatName" bindValue="code" placeholder="Select Format"
36
+ [(ngModel)]="selectedExportOption" [clearable]="false" class="export-selector" required>
37
+ </ng-select>
38
+ </div>
39
+ <button class="btn btn-report" (click)="handleExport()">Export</button>
40
+ </div>
41
+ </div>
42
+ </section>
@@ -0,0 +1,95 @@
1
+ .title {
2
+ text-align: center;
3
+ font-size: 18px;
4
+ font-weight: bold !important;
5
+ }
6
+
7
+ .meta{
8
+ position:relative;
9
+ display: flex;
10
+ justify-content: space-between;
11
+ align-items: center;
12
+ }
13
+
14
+ .labl {
15
+ font-size: 11.2px;
16
+ font-weight: bold !important;
17
+ }
18
+
19
+ .info {
20
+ font-size: 12px !important;
21
+ font-weight: 400;
22
+ padding-left: 0.5rem;
23
+ }
24
+ .meta-td{
25
+ padding: 0 !important;
26
+ }
27
+
28
+ .search-export{
29
+ position: relative;
30
+ display: flex;
31
+ justify-content: space-between;
32
+ }
33
+
34
+ .searchBox{
35
+ display: inline-flex;
36
+ }
37
+
38
+ .search-btn {
39
+ height: 32px;
40
+ width: 36px;
41
+ background-color: #8091a5;
42
+ border: none;
43
+ border-top-right-radius: 4px;
44
+ border-bottom-right-radius: 4px;
45
+ border-top-left-radius: 0;
46
+ border-bottom-left-radius: 0;
47
+ display: flex;
48
+ justify-content: center;
49
+ align-items: center;
50
+ }
51
+
52
+ .search-input {
53
+ outline: none !important;
54
+ border: 1px solid #ccc !important;
55
+ width: 190px;
56
+ height: 32px !important;
57
+ font-size: 0.75rem;
58
+ padding: 0.25rem 0.5rem;
59
+ border-top-left-radius: 4px;
60
+ border-bottom-left-radius: 4px;
61
+ border-top-right-radius: 0 !important;
62
+ border-bottom-right-radius: 0 !important;
63
+ text-transform: uppercase;
64
+ }
65
+ .search-input:focus{
66
+ box-shadow: 0 0 5px 3px rgba(24,119,242,1.000) !important;
67
+ }
68
+
69
+ .export{
70
+ display: flex;
71
+ }
72
+
73
+ .exp-options{
74
+ display: inline-flex;
75
+ font-size: 0.75rem;
76
+ height: 2rem !important;
77
+ width: 5rem !important;
78
+ }
79
+ :host ::ng-deep .exp-options .ng-select {
80
+ width: 100%;
81
+ }
82
+
83
+ .btn-report{
84
+ border-radius: 3px;
85
+ background-color: #8091a5;
86
+ color: #fff !important;
87
+ font-size: 14px !important;
88
+ height: 32px !important;
89
+ height: 32px;
90
+ min-width: 103px;
91
+ margin: 0 0 0 20px !important;
92
+ padding: 4px 15px !important;
93
+ }
94
+
95
+
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { MetadataComponent } from './metadata.component';
4
+
5
+ describe('MetadataComponent', () => {
6
+ let component: MetadataComponent;
7
+ let fixture: ComponentFixture<MetadataComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ MetadataComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(MetadataComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });