@sachin9822/reports-lib 0.0.213 → 0.0.215

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/esm2020/lib/components/acc-gl-details-enquiry-report/acc-gl-details-enquiry-report.component.mjs +240 -0
  2. package/esm2020/lib/components/accounting-report/accounting-report.component.mjs +614 -0
  3. package/esm2020/lib/components/branch-activity-receive-report/branch-activity-receive-report.component.mjs +218 -0
  4. package/esm2020/lib/components/branch-activity-send-report/branch-activity-send-report.component.mjs +263 -0
  5. package/esm2020/lib/components/branch-activity-send-summary-report/branch-activity-send-summary-report.component.mjs +718 -0
  6. package/esm2020/lib/components/cancellation-transaction-report/cancellation-transaction-report.component.mjs +275 -0
  7. package/esm2020/lib/components/credit-limit-status-enquiry-report/credit-limit-status-enquiry-report.component.mjs +192 -0
  8. package/esm2020/lib/components/funding-report/funding-report.component.mjs +198 -0
  9. package/esm2020/lib/components/revenue-per-transaction-report/revenue-per-transaction-report.component.mjs +244 -0
  10. package/esm2020/lib/components/statement-of-accounts-report/statement-of-accounts-report.component.mjs +776 -0
  11. package/esm2020/lib/components/transaction-enquiry-report/transaction-enquiry-report.component.mjs +282 -0
  12. package/esm2020/lib/components/transaction-monitoring-report/transaction-monitoring-report.component.mjs +332 -0
  13. package/esm2020/lib/components/trial-balance-accounts-report/trial-balance-accounts-report.component.mjs +631 -0
  14. package/esm2020/lib/models/acc-gl-details-enquiry-report/accgl-details-enquiry-reportmodel.mjs +2 -0
  15. package/esm2020/lib/models/acc-gl-details-enquiry-report/journal-voucher-entry-model.mjs +2 -0
  16. package/esm2020/lib/models/accounting-report/accounting-report-branch-group.mjs +2 -0
  17. package/esm2020/lib/models/accounting-report/accounting-report-entry-model.mjs +2 -0
  18. package/esm2020/lib/models/accounting-report/accounting-report-model.mjs +2 -0
  19. package/esm2020/lib/models/accounting-report/accounting-report-sub-group.mjs +2 -0
  20. package/esm2020/lib/models/app-config.model.mjs +2 -0
  21. package/esm2020/lib/models/branch-activity-receive-report/branch-activity-receive.model.mjs +2 -0
  22. package/esm2020/lib/models/branch-activity-report/branch-activity-send-report-request-domain-model.mjs +6 -0
  23. package/esm2020/lib/models/branch-activity-report/branch-activity-send-report.mjs +3 -0
  24. package/esm2020/lib/models/cancellation-transaction-report/cancellation-transaction.model.mjs +10 -0
  25. package/esm2020/lib/models/component-loading-states.mjs +7 -0
  26. package/esm2020/lib/models/credit-limit-status-enquiry-report/credit-limit-status-enquiry.model.mjs +5 -0
  27. package/esm2020/lib/models/revenue-per-transaction-report/revenue-per-transaction.model.mjs +2 -0
  28. package/esm2020/lib/models/statement-of-account-report/statement-of-accounts.model.mjs +2 -0
  29. package/esm2020/lib/models/transaction-enquiry-report/transaction-enquiry.model.mjs +8 -0
  30. package/esm2020/lib/models/transaction-monitoring-report/transaction-monitoring-report-request-domain-model.mjs +6 -0
  31. package/esm2020/lib/models/transaction-monitoring-report/transaction-monitoring-report.mjs +5 -0
  32. package/esm2020/lib/models/trial-balance-accounts-report/trial-balance-accounts.models.mjs +3 -0
  33. package/esm2020/lib/reports-lib-routing.module.mjs +24 -0
  34. package/esm2020/lib/reports-lib.component.mjs +22 -0
  35. package/esm2020/lib/reports-lib.module.mjs +172 -0
  36. package/esm2020/lib/reports-lib.service.mjs +14 -0
  37. package/esm2020/lib/services/config.service.mjs +39 -0
  38. package/esm2020/lib/services/report.service.mjs +374 -0
  39. package/esm2020/lib/shared/export-generic.service.mjs +443 -0
  40. package/esm2020/lib/shared/export.service.mjs +379 -0
  41. package/esm2020/lib/shared/loader/loader.component.mjs +11 -0
  42. package/esm2020/lib/shared/metadata/metadata.component.mjs +51 -0
  43. package/esm2020/lib/shared/page-size-selector/page-size-selector.component.mjs +44 -0
  44. package/esm2020/lib/shared/search-filter/search-filter.component.mjs +2147 -0
  45. package/esm2020/lib/shared/shared.module.mjs +21 -0
  46. package/esm2020/public-api.mjs +41 -0
  47. package/esm2020/sachin9822-reports-lib.mjs +5 -0
  48. package/fesm2015/sachin9822-reports-lib.mjs +8649 -0
  49. package/fesm2015/sachin9822-reports-lib.mjs.map +1 -0
  50. package/fesm2020/sachin9822-reports-lib.mjs +8510 -0
  51. package/fesm2020/sachin9822-reports-lib.mjs.map +1 -0
  52. package/index.d.ts +5 -0
  53. package/lib/components/acc-gl-details-enquiry-report/acc-gl-details-enquiry-report.component.d.ts +70 -0
  54. package/lib/components/accounting-report/accounting-report.component.d.ts +76 -0
  55. package/lib/components/branch-activity-receive-report/branch-activity-receive-report.component.d.ts +58 -0
  56. package/lib/components/branch-activity-send-report/branch-activity-send-report.component.d.ts +69 -0
  57. package/lib/components/branch-activity-send-summary-report/branch-activity-send-summary-report.component.d.ts +78 -0
  58. package/lib/components/cancellation-transaction-report/cancellation-transaction-report.component.d.ts +108 -0
  59. package/lib/components/credit-limit-status-enquiry-report/credit-limit-status-enquiry-report.component.d.ts +55 -0
  60. package/lib/components/funding-report/funding-report.component.d.ts +55 -0
  61. package/lib/components/revenue-per-transaction-report/revenue-per-transaction-report.component.d.ts +57 -0
  62. package/lib/components/statement-of-accounts-report/statement-of-accounts-report.component.d.ts +109 -0
  63. package/lib/components/transaction-enquiry-report/transaction-enquiry-report.component.d.ts +76 -0
  64. package/lib/components/transaction-monitoring-report/transaction-monitoring-report.component.d.ts +69 -0
  65. package/lib/components/trial-balance-accounts-report/trial-balance-accounts-report.component.d.ts +71 -0
  66. package/lib/models/acc-gl-details-enquiry-report/accgl-details-enquiry-reportmodel.d.ts +8 -0
  67. package/lib/models/acc-gl-details-enquiry-report/journal-voucher-entry-model.d.ts +18 -0
  68. package/lib/models/accounting-report/accounting-report-branch-group.d.ts +6 -0
  69. package/lib/models/accounting-report/accounting-report-entry-model.d.ts +24 -0
  70. package/lib/models/accounting-report/accounting-report-model.d.ts +6 -0
  71. package/{src/lib/models/accounting-report/accounting-report-sub-group.ts → lib/models/accounting-report/accounting-report-sub-group.d.ts} +2 -3
  72. package/{src/lib/models/app-config.model.ts → lib/models/app-config.model.d.ts} +7 -8
  73. package/lib/models/branch-activity-receive-report/branch-activity-receive.model.d.ts +18 -0
  74. package/lib/models/branch-activity-report/branch-activity-send-report-request-domain-model.d.ts +13 -0
  75. package/lib/models/branch-activity-report/branch-activity-send-report.d.ts +24 -0
  76. package/lib/models/cancellation-transaction-report/cancellation-transaction.model.d.ts +44 -0
  77. package/lib/models/component-loading-states.d.ts +5 -0
  78. package/lib/models/credit-limit-status-enquiry-report/credit-limit-status-enquiry.model.d.ts +26 -0
  79. package/{src/lib/models/revenue-per-transaction-report/revenue-per-transaction.model.ts → lib/models/revenue-per-transaction-report/revenue-per-transaction.model.d.ts} +1 -1
  80. package/lib/models/statement-of-account-report/statement-of-accounts.model.d.ts +18 -0
  81. package/lib/models/transaction-enquiry-report/transaction-enquiry.model.d.ts +113 -0
  82. package/lib/models/transaction-monitoring-report/transaction-monitoring-report-request-domain-model.d.ts +13 -0
  83. package/lib/models/transaction-monitoring-report/transaction-monitoring-report.d.ts +23 -0
  84. package/lib/models/trial-balance-accounts-report/trial-balance-accounts.models.d.ts +38 -0
  85. package/lib/reports-lib-routing.module.d.ts +7 -0
  86. package/lib/reports-lib.component.d.ts +8 -0
  87. package/lib/reports-lib.module.d.ts +33 -0
  88. package/lib/reports-lib.service.d.ts +6 -0
  89. package/lib/services/config.service.d.ts +20 -0
  90. package/lib/services/report.service.d.ts +80 -0
  91. package/lib/shared/export-generic.service.d.ts +50 -0
  92. package/lib/shared/export.service.d.ts +32 -0
  93. package/lib/shared/loader/loader.component.d.ts +5 -0
  94. package/lib/shared/metadata/metadata.component.d.ts +24 -0
  95. package/lib/shared/page-size-selector/page-size-selector.component.d.ts +15 -0
  96. package/lib/shared/search-filter/search-filter.component.d.ts +127 -0
  97. package/lib/shared/shared.module.d.ts +11 -0
  98. package/package.json +31 -16
  99. package/{src/public-api.ts → public-api.d.ts} +7 -17
  100. package/karma.conf.js +0 -44
  101. package/ng-package.json +0 -17
  102. package/src/assets/images/BreadcrumbArrow.png +0 -0
  103. package/src/assets/images/XMCoral.png +0 -0
  104. package/src/lib/assets/images/Search.svg +0 -10
  105. package/src/lib/components/acc-gl-details-enquiry-report/acc-gl-details-enquiry-report.component.html +0 -27
  106. package/src/lib/components/acc-gl-details-enquiry-report/acc-gl-details-enquiry-report.component.scss +0 -46
  107. package/src/lib/components/acc-gl-details-enquiry-report/acc-gl-details-enquiry-report.component.spec.ts +0 -23
  108. package/src/lib/components/acc-gl-details-enquiry-report/acc-gl-details-enquiry-report.component.ts +0 -292
  109. package/src/lib/components/accounting-report/accounting-report.component.html +0 -64
  110. package/src/lib/components/accounting-report/accounting-report.component.scss +0 -24
  111. package/src/lib/components/accounting-report/accounting-report.component.spec.ts +0 -23
  112. package/src/lib/components/accounting-report/accounting-report.component.ts +0 -738
  113. package/src/lib/components/branch-activity-receive-report/branch-activity-receive-report.component.html +0 -46
  114. package/src/lib/components/branch-activity-receive-report/branch-activity-receive-report.component.scss +0 -2
  115. package/src/lib/components/branch-activity-receive-report/branch-activity-receive-report.component.spec.ts +0 -23
  116. package/src/lib/components/branch-activity-receive-report/branch-activity-receive-report.component.ts +0 -247
  117. package/src/lib/components/branch-activity-send-report/branch-activity-send-report.component.html +0 -46
  118. package/src/lib/components/branch-activity-send-report/branch-activity-send-report.component.scss +0 -3
  119. package/src/lib/components/branch-activity-send-report/branch-activity-send-report.component.spec.ts +0 -23
  120. package/src/lib/components/branch-activity-send-report/branch-activity-send-report.component.ts +0 -276
  121. package/src/lib/components/branch-activity-send-summary-report/branch-activity-send-summary-report.component.html +0 -51
  122. package/src/lib/components/branch-activity-send-summary-report/branch-activity-send-summary-report.component.scss +0 -7
  123. package/src/lib/components/branch-activity-send-summary-report/branch-activity-send-summary-report.component.spec.ts +0 -23
  124. package/src/lib/components/branch-activity-send-summary-report/branch-activity-send-summary-report.component.ts +0 -840
  125. package/src/lib/components/cancellation-transaction-report/cancellation-transaction-report.component.html +0 -68
  126. package/src/lib/components/cancellation-transaction-report/cancellation-transaction-report.component.scss +0 -65
  127. package/src/lib/components/cancellation-transaction-report/cancellation-transaction-report.component.spec.ts +0 -23
  128. package/src/lib/components/cancellation-transaction-report/cancellation-transaction-report.component.ts +0 -290
  129. package/src/lib/components/credit-limit-status-enquiry-report/credit-limit-status-enquiry-report.component.html +0 -25
  130. package/src/lib/components/credit-limit-status-enquiry-report/credit-limit-status-enquiry-report.component.scss +0 -1
  131. package/src/lib/components/credit-limit-status-enquiry-report/credit-limit-status-enquiry-report.component.spec.ts +0 -23
  132. package/src/lib/components/credit-limit-status-enquiry-report/credit-limit-status-enquiry-report.component.ts +0 -213
  133. package/src/lib/components/funding-report/funding-report.component.html +0 -49
  134. package/src/lib/components/funding-report/funding-report.component.scss +0 -1
  135. package/src/lib/components/funding-report/funding-report.component.spec.ts +0 -23
  136. package/src/lib/components/funding-report/funding-report.component.ts +0 -221
  137. package/src/lib/components/revenue-per-transaction-report/revenue-per-transaction-report.component.html +0 -26
  138. package/src/lib/components/revenue-per-transaction-report/revenue-per-transaction-report.component.scss +0 -1
  139. package/src/lib/components/revenue-per-transaction-report/revenue-per-transaction-report.component.spec.ts +0 -23
  140. package/src/lib/components/revenue-per-transaction-report/revenue-per-transaction-report.component.ts +0 -267
  141. package/src/lib/components/statement-of-accounts-report/statement-of-accounts-report.component.html +0 -95
  142. package/src/lib/components/statement-of-accounts-report/statement-of-accounts-report.component.scss +0 -54
  143. package/src/lib/components/statement-of-accounts-report/statement-of-accounts-report.component.spec.ts +0 -23
  144. package/src/lib/components/statement-of-accounts-report/statement-of-accounts-report.component.ts +0 -904
  145. package/src/lib/components/transaction-enquiry-report/transaction-enquiry-report.component.html +0 -49
  146. package/src/lib/components/transaction-enquiry-report/transaction-enquiry-report.component.scss +0 -2
  147. package/src/lib/components/transaction-enquiry-report/transaction-enquiry-report.component.spec.ts +0 -32
  148. package/src/lib/components/transaction-enquiry-report/transaction-enquiry-report.component.ts +0 -304
  149. package/src/lib/components/transaction-monitoring-report/transaction-monitoring-report.component.html +0 -46
  150. package/src/lib/components/transaction-monitoring-report/transaction-monitoring-report.component.scss +0 -7
  151. package/src/lib/components/transaction-monitoring-report/transaction-monitoring-report.component.ts +0 -343
  152. package/src/lib/components/trial-balance-accounts-report/trial-balance-accounts-report.component.html +0 -25
  153. package/src/lib/components/trial-balance-accounts-report/trial-balance-accounts-report.component.scss +0 -23
  154. package/src/lib/components/trial-balance-accounts-report/trial-balance-accounts-report.component.spec.ts +0 -23
  155. package/src/lib/components/trial-balance-accounts-report/trial-balance-accounts-report.component.ts +0 -745
  156. package/src/lib/models/acc-gl-details-enquiry-report/accgl-details-enquiry-reportmodel.ts +0 -10
  157. package/src/lib/models/acc-gl-details-enquiry-report/journal-voucher-entry-model.ts +0 -20
  158. package/src/lib/models/accounting-report/accounting-report-branch-group.ts +0 -7
  159. package/src/lib/models/accounting-report/accounting-report-entry-model.ts +0 -25
  160. package/src/lib/models/accounting-report/accounting-report-model.ts +0 -7
  161. package/src/lib/models/branch-activity-receive-report/branch-activity-receive.model.ts +0 -18
  162. package/src/lib/models/branch-activity-report/branch-activity-send-report-request-domain-model.ts +0 -16
  163. package/src/lib/models/branch-activity-report/branch-activity-send-report.ts +0 -26
  164. package/src/lib/models/cancellation-transaction-report/cancellation-transaction.model.ts +0 -65
  165. package/src/lib/models/component-loading-states.ts +0 -5
  166. package/src/lib/models/credit-limit-status-enquiry-report/credit-limit-status-enquiry.model.ts +0 -28
  167. package/src/lib/models/statement-of-account-report/statement-of-accounts.model.ts +0 -21
  168. package/src/lib/models/transaction-enquiry-report/transaction-enquiry.model.ts +0 -127
  169. package/src/lib/models/transaction-monitoring-report/transaction-monitoring-report-request-domain-model.ts +0 -16
  170. package/src/lib/models/transaction-monitoring-report/transaction-monitoring-report.ts +0 -29
  171. package/src/lib/models/trial-balance-accounts-report/trial-balance-accounts.models.ts +0 -46
  172. package/src/lib/reports-lib-routing.module.ts +0 -20
  173. package/src/lib/reports-lib.component.spec.ts +0 -23
  174. package/src/lib/reports-lib.component.ts +0 -20
  175. package/src/lib/reports-lib.module.ts +0 -102
  176. package/src/lib/reports-lib.service.spec.ts +0 -16
  177. package/src/lib/reports-lib.service.ts +0 -9
  178. package/src/lib/services/config.service.ts +0 -43
  179. package/src/lib/services/report.service.spec.ts +0 -16
  180. package/src/lib/services/report.service.ts +0 -463
  181. package/src/lib/shared/export-generic.service.ts +0 -557
  182. package/src/lib/shared/export.service.spec.ts +0 -16
  183. package/src/lib/shared/export.service.ts +0 -457
  184. package/src/lib/shared/loader/loader.component.html +0 -8
  185. package/src/lib/shared/loader/loader.component.scss +0 -52
  186. package/src/lib/shared/loader/loader.component.ts +0 -10
  187. package/src/lib/shared/metadata/metadata.component.html +0 -42
  188. package/src/lib/shared/metadata/metadata.component.scss +0 -95
  189. package/src/lib/shared/metadata/metadata.component.spec.ts +0 -23
  190. package/src/lib/shared/metadata/metadata.component.ts +0 -38
  191. package/src/lib/shared/page-size-selector/page-size-selector.component.html +0 -7
  192. package/src/lib/shared/page-size-selector/page-size-selector.component.scss +0 -42
  193. package/src/lib/shared/page-size-selector/page-size-selector.component.spec.ts +0 -23
  194. package/src/lib/shared/page-size-selector/page-size-selector.component.ts +0 -38
  195. package/src/lib/shared/search-filter/search-filter.component.html +0 -601
  196. package/src/lib/shared/search-filter/search-filter.component.scss +0 -203
  197. package/src/lib/shared/search-filter/search-filter.component.spec.ts +0 -23
  198. package/src/lib/shared/search-filter/search-filter.component.ts +0 -2387
  199. package/src/lib/shared/shared.module.ts +0 -13
  200. package/src/styles/ag-grid-report-style.scss +0 -71
  201. package/src/styles/common-ag-grid-style.scss +0 -146
  202. package/src/styles/common-report-style.scss +0 -395
  203. package/src/styles/common-style.scss +0 -615
  204. package/src/test.ts +0 -27
  205. package/tsconfig.lib.json +0 -15
  206. package/tsconfig.lib.prod.json +0 -10
  207. package/tsconfig.spec.json +0 -17
  208. /package/{src/lib → lib}/assets/config/app-config.json +0 -0
  209. /package/{src → lib}/assets/images/Search.svg +0 -0
  210. /package/{src/lib → lib}/assets/images/XMLogo.png +0 -0
  211. /package/{src/lib → lib}/assets/svg-loaders/blue-tail-spin.svg +0 -0
@@ -1,904 +0,0 @@
1
- import { Component, OnInit } from '@angular/core';
2
- import { GridApi } from 'ag-grid-community';
3
- import { Subject } from 'rxjs';
4
- import { finalize, takeUntil } from 'rxjs/operators';
5
- import { ComponentLoadingStates } from '../../models/component-loading-states';
6
- import { ReportService } from '../../services/report.service';
7
- import { formatDate } from '@angular/common';
8
- import { StatementOfAccountItem } from '../../models/statement-of-account-report/statement-of-accounts.model';
9
- import jsPDF from 'jspdf';
10
- import 'jspdf-autotable';
11
- import * as ExcelJS from 'exceljs';
12
- import * as FileSaver from 'file-saver';
13
-
14
- @Component({
15
- selector: 'lib-statement-of-accounts-report',
16
- templateUrl: './statement-of-accounts-report.component.html',
17
- styleUrls: ['./statement-of-accounts-report.component.scss']
18
- })
19
-
20
- export class StatementOfAccountsReportComponent implements OnInit {
21
-
22
- ReportName = "Statement of Accounts";
23
- ComponentLoadingState = ComponentLoadingStates;
24
- loadingState: ComponentLoadingStates = ComponentLoadingStates.Complete;
25
- errorMessage: string;
26
- hasSearched: boolean;
27
- private destroy$ = new Subject<void>();
28
- openingBalAndFunding: StatementOfAccountItem[] = [];
29
- sendDetails: StatementOfAccountItem[] = [];
30
- receiveDetails: StatementOfAccountItem[] = [];
31
- noDataFromApi: boolean;
32
- metaDataOne: Record<string, string>;
33
- metaDataTwo: Record<string, string>;
34
- user: any;
35
- currentDateTime: Date = new Date();
36
- sendPinnedBottomRow: any[] = [];
37
- receivePinnedBottomRow: any[] = [];
38
- private sendGridApi!: GridApi;
39
- private receiveGridApi!: GridApi;
40
- private openingGridApi!: GridApi;
41
- searchText: string;
42
- closingBalance: number = 0;
43
-
44
- closingBalanceCurrency = 'USD';
45
- closingBalanceUSDInWords: string = '';
46
-
47
- selectedClientType: string = '';
48
- showTables = false;
49
- private logoBase64?: string;
50
- selectedExportOption: string;
51
-
52
- closingBalanceInSettlment: number = 0;
53
- closingBalanceSettlmentCurrency: string = '';
54
- closingBalanceSettlmentInWords: string = '';
55
- closingBalanceSettlmentFormatted: string = '0.000';
56
- closingBalanceInUsdFormatted: string = '0.000';
57
- reportUserandTime: string;
58
- searchCriteria: [string, string][];
59
- isFormValid: boolean = false;
60
-
61
- constructor(private reportService: ReportService) { }
62
-
63
- async ngOnInit(): Promise<void> {
64
- this.logoBase64 = await this.loadImageAsBase64('assets/reports-lib/assets/images/XMLogo.png');
65
- }
66
-
67
- columnDefs = [
68
- // { headerName: 'ID', field: 'id', width: 100 },
69
- { headerName: 'Description', field: 'description', flex: 4, tooltipField: 'description', cellClassRules: { 'pinned-total-cell': params => params.node.rowPinned === 'bottom' } },
70
- { headerName: 'Settlment Ccy', field: 'settlmentCcy', flex: 1, tooltipField: 'settlmentCcy', cellClassRules: { 'pinned-total-cell': params => params.node.rowPinned === 'bottom' } },
71
- { headerName: 'Amount In Settlment Ccy', field: 'amountInSettlmentCcy', flex: 2.1, cellClass: 'ag-right-aligned-cell', valueFormatter: this.currencyFormatter, tooltipValueGetter: (params: any) => this.currencyFormatter(params), cellClassRules: { 'pinned-total-cell': params => params.node.rowPinned === 'bottom' } },
72
- { headerName: 'Amount In USD', field: 'amountInUSD', flex: 2.1, cellClass: 'ag-right-aligned-cell', valueFormatter: this.currencyFormatter, tooltipValueGetter: (params: any) => this.currencyFormatter(params), cellClassRules: { 'pinned-total-cell': params => params.node.rowPinned === 'bottom' } }
73
- ];
74
-
75
- defaultColDef = {
76
- sortable: true,
77
- filter: true,
78
- resizable: true,
79
- minwidth: 40,
80
- wrapHeaderText: true,
81
- autoHeaderHeight: true,
82
- suppressSizeToFit: false,
83
- wrapText: true,
84
- autoHeight: true
85
- };
86
-
87
- currencyFormatter(params: any) {
88
- if (params.value == null) return '0.000';
89
- const num = Number(params.value);
90
- return num.toFixed(3); // rounds to 3 decimals
91
- }
92
-
93
-
94
- async handleSearch(criteria: any): Promise<void> {
95
- this.searchCriteria = criteria.searchCriteria;
96
- const modal = criteria.modal;
97
- this.reportUserandTime = `${criteria.sysUserID} @ ${formatDate(this.currentDateTime, 'dd/MM/yyyy hh:mm a', 'en-US')}`;
98
- const payload = {
99
- businessPartnerID: Number(modal.client),
100
- fromDate: new Date(modal.fromDate).toISOString(),
101
- toDate: new Date(modal.toDate).toISOString(),
102
- clientType: criteria.clientType
103
- };
104
- this.user = criteria.sysUserID
105
- this.metaDataOne = {
106
- 'Report Period ': criteria.reportPeriod
107
- }
108
- this.metaDataTwo = {
109
- 'Report User & Time ': this.reportUserandTime
110
- }
111
- try {
112
- const sdate = new Date(payload?.fromDate);
113
- const edate = new Date(payload?.toDate);
114
- payload.fromDate = sdate.toISOString().split("T")[0];
115
- payload.toDate = edate.toISOString().split("T")[0];
116
- } catch (err) {
117
- throw new Error("Invalid Date");
118
- }
119
- this.searchCriteria = criteria.searchCriteria;
120
- console.log(criteria.clientName)
121
- this.loadingState = ComponentLoadingStates.Loading;
122
- this.errorMessage = '';
123
- this.showTables = false;
124
- this.selectedClientType = criteria.clientType;
125
-
126
- this.reportService.getStatementOfAccount(payload)
127
- .pipe(
128
- finalize(() => {
129
- this.loadingState = ComponentLoadingStates.Complete;
130
- this.hasSearched = true;
131
- this.showTables = true;
132
- }),
133
- takeUntil(this.destroy$)
134
- )
135
- .subscribe({
136
- next: (data) => {
137
- console.log(data)
138
- this.openingBalAndFunding = data.openingBalAndFunding ?? [];
139
- this.sendDetails = data.sendDetails ?? [];
140
- this.receiveDetails = data.receiveDetails ?? [];
141
-
142
- // add pinned totals
143
- if (this.selectedClientType == "PayIn") {
144
- this.sendPinnedBottomRow = [this.buildTotalRow(this.sendDetails)];
145
- this.receivePinnedBottomRow = [];
146
- }
147
- else if (this.selectedClientType == "PayOut") {
148
- this.receivePinnedBottomRow = [this.buildTotalRow(this.receiveDetails)];
149
- this.sendPinnedBottomRow = [];
150
- }
151
- else if (this.selectedClientType === "Both") {
152
- this.sendPinnedBottomRow = [this.buildTotalRow(this.sendDetails)];
153
- this.receivePinnedBottomRow = [this.buildTotalRow(this.receiveDetails)];
154
- }
155
- else {
156
- this.sendPinnedBottomRow = [];
157
- this.receivePinnedBottomRow = [];
158
- }
159
- this.calculateClosingBalance();
160
-
161
- this.noDataFromApi =
162
- this.openingBalAndFunding.length === 0 &&
163
- this.sendDetails.length === 0 &&
164
- (!this.receiveDetails || this.receiveDetails.length === 0);
165
- },
166
- error: (err) => {
167
- console.error('Error fetching Statement of Accounts:', err);
168
- this.errorMessage = 'Failed to load Statement of Accounts';
169
- this.openingBalAndFunding = [];
170
- this.sendDetails = [];
171
- this.receiveDetails = [];
172
- this.loadingState = ComponentLoadingStates.Error;
173
- this.showTables = false;
174
- }
175
- });
176
- }
177
-
178
- private buildTotalRow(rows: { amountInSettlmentCcy: number; amountInUSD: number }[]) {
179
- const totalSettle = (rows || []).reduce((sum, r) => sum + (Number(r.amountInSettlmentCcy) || 0), 0);
180
- const totalUsd = (rows || []).reduce((sum, r) => sum + (Number(r.amountInUSD) || 0), 0);
181
-
182
- return {
183
- id: null,
184
- description: 'Total',
185
- settlmentCcy: '',
186
- amountInSettlmentCcy: Number(totalSettle.toFixed(3)),
187
- amountInUSD: Number(totalUsd.toFixed(3))
188
- };
189
- }
190
-
191
- onOpeningGridReady(params: any) {
192
- this.openingGridApi = params.api;
193
- }
194
- onSendGridReady(params: any) {
195
- this.sendGridApi = params.api;
196
- }
197
- onReceiveGridReady(params: any) {
198
- this.receiveGridApi = params.api;
199
- }
200
-
201
- filter(text: string) {
202
- this.searchText = text;
203
- if (this.openingGridApi) {
204
- this.openingGridApi.setQuickFilter(this.searchText);
205
- }
206
- if (this.sendGridApi) {
207
- this.sendGridApi.setQuickFilter(this.searchText);
208
- }
209
- if (this.receiveGridApi) {
210
- this.receiveGridApi.setQuickFilter(this.searchText);
211
- }
212
- }
213
-
214
- private calculateClosingBalance(): void {
215
- // USD totals (existing logic)
216
- const openingBalTotalUsd = (this.openingBalAndFunding || []).reduce(
217
- (sum, r: any) => sum + (Number(r.amountInUSD) || 0), 0
218
- );
219
- const sendTotalUsd = (this.sendDetails || []).reduce(
220
- (sum, r: any) => sum + (Number(r.amountInUSD) || 0), 0
221
- );
222
- const receiveTotalUsd = (this.receiveDetails || []).reduce(
223
- (sum, r: any) => sum + (Number(r.amountInUSD) || 0), 0
224
- );
225
- const rawClosingUsd = openingBalTotalUsd + sendTotalUsd + receiveTotalUsd;
226
- this.closingBalance = Number(rawClosingUsd.toFixed(3)); // numeric USD
227
-
228
- // Settlement currency totals (new)
229
- const openingSettle = (this.openingBalAndFunding || []).reduce(
230
- (sum, r: any) => sum + (Number(r.amountInSettlmentCcy) || 0), 0
231
- );
232
- const sendSettle = (this.sendDetails || []).reduce(
233
- (sum, r: any) => sum + (Number(r.amountInSettlmentCcy) || 0), 0
234
- );
235
- const receiveSettle = (this.receiveDetails || []).reduce(
236
- (sum, r: any) => sum + (Number(r.amountInSettlmentCcy) || 0), 0
237
- );
238
- const rawClosingSettle = openingSettle + sendSettle + receiveSettle;
239
- this.closingBalanceInSettlment = Number(rawClosingSettle.toFixed(3));
240
-
241
- // pick a settlement currency to display (first non-empty)
242
- this.closingBalanceSettlmentCurrency = this.getFirstSettlementCurrency();
243
-
244
- // formatted strings (no-thousand-comma, 3 decimals)
245
- this.closingBalanceInUsdFormatted = this.formatNoComma(this.closingBalance);
246
- this.closingBalanceSettlmentFormatted = this.formatNoComma(this.closingBalanceInSettlment);
247
-
248
- this.closingBalanceUSDInWords = this.numberToWords(this.closingBalance);
249
- this.closingBalanceSettlmentInWords =
250
- this.closingBalanceInSettlment !== null &&
251
- this.closingBalanceInSettlment !== undefined &&
252
- !isNaN(Number(this.closingBalanceInSettlment))
253
- ? this.numberToWords(this.closingBalanceInSettlment)
254
- : '';
255
- }
256
-
257
- private formatNoComma(value: number | null | undefined): string {
258
- if (value === null || value === undefined || isNaN(Number(value))) return '0.000';
259
- const num = Number(value);
260
- const truncated = Math.trunc(num * 1000) / 1000;
261
- return truncated.toFixed(3);
262
- }
263
-
264
-
265
- private getFirstSettlementCurrency(): string {
266
- const tryGet = (arr: any[]) => {
267
- if (!arr || arr.length === 0) return '';
268
- for (const r of arr) {
269
- if (r && r.settlmentCcy) return r.settlmentCcy;
270
- }
271
- return '';
272
- };
273
-
274
- return tryGet(this.openingBalAndFunding) || tryGet(this.sendDetails) || tryGet(this.receiveDetails) || '';
275
- }
276
-
277
- numberToWords(num: number): string {
278
- if (num === 0) return "Zero Point Zero Zero Zero Only";
279
-
280
- let result = "";
281
-
282
- // Handle negative numbers
283
- if (num < 0) {
284
- result = "Negative ";
285
- num = Math.abs(num);
286
- }
287
-
288
- // Split integer and decimal parts
289
- const integerPart = Math.floor(num);
290
- const decimalPart = Math.round((num - integerPart) * 1000); // up to 3 decimal places
291
-
292
- result += this.convertNumber(integerPart);
293
-
294
- if (decimalPart > 0) {
295
- result += " Point";
296
- const decimalStr = decimalPart.toString().padStart(3, "0"); // keep 3 digits
297
- for (const digit of decimalStr) {
298
- result += " " + this.ones[+digit];
299
- }
300
- }
301
-
302
- return result + " Only";
303
- }
304
-
305
- // Helper arrays
306
- private ones = ["Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"];
307
- private teens = ["Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"];
308
- private tens = ["", "", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"];
309
-
310
- // Convert whole numbers (Indian/International system)
311
- private convertNumber(num: number): string {
312
- if (num === 0) return "";
313
- if (num < 10) return this.ones[num];
314
- if (num < 20) return this.teens[num - 10];
315
- if (num < 100) return this.tens[Math.floor(num / 10)] + (num % 10 !== 0 ? " " + this.ones[num % 10] : "");
316
- if (num < 1000) return this.convertNumber(Math.floor(num / 100)) + " Hundred" + (num % 100 !== 0 ? " " + this.convertNumber(num % 100) : "");
317
- if (num < 1000000) return this.convertNumber(Math.floor(num / 1000)) + " Thousand" + (num % 1000 !== 0 ? " " + this.convertNumber(num % 1000) : "");
318
- if (num < 1000000000) return this.convertNumber(Math.floor(num / 1000000)) + " Million" + (num % 1000000 !== 0 ? " " + this.convertNumber(num % 1000000) : "");
319
- return this.convertNumber(Math.floor(num / 1000000000)) + " Billion" + (num % 1000000000 !== 0 ? " " + this.convertNumber(num % 1000000000) : "");
320
- }
321
-
322
- onExportChange(value: string): void {
323
- this.selectedExportOption = value;
324
- }
325
-
326
- handleExport(option: string) {
327
- this.selectedExportOption = option;
328
- switch ((this.selectedExportOption || '').toLowerCase()) {
329
- case 'pdf': this.exportToPDF(); break;
330
- case 'excel': this.exportToExcel(); break;
331
- case 'csv': this.exportToCSV(); break;
332
- default: console.warn('Unknown export type:', this.selectedExportOption);
333
- }
334
- }
335
-
336
- exportToPDF(): void {
337
- const sections = this.getVisibleGrids()
338
- .map(s => {
339
- const data = this.getDisplayedData(s.api);
340
- const headers = this.getHeaders();
341
- let rows = this.buildRows(data);
342
-
343
- if (s.title === 'Send Details' && this.sendPinnedBottomRow?.length) {
344
- rows = rows.concat(this.buildRows(this.sendPinnedBottomRow));
345
- }
346
- if (s.title === 'Receive Details' && this.receivePinnedBottomRow?.length) {
347
- rows = rows.concat(this.buildRows(this.receivePinnedBottomRow));
348
- }
349
-
350
- return rows.length ? { title: s.title, headers, rows } : null;
351
- })
352
- .filter(Boolean) as { title: string; headers: string[]; rows: any[][] }[];
353
- if (!sections.length) return;
354
-
355
- const doc = new jsPDF({ orientation: 'landscape', unit: 'mm', format: 'a4' });
356
-
357
- if (this.logoBase64) {
358
- doc.addImage(this.logoBase64, 'PNG', 15, 10, 38, 18);
359
- }
360
-
361
- const pageWidth = doc.internal.pageSize.getWidth();
362
- const pageHeight = doc.internal.pageSize.getHeight();
363
- doc.setFont('helvetica', 'bold');
364
- doc.setFontSize(15);
365
- doc.text(this.ReportName, pageWidth / 2, 18, { align: 'center' });
366
-
367
- let y = 34;
368
- doc.setFontSize(10);
369
- Object.entries(this.metaDataOne || {}).forEach(([k, v]) => {
370
- doc.setFont('helvetica', 'bold');
371
- doc.text(`${k}: `, 15, y);
372
- const w = doc.getTextWidth(`${k}: `);
373
- doc.setFont('helvetica', 'normal');
374
- doc.text(String(v ?? ''), 15 + w, y);
375
- y += 6;
376
- });
377
-
378
- Object.entries(this.metaDataTwo || {}).forEach(([k, v]) => {
379
- doc.setFont('helvetica', 'bold');
380
- doc.text(`${k}: `, 15, y);
381
- const w = doc.getTextWidth(`${k}: `);
382
- doc.setFont('helvetica', 'normal');
383
- doc.text(String(v ?? ''), 15 + w, y);
384
- y += 6;
385
- });
386
-
387
-
388
- // --- search criteria ---
389
- const searchCriteria: [string, string][] = this.searchCriteria || [];
390
-
391
- // ===================== Search Criteria Section =====================
392
-
393
- // Start just below metadata
394
- let marginLeft = 15;
395
- let currentY = y + 5; // continue below metadata
396
-
397
- // --- heading ---
398
- doc.setFont('helvetica', 'bold');
399
- doc.text('Search Criteria:-', marginLeft, currentY);
400
- currentY += 8;
401
-
402
- const rowHeightPerLine = 6;
403
- const minGap = 2; // gap between key and value
404
- const betweenColumnsGap = 15; // gap between left and right columns
405
- const pageContentWidth = doc.internal.pageSize.width - 2 * marginLeft;
406
-
407
- // --- helper to measure pair width ---
408
- const measurePairWidth = (key: string, value: string): number => {
409
- doc.setFont('helvetica', 'bold');
410
- const keyWidth = doc.getTextWidth(key + ' ');
411
- doc.setFont('helvetica', 'normal');
412
- const valueWidth = doc.getTextWidth(value);
413
- return keyWidth + minGap + valueWidth;
414
- };
415
-
416
- // --- compute max width of left column ---
417
- let maxLeftPairWidth = 0;
418
- for (let i = 0; i < searchCriteria.length; i += 2) {
419
- if (searchCriteria[i]) {
420
- const [key, value] = searchCriteria[i];
421
- const width = measurePairWidth(key, value);
422
- if (width > maxLeftPairWidth) maxLeftPairWidth = width;
423
- }
424
- }
425
-
426
- // --- calculate where right column starts ---
427
- const leftColumnStart = marginLeft;
428
- const rightColumnStart = leftColumnStart + maxLeftPairWidth + betweenColumnsGap;
429
-
430
- // --- print pairs dynamically ---
431
- for (let i = 0; i < searchCriteria.length; i += 2) {
432
- // Left column
433
- if (searchCriteria[i]) {
434
- const [key, value] = searchCriteria[i];
435
- doc.setFont('helvetica', 'bold');
436
- doc.text(key, leftColumnStart, currentY);
437
-
438
- doc.setFont('helvetica', 'normal');
439
- const keyWidth = doc.getTextWidth(key + ' ');
440
- const valueX = leftColumnStart + keyWidth + minGap;
441
- doc.text(value, valueX, currentY);
442
- }
443
-
444
- // Right column
445
- if (searchCriteria[i + 1]) {
446
- const [key, value] = searchCriteria[i + 1];
447
- doc.setFont('helvetica', 'bold');
448
- doc.text(key, rightColumnStart, currentY);
449
-
450
- doc.setFont('helvetica', 'normal');
451
- const keyWidth = doc.getTextWidth(key + ' ');
452
- const valueX = rightColumnStart + keyWidth + minGap;
453
- doc.text(value, valueX, currentY);
454
- }
455
-
456
- currentY += rowHeightPerLine;
457
- }
458
-
459
- // Update Y position for next sections
460
- y = currentY + 4;
461
-
462
- const HEAD = this.getHeaders();
463
-
464
- const margin = { left: 15, right: 15 };
465
- const avail = pageWidth - margin.left - margin.right;
466
- const weights = [4, 1, 2, 2];
467
- const sum = weights.reduce((a, b) => a + b, 0);
468
- const widths = weights.map(w => (w / sum) * avail);
469
-
470
- const sharedColumnStyles = {
471
- 0: { cellWidth: widths[0] },
472
- 1: { cellWidth: widths[1] },
473
- 2: { cellWidth: widths[2], halign: 'right' },
474
- 3: { cellWidth: widths[3], halign: 'right' }
475
- };
476
-
477
- const titleGapAboveFirst = 0;
478
- const titleGapAboveDefault = 4;
479
- const titleGapAboveBig = 6;
480
- const titleToTableGap = 2;
481
- const topStartY = 20;
482
- const bottomReserve = 20;
483
-
484
- sections.forEach((s, idx) => {
485
- const isFirst = idx === 0;
486
- const isSendOrReceive = s.title === 'Send Details' || s.title === 'Receive Details';
487
- const preTitleGap = isFirst ? 0 : (isSendOrReceive ? titleGapAboveBig : titleGapAboveDefault);
488
-
489
- if (y + preTitleGap + titleToTableGap > pageHeight - bottomReserve) {
490
- doc.addPage();
491
- y = topStartY;
492
- } else {
493
- y += preTitleGap;
494
- }
495
-
496
- doc.setFont('helvetica', 'bold');
497
- doc.setFontSize(11);
498
- doc.text(s.title, margin.left, y);
499
-
500
- const startYForTable = y + (isFirst ? 0 : titleToTableGap);
501
-
502
- doc.autoTable({
503
- head: [HEAD],
504
- body: s.rows,
505
- startY: startYForTable,
506
- theme: 'grid',
507
- margin,
508
- tableWidth: avail,
509
- columnStyles: sharedColumnStyles,
510
- headStyles: { fillColor: [220, 220, 220], textColor: 0, fontStyle: 'bold', fontSize: 9, halign: 'center' },
511
- bodyStyles: { fontSize: 8 },
512
- styles: { cellPadding: 2, overflow: 'linebreak', minCellHeight: 6 }
513
- });
514
-
515
- y = (doc as any).lastAutoTable.finalY;
516
- });
517
- if (y + 30 > pageHeight - bottomReserve) {
518
- doc.addPage();
519
- y = topStartY;
520
- }
521
-
522
- const closingBody = [
523
- [
524
- { content: 'Closing Balance', colSpan: 2, styles: { halign: 'left', fontStyle: 'bold' } },
525
- { content: Number(this.closingBalanceInSettlment || 0).toFixed(3), styles: { halign: 'right' } },
526
- { content: Number(this.closingBalance || 0).toFixed(3), styles: { halign: 'right' } }
527
- ],
528
- [
529
- { content: `${this.closingBalanceSettlmentCurrency || ''} - ${this.closingBalanceSettlmentInWords || ''}`, colSpan: 4, styles: { halign: 'left' } }
530
- ],
531
- [
532
- { content: `${this.closingBalanceCurrency || ''} - ${this.closingBalanceUSDInWords || ''}`, colSpan: 4, styles: { halign: 'left' } }
533
- ]
534
- ];
535
-
536
- doc.autoTable({
537
- body: closingBody,
538
- startY: y,
539
- theme: 'grid',
540
- margin,
541
- tableWidth: avail,
542
- columnStyles: sharedColumnStyles,
543
- styles: { cellPadding: 2, fontSize: 9 }
544
- });
545
-
546
- doc.save('Statement_of_Accounts.pdf');
547
- }
548
-
549
- exportToExcel(): void {
550
- const sections = this.getVisibleGrids()
551
- .map(s => {
552
- const data = this.getDisplayedData(s.api);
553
- const headers = this.getHeaders();
554
- let rows = this.buildRows(data);
555
-
556
- if (s.title === 'Send Details' && this.sendPinnedBottomRow?.length) {
557
- rows = rows.concat(this.buildRows(this.sendPinnedBottomRow));
558
- }
559
- if (s.title === 'Receive Details' && this.receivePinnedBottomRow?.length) {
560
- rows = rows.concat(this.buildRows(this.receivePinnedBottomRow));
561
- }
562
-
563
- return rows.length ? { title: s.title, headers, rows } : null;
564
- })
565
- .filter(Boolean) as { title: string; headers: string[]; rows: any[][] }[];
566
-
567
- if (!sections.length) return;
568
-
569
- const wb = new ExcelJS.Workbook();
570
- const ws = wb.addWorksheet('Statement of Accounts');
571
- let r = 1;
572
-
573
- if (this.logoBase64) {
574
- const imgId = wb.addImage({ base64: this.logoBase64, extension: 'png' });
575
- ws.addImage(imgId, { tl: { col: 0, row: 0 }, ext: { width: 145, height: 66 }, editAs: 'oneCell' });
576
- }
577
-
578
- ws.getRow(r).getCell(2).value = this.ReportName;
579
- ws.getRow(r).getCell(2).font = { bold: true, size: 16 };
580
- r += 3;
581
-
582
- Object.entries(this.metaDataOne || {}).forEach(([k, v]) => {
583
- const row = ws.getRow(r++);
584
- row.getCell(1).value = {
585
- richText: [
586
- { text: k + ': ', font: { bold: true } }, // key bold
587
- { text: v ?? '' } // value normal
588
- ]
589
- };
590
- row.getCell(1).alignment = { wrapText: false, vertical: 'middle' };
591
- });
592
-
593
- Object.entries(this.metaDataTwo || {}).forEach(([k, v]) => {
594
- const row = ws.getRow(r++);
595
- row.getCell(1).value = {
596
- richText: [
597
- { text: k + ': ', font: { bold: true } }, // key bold
598
- { text: v ?? '' } // value normal
599
- ]
600
- };
601
- row.getCell(1).alignment = { wrapText: false, vertical: 'middle' };
602
- });
603
-
604
- r++;
605
- // --- search criteria ---
606
- const searchCriteria: [string, string][] = this.searchCriteria || [];
607
-
608
- ws.mergeCells(r, 1, r, 4); // previously 1..6
609
- ws.getCell(r, 1).value = 'Search Criteria:-';
610
- ws.getCell(r, 1).font = { bold: true };
611
- r += 2;
612
-
613
- for (let i = 0; i < searchCriteria.length; i += 2) {
614
- const left = searchCriteria[i];
615
- const right = searchCriteria[i + 1];
616
- const row = ws.getRow(r++);
617
-
618
- // Left column (reduced merge)
619
- ws.mergeCells(row.number, 1, row.number, 1); // was 1..3
620
- row.getCell(1).value = {
621
- richText: [
622
- { text: left[0] + ' ', font: { bold: true } },
623
- { text: left[1] }
624
- ]
625
- };
626
- row.getCell(1).alignment = { wrapText: true, vertical: 'middle' };
627
-
628
- // Right column (start closer to left)
629
- if (right) {
630
- ws.mergeCells(row.number, 2, row.number, 3); // was 4..6
631
- row.getCell(3).value = {
632
- richText: [
633
- { text: right[0] + ' ', font: { bold: true } },
634
- { text: right[1] }
635
- ]
636
- };
637
- row.getCell(3).alignment = { wrapText: true, vertical: 'middle' };
638
- }
639
- }
640
-
641
- r++;
642
-
643
- const writeSection = (sec: { title: string; headers: string[]; rows: any[][] }) => {
644
- const titleRow = ws.getRow(r++);
645
- const titleCell = titleRow.getCell(1);
646
- titleCell.value = sec.title;
647
- titleCell.font = { bold: true, size: 12 };
648
- titleCell.alignment = { horizontal: 'left', vertical: 'middle' };
649
-
650
- const headerRow = ws.getRow(r++);
651
- sec.headers.forEach((h, i) => {
652
- const c = headerRow.getCell(i + 1);
653
- c.value = h;
654
- c.font = { bold: true };
655
- c.alignment = { vertical: 'middle', horizontal: 'center' };
656
- c.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'D9D9D9' } };
657
- c.border = { top: { style: 'thin' }, bottom: { style: 'thin' }, left: { style: 'thin' }, right: { style: 'thin' } };
658
- });
659
-
660
- const dataStart = r;
661
-
662
- sec.rows.forEach(rowData => {
663
- const row = ws.getRow(r++);
664
- rowData.forEach((v, i) => {
665
- const c = row.getCell(i + 1);
666
- if (sec.headers[i] === 'Amount In Settlment Ccy' || sec.headers[i] === 'Amount In USD') {
667
- const num = typeof v === 'string' ? Number(v.replace(/[, ]+/g, '')) : Number(v);
668
- c.value = isNaN(num) ? (v ?? '') : num;
669
- c.alignment = { horizontal: 'right' };
670
- if (!isNaN(num)) c.numFmt = '0.000';
671
- } else {
672
- c.value = v ?? '';
673
- }
674
- c.border = { top: { style: 'thin' }, bottom: { style: 'thin' }, left: { style: 'thin' }, right: { style: 'thin' } };
675
- });
676
- });
677
-
678
- for (let col = 1; col <= sec.headers.length; col++) {
679
- let max = (sec.headers[col - 1] || '').toString().length;
680
- for (let rr = dataStart - 1; rr < r; rr++) {
681
- const val = (ws.getRow(rr).getCell(col).value ?? '').toString();
682
- if (val) max = Math.max(max, val.length + 2);
683
- }
684
- ws.getColumn(col).width = Math.min(Math.max(max, 8), 60);
685
- }
686
- };
687
-
688
- sections.forEach((sec, idx) => {
689
- writeSection(sec);
690
- if (idx < sections.length - 1) {
691
- r++;
692
- }
693
- });
694
-
695
- const totalCols = sections.length
696
- ? Math.max(...sections.map(s => s.headers.length))
697
- : this.columnDefs.length;
698
- const cols = Math.max(totalCols, 4);
699
- const labelColsEnd = 2;
700
- const settleCol = 3;
701
- const usdCol = 4;
702
-
703
- const row1 = ws.getRow(r++);
704
- ws.mergeCells(row1.number, 1, row1.number, labelColsEnd);
705
- row1.getCell(1).value = 'Closing Balance';
706
- row1.getCell(1).font = { bold: true };
707
- row1.getCell(1).alignment = { horizontal: 'left', vertical: 'middle' };
708
-
709
- const settleValue = Number(this.closingBalanceInSettlment ?? 0);
710
- const usdValue = Number(this.closingBalance ?? 0);
711
-
712
- const settleCell = row1.getCell(settleCol);
713
- settleCell.value = isNaN(settleValue) ? '' : settleValue;
714
- settleCell.alignment = { horizontal: 'right' };
715
- if (!isNaN(settleValue)) settleCell.numFmt = '0.000';
716
-
717
- const usdCell = row1.getCell(usdCol);
718
- usdCell.value = isNaN(usdValue) ? '' : usdValue;
719
- usdCell.alignment = { horizontal: 'right' };
720
- if (!isNaN(usdValue)) usdCell.numFmt = '0.000';
721
-
722
- for (let c = 1; c <= cols; c++) {
723
- row1.getCell(c).border = {
724
- top: { style: 'thin' },
725
- bottom: { style: 'thin' },
726
- left: { style: 'thin' },
727
- right: { style: 'thin' }
728
- };
729
- }
730
-
731
- const row2 = ws.getRow(r++);
732
- ws.mergeCells(row2.number, 1, row2.number, cols);
733
- row2.getCell(1).value = `${this.closingBalanceSettlmentCurrency || ''} - ${this.closingBalanceSettlmentInWords || ''}`;
734
- row2.getCell(1).alignment = { horizontal: 'left', vertical: 'middle' };
735
- row2.getCell(1).font = { italic: false };
736
-
737
- for (let c = 1; c <= cols; c++) {
738
- const edge: any = { top: { style: 'thin' }, bottom: { style: 'thin' } };
739
- if (c === 1) edge.left = { style: 'thin' };
740
- if (c === cols) edge.right = { style: 'thin' };
741
- row2.getCell(c).border = edge;
742
- }
743
-
744
- const row3 = ws.getRow(r++);
745
- ws.mergeCells(row3.number, 1, row3.number, cols);
746
- row3.getCell(1).value = `${this.closingBalanceCurrency || ''} - ${this.closingBalanceUSDInWords || ''}`;
747
- row3.getCell(1).alignment = { horizontal: 'left', vertical: 'middle' };
748
-
749
- for (let c = 1; c <= cols; c++) {
750
- const edge: any = { top: { style: 'thin' }, bottom: { style: 'thin' } };
751
- if (c === 1) edge.left = { style: 'thin' };
752
- if (c === cols) edge.right = { style: 'thin' };
753
- row3.getCell(c).border = edge;
754
- }
755
-
756
- wb.xlsx.writeBuffer().then(buf => {
757
- FileSaver.saveAs(
758
- new Blob([buf], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }),
759
- 'Statement_of_Accounts.xlsx'
760
- );
761
- });
762
- }
763
-
764
- exportToCSV(): void {
765
- const sections = this.getVisibleGrids()
766
- .map(s => {
767
- const data = this.getDisplayedData(s.api);
768
- let rows = this.buildRows(data);
769
-
770
- if (s.title === 'Send Details' && this.sendPinnedBottomRow?.length) {
771
- rows = rows.concat(this.buildRows(this.sendPinnedBottomRow));
772
- }
773
- if (s.title === 'Receive Details' && this.receivePinnedBottomRow?.length) {
774
- rows = rows.concat(this.buildRows(this.receivePinnedBottomRow));
775
- }
776
-
777
- return rows.length ? { title: s.title, headers: this.getHeaders(), rows } : null;
778
- })
779
- .filter(Boolean) as { title: string; headers: string[]; rows: any[][] }[];
780
-
781
- if (!sections.length) return;
782
-
783
- const lines: string[] = [];
784
- lines.push(this.ReportName);
785
-
786
- Object.entries(this.metaDataOne || {}).forEach(([k, v]) => lines.push(`${k}: ${v ?? ''}`));
787
- Object.entries(this.metaDataTwo || {}).forEach(([k, v]) => lines.push(`${k}: ${v ?? ''}`));
788
-
789
- // --- SEARCH CRITERIA BLOCK ---
790
- const searchCriteria: [string, string][] = this.searchCriteria || [];
791
-
792
- if (searchCriteria?.length) {
793
- lines.push('');
794
- lines.push('Search Criteria:-');
795
-
796
- // Determine max length of left column for padding
797
- const maxLeftLength = Math.max(...searchCriteria.map(([k, v]) => (k + ' ' + v).length));
798
-
799
- for (let i = 0; i < searchCriteria.length; i += 2) {
800
- const left = searchCriteria[i];
801
- const right = searchCriteria[i + 1];
802
-
803
- const leftText = left ? `${left[0]} ${left[1]}`.padEnd(maxLeftLength + 5, ' ') : '';
804
- const rightText = right ? `${right[0]} ${right[1]}` : '';
805
-
806
- // Each pair stays in its own column
807
- lines.push(`"${leftText}${rightText}"`);
808
- }
809
-
810
- lines.push(''); // blank line after search criteria
811
- }
812
-
813
- sections.forEach((sec, idx) => {
814
- lines.push(sec.title);
815
- lines.push(sec.headers.join(','));
816
- sec.rows.forEach(r => lines.push(r.map(v => `"${v ?? ''}"`).join(',')));
817
-
818
- if (idx < sections.length - 1) {
819
- lines.push('');
820
- }
821
- });
822
-
823
- lines.push(
824
- `"Closing Balance",,"${Number(this.closingBalanceInSettlment || 0).toFixed(3)}","${Number(this.closingBalance || 0).toFixed(3)}"`
825
- );
826
-
827
- lines.push(`"${this.closingBalanceSettlmentCurrency || ''} - ${this.closingBalanceSettlmentInWords || ''}"`);
828
-
829
- lines.push(`"${this.closingBalanceCurrency || ''} - ${this.closingBalanceUSDInWords || ''}"`);
830
-
831
- const csv = lines.join('\n');
832
- FileSaver.saveAs(
833
- new Blob([csv], { type: 'text/csv;charset=utf-8' }),
834
- 'Statement_of_Accounts.csv'
835
- );
836
- }
837
-
838
-
839
- private loadImageAsBase64(src: string): Promise<string> {
840
- return new Promise((resolve, reject) => {
841
- const img = new Image();
842
- img.crossOrigin = 'anonymous';
843
- img.src = src;
844
- img.onload = () => {
845
- const canvas = document.createElement('canvas');
846
- canvas.width = img.width;
847
- canvas.height = img.height;
848
- const ctx = canvas.getContext('2d');
849
- if (!ctx) return reject('Canvas context failed');
850
- ctx.drawImage(img, 0, 0);
851
- resolve(canvas.toDataURL('image/png'));
852
- };
853
- img.onerror = () => reject('Failed to load image: ' + src);
854
- });
855
- }
856
-
857
- private getDisplayedData(api?: GridApi): any[] {
858
- if (!api) return [];
859
- const rows: any[] = [];
860
- const count = api.getDisplayedRowCount();
861
- for (let i = 0; i < count; i++) {
862
- const node = api.getDisplayedRowAtIndex(i);
863
- if (node && !node.group && !node.rowPinned) rows.push(node.data);
864
- }
865
- return rows;
866
- }
867
-
868
- private getHeaders(): string[] {
869
- return this.columnDefs.map(c => c.headerName || c.field);
870
- }
871
- private format3(n: any): string {
872
- if (n == null || n === '') return '';
873
- const num = Number(n);
874
- return num.toFixed(3);
875
- }
876
- private buildRows(data: any[]): any[][] {
877
- return data.map(row =>
878
- this.columnDefs.map(col => {
879
- const f = col.field;
880
- if (f === 'amountInSettlmentCcy' || f === 'amountInUSD') {
881
- return this.format3(row[f]);
882
- }
883
- return row[f] ?? '';
884
- })
885
- );
886
- }
887
-
888
- private getVisibleGrids(): { title: string; api?: GridApi }[] {
889
- const out: { title: string; api?: GridApi }[] = [];
890
- out.push({ title: '', api: this.openingGridApi });
891
- if (this.selectedClientType === 'PayIn' || this.selectedClientType === 'Both') {
892
- out.push({ title: 'Send Details', api: this.sendGridApi });
893
- }
894
- if (this.selectedClientType === 'PayOut' || this.selectedClientType === 'Both') {
895
- out.push({ title: 'Receive Details', api: this.receiveGridApi });
896
- }
897
- return out;
898
- }
899
-
900
- handleFormValid(isValid: boolean): void {
901
- this.isFormValid = isValid;
902
- }
903
-
904
- }