@sachin9822/reports-lib 0.0.211 → 0.0.213

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,2387 @@
1
+ import { Component, EventEmitter, Input, OnInit, OnDestroy, Output, ChangeDetectorRef } from '@angular/core';
2
+ import { FormBuilder, FormGroup, Validators } from '@angular/forms';
3
+ import { ComponentLoadingState, Client, Branch, Currency, Product, TransactionStatus, User } from '../../models/transaction-enquiry-report/transaction-enquiry.model';
4
+ import { Subject } from 'rxjs';
5
+ import { forkJoin, of } from 'rxjs';
6
+ import { catchError, finalize, map, switchMap } from 'rxjs/operators';
7
+ import { takeUntil } from 'rxjs/operators';
8
+ import { ReportService } from '../../services/report.service';
9
+ import { ConfigService } from '../../services/config.service';
10
+ import { NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';
11
+ import * as angularCommon from '@angular/common';
12
+
13
+ @Component({
14
+ selector: 'lib-search-filter',
15
+ templateUrl: './search-filter.component.html',
16
+ styleUrls: ['./search-filter.component.scss']
17
+ })
18
+
19
+ export class SearchFilterComponent implements OnInit, OnDestroy {
20
+ @Input() ReportName!: string;
21
+ @Output() searchClicked = new EventEmitter<any>();
22
+ @Output() formValid = new EventEmitter<boolean>();
23
+ searchForm!: FormGroup;
24
+ @Input() initialFilters: any;
25
+ formValidationError: boolean = false;
26
+ private destroy$ = new Subject<void>();
27
+
28
+ loadingState: ComponentLoadingState = ComponentLoadingState.Complete;
29
+ ComponentLoadingState = ComponentLoadingState;
30
+ hasSearched: boolean = false;
31
+ private _errorMessage: string = '';
32
+
33
+ currentUser: string = '';
34
+ usernameMissing: boolean = false;
35
+ token = sessionStorage.getItem('access_token');
36
+ applicationType = 'ezremit';
37
+ companyCode = 'BH';
38
+ serviceUrl: string;
39
+ public isOpen = false;
40
+
41
+ clients1: Client[] = [];
42
+ branches: Branch[] = [];
43
+ users: User[] = [];
44
+ currencies: Currency[] = [];
45
+ products: Product[] = [];
46
+ transactionStatuses: TransactionStatus[] = [];
47
+ summaryReportTypes: any[] = [];
48
+ selectedStatuses: string[] = [];
49
+ showStatusDropdown: boolean = false;
50
+ visibleFieldKeys: string[] = [];
51
+ params: any;
52
+ countries: any[] = [];
53
+ transactionProducts: any[] = [];
54
+ dateType: any = 1;
55
+ date: any;
56
+ sendBusinessPartnerAgents: any[] = [];
57
+ recvBusinessPartnerAgents: any[] = [];
58
+ clientName: string;
59
+ clientType: string;
60
+ disabledDate: NgbDateStruct;
61
+ isSelectAllChecked = true;
62
+ erroMessage: string = 'Error in Loading Data';
63
+
64
+ // for Trial Balance - Accounts Report
65
+ businessUnits: any[] = [];
66
+ accountStatuses: any[] = [];
67
+ currency: any[] = [];
68
+ financialYears: any[] = [];
69
+ fromMonths: any[] = [];
70
+ toMonths: any[] = [];
71
+ dateTypes: any[] = [];
72
+ fromDays: any[] = [];
73
+ toDays: any[] = [];
74
+ paramDateDefault: any[] = [];
75
+
76
+ // Field visibility map, 'fromDate', 'toDate','product','userId','currency','transactionStatus','transactionNo'
77
+ visibleFieldsMap: { [report: string]: string[] } = {
78
+ 'Transaction Enquiry': ['client', 'fromDate', 'toDate', 'branch', 'product', 'currency', 'transactionStatus', 'transactionNo'],
79
+ 'FC Ledger': ['client', 'fromDate', 'toDate', 'currency', 'product'],
80
+ 'Branch Activity Send': ['client', 'fromDate', 'toDate', 'branch', 'transactionProduct', 'receiveCurrency', 'transactionStatus', 'sendCountry', 'receiveCountry'],
81
+ 'ACC GL Details Enquiry': ['dateType', 'date'],
82
+ 'Branch Activity Receive': ['client', 'fromDate', 'toDate', 'branch', 'transactionProduct', 'receiveCurrency', 'transactionStatus', 'sendCountry', 'receiveCountry'],
83
+ 'Cancellation Transaction': ['client', 'fromDate', 'toDate', 'branch', 'sendCountry', 'receiveCountry', 'product', 'receiveCurrency'],
84
+ 'Revenue Per Transaction': ['sendBusinessPartner', 'fromDate', 'toDate', 'recvBusinessPartner', 'sendCountry', 'receiveCountry', 'transactionStatus'],
85
+ 'Statement of Accounts': ['client', 'fromDate', 'toDate'],
86
+ 'Accounting': ['client', 'fromDate', 'toDate', 'branch', 'transactionProduct', 'sendCurrency', 'transactionStatus', 'sendCountry', 'receiveCountry'],
87
+ 'Credit Limit Status Enquiry': ['client', 'fromDate', 'toDate', 'transactionStatusSingleSelect'],
88
+ 'Funding': ['fromDate', 'toDate'],
89
+ 'Trial Balance - Accounts': ['businessUnit', 'accountStatus', 'currency', 'financialYear', 'fromMonth', 'toMonth', 'dateTypeForTrialBalanceAccounts', 'fromDay', 'toDay'],
90
+ 'Branch Activity Send Summary': ['client', 'fromDate', 'toDate', 'branch', 'transactionProduct', 'receiveCurrency', 'transactionStatus', 'sendCountry', 'receiveCountry', 'summaryReport'],
91
+
92
+ 'Transaction Monitoring': ['client', 'fromDate', 'toDate', 'branch', 'transactionProduct', 'receiveCurrency', 'transactionStatus', 'sendCountry', 'receiveCountry'],
93
+ // Add more report types here
94
+ };
95
+
96
+ get visibleFields(): string[] {
97
+ return this.visibleFieldsMap[this.ReportName] || [];
98
+ }
99
+
100
+ isFieldVisible(field: string): boolean {
101
+ return this.visibleFields.includes(field);
102
+ }
103
+
104
+ constructor(
105
+ private reportService: ReportService,
106
+ private fb: FormBuilder,
107
+ private config: ConfigService,
108
+ private cd: ChangeDetectorRef
109
+ ) {
110
+ this.serviceUrl = this.config.get.serviceUrl;
111
+ let fossilUser = sessionStorage.getItem('fossilusername');
112
+ let ezremitUser = sessionStorage.getItem('ezremitusername');
113
+
114
+ if (fossilUser) this.currentUser = fossilUser;
115
+ else if (ezremitUser) this.currentUser = ezremitUser;
116
+ else {
117
+ this.usernameMissing = true;
118
+ }
119
+ this.currentUser = this.currentUser.replace(/^["'](.*)["']$/, '$1');
120
+ }
121
+
122
+ ngOnInit(): void {
123
+ const today = new Date();
124
+ this.disabledDate = {
125
+ year: today.getFullYear(),
126
+ month: today.getMonth() + 1,
127
+ day: today.getDate()
128
+ };
129
+ this.checkReport();
130
+ }
131
+
132
+ ngOnDestroy(): void {
133
+ this.destroy$.next();
134
+ this.destroy$.complete();
135
+ }
136
+
137
+ private checkReport() {
138
+ if (this.ReportName == "Transaction Enquiry") {
139
+ this.initializeForm();
140
+ this.subscribeToDateChanges();
141
+ this.loadInitialData();
142
+ this.transactionStatusSubscribe();
143
+ }
144
+ if (this.ReportName == "Branch Activity Send") {
145
+ this.initializeForm();
146
+ this.loadInitialData();
147
+ this.subscribeToDateChanges();
148
+ this.transactionStatusSubscribe();
149
+ }
150
+ if (this.ReportName == "ACC GL Details Enquiry") {
151
+ this.initializeForm();
152
+ }
153
+ if (this.ReportName == "Cancellation Transaction") {
154
+ this.initializeForm();
155
+ this.loadInitialData();
156
+ this.subscribeToDateChanges();
157
+ }
158
+ if (this.ReportName === "Branch Activity Receive") {
159
+ this.initializeForm();
160
+ this.loadInitialData();
161
+ this.subscribeToDateChanges();
162
+ this.transactionStatusSubscribe();
163
+ }
164
+ if (this.ReportName === "Revenue Per Transaction") {
165
+ this.initializeForm()
166
+ this.loadInitialData();
167
+ this.subscribeToDateChanges();
168
+ this.transactionStatusSubscribe();
169
+ }
170
+ if (this.ReportName == "Statement of Accounts") {
171
+ this.initializeForm();
172
+ this.loadInitialData();
173
+ this.subscribeToDateChanges();
174
+ }
175
+ if (this.ReportName == "Accounting") {
176
+ this.initializeForm();
177
+ this.loadInitialData();
178
+ this.subscribeToDateChanges();
179
+ this.transactionStatusSubscribe();
180
+ }
181
+ if (this.ReportName === "Credit Limit Status Enquiry") {
182
+ this.initializeForm();
183
+ this.loadInitialData();
184
+ this.subscribeToDateChanges();
185
+ }
186
+ if (this.ReportName == "Funding") {
187
+ this.initializeForm();
188
+ this.subscribeToDateChanges();
189
+ }
190
+ if (this.ReportName == "Trial Balance - Accounts") {
191
+ this.initializeForm();
192
+ this.loadInitialData();
193
+ }
194
+ if (this.ReportName == "Branch Activity Send Summary") {
195
+ this.initializeForm();
196
+ this.loadInitialData();
197
+ this.subscribeToDateChanges();
198
+ this.transactionStatusSubscribe();
199
+ }
200
+ if (this.ReportName == "Transaction Monitoring") {
201
+ this.initializeForm();
202
+ this.loadInitialData();
203
+ this.subscribeToDateChanges();
204
+ this.transactionStatusSubscribe();
205
+ }
206
+ }
207
+
208
+ loadInitialData() {
209
+ if (this.ReportName == 'Transaction Enquiry') {
210
+ this.loadInitialDatafortxnEnquiry();
211
+ }
212
+
213
+ if (this.ReportName == "Branch Activity Send") {
214
+ this.loadInitialDataforBranchActivitySend();
215
+ }
216
+
217
+ if (this.ReportName === "Branch Activity Receive") {
218
+ this.loadInitialDataforBranchActivityReceive();
219
+ }
220
+ if (this.ReportName == "Cancellation Transaction") {
221
+ this.loadInitialDataForCancellationReport();
222
+ }
223
+ if (this.ReportName === "Revenue Per Transaction") {
224
+ this.loadDataForRevenuePerTransactionReport();
225
+ }
226
+ if (this.ReportName == "Statement of Accounts") {
227
+ this.loadInitialDataForStatementOfAccounts();
228
+ }
229
+ if (this.ReportName == "Accounting") {
230
+ this.loadInitialDataforAccounting();
231
+ }
232
+ if (this.ReportName == "Trial Balance - Accounts") {
233
+ this.loadInitialDataForTrialBalanceAccounts();
234
+ }
235
+
236
+ if (this.ReportName === "Credit Limit Status Enquiry") {
237
+ this.loadInitialDataForCreditLimitStatusEnquiry();
238
+ }
239
+ if (this.ReportName == "Branch Activity Send Summary") {
240
+ this.loadInitialDataforBranchActivitySendSummary();
241
+ }
242
+ if (this.ReportName == "Transaction Monitoring") {
243
+ this.loadInitialDataforTransactionMonitoring();
244
+ }
245
+ }
246
+
247
+ loadInitialDataforBranchActivitySendSummary() {
248
+ this.loadingState = ComponentLoadingState.Loading;
249
+ forkJoin({
250
+ params: this.reportService.getParamsForSendSummaryReport().pipe(
251
+ catchError(err => {
252
+ console.error('Error loading params', err);
253
+ return of(null);
254
+ })
255
+ ),
256
+ clients: this.reportService.getPayInAgentforSendSummaryReport().pipe(
257
+ map((clients: any[]): Client[] =>
258
+ clients.map((client, index) => ({
259
+ businessPartnerName: client.agent,
260
+ businessPartnerCode: client.code,
261
+ displayOrder: index,
262
+ clientType: ""
263
+ }))
264
+ ),
265
+ catchError(err => {
266
+ console.error('Error loading clients', err);
267
+ return of([]);
268
+ })
269
+ )
270
+ }).subscribe(
271
+ {
272
+ next: ({ params, clients }) => {
273
+ this.params = params;
274
+ this.clients1 = clients;
275
+ this.countries = [...params?.countries]
276
+ this.currencies = [...params?.currencies];
277
+ this.transactionStatuses = [...params?.transactionStatusTypes];
278
+ this.transactionProducts = [...params?.transactionProductTypes];
279
+ this.summaryReportTypes = [
280
+ { label: 'Date-Wise Summary', value: 'Date-Wise Summary' },
281
+ { label: 'Total Summary', value: 'Total Summary' }
282
+ ];
283
+
284
+ this.searchForm.patchValue({ client: this.clients1[0].businessPartnerCode });
285
+ this.onClientChange();
286
+ },
287
+ error: err => {
288
+ console.error('Unexpected forkJoin error', err);
289
+ this.loadingState = ComponentLoadingState.Complete;
290
+ },
291
+ complete: () => {
292
+ this.loadingState = ComponentLoadingState.Complete;
293
+ }
294
+ }
295
+ );
296
+ }
297
+
298
+ loadInitialDataforTransactionMonitoring() {
299
+ this.loadingState = ComponentLoadingState.Loading;
300
+ forkJoin({
301
+ params: this.reportService.getParamsForTransactionMonitoringReport().pipe(
302
+ catchError(err => {
303
+ console.error('Error loading params', err);
304
+ return of(null);
305
+ })
306
+ ),
307
+ clients: this.reportService.getPayInAgentforTransactionMonitoringReport().pipe(
308
+ map((clients: any[]): Client[] =>
309
+ clients.map((client, index) => ({
310
+ businessPartnerName: client.agent,
311
+ businessPartnerCode: client.code,
312
+ displayOrder: index,
313
+ clientType: ""
314
+ }))
315
+ ),
316
+ catchError(err => {
317
+ console.error('Error loading clients', err);
318
+ return of([]);
319
+ })
320
+ )
321
+ }).subscribe(
322
+ {
323
+ next: ({ params, clients }) => {
324
+ this.params = params;
325
+ this.clients1 = clients;
326
+ this.countries = [...params?.countries]
327
+ this.currencies = [...params?.currencies];
328
+ this.transactionStatuses = [...params?.transactionStatusTypes];
329
+ this.transactionProducts = [...params?.transactionProductTypes];
330
+
331
+ this.searchForm.patchValue({ client: this.clients1[0].businessPartnerCode });
332
+ if (this.initialFilters) {
333
+ //patch data
334
+ this.applyInitialFilters();
335
+ }
336
+
337
+
338
+ this.onClientChange();
339
+ // AUTO LOAD ONLY for routed case
340
+ if (this.initialFilters) {
341
+ this.onSearch();
342
+ }
343
+ },
344
+ error: err => {
345
+ console.error('Unexpected forkJoin error', err);
346
+ this.loadingState = ComponentLoadingState.Complete;
347
+ },
348
+ complete: () => {
349
+ this.loadingState = ComponentLoadingState.Complete;
350
+ }
351
+ }
352
+ );
353
+ }
354
+
355
+ private applyInitialFilters() {
356
+ if (!this.initialFilters) return;
357
+ const patch: any = {};
358
+ // Transaction Status (STRING → ARRAY)
359
+ if (this.initialFilters.transactionStatus) {
360
+ patch.transactionStatus = [this.initialFilters.transactionStatus];
361
+ }
362
+
363
+ // Receive Country
364
+ if (this.initialFilters.receiveCountry) {
365
+ patch.receiveCountry = this.initialFilters.receiveCountry;
366
+ }
367
+
368
+ // Realtime handling
369
+ if (this.initialFilters.isRealtime) {
370
+
371
+ patch.fromDate = '';
372
+ patch.toDate = '';
373
+ //clear
374
+ this.searchForm.get('fromDate')?.clearValidators();
375
+ this.searchForm.get('toDate')?.clearValidators();
376
+
377
+ } else {
378
+
379
+ // Only override if values exist (VERY IMPORTANT)
380
+ if (this.initialFilters.toDate) {
381
+ patch.toDate = this.initialFilters.toDate;
382
+ }
383
+ if (this.initialFilters.fromDate) {
384
+ patch.fromDate = this.initialFilters.fromDate;
385
+ }
386
+
387
+ this.searchForm.get('fromDate')?.setValidators(Validators.required);
388
+ this.searchForm.get('toDate')?.setValidators(Validators.required);
389
+
390
+ }
391
+
392
+ // Single patch call (avoids multiple triggers)
393
+ this.searchForm.patchValue(patch, { emitEvent: false });
394
+ this.searchForm.get('fromDate')?.updateValueAndValidity({ emitEvent: false });
395
+ this.searchForm.get('toDate')?.updateValueAndValidity({ emitEvent: false });
396
+
397
+ }
398
+
399
+ private initializeForm(): void {
400
+ if (this.ReportName == "Transaction Enquiry") {
401
+ this.searchForm = this.fb.group(
402
+ {
403
+ client: [null, Validators.required],
404
+ fromDate: [new Date().toISOString().split("T")[0], Validators.required],
405
+ toDate: [new Date().toISOString().split("T")[0], Validators.required],
406
+ branch: [null, Validators.required],
407
+ product: [null, Validators.required],
408
+ currency: ['All'],
409
+ transactionStatus: [['All'], Validators.required],
410
+ transactionNo: ['']
411
+ },
412
+ );
413
+ }
414
+
415
+ if (this.ReportName == "ACC GL Details Enquiry") {
416
+ this.searchForm = this.fb.group(
417
+ {
418
+ date: [new Date().toISOString().split("T")[0], Validators.required],
419
+ dateType: [1, Validators.required]
420
+ });
421
+ }
422
+
423
+ if (this.ReportName == "Branch Activity Send") {
424
+ this.searchForm = this.fb.group(
425
+ {
426
+ client: [null, Validators.required],
427
+ fromDate: [new Date().toISOString().split("T")[0], Validators.required],
428
+ toDate: [new Date().toISOString().split("T")[0], Validators.required],
429
+ branch: [null, Validators.required],
430
+ receiveCurrency: ['All'],
431
+ product: ['All', Validators.required],
432
+ transactionStatus: [['All'], Validators.required],
433
+ sendCountry: ['All'],
434
+ receiveCountry: ['All']
435
+ }
436
+ );
437
+ }
438
+
439
+ if (this.ReportName == "Branch Activity Receive") {
440
+ this.searchForm = this.fb.group(
441
+ {
442
+ client: [null, Validators.required],
443
+ fromDate: [new Date().toISOString().split("T")[0], Validators.required],
444
+ toDate: [new Date().toISOString().split("T")[0], Validators.required],
445
+ branch: [null, Validators.required],
446
+ receiveCurrency: ['All'],
447
+ product: ['All', Validators.required],
448
+ transactionStatus: [['All'], Validators.required],
449
+ sendCountry: ['All'],
450
+ receiveCountry: ['All']
451
+ }
452
+ );
453
+ }
454
+
455
+ if (this.ReportName == "Cancellation Transaction") {
456
+ this.searchForm = this.fb.group(
457
+ {
458
+ client: [null, Validators.required],
459
+ fromDate: [new Date().toISOString().split("T")[0], Validators.required],
460
+ toDate: [new Date().toISOString().split("T")[0], Validators.required],
461
+ branch: [null, Validators.required],
462
+ sendCountry: [null],
463
+ receiveCountry: [null],
464
+ product: [null, Validators.required],
465
+ receiveCurrency: [null, Validators.required],
466
+ }
467
+ );
468
+ }
469
+
470
+ if (this.ReportName === "Revenue Per Transaction") {
471
+ this.searchForm = this.fb.group({
472
+ sendBusinessPartner: [null, Validators.required],
473
+ fromDate: [new Date().toISOString().split("T")[0], Validators.required],
474
+ toDate: [new Date().toISOString().split("T")[0], Validators.required],
475
+ recvBusinessPartner: [null, Validators.required],
476
+ transactionStatus: [['All'], Validators.required],
477
+ sendCountry: ['All'],
478
+ receiveCountry: ['All']
479
+ })
480
+ }
481
+
482
+ if (this.ReportName == "Statement of Accounts") {
483
+ this.searchForm = this.fb.group(
484
+ {
485
+ client: [null, Validators.required],
486
+ fromDate: [new Date().toISOString().split("T")[0], Validators.required],
487
+ toDate: [new Date().toISOString().split("T")[0], Validators.required]
488
+ }
489
+ );
490
+ }
491
+
492
+ if (this.ReportName == "Accounting") {
493
+ this.searchForm = this.fb.group(
494
+ {
495
+ client: [null, Validators.required],
496
+ fromDate: [new Date().toISOString().split("T")[0], Validators.required],
497
+ toDate: [new Date().toISOString().split("T")[0], Validators.required],
498
+ branch: [null, Validators.required],
499
+ currency: ['All'],
500
+ product: ['All', Validators.required],
501
+ transactionStatus: [['All'], Validators.required],
502
+ sendCountry: ['All'],
503
+ receiveCountry: ['All']
504
+ }
505
+ );
506
+ }
507
+
508
+ if (this.ReportName === "Credit Limit Status Enquiry") {
509
+ this.searchForm = this.fb.group(
510
+ {
511
+ client: [null, Validators.required],
512
+ fromDate: [new Date().toISOString().split("T")[0], Validators.required],
513
+ toDate: [new Date().toISOString().split("T")[0], Validators.required],
514
+ transactionStatus: ['All', Validators.required],
515
+ }
516
+ );
517
+ }
518
+ if (this.ReportName == "Funding") {
519
+ this.searchForm = this.fb.group(
520
+ {
521
+ fromDate: [new Date().toISOString().split("T")[0], Validators.required],
522
+ toDate: [new Date().toISOString().split("T")[0], Validators.required]
523
+ }
524
+ );
525
+ }
526
+ if (this.ReportName == "Trial Balance - Accounts") {
527
+ this.searchForm = this.fb.group(
528
+ {
529
+ // Added fields
530
+ businessUnit: ['All'],
531
+ accountStatus: [['Active']],
532
+ financialYear: [new Date().getFullYear().toString()], // default to current year
533
+ fromMonth: [''],
534
+ toMonth: [''],
535
+ dateType: ['VD'], // example default
536
+ fromDay: [null, Validators.required],
537
+ toDay: [{ value: null, disabled: true }, Validators.required],
538
+ currency: ['All'],
539
+
540
+ }
541
+ );
542
+
543
+ this.reportService.GetParamDateDefaultForTrialBalanceAccountsReport().subscribe({
544
+ next: (response) => {
545
+ let financialMonth: string = response[0].financialMonth;
546
+ console.log(`financialMonth in init form of Trial Balance - Accounts: ${financialMonth}`);
547
+ this.searchForm.patchValue({
548
+ fromMonth: financialMonth,
549
+ toMonth: financialMonth
550
+ });
551
+ }, error: (err) => { console.error('Error fetching data:', err); }
552
+ });
553
+ }
554
+ if (this.ReportName == "Branch Activity Send Summary") {
555
+ this.searchForm = this.fb.group(
556
+ {
557
+ client: [null, Validators.required],
558
+ fromDate: [new Date().toISOString().split("T")[0], Validators.required],
559
+ toDate: [new Date().toISOString().split("T")[0], Validators.required],
560
+ branch: [null, Validators.required],
561
+ receiveCurrency: ['All'],
562
+ product: ['All', Validators.required],
563
+ transactionStatus: [['All'], Validators.required],
564
+ sendCountry: ['All'],
565
+ receiveCountry: ['All'],
566
+ summaryReport: ['Date-Wise Summary']
567
+ });
568
+ }
569
+ if (this.ReportName == "Transaction Monitoring") {
570
+ this.searchForm = this.fb.group(
571
+ {
572
+ client: [null, Validators.required],
573
+ fromDate: [new Date().toISOString().split("T")[0], Validators.required],
574
+ toDate: [new Date().toISOString().split("T")[0], Validators.required],
575
+ branch: [null, Validators.required],
576
+ receiveCurrency: ['All'],
577
+ product: ['All', Validators.required],
578
+ transactionStatus: [['All'], Validators.required],
579
+ sendCountry: ['All'],
580
+ receiveCountry: ['All']
581
+ }
582
+ );
583
+ }
584
+ }
585
+
586
+ loadInitialDataforBranchActivitySend() {
587
+ this.loadingState = ComponentLoadingState.Loading;
588
+ forkJoin({
589
+ params: this.reportService.getParams().pipe(
590
+ catchError(err => {
591
+ console.error('Error loading params', err);
592
+ return of(null);
593
+ })
594
+ ),
595
+ clients: this.reportService.getPayInAgents().pipe(
596
+ map((clients: any[]): Client[] =>
597
+ clients.map((client, index) => ({
598
+ businessPartnerName: client.agent,
599
+ businessPartnerCode: client.code,
600
+ displayOrder: index,
601
+ clientType: ""
602
+ }))
603
+ ),
604
+ catchError(err => {
605
+ console.error('Error loading clients', err);
606
+ return of([]);
607
+ })
608
+ )
609
+ }).subscribe(
610
+ {
611
+ next: ({ params, clients }) => {
612
+ this.params = params;
613
+ this.clients1 = clients;
614
+ this.countries = [...params?.countries]
615
+ this.currencies = [...params?.currencies];
616
+ this.transactionStatuses = [...params?.transactionStatusTypes];
617
+ this.transactionProducts = [...params?.transactionProductTypes];
618
+
619
+ this.searchForm.patchValue({ client: this.clients1[0].businessPartnerCode});
620
+ this.onClientChange();
621
+
622
+ },
623
+ error: err => {
624
+ console.error('Unexpected forkJoin error', err);
625
+ this.loadingState = ComponentLoadingState.Complete;
626
+ },
627
+ complete: () => {
628
+ this.loadingState = ComponentLoadingState.Complete;
629
+ }
630
+ }
631
+ );
632
+ }
633
+
634
+ private async loadInitialDatafortxnEnquiry(): Promise<void> {
635
+ this.loadingState = ComponentLoadingState.Loading;
636
+ this.errorMessage = '';
637
+ try {
638
+ const data = await this.reportService
639
+ .getPageLoadData()
640
+ .pipe(takeUntil(this.destroy$))
641
+ .toPromise();
642
+
643
+ if (data) {
644
+ this.clients1 = data.clients || [];
645
+ this.currencies = data.currencies || [];
646
+ this.products = data.products || [];
647
+ this.transactionStatuses = (data.transactionStatuses || []).filter(
648
+ ts => ts.transactionStatus !== ''
649
+ );
650
+ if (
651
+ !this.transactionStatuses.some(
652
+ s => s.transactionStatus === 'All'
653
+ )
654
+ ) {
655
+ this.transactionStatuses.unshift({
656
+ transactionStatus: 'All',
657
+ } as TransactionStatus);
658
+ }
659
+ this.searchForm.patchValue({ product: 'All' });
660
+
661
+ this.searchForm.patchValue({ client: this.clients1[0].businessPartnerCode});
662
+ await this.onClientChange();
663
+ }
664
+
665
+ this.loadingState = ComponentLoadingState.Complete;
666
+ } catch (error) {
667
+ this.errorMessage = 'Failed to load initial data';
668
+ this.loadingState = ComponentLoadingState.Error;
669
+ }
670
+ }
671
+
672
+ loadInitialDataforBranchActivityReceive() {
673
+ this.loadingState = ComponentLoadingState.Loading;
674
+ forkJoin({
675
+ params: this.reportService.getBranchActivityReceiveParams()
676
+ .pipe(catchError(err => {
677
+ console.error('Error loading params', err);
678
+ return of(null);
679
+ })
680
+ ),
681
+ payoutAgents: this.reportService.getAllPayOutAgents()
682
+ .pipe(map((clients: any[]): Client[] =>
683
+ clients.map((client, index) => ({
684
+ businessPartnerName: client.agent,
685
+ businessPartnerCode: client.code,
686
+ displayOrder: client.number,
687
+ clientType: ""
688
+ }))
689
+ ), catchError(err => {
690
+ return of([]);
691
+ }))
692
+ }).subscribe({
693
+ next: ({ params, payoutAgents }) => {
694
+ this.params = params;
695
+ this.clients1 = payoutAgents;
696
+ this.countries = [...params?.countries]
697
+ this.currencies = [...params?.currencies];
698
+ this.transactionStatuses = [...params?.transactionStatusTypes];
699
+ this.transactionProducts = [...params?.transactionProductTypes];
700
+
701
+ this.searchForm.patchValue({ client: this.clients1[0].businessPartnerCode});
702
+ this.onClientChange();
703
+ },
704
+ error: err => {
705
+ console.error('Unexpected forkJoin error', err);
706
+ this.loadingState = ComponentLoadingState.Complete;
707
+ },
708
+ complete: () => {
709
+ this.loadingState = ComponentLoadingState.Complete;
710
+ }
711
+ })
712
+ }
713
+ private async loadInitialDataForCancellationReport(): Promise<void> {
714
+ this.loadingState = ComponentLoadingState.Loading;
715
+ this.errorMessage = '';
716
+
717
+ try {
718
+ const data = await this.reportService
719
+ .loadDataforCancallation()
720
+ .pipe(takeUntil(this.destroy$))
721
+ .toPromise();
722
+
723
+ if (data) {
724
+ this.countries = data.countries ?? [];
725
+ this.clients1 = (data.payInAgents ?? []).map((agent) => ({
726
+ businessPartnerName: agent.agent,
727
+ businessPartnerCode: agent.code
728
+ }));
729
+ this.products = (data.productTypes ?? []).map((pt) => ({
730
+ productCode: pt.productCode,
731
+ productName: pt.name
732
+ }));
733
+ this.currencies = data.currencies ?? [];
734
+
735
+ this.searchForm.patchValue({
736
+ product: this.products[0]?.productCode,
737
+ receiveCountry: this.countries[0]?.country,
738
+ sendCountry: this.countries[0]?.country,
739
+ receiveCurrency: this.currencies[0]?.currencyCode
740
+ });
741
+
742
+ this.searchForm.patchValue({ client: this.clients1[0].businessPartnerCode});
743
+ await this.onClientChange();
744
+
745
+ } else {
746
+ // No data case
747
+ this.countries = [];
748
+ this.clients1 = [];
749
+ this.products = [];
750
+ this.currencies = [];
751
+ }
752
+
753
+ this.loadingState = ComponentLoadingState.Complete;
754
+
755
+ } catch (error) {
756
+ console.error('Error loading cancellation report data', error);
757
+ this.errorMessage = 'Failed to load cancellation report data';
758
+ this.loadingState = ComponentLoadingState.Error;
759
+ }
760
+ }
761
+
762
+ loadDataForRevenuePerTransactionReport() {
763
+ const $agents = this.reportService.getAgentsForRevenuePerTransaction();
764
+ const $params = this.reportService.getRevenuePerTransactionReportParams();
765
+ this.loadingState = ComponentLoadingState.Loading;
766
+ forkJoin([$agents, $params]).subscribe({
767
+ next: ([agents, params]) => {
768
+ this.sendBusinessPartnerAgents = agents.filter(agent => agent.transactionLeg === "PayIn");
769
+ this.recvBusinessPartnerAgents = agents.filter(agent => agent.transactionLeg === "PayOut");
770
+ this.transactionStatuses = params.transactionStatusTypes
771
+ this.countries = params.countries;
772
+
773
+ this.searchForm.patchValue({
774
+ sendBusinessPartner: this.sendBusinessPartnerAgents[0].id,
775
+ recvBusinessPartner: this.recvBusinessPartnerAgents[0].id
776
+ });
777
+
778
+ },
779
+ error: (err) => {
780
+ this.loadingState = ComponentLoadingState.Complete;
781
+ },
782
+ complete: () => {
783
+ this.loadingState = ComponentLoadingState.Complete;
784
+ }
785
+ })
786
+ }
787
+
788
+
789
+ loadInitialDataforAccounting() {
790
+ this.loadingState = ComponentLoadingState.Loading;
791
+
792
+ forkJoin({
793
+ clients: this.reportService.getClientsForAccountingReport(this.currentUser).pipe(
794
+ map((clients: any[]): Client[] =>
795
+ clients.map((client, index) => ({
796
+ businessPartnerName: client.agent,
797
+ businessPartnerCode: client.correlationId,
798
+ displayOrder: index,
799
+ clientType: ""
800
+ }))
801
+ ),
802
+ catchError(err => {
803
+ console.error('Error loading clients', err);
804
+ return of([]);
805
+ })
806
+ ),
807
+ products: this.reportService.getTransactionTypesForAccountingReport().pipe(
808
+ catchError(err => {
809
+ console.error('Error loading transaction types', err);
810
+ return of([]);
811
+ })
812
+ ),
813
+ currencies: this.reportService.getAllCurrenciesForAccountingReport().pipe(
814
+ catchError(err => {
815
+ console.error('Error loading currencies', err);
816
+ return of([]);
817
+ })
818
+ ),
819
+ statuses: this.reportService.getAllTransactionStatusForAccountingReport().pipe(
820
+ catchError(err => {
821
+ console.error('Error loading statuses', err);
822
+ return of([]);
823
+ })
824
+ ),
825
+ countries: this.reportService.getAllCountriesForAccountingReport().pipe(
826
+ catchError(err => {
827
+ console.error('Error loading countries', err);
828
+ return of([]);
829
+ })
830
+ )
831
+ }).subscribe({
832
+ next: ({ clients, products, currencies, statuses, countries }) => {
833
+ this.clients1 = clients;
834
+ this.transactionProducts = products;
835
+ this.currencies = currencies;
836
+ this.transactionStatuses = statuses;
837
+ this.countries = countries;
838
+
839
+ this.searchForm.patchValue({ client: this.clients1[0].businessPartnerCode});
840
+ this.onClientChange();
841
+ },
842
+ error: err => {
843
+ console.error('Unexpected forkJoin error in Accounting init', err);
844
+ this.loadingState = ComponentLoadingState.Error;
845
+ },
846
+ complete: () => {
847
+ this.loadingState = ComponentLoadingState.Complete;
848
+ }
849
+ });
850
+
851
+ }
852
+
853
+ loadInitialDataForCreditLimitStatusEnquiry() {
854
+ const $agents = this.reportService.getClientsForCreditLimitStatusEnquiryReport();
855
+ const $status = this.reportService.getTransactionTypesForCreditLimitStatusEnquiryReport();
856
+ this.loadingState = ComponentLoadingState.Loading;
857
+ forkJoin({
858
+ agents: $agents.pipe(
859
+ map((clients: any[]): Client[] =>
860
+ clients.map((client, index) => ({
861
+ businessPartnerName: client.name,
862
+ businessPartnerCode: client.code,
863
+ displayOrder: index,
864
+ clientType: ""
865
+ }))
866
+ )
867
+ ),
868
+ status: $status
869
+ }).subscribe({
870
+ next: ({ agents, status }) => {
871
+ this.clients1 = agents;
872
+ this.searchForm.patchValue({ client: this.clients1[0].businessPartnerCode });
873
+ this.transactionStatuses = status;
874
+ },
875
+ error: (err) => {
876
+ this.loadingState = ComponentLoadingState.Complete;
877
+ console.error('Unexpected forkJoin error', err);
878
+ },
879
+ complete: () => {
880
+ this.loadingState = ComponentLoadingState.Complete;
881
+ }
882
+
883
+ })
884
+ }
885
+ loadInitialDataForTrialBalanceAccounts() {
886
+ this.loadingState = ComponentLoadingState.Loading;
887
+
888
+ forkJoin({
889
+ businessUnits: this.reportService.GetBusinessUnitForTrialBalanceAccountsReport()
890
+ .pipe(catchError(err => of([]))),
891
+ accountStatuses: this.reportService.GetAccountStatusForTrialBalanceAccountsReport()
892
+ .pipe(catchError(err => of([]))),
893
+ dateTypes: this.reportService.GetDateTypeForTrialBalanceAccountsReport()
894
+ .pipe(catchError(err => of([]))),
895
+ financialYears: this.reportService.GetYearForTrialBalanceAccountsReport()
896
+ .pipe(catchError(err => of([]))),
897
+ fromMonths: this.reportService.GetFromMonthsForTrialBalanceAccountsReport()
898
+ .pipe(catchError(err => of([]))),
899
+ currency: this.reportService.GetCurrenciesForTrialBalanceAccountsReport()
900
+ .pipe(catchError(err => of([]))),
901
+ paramDateDefault: this.reportService.GetParamDateDefaultForTrialBalanceAccountsReport()
902
+ .pipe(catchError(err => of([])))
903
+ })
904
+ .pipe(
905
+ switchMap(results => {
906
+ // assign base results
907
+ this.businessUnits = results.businessUnits;
908
+ this.accountStatuses = results.accountStatuses;
909
+ this.dateTypes = results.dateTypes;
910
+ this.financialYears = results.financialYears
911
+ .sort((a, b) => Number(a.financialYear) - Number(b.financialYear));
912
+ this.fromMonths = results.fromMonths;
913
+ this.currencies = results.currency;
914
+ this.paramDateDefault = results.paramDateDefault;
915
+
916
+ // resolve year/month for fromDays & toMonths
917
+ const year = +(new Date().getFullYear());
918
+ const month = this.paramDateDefault[0].financialMonth;
919
+
920
+ const selectedPMonth = this.searchForm.get('fromMonth')?.value;
921
+ const fromMonthObj = this.fromMonths.find(m => m.pOrder === selectedPMonth);
922
+ const fromMonthLabel = fromMonthObj?.period;
923
+
924
+ // first call fromDays with year/month
925
+ return this.reportService.GetFromDatesForTrialBalanceAccountsReport(
926
+ year, fromMonthLabel
927
+ ).pipe(
928
+ catchError(err => of([])),
929
+ switchMap(fromDays => {
930
+ this.fromDays = fromDays;
931
+ this.searchForm.patchValue({
932
+ fromDay: this.paramDateDefault[0]?.tDate,
933
+ });
934
+
935
+ const financialYear = this.searchForm.get('financialYear')?.value;
936
+ const fromMonth = this.searchForm.get('fromMonth')?.value;
937
+ const toMonth = this.searchForm.get('toMonth')?.value;
938
+ const fromDay = this.searchForm.get('fromDay')?.value;
939
+
940
+ const requestPayload = {
941
+ Year: financialYear,
942
+ FromMonth: fromMonth,
943
+ ToMonth: toMonth,
944
+ FromDate: fromDay // assuming fromDay is already a Date or ISO string
945
+ };
946
+
947
+ // now chain to: toDays + toMonths
948
+ return forkJoin({
949
+ toDays: this.reportService.GetToDatesForTrialBalanceAccountsReport(requestPayload)
950
+ .pipe(catchError(err => of([]))),
951
+ toMonths: this.reportService.GetToMonthsForTrialBalanceAccountsReport(year, month)
952
+ .pipe(catchError(err => of([])))
953
+ }).pipe(
954
+ map(extra => ({ ...results, fromDays, ...extra }))
955
+ );
956
+ })
957
+ );
958
+ })
959
+ )
960
+ .subscribe({
961
+ next: (allResults) => {
962
+ this.toDays = allResults.toDays;
963
+ this.toMonths = allResults.toMonths;
964
+
965
+ // patch form defaults
966
+ this.searchForm.patchValue({
967
+ businessUnit: this.businessUnits[0]?.companyCode ?? null,
968
+ accountStatus: this.accountStatuses.length ? [this.accountStatuses[0].statusCode] : [],
969
+ financialYear: this.paramDateDefault[0]?.financialYear ?? new Date().getFullYear().toString(),
970
+ fromMonth: this.paramDateDefault[0]?.financialMonth,
971
+ toMonth: this.paramDateDefault[0]?.financialMonth,
972
+ dateType: this.dateTypes[0]?.dateTypeCode ?? 'VD',
973
+ fromDay: this.fromDays[0]?.tDate,
974
+ toDay: this.toDays.find(d => d.isToday)?.value ?? new Date().getDate(),
975
+ currency: this.currency[0]?.currencyCode ?? 'All'
976
+ });
977
+ },
978
+ error: (err) => {
979
+ console.error('Failed to load Trial Balance dropdown data', err);
980
+ this.loadingState = ComponentLoadingState.Error;
981
+ },
982
+ complete: () => {
983
+ this.loadingState = ComponentLoadingState.Complete;
984
+ }
985
+ });
986
+ }
987
+
988
+ private subscribeToDateChanges(): void {
989
+ this.searchForm.get('fromDate')?.valueChanges.subscribe(fromDateStr => {
990
+ const toDateControl = this.searchForm.get('toDate');
991
+ const toDateStr = toDateControl?.value;
992
+ if (!fromDateStr || !toDateStr) return;
993
+ const fromDate = new Date(fromDateStr);
994
+ const toDate = new Date(toDateStr);
995
+ const maxToDate = new Date(fromDate);
996
+ maxToDate?.setDate(fromDate.getDate() + 30);
997
+ if (toDate.setHours(0, 0, 0, 0) > maxToDate.setHours(0, 0, 0, 0) || toDate.setHours(0, 0, 0, 0) < fromDate.setHours(0, 0, 0, 0)) {
998
+ maxToDate.setHours(12, 0, 0, 0);
999
+ toDateControl?.patchValue(maxToDate.toISOString().split("T")[0]);
1000
+ // setTimeout(() => toDateControl?.patchValue(maxToDate.toISOString().split("T")[0]));
1001
+ this.cd.detectChanges();
1002
+ }
1003
+ this.disabledDate = this.toNgbDateStruct(fromDate);
1004
+ // setTimeout(() => this.disabledDate = this.toNgbDateStruct(fromDate));
1005
+
1006
+ });
1007
+
1008
+ this.searchForm.get('toDate')?.valueChanges.subscribe(toDateStr => {
1009
+ const fromDateControl = this.searchForm.get('fromDate');
1010
+ const fromDateStr = fromDateControl?.value;
1011
+ if (!toDateStr || !fromDateStr) return;
1012
+ const toDate = new Date(toDateStr);
1013
+ const fromDate = new Date(fromDateStr);
1014
+ this.disabledDate = this.toNgbDateStruct(fromDate);
1015
+ const minFromDate = new Date(toDate);
1016
+ minFromDate?.setDate(toDate.getDate() - 30);
1017
+ if (fromDate.setHours(0, 0, 0, 0) < minFromDate.setHours(0, 0, 0, 0)) {
1018
+ minFromDate.setHours(12, 0, 0, 0);
1019
+ fromDateControl?.patchValue(minFromDate.toISOString().split("T")[0]);
1020
+ this.cd.detectChanges();
1021
+ }
1022
+
1023
+ if (fromDate.setHours(0, 0, 0, 0) > toDate.setHours(0, 0, 0, 0)) {
1024
+ fromDateControl?.patchValue(minFromDate.toISOString().split("T")[0]);
1025
+ this.cd.detectChanges();
1026
+ }
1027
+ });
1028
+ }
1029
+
1030
+ private async loadInitialDataForStatementOfAccounts(): Promise<void> {
1031
+ this.loadingState = ComponentLoadingState.Loading;
1032
+ this.errorMessage = '';
1033
+
1034
+ try {
1035
+ const clients = await this.reportService
1036
+ .loadClientsForStatementOfAccounts()
1037
+ .pipe(takeUntil(this.destroy$))
1038
+ .toPromise();
1039
+
1040
+ if (clients && clients.length > 0) {
1041
+ this.clients1 = clients.map((c, index) => ({
1042
+ businessPartnerCode: c.agentID,
1043
+ businessPartnerName: c.agentName,
1044
+ displayOrder: index,
1045
+ clientType: c.clientType
1046
+ }));
1047
+ } else {
1048
+ this.clients1 = [];
1049
+ }
1050
+ if (this.clients1.length === 1) {
1051
+ this.searchForm.patchValue({
1052
+ client: this.clients1[0].businessPartnerCode
1053
+ });
1054
+ await this.onClientChange();
1055
+ }
1056
+
1057
+ this.loadingState = ComponentLoadingState.Complete;
1058
+
1059
+ } catch (error) {
1060
+ console.error('Error loading Statement of Accounts clients', error);
1061
+ this.errorMessage = 'Failed to load clients for Statement of Accounts';
1062
+ this.loadingState = ComponentLoadingState.Error;
1063
+ }
1064
+ }
1065
+
1066
+ async onClientChange(): Promise<void> {
1067
+
1068
+ if (this.ReportName == "Transaction Enquiry") {
1069
+ this.loadingState = ComponentLoadingState.Loading;
1070
+ const selectedClient = this.searchForm.get('client')?.value;
1071
+ if (!selectedClient) return;
1072
+ this.branches = [];
1073
+ if (selectedClient === 'All') {
1074
+ this.branches = [{
1075
+ businessPartnerBranch: 'All',
1076
+ businessPartnerBranch_CorrelationId: 'All',
1077
+ branchCode: 'All',
1078
+ bank: 'All',
1079
+ number: 1
1080
+ }];
1081
+ this.searchForm.patchValue({ branch: this.branches[0].branchCode });
1082
+ this.loadingState = ComponentLoadingState.Complete;
1083
+ return;
1084
+ }
1085
+ else {
1086
+ try {
1087
+ await Promise.all([
1088
+ this.loadBranchesByAgent(selectedClient)
1089
+ ]);
1090
+ this.loadingState = ComponentLoadingState.Complete;
1091
+ } catch (err) {
1092
+ this.errorMessage = 'Failed to load branch';
1093
+ this.loadingState = ComponentLoadingState.Complete;
1094
+ }
1095
+ }
1096
+ }
1097
+
1098
+ if (this.ReportName == "Branch Activity Send") {
1099
+ const selectedClient = this.searchForm.get('client')?.value;
1100
+ if (!selectedClient) return;
1101
+ this.loadingState = ComponentLoadingState.Loading;
1102
+ this.branches = [];
1103
+ if (selectedClient === 'All') {
1104
+ this.branches = [{
1105
+ businessPartnerBranch: 'All',
1106
+ businessPartnerBranch_CorrelationId: 'All',
1107
+ branchCode: 'All',
1108
+ bank: 'All',
1109
+ number: 1
1110
+ }];
1111
+ this.searchForm.patchValue({ branch: this.branches[0].branchCode });
1112
+ this.loadingState = ComponentLoadingState.Complete;
1113
+ return;
1114
+ }
1115
+ else {
1116
+ this.reportService.getBranchByAgent(selectedClient).subscribe({
1117
+ next: (data) => {
1118
+ this.branches = data;
1119
+ this.searchForm.patchValue({ branch: this.branches[0].branchCode });
1120
+ },
1121
+ error: (err) => {
1122
+ this.loadingState = ComponentLoadingState.Complete;
1123
+ },
1124
+ complete: () => {
1125
+ this.loadingState = ComponentLoadingState.Complete;
1126
+ }
1127
+ });
1128
+ }
1129
+ }
1130
+
1131
+ if (this.ReportName === "Branch Activity Receive") {
1132
+ const selectedClient = this.searchForm.get('client')?.value;
1133
+ if (!selectedClient) return;
1134
+ this.loadingState = ComponentLoadingState.Loading;
1135
+ this.branches = [];
1136
+ if (selectedClient === 'All') {
1137
+ this.branches = [{
1138
+ businessPartnerBranch: 'All',
1139
+ businessPartnerBranch_CorrelationId: 'All',
1140
+ branchCode: 'All',
1141
+ bank: 'All',
1142
+ number: 1
1143
+ }];
1144
+ this.searchForm.patchValue({ branch: this.branches[0].branchCode });
1145
+ this.loadingState = ComponentLoadingState.Complete;
1146
+ return;
1147
+ }
1148
+ else {
1149
+ this.reportService.getBranchActivityReceivePayoutAgentBranch(selectedClient).subscribe({
1150
+ next: (data) => {
1151
+ this.branches = data;
1152
+ this.searchForm.patchValue({ branch: this.branches[0].branchCode });
1153
+ },
1154
+ error: (err) => {
1155
+ this.loadingState = ComponentLoadingState.Complete;
1156
+ },
1157
+ complete: () => {
1158
+ this.loadingState = ComponentLoadingState.Complete;
1159
+ }
1160
+ });
1161
+ }
1162
+ }
1163
+
1164
+ if (this.ReportName == "Cancellation Transaction") {
1165
+ this.loadingState = ComponentLoadingState.Loading;
1166
+ this.errorMessage = '';
1167
+ const selectedClient = this.searchForm.get('client')?.value;
1168
+ this.branches = [];
1169
+ if (selectedClient === 'All') {
1170
+ this.branches = [{
1171
+ businessPartnerBranch: 'All',
1172
+ businessPartnerBranch_CorrelationId: 'All',
1173
+ branchCode: 'All',
1174
+ bank: 'All',
1175
+ number: 1
1176
+ }];
1177
+ this.searchForm.patchValue({ branch: this.branches[0].branchCode });
1178
+ this.loadingState = ComponentLoadingState.Complete;
1179
+ return;
1180
+ }
1181
+ else {
1182
+ try {
1183
+ const data = await this.reportService
1184
+ .getBranches(selectedClient)
1185
+ .pipe(takeUntil(this.destroy$))
1186
+ .toPromise();
1187
+
1188
+ if (data) {
1189
+ this.branches = data;
1190
+ this.searchForm.patchValue({ branch: this.branches[0].branchCode });
1191
+ }
1192
+ this.loadingState = ComponentLoadingState.Complete;
1193
+
1194
+ } catch (error) {
1195
+ console.error('Failed to load branches', error);
1196
+ this.errorMessage = 'Failed to load branch data';
1197
+ this.loadingState = ComponentLoadingState.Error;
1198
+ }
1199
+ }
1200
+ }
1201
+
1202
+ if (this.ReportName == "Statement of Accounts") {
1203
+ this.loadingState = ComponentLoadingState.Loading;
1204
+ this.errorMessage = '';
1205
+ const ClientId = this.searchForm.get('client')?.value;
1206
+ const selectedClient = this.clients1.find(c => c.businessPartnerCode === ClientId);
1207
+ this.clientName = selectedClient?.businessPartnerName || '';
1208
+ this.clientType = selectedClient?.clientType || '';
1209
+ this.loadingState = ComponentLoadingState.Complete;
1210
+ }
1211
+
1212
+ // accounting report
1213
+ if (this.ReportName == "Accounting") {
1214
+ const selectedClient = this.searchForm.get('client')?.value;
1215
+ if (!selectedClient) return;
1216
+ this.loadingState = ComponentLoadingState.Loading;
1217
+
1218
+ this.branches = [];
1219
+ if (selectedClient === 'All') {
1220
+ this.branches = [{
1221
+ businessPartnerBranch: 'All',
1222
+ businessPartnerBranch_CorrelationId: 'All',
1223
+ branchCode: 'All',
1224
+ bank: 'All',
1225
+ number: 1
1226
+ }];
1227
+ this.searchForm.patchValue({ branch: this.branches[0].branchCode });
1228
+ this.loadingState = ComponentLoadingState.Complete;
1229
+ return;
1230
+ }
1231
+ else {
1232
+ this.reportService.getBranchByAgentForAccountingReport(this.currentUser, selectedClient).subscribe({
1233
+ next: (data) => {
1234
+ this.branches = data;
1235
+ this.searchForm.patchValue({ branch: this.branches[0].branchCode });
1236
+ },
1237
+ error: (err) => {
1238
+ this.loadingState = ComponentLoadingState.Complete;
1239
+ },
1240
+ complete: () => {
1241
+ this.loadingState = ComponentLoadingState.Complete;
1242
+ }
1243
+ });
1244
+ }
1245
+ }
1246
+
1247
+ if (this.ReportName == "Branch Activity Send") {
1248
+ this.loadingState = ComponentLoadingState.Loading;
1249
+ const selectedClient = this.searchForm.get('client')?.value;
1250
+ this.branches = [];
1251
+ if (selectedClient === 'All') {
1252
+ this.branches = [{
1253
+ businessPartnerBranch: 'All',
1254
+ businessPartnerBranch_CorrelationId: 'All',
1255
+ branchCode: 'All',
1256
+ bank: 'All',
1257
+ number: 1
1258
+ }];
1259
+ this.searchForm.patchValue({ branch: this.branches[0].branchCode });
1260
+ this.loadingState = ComponentLoadingState.Complete;
1261
+ return;
1262
+ }
1263
+ else {
1264
+ this.reportService.getBranchByAgent(selectedClient).subscribe({
1265
+ next: (data) => {
1266
+ this.branches = data;
1267
+ this.searchForm.patchValue({ branch: this.branches[0].branchCode });
1268
+ },
1269
+ error: (err) => {
1270
+ throw err;
1271
+ },
1272
+ complete: () => {
1273
+ this.loadingState = ComponentLoadingState.Complete;
1274
+ }
1275
+ });
1276
+ }
1277
+ }
1278
+ if (this.ReportName == "Transaction Monitoring") {
1279
+ const selectedClient = this.searchForm.get('client')?.value;
1280
+ if (!selectedClient) return;
1281
+ this.loadingState = ComponentLoadingState.Loading;
1282
+ this.branches = [];
1283
+ if (selectedClient === 'All') {
1284
+ this.branches = [{
1285
+ businessPartnerBranch: 'All',
1286
+ businessPartnerBranch_CorrelationId: 'All',
1287
+ branchCode: 'All',
1288
+ bank: 'All',
1289
+ number: 1
1290
+ }];
1291
+ this.searchForm.patchValue({ branch: this.branches[0].branchCode });
1292
+ this.loadingState = ComponentLoadingState.Complete;
1293
+ return;
1294
+ }
1295
+ else {
1296
+ this.reportService.getBranchByAgentForTransactionMonitoringReport(selectedClient).subscribe({
1297
+ next: (data) => {
1298
+ this.branches = data;
1299
+ this.searchForm.patchValue({ branch: this.branches[0].branchCode });
1300
+ },
1301
+ error: (err) => {
1302
+ this.loadingState = ComponentLoadingState.Complete;
1303
+ },
1304
+ complete: () => {
1305
+ this.loadingState = ComponentLoadingState.Complete;
1306
+ }
1307
+ });
1308
+ }
1309
+ }
1310
+ if (this.ReportName == "Branch Activity Send Summary") {
1311
+ this.loadingState = ComponentLoadingState.Loading;
1312
+ const selectedClient = this.searchForm.get('client')?.value;
1313
+ this.branches = [];
1314
+ if (selectedClient === 'All') {
1315
+ this.branches = [{
1316
+ businessPartnerBranch: 'All',
1317
+ businessPartnerBranch_CorrelationId: 'All',
1318
+ branchCode: 'All',
1319
+ bank: 'All',
1320
+ number: 1
1321
+ }];
1322
+ this.searchForm.patchValue({ branch: this.branches[0].branchCode });
1323
+ this.loadingState = ComponentLoadingState.Complete;
1324
+ return;
1325
+ }
1326
+ else {
1327
+ this.reportService.getBranchByAgentForSendSummaryReport(selectedClient).subscribe({
1328
+ next: (data) => {
1329
+ this.branches = data;
1330
+ this.searchForm.patchValue({ branch: this.branches[0].branchCode });
1331
+ },
1332
+ error: (err) => {
1333
+ throw err;
1334
+ },
1335
+ complete: () => {
1336
+ this.loadingState = ComponentLoadingState.Complete;
1337
+ }
1338
+ });
1339
+ }
1340
+ }
1341
+ }
1342
+
1343
+
1344
+ private async loadBranchesByAgent(agentCode: string): Promise<void> {
1345
+ const branches = await this.reportService
1346
+ .getBranchesByAgent(agentCode)
1347
+ .pipe(takeUntil(this.destroy$))
1348
+ .toPromise();
1349
+ this.branches = branches || [];
1350
+
1351
+ if (this.branches.length === 1) {
1352
+ this.searchForm.patchValue({ branch: this.branches[0].branchCode });
1353
+ // await this.loadUsersByBranch(agentCode, this.branches[0].branchCode);
1354
+ } else if (this.branches.some(b => b.branchCode === 'All')) {
1355
+ this.searchForm.patchValue({ branch: 'All' });
1356
+ // await this.loadUsersByBranch(agentCode, 'All');
1357
+ } else {
1358
+ this.searchForm.patchValue({ branch: '' });
1359
+ this.users = [];
1360
+ }
1361
+ }
1362
+
1363
+ async onBranchChange(): Promise<void> {
1364
+
1365
+ }
1366
+
1367
+ onSearch(): void {
1368
+ if (this.ReportName == "Transaction Enquiry") {
1369
+ this.hasSearched = true;
1370
+ if (this.searchForm.invalid) {
1371
+ this.formValidationError = true;
1372
+ this.formValid.emit(false);
1373
+ return;
1374
+ }
1375
+ this.formValidationError = false;
1376
+ this.formValid.emit(true);
1377
+ this.searchClicked.emit(this.buildSearchCriteria());
1378
+ }
1379
+
1380
+ if (this.ReportName == "Branch Activity Send") {
1381
+ this.hasSearched = true;
1382
+ if (this.searchForm.invalid) {
1383
+ this.formValidationError = true;
1384
+ this.formValid.emit(false);
1385
+ return;
1386
+ }
1387
+ this.formValidationError = false;
1388
+ this.formValid.emit(true);
1389
+ this.searchClicked.emit(this.buildSearchCriteria());
1390
+ }
1391
+
1392
+ if (this.ReportName == "ACC GL Details Enquiry") {
1393
+ this.hasSearched = true;
1394
+ if (this.searchForm.invalid) {
1395
+ this.formValidationError = true;
1396
+ this.formValid.emit(false);
1397
+ return;
1398
+ }
1399
+ this.formValidationError = false;
1400
+ const modal = {
1401
+ selectedDateType: this.searchForm.controls["dateType"]?.value,
1402
+ selectedDate: this.searchForm.controls["date"]?.value
1403
+ }
1404
+ this.formValid.emit(true);
1405
+ this.searchClicked.emit(modal);
1406
+ }
1407
+
1408
+ if (this.ReportName === "Branch Activity Receive") {
1409
+ this.hasSearched = true;
1410
+ if (this.searchForm.invalid) {
1411
+ this.formValidationError = true;
1412
+ this.formValid.emit(false);
1413
+ return;
1414
+ }
1415
+ this.formValidationError = false;
1416
+ this.formValid.emit(true);
1417
+ this.searchClicked.emit(this.buildSearchCriteria());
1418
+ }
1419
+
1420
+ if (this.ReportName == "Cancellation Transaction") {
1421
+ this.hasSearched = true;
1422
+ if (this.searchForm.invalid) {
1423
+ this.formValidationError = true;
1424
+ this.formValid.emit(false);
1425
+ return;
1426
+ }
1427
+ this.formValidationError = false;
1428
+ this.formValid.emit(true);
1429
+ this.searchClicked.emit(this.buildSearchCriteria());
1430
+ }
1431
+
1432
+ if (this.ReportName === "Revenue Per Transaction") {
1433
+ this.hasSearched = true;
1434
+ if (this.searchForm.invalid) {
1435
+ this.formValidationError = true;
1436
+ this.formValid.emit(false);
1437
+ return;
1438
+ }
1439
+ this.formValidationError = false;
1440
+ this.formValid.emit(true);
1441
+ this.searchClicked.emit(this.buildSearchCriteria());
1442
+ }
1443
+
1444
+ if (this.ReportName == "Statement of Accounts") {
1445
+ this.hasSearched = true;
1446
+ if (this.searchForm.invalid) {
1447
+ this.formValidationError = true;
1448
+ this.formValid.emit(false);
1449
+ return;
1450
+ }
1451
+ this.formValidationError = false;
1452
+ this.formValid.emit(true);
1453
+ this.searchClicked.emit(this.buildSearchCriteria());
1454
+ }
1455
+
1456
+
1457
+ if (this.ReportName == "Accounting") {
1458
+ this.hasSearched = true;
1459
+ if (this.searchForm.invalid) {
1460
+ this.formValidationError = true;
1461
+ // this.markFormGroupTouched(this.searchForm);
1462
+ this.formValid.emit(false);
1463
+ return;
1464
+ }
1465
+ this.formValidationError = false;
1466
+ this.formValid.emit(true);
1467
+ this.searchClicked.emit(this.buildSearchCriteria());
1468
+ }
1469
+
1470
+ if (this.ReportName === "Credit Limit Status Enquiry") {
1471
+ this.hasSearched = true;
1472
+ if (this.searchForm.invalid) {
1473
+ this.formValidationError = true;
1474
+ this.formValid.emit(false);
1475
+ return;
1476
+ }
1477
+ this.formValidationError = false;
1478
+ this.formValid.emit(true);
1479
+ this.searchClicked.emit(this.buildSearchCriteria());
1480
+ }
1481
+ if (this.ReportName == "Funding") {
1482
+ this.hasSearched = true;
1483
+ if (this.searchForm.invalid) {
1484
+ this.formValidationError = true;
1485
+ this.formValid.emit(false);
1486
+ return;
1487
+ }
1488
+ this.formValidationError = false;
1489
+ this.formValid.emit(true);
1490
+ this.searchClicked.emit(this.buildSearchCriteria());
1491
+ }
1492
+ if (this.ReportName == "Trial Balance - Accounts") {
1493
+ this.hasSearched = true;
1494
+ if (this.searchForm.invalid) {
1495
+ this.formValidationError = true;
1496
+ this.formValid.emit(false);
1497
+ return;
1498
+ }
1499
+ this.formValidationError = false;
1500
+ this.formValid.emit(true);
1501
+ this.searchClicked.emit(this.buildSearchCriteria());
1502
+ }
1503
+ if (this.ReportName == "Branch Activity Send Summary")
1504
+ {
1505
+ this.hasSearched = true;
1506
+ if (this.searchForm.invalid) {
1507
+ this.formValidationError = true;
1508
+ this.formValid.emit(false);
1509
+ return;
1510
+ }
1511
+ this.formValidationError = false;
1512
+ this.formValid.emit(true);
1513
+ this.searchClicked.emit(this.buildSearchCriteria());
1514
+ }
1515
+ if (this.ReportName == "Transaction Monitoring") {
1516
+ this.hasSearched = true;
1517
+ if (this.searchForm.invalid) {
1518
+ this.formValidationError = true;
1519
+ this.formValid.emit(false);
1520
+ return;
1521
+ }
1522
+ this.formValidationError = false;
1523
+ this.formValid.emit(true);
1524
+ this.searchClicked.emit(this.buildSearchCriteria());
1525
+ }
1526
+ }
1527
+
1528
+ private buildSearchCriteria(): any {
1529
+
1530
+ const formValue = this.searchForm.value;
1531
+ const fromDate = new Date(formValue.fromDate);
1532
+ const toDate = new Date(formValue.toDate);
1533
+
1534
+ const formatDate = (d: Date) => {
1535
+ const day = String(d.getDate()).padStart(2, "0");
1536
+ const month = String(d.getMonth() + 1).padStart(2, "0");
1537
+ const year = d.getFullYear();
1538
+ return `${day}/${month}/${year}`;
1539
+ };
1540
+
1541
+ const searchCriteria = this.getSearchCriteriaArray();
1542
+
1543
+ if (this.ReportName == "Transaction Enquiry") {
1544
+ const formValue = this.searchForm.value;
1545
+ formValue.fromDate = this.toIsoFormat(formValue.fromDate);
1546
+ formValue.toDate = this.toIsoFormat(formValue.toDate);
1547
+ return {
1548
+ modal: formValue,
1549
+ sysUserID: this.currentUser,
1550
+ reportPeriod: `${formatDate(fromDate)} - ${formatDate(toDate)}`,
1551
+ searchCriteria: searchCriteria
1552
+ };
1553
+ }
1554
+
1555
+ if (this.ReportName == "Branch Activity Send") {
1556
+ const formValue = this.searchForm.value;
1557
+ formValue.fromDate = this.toIsoFormat(formValue.fromDate);
1558
+ formValue.toDate = this.toIsoFormat(formValue.toDate);
1559
+ const searchCriteria: [string, string][] = [
1560
+ ['Client:', this.clients1.find(c => c.businessPartnerCode === formValue.client)?.businessPartnerName || ''],
1561
+ ['Transaction Status:', formValue.transactionStatus.join(",")],
1562
+ ['Branch:', this.branches.find(b => b.branchCode === formValue.branch)?.businessPartnerBranch || ''],
1563
+ ['Product:', formValue.product],
1564
+ ['From Date:', angularCommon.formatDate(this.toIsoFormat(formValue.fromDate), 'dd/MM/yyyy', 'en-US')],
1565
+ ['Receive Currency:', this.currencies.find(c => c.currencyCode === formValue.receiveCurrency)?.currency || ''],
1566
+ ['To Date:', angularCommon.formatDate(this.toIsoFormat(formValue.toDate), 'dd/MM/yyyy', 'en-US')],
1567
+ ['Send Country:', this.countries.find(c => c.countryCode === formValue.sendCountry)?.country || ''],
1568
+ ['Receive Country:', this.countries.find(c => c.countryCode === formValue.receiveCountry)?.country || ''],
1569
+ ];
1570
+ return {
1571
+ modal: formValue,
1572
+ sysUserID: this.currentUser,
1573
+ searchCriteria: searchCriteria
1574
+ }
1575
+ }
1576
+
1577
+ if (this.ReportName == "Branch Activity Receive") {
1578
+ const formValue = this.searchForm.value;
1579
+ formValue.fromDate = this.toIsoFormat(formValue.fromDate);
1580
+ formValue.toDate = this.toIsoFormat(formValue.toDate);
1581
+ const searchCriteria: [string, string][] = [
1582
+ ['Client:', this.clients1.find(c => c.businessPartnerCode === formValue.client)?.businessPartnerName || ''],
1583
+ ['Transaction Status:', formValue.transactionStatus.join(",")],
1584
+ ['Branch:', this.branches.find(b => b.branchCode === formValue.branch)?.businessPartnerBranch || ''],
1585
+ ['Product:', formValue.product],
1586
+ ['From Date:', angularCommon.formatDate(this.toIsoFormat(formValue.fromDate), 'dd/MM/yyyy', 'en-US')],
1587
+ ['Receive Currency:', this.currencies.find(c => c.currencyCode === formValue.receiveCurrency)?.currency || ''],
1588
+ ['To Date:', angularCommon.formatDate(this.toIsoFormat(formValue.toDate), 'dd/MM/yyyy', 'en-US')],
1589
+ ['Send Country:', this.countries.find(c => c.countryCode === formValue.sendCountry)?.country || ''],
1590
+ ['Receive Country:', this.countries.find(c => c.countryCode === formValue.receiveCountry)?.country || ''],
1591
+ ];
1592
+ return {
1593
+ modal: formValue,
1594
+ sysUserID: this.currentUser,
1595
+ searchCriteria: searchCriteria
1596
+ }
1597
+ }
1598
+
1599
+ if (this.ReportName == "Cancellation Transaction") {
1600
+ const formValue = this.searchForm.value;
1601
+ formValue.fromDate = this.toIsoFormat(formValue.fromDate);
1602
+ formValue.toDate = this.toIsoFormat(formValue.toDate);
1603
+ const searchCriteria: [string, string][] = [
1604
+ ['Client:', this.clients1.find(c => c.businessPartnerCode === formValue.client)?.businessPartnerName || ''],
1605
+ ['Branch:', this.branches.find(b => b.branchCode === formValue.branch)?.businessPartnerBranch || ''],
1606
+ ['Product:', formValue.product],
1607
+ ['From Date:', angularCommon.formatDate(this.toIsoFormat(formValue.fromDate), 'dd/MM/yyyy', 'en-US')],
1608
+ ['Receive Currency:', this.currencies.find(c => c.currencyCode === formValue.receiveCurrency)?.currency || ''],
1609
+ ['To Date:', angularCommon.formatDate(this.toIsoFormat(formValue.toDate), 'dd/MM/yyyy', 'en-US')],
1610
+ ['Send Country:', this.countries.find(c => c.countryCode === formValue.sendCountry)?.country || ''],
1611
+ ['Receive Country:', this.countries.find(c => c.countryCode === formValue.receiveCountry)?.country || ''],
1612
+
1613
+ ];
1614
+ return {
1615
+ modal: formValue,
1616
+ sysUserID: this.currentUser,
1617
+ reportPeriod: `${formatDate(fromDate)} - ${formatDate(toDate)}`,
1618
+ searchCriteria: searchCriteria
1619
+ };
1620
+ }
1621
+
1622
+ if (this.ReportName === "Revenue Per Transaction") {
1623
+ const formValue = this.searchForm.value;
1624
+ formValue.fromDate = this.toIsoFormat(formValue.fromDate);
1625
+ formValue.toDate = this.toIsoFormat(formValue.toDate);
1626
+ const searchCriteria: [string, string][] = [
1627
+ ['Sender Partner:', this.sendBusinessPartnerAgents.find(c => c.id === formValue.sendBusinessPartner)?.name || ''],
1628
+ ['Receive Partner:', this.recvBusinessPartnerAgents.find(c => c.id === formValue.recvBusinessPartner)?.name || ''],
1629
+ ['Send Country:', this.countries.find(c => c.countryCode === formValue.sendCountry)?.country || ''],
1630
+ ['Receive Country:', this.countries.find(c => c.countryCode === formValue.receiveCountry)?.country || ''],
1631
+ ['From Date:', angularCommon.formatDate(this.toIsoFormat(formValue.fromDate), 'dd/MM/yyyy', 'en-US')],
1632
+ ['To Date:', angularCommon.formatDate(this.toIsoFormat(formValue.toDate), 'dd/MM/yyyy', 'en-US')],
1633
+ ['Transaction Status:', formValue.transactionStatus.join(",")],
1634
+ ];
1635
+ return {
1636
+ modal: formValue,
1637
+ sysUserId: this.currentUser,
1638
+ searchCriteria: searchCriteria
1639
+ }
1640
+ }
1641
+
1642
+ if (this.ReportName == "Statement of Accounts") {
1643
+ const formValue = this.searchForm.value;
1644
+ formValue.fromDate = this.toIsoFormat(formValue.fromDate);
1645
+ formValue.toDate = this.toIsoFormat(formValue.toDate);
1646
+ return {
1647
+ modal: formValue,
1648
+ clientType: this.clientType,
1649
+ sysUserID: this.currentUser,
1650
+ clientName: this.clientName,
1651
+ reportPeriod: `${formatDate(fromDate)} - ${formatDate(toDate)}`,
1652
+ searchCriteria: searchCriteria
1653
+ }
1654
+ }
1655
+
1656
+ if (this.ReportName == "Accounting") {
1657
+ const formValue = this.searchForm.value;
1658
+ const searchCriteria = [
1659
+ ['Client:', this.clients1.find(c => c.businessPartnerCode === formValue.client)?.businessPartnerName || ''],
1660
+ ['Transaction Status:', formValue.transactionStatus.join(",")],
1661
+ ['Branch:', this.branches.find(b => b.branchCode === formValue.branch)?.businessPartnerBranch || ''],
1662
+ ['Product:', this.transactionProducts.find(t => t.productCode === formValue.product)?.name || ''],
1663
+ ['From Date:', angularCommon.formatDate(this.toIsoFormat(formValue.fromDate), 'dd/MM/yyyy', 'en-US')],
1664
+ ['Send Currency:', this.currencies.find(c => c.currencyCode === formValue.currency)?.currency || ''],
1665
+ ['To Date:', angularCommon.formatDate(this.toIsoFormat(formValue.toDate), 'dd/MM/yyyy', 'en-US')],
1666
+ ['Send Country:', this.countries.find(c => c.countryCode === formValue.sendCountry)?.country || ''],
1667
+ ['Receive Country:', this.countries.find(c => c.countryCode === formValue.receiveCountry)?.country || ''],
1668
+ ];
1669
+ return {
1670
+ modal: {
1671
+ ...formValue,
1672
+ fromDate: this.toIsoFormat(formValue.fromDate),
1673
+ toDate: this.toIsoFormat(formValue.toDate),
1674
+ },
1675
+ sysUserID: this.currentUser,
1676
+ searchCriteria: searchCriteria
1677
+ };
1678
+ }
1679
+
1680
+ if (this.ReportName === "Credit Limit Status Enquiry") {
1681
+ const clientCode = this.searchForm.controls['client'].value;
1682
+ const formValue = this.searchForm.value;
1683
+ formValue.fromDate = this.toIsoFormat(formValue.fromDate);
1684
+ formValue.toDate = this.toIsoFormat(formValue.toDate);
1685
+ formValue.client = this.clients1.find(c => c.businessPartnerCode === clientCode)?.businessPartnerName || '';
1686
+ const searchCriteria: [string, string][] = [
1687
+ ['Client:', this.clients1.find(c => c.businessPartnerCode === clientCode)?.businessPartnerName || ''],
1688
+ ['Transaction status:', formValue.transactionStatus],
1689
+ ['From Date:', angularCommon.formatDate(this.toIsoFormat(formValue.fromDate), 'dd/MM/yyyy', 'en-US')],
1690
+ ['To Date:', angularCommon.formatDate(this.toIsoFormat(formValue.toDate), 'dd/MM/yyyy', 'en-US')],
1691
+ ];
1692
+ return {
1693
+ modal: formValue,
1694
+ sysUserID: this.currentUser,
1695
+ searchCriteria: searchCriteria
1696
+ }
1697
+ }
1698
+ if (this.ReportName == "Funding") {
1699
+ return {
1700
+ modal: formValue,
1701
+ sysUserID: this.currentUser,
1702
+ reportPeriod: `${formatDate(fromDate)} - ${formatDate(toDate)}`,
1703
+ searchCriteria: searchCriteria
1704
+ };
1705
+ }
1706
+ if (this.ReportName == "Trial Balance - Accounts") {
1707
+ const formValue = this.searchForm.value;
1708
+ const dateRange = this.prepareFromDateAndToDateForTrialBalanceAccountReport();
1709
+ return {
1710
+ modal: {
1711
+ ...formValue,
1712
+ fromDate: dateRange.fromDate,
1713
+ toDate: dateRange.toDate,
1714
+ },
1715
+ sysUserID: this.currentUser
1716
+ };
1717
+
1718
+ }
1719
+ if (this.ReportName == "Branch Activity Send Summary")
1720
+ {
1721
+ const formValue = this.searchForm.value;
1722
+ formValue.fromDate = this.toIsoFormat(formValue.fromDate);
1723
+ formValue.toDate = this.toIsoFormat(formValue.toDate);
1724
+ const searchCriteria: [string, string][] = [
1725
+ ['Client:', this.clients1.find(c => c.businessPartnerCode === formValue.client)?.businessPartnerName || ''],
1726
+ ['Transaction Status:', formValue.transactionStatus.join(",")],
1727
+ ['Branch:', this.branches.find(b => b.branchCode === formValue.branch)?.businessPartnerBranch || ''],
1728
+ ['Product:', formValue.product],
1729
+ ['From Date:', angularCommon.formatDate(this.toIsoFormat(formValue.fromDate), 'dd/MM/yyyy', 'en-US')],
1730
+ ['Receive Currency:', this.currencies.find(c => c.currencyCode === formValue.receiveCurrency)?.currency || ''],
1731
+ ['To Date:', angularCommon.formatDate(this.toIsoFormat(formValue.toDate), 'dd/MM/yyyy', 'en-US')],
1732
+ ['Send Country:', this.countries.find(c => c.countryCode === formValue.sendCountry)?.country || ''],
1733
+ ['Receive Country:', this.countries.find(c => c.countryCode === formValue.receiveCountry)?.country || ''],
1734
+ ['Summary Report:', formValue.summaryReport],
1735
+ ];
1736
+ return {
1737
+ modal: formValue,
1738
+ sysUserID: this.currentUser,
1739
+ searchCriteria: searchCriteria
1740
+ }
1741
+ }
1742
+ if (this.ReportName == "Transaction Monitoring") {
1743
+ const formValue = this.searchForm.value;
1744
+ // formValue.fromDate = this.toIsoFormat(formValue.fromDate);
1745
+ // formValue.toDate = this.toIsoFormat(formValue.toDate);
1746
+ if (this.initialFilters?.isRealtime && (formValue.fromDate == '' && formValue.toDate == '')) {
1747
+ formValue.fromDate = null;
1748
+ formValue.toDate = null;
1749
+ } else {
1750
+ formValue.fromDate = this.toIsoFormat(fromDate);
1751
+ formValue.toDate = this.toIsoFormat(toDate);
1752
+ if (this.initialFilters?.isRealtime) {
1753
+ this.initialFilters.isRealtime = false;
1754
+ }
1755
+
1756
+ }
1757
+ const searchCriteria: [string, string][] = [
1758
+ ['Client:', this.clients1.find(c => c.businessPartnerCode === formValue.client)?.businessPartnerName || ''],
1759
+ ['Transaction Status:', formValue.transactionStatus.join(",")],
1760
+ ['Branch:', this.branches.find(b => b.branchCode === formValue.branch)?.businessPartnerBranch || ''],
1761
+ ['Product:', formValue.product],
1762
+ ['From Date:', this.initialFilters?.isRealtime ? '' : angularCommon.formatDate(this.toIsoFormat(formValue.fromDate), 'dd/MM/yyyy', 'en-US')],
1763
+ ['Receive Currency:', this.currencies.find(c => c.currencyCode === formValue.receiveCurrency)?.currency || ''],
1764
+ ['To Date:', this.initialFilters?.isRealtime ? '' : angularCommon.formatDate(this.toIsoFormat(formValue.toDate), 'dd/MM/yyyy', 'en-US')],
1765
+ ['Send Country:', this.countries.find(c => c.countryCode === formValue.sendCountry)?.country || ''],
1766
+ ['Receive Country:', this.countries.find(c => c.countryCode === formValue.receiveCountry)?.country || ''],
1767
+ ];
1768
+ return {
1769
+ modal: formValue,
1770
+ sysUserID: this.currentUser,
1771
+ isRealtime: this.initialFilters?.isRealtime,
1772
+ searchCriteria: searchCriteria
1773
+ }
1774
+ }
1775
+ }
1776
+
1777
+ toIsoFormat(dateInput: any): string | undefined {
1778
+ if (!dateInput) return undefined;
1779
+
1780
+ // Handle { year, month, day }
1781
+ if (
1782
+ typeof dateInput === 'object' &&
1783
+ dateInput.year &&
1784
+ dateInput.month &&
1785
+ dateInput.day
1786
+ ) {
1787
+ const year = dateInput.year;
1788
+ const month = String(dateInput.month).padStart(2, '0');
1789
+ const day = String(dateInput.day).padStart(2, '0');
1790
+ return `${year}-${month}-${day}`;
1791
+ }
1792
+
1793
+ // Handle JS Date object
1794
+ if (dateInput instanceof Date) {
1795
+ if (isNaN(dateInput.getTime())) return undefined;
1796
+ const year = dateInput.getFullYear();
1797
+ const month = String(dateInput.getMonth() + 1).padStart(2, '0');
1798
+ const day = String(dateInput.getDate()).padStart(2, '0');
1799
+ return `${year}-${month}-${day}`;
1800
+ }
1801
+
1802
+ // Handle dd/MM/yyyy string
1803
+ if (typeof dateInput === 'string' && dateInput.includes('/')) {
1804
+ const parts = dateInput.split('/');
1805
+ if (parts.length === 3) {
1806
+ const [day, month, year] = parts;
1807
+ return `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`;
1808
+ }
1809
+ }
1810
+
1811
+ // Handle ISO string (yyyy-MM-dd or yyyy-MM-ddTHH:mm:ss.sssZ)
1812
+ if (typeof dateInput === 'string' && /^\d{4}-\d{2}-\d{2}/.test(dateInput)) {
1813
+ // Use only date part if full ISO string
1814
+ return dateInput.substring(0, 10);
1815
+ }
1816
+
1817
+ return undefined;
1818
+ }
1819
+
1820
+ onOpen() {
1821
+ this.isOpen = true;
1822
+ }
1823
+ onClose() {
1824
+ this.isOpen = false;
1825
+ }
1826
+
1827
+
1828
+ get errorMessage(): string {
1829
+ return this._errorMessage;
1830
+ }
1831
+
1832
+ set errorMessage(value: string) {
1833
+ this._errorMessage = value;
1834
+ }
1835
+
1836
+ get isLoading(): boolean {
1837
+ return this.loadingState === ComponentLoadingState.Loading;
1838
+ }
1839
+
1840
+ get isError(): boolean {
1841
+ return this.loadingState === ComponentLoadingState.Error;
1842
+ }
1843
+
1844
+ currencySearch = (term: string, item: any) => {
1845
+ term = term.toLowerCase();
1846
+ return (
1847
+ item.currencyCode.toLowerCase().includes(term)
1848
+ );
1849
+ };
1850
+
1851
+ toNgbDateStruct(fromDate: Date): NgbDateStruct {
1852
+ return {
1853
+ year: fromDate.getFullYear(),
1854
+ month: fromDate.getMonth() + 1,
1855
+ day: fromDate.getDate()
1856
+ };
1857
+ }
1858
+
1859
+ transactionStatusSubscribe() {
1860
+ this.searchForm.get('transactionStatus').valueChanges.subscribe((val) => {
1861
+ const allStatus = this.transactionStatuses
1862
+ .map((status) => status.transactionStatus);
1863
+
1864
+ if (val.includes('All')) {
1865
+ if (this.isSelectAllChecked) {
1866
+ const filteredStatus = val.filter(s => s !== 'All');
1867
+ this.searchForm.get('transactionStatus')
1868
+ .setValue(filteredStatus, { emitEvent: false });
1869
+ this.isSelectAllChecked = false;
1870
+ } else {
1871
+ this.searchForm.get('transactionStatus')
1872
+ .setValue(['All'], { emitEvent: false });
1873
+ this.isSelectAllChecked = true;
1874
+ }
1875
+ }
1876
+
1877
+ })
1878
+ }
1879
+
1880
+ handleDateChange() {
1881
+ this.searchForm.get('fromDate')?.valueChanges.subscribe(fromDateStr => {
1882
+ const toDateControl = this.searchForm.get('toDate');
1883
+ const toDateStr = toDateControl?.value;
1884
+ if (!fromDateStr || !toDateStr) return;
1885
+ const fromDate = new Date(fromDateStr);
1886
+ this.disabledDate = this.toNgbDateStruct(fromDate);
1887
+ });
1888
+ }
1889
+
1890
+
1891
+ // ** for trial balance accounting report -
1892
+
1893
+ onSelectFromMonth() {
1894
+ this.loadingState = ComponentLoadingState.Loading;
1895
+ const year = +this.searchForm.get('financialYear')?.value;
1896
+ const fromMonth = +this.searchForm.get('fromMonth')?.value;
1897
+
1898
+ if (!year || !fromMonth) {
1899
+ return;
1900
+ }
1901
+
1902
+ this.reportService.GetToMonthsForTrialBalanceAccountsReport(year, fromMonth)
1903
+ .pipe(catchError(err => of([])))
1904
+ .subscribe((toMonths) => {
1905
+ this.toMonths = toMonths;
1906
+
1907
+ // update "toMonth" form control with default (first option)
1908
+ this.searchForm.patchValue({
1909
+ toMonth: this.toMonths[0]?.pMonth ?? ""
1910
+ });
1911
+ this.loadingState = ComponentLoadingState.Complete;
1912
+ });
1913
+
1914
+ // on select fromMonth goes call to fromDay
1915
+
1916
+ const financialYear = +this.searchForm.get('financialYear')?.value;
1917
+ const selectedPMonth = this.searchForm.get('fromMonth')?.value;
1918
+ const fromMonthObj = this.fromMonths.find(m => m.pOrder === selectedPMonth);
1919
+ const fromMonthLabel = fromMonthObj?.period;
1920
+ this.reportService.GetFromDatesForTrialBalanceAccountsReport(financialYear, fromMonthLabel)
1921
+ .subscribe(
1922
+ (fromDays) => {
1923
+ this.fromDays = fromDays;
1924
+ this.searchForm.patchValue({ fromDay: undefined })
1925
+ this.searchForm.patchValue({ toDay: "" })
1926
+ this.searchForm.get('toDay')?.disable();
1927
+ },
1928
+ (error) => {
1929
+ console.error('Error while fetching To Days:', error);
1930
+ }
1931
+ );
1932
+
1933
+ }
1934
+
1935
+ onSelectFromDay() {
1936
+ this.loadingState = ComponentLoadingState.Loading;
1937
+ const currentToDayValue = this.searchForm.get('toDay')?.value;
1938
+ const currentToDayObject = this.toDays.find(d => d.individualDate === currentToDayValue)
1939
+
1940
+ const financialYear = this.searchForm.get('financialYear')?.value;
1941
+ const fromMonth = this.searchForm.get('fromMonth')?.value;
1942
+ const toMonth = this.searchForm.get('toMonth')?.value;
1943
+ const fromDay = this.searchForm.get('fromDay')?.value;
1944
+
1945
+ const requestPayload = {
1946
+ Year: financialYear,
1947
+ FromMonth: fromMonth,
1948
+ ToMonth: toMonth,
1949
+ FromDate: fromDay
1950
+ };
1951
+
1952
+ this.reportService.GetToDatesForTrialBalanceAccountsReport(requestPayload)
1953
+ .pipe(
1954
+ finalize(() => {
1955
+ this.loadingState = ComponentLoadingState.Complete;
1956
+ })
1957
+ )
1958
+ .subscribe(
1959
+ (toDays) => {
1960
+ this.toDays = toDays;
1961
+
1962
+ if (this.searchForm.get('fromMonth')?.value != this.searchForm.get('toMonth')?.value && this.searchForm.get('toDay')?.value) {
1963
+ const matchedToDayObject = this.toDays.find(d => d.pDate === currentToDayObject.pDate);
1964
+ this.searchForm.patchValue({
1965
+ toDay: matchedToDayObject.individualDate ?? ""
1966
+ });
1967
+ } else {
1968
+ this.searchForm.patchValue({
1969
+ toDay: this.toDays[0]?.individualDate ?? ""
1970
+ });
1971
+ }
1972
+ this.searchForm.get('toDay')?.enable();
1973
+
1974
+ },
1975
+ (error) => {
1976
+ console.error('Error fetching To Days:', error);
1977
+ window.alert('Error fetching To Days');
1978
+ this.toDays = [];
1979
+ this.searchForm.get('toDay')?.patchValue("");
1980
+ },
1981
+ () => {
1982
+ this.loadingState = ComponentLoadingState.Complete;
1983
+ }
1984
+ );
1985
+ }
1986
+
1987
+
1988
+ onSelectToMonth() {
1989
+ this.loadingState = ComponentLoadingState.Loading;
1990
+
1991
+ const currentToDayValue = this.searchForm.get('toDay')?.value;
1992
+
1993
+ const financialYear = this.searchForm.get('financialYear')?.value;
1994
+ const fromMonth = this.searchForm.get('fromMonth')?.value;
1995
+ const toMonth = this.searchForm.get('toMonth')?.value;
1996
+ const fromDay = this.searchForm.get('fromDay')?.value;
1997
+
1998
+ if (!financialYear || !fromMonth || !toMonth || !fromDay) {
1999
+ this.loadingState = ComponentLoadingState.Complete;
2000
+ return;
2001
+ }
2002
+
2003
+ const requestPayload = {
2004
+ Year: financialYear,
2005
+ FromMonth: fromMonth,
2006
+ ToMonth: toMonth,
2007
+ FromDate: fromDay
2008
+ };
2009
+
2010
+ this.reportService.GetToDatesForTrialBalanceAccountsReport(requestPayload)
2011
+ .subscribe(
2012
+ (toDays) => {
2013
+ this.toDays = toDays;
2014
+
2015
+ if (this.searchForm.get('fromMonth')?.value === this.searchForm.get('toMonth')?.value) {
2016
+ const fromDay = this.searchForm.get('fromDay')?.value;
2017
+ const fromDayObject = this.fromDays.find(d => d.individualDate === fromDay);
2018
+ const toDayObject = this.toDays.find(d => d.pDate === fromDayObject?.individualDay);
2019
+
2020
+ this.searchForm.patchValue({
2021
+ toDay: toDayObject?.individualDate ?? ""
2022
+ });
2023
+ } else {
2024
+ this.searchForm.patchValue({
2025
+ toDay: this.toDays[0].individualDate
2026
+ });
2027
+ }
2028
+ },
2029
+
2030
+ (error) => {
2031
+ console.error('Error fetching To Days:', error);
2032
+ window.alert('Error fetching To Days:');
2033
+ this.toDays = [];
2034
+ this.searchForm.get('toDay')?.patchValue("");
2035
+ },
2036
+ () => {
2037
+ this.loadingState = ComponentLoadingState.Complete;
2038
+ }
2039
+ );
2040
+ }
2041
+
2042
+ onSelectFinancialYear() {
2043
+ // on financialYear change fromday and today should change to default values acocrding to year and frommonth,tomonth -
2044
+
2045
+ this.loadingState = ComponentLoadingState.Loading;
2046
+
2047
+ // call fromDays
2048
+
2049
+ const financialYear = +this.searchForm.get('financialYear')?.value;
2050
+
2051
+ const selectedPMonth = this.searchForm.get('fromMonth')?.value;
2052
+ const fromMonthObj = this.fromMonths.find(m => m.pOrder === selectedPMonth);
2053
+ const fromMonthLabel = fromMonthObj?.period;
2054
+
2055
+ this.reportService.GetFromDatesForTrialBalanceAccountsReport(financialYear, fromMonthLabel)
2056
+ .subscribe(
2057
+ (fromDays) => {
2058
+ this.fromDays = fromDays;
2059
+ this.searchForm.patchValue({ fromDay: undefined })
2060
+ this.searchForm.patchValue({ toDay: "" })
2061
+ this.searchForm.get('toDay')?.disable();
2062
+ },
2063
+ (error) => {
2064
+ console.error('Error while fetching To Days:', error);
2065
+ }
2066
+ );
2067
+
2068
+ const fromMonth = this.searchForm.get('fromMonth')?.value;
2069
+ const toMonth = this.searchForm.get('toMonth')?.value;
2070
+ const fromDay = this.searchForm.get('fromDay')?.value;
2071
+
2072
+ const requestPayload = {
2073
+ Year: financialYear,
2074
+ FromMonth: fromMonth,
2075
+ ToMonth: toMonth,
2076
+ FromDate: fromDay
2077
+ };
2078
+
2079
+ this.reportService.GetToDatesForTrialBalanceAccountsReport(requestPayload)
2080
+ .subscribe(
2081
+ (toDays) => {
2082
+ this.toDays = toDays;
2083
+
2084
+ if (this.searchForm.get('fromMonth')?.value === this.searchForm.get('toMonth')?.value) {
2085
+ const fromDay = this.searchForm.get('fromDay')?.value;
2086
+ const fromDayObject = this.fromDays.find(d => d.individualDate === fromDay);
2087
+ const toDayObject = this.toDays.find(d => d.pDate === fromDayObject?.individualDay);
2088
+
2089
+ this.searchForm.patchValue({
2090
+ toDay: toDayObject?.individualDate ?? ""
2091
+ });
2092
+ } else {
2093
+ this.searchForm.patchValue({
2094
+ toDay: ""
2095
+ });
2096
+ this.searchForm.get('toDay')?.disable();
2097
+ }
2098
+ },
2099
+
2100
+ (error) => {
2101
+ console.error('Error fetching To Days:', error);
2102
+ window.alert('Error fetching To Days:');
2103
+ this.toDays = [];
2104
+ this.searchForm.get('toDay')?.patchValue("");
2105
+ },
2106
+ () => {
2107
+ this.loadingState = ComponentLoadingState.Complete;
2108
+ }
2109
+ );
2110
+ }
2111
+
2112
+
2113
+
2114
+ prepareFromDateAndToDateForTrialBalanceAccountReport() {
2115
+ const financialYear = +this.searchForm.get('financialYear')?.value;
2116
+ const fromMonth = this.searchForm.get('fromMonth')?.value;
2117
+ const toMonth = this.searchForm.get('toMonth')?.value;
2118
+
2119
+ const selectedFromDay = this.searchForm.get('fromDay')?.value;
2120
+ const fromDayObj = this.fromDays.find(m => m.individualDate === selectedFromDay);
2121
+ const fromDay = fromDayObj?.individualDay;
2122
+
2123
+ const selectedToDay = this.searchForm.get('toDay')?.value;
2124
+ const toDayObj = this.toDays.find(m => m.individualDate === selectedToDay);
2125
+ const toDay = toDayObj?.pDate;
2126
+
2127
+ const fromDate = new Date(financialYear, +fromMonth - 1, +fromDay); // JS month is 0-based
2128
+ const toDate = new Date(financialYear, +toMonth - 1, +toDay);
2129
+
2130
+ return {
2131
+ fromDate: fromDate,
2132
+ toDate: toDate
2133
+ };
2134
+ }
2135
+
2136
+ // ----------------- Improved search criteria helpers (handles product) -----------------
2137
+
2138
+ private fieldLabelMap: Record<string, string> = {
2139
+ client: 'Client:',
2140
+ branch: 'Branch:',
2141
+ fromDate: 'From Date:',
2142
+ toDate: 'To Date:',
2143
+ product: 'Product:',
2144
+ transactionProduct: 'Product:',
2145
+ userId: 'User:',
2146
+ currency: 'Currency:',
2147
+ sendCurrency: 'Send Currency:',
2148
+ receiveCurrency: 'Receive Currency:',
2149
+ transactionStatus: 'Txn. Status:',
2150
+ transactionStatusSingleSelect: 'Txn. Status:',
2151
+ transactionNo: 'Txn. Number:',
2152
+ date: 'Date:',
2153
+ dateType: 'Date Type:',
2154
+ valueDate: 'Value Date:',
2155
+ sendCountry: 'Send Country:',
2156
+ receiveCountry: 'Receive Country:',
2157
+ sendBusinessPartner: 'Sender Partner:',
2158
+ recvBusinessPartner: 'Receiver Partner:',
2159
+ businessUnit: 'Business Unit:',
2160
+ financialYear: 'Financial Year:',
2161
+ fromMonth: 'From Month:',
2162
+ toMonth: 'To Month:',
2163
+ fromDay: 'From Day:',
2164
+ toDay: 'To Day:',
2165
+ accountStatus: 'Account Status:',
2166
+ // add more mappings as needed
2167
+ };
2168
+
2169
+ // map visible field name -> actual form control name (when they differ)
2170
+ private fieldToControlMap: Record<string, string> = {
2171
+ transactionStatusSingleSelect: 'transactionStatus',
2172
+ transactionProduct: 'product', // important: transactionProduct UI uses form control named 'product'
2173
+ // add other mappings if visibleField name differs from the form control name
2174
+ };
2175
+
2176
+ // maps to use bindLabel / bindValue for lookups
2177
+ private fieldBindLabelMap: Record<string, string> = {
2178
+ client: 'businessPartnerName',
2179
+ branch: 'businessPartnerBranch',
2180
+ product: 'productCode',
2181
+ transactionProduct: 'productCode',
2182
+ transactionStatus: 'transactionStatus',
2183
+ transactionStatusSingleSelect: 'transactionStatus',
2184
+ userId: 'userName',
2185
+ currency: 'currency',
2186
+ sendCurrency: 'currency',
2187
+ receiveCurrency: 'currency',
2188
+ sendBusinessPartner: 'name',
2189
+ recvBusinessPartner: 'name',
2190
+ businessUnit: 'businessUnit',
2191
+ financialYear: 'financialYear',
2192
+ fromMonth: 'period',
2193
+ toMonth: 'pMonthName',
2194
+ fromDay: 'individualDay',
2195
+ toDay: 'pDate',
2196
+ accountStatus: 'statusName'
2197
+ };
2198
+
2199
+ private fieldBindValueMap: Record<string, string> = {
2200
+ client: 'businessPartnerCode',
2201
+ branch: 'branchCode',
2202
+ product: 'productCode',
2203
+ transactionProduct: 'productCode',
2204
+ transactionStatus: 'transactionStatus',
2205
+ transactionStatusSingleSelect: 'transactionStatus',
2206
+ userId: 'userId',
2207
+ currency: 'currencyCode',
2208
+ sendCurrency: 'currencyCode',
2209
+ receiveCurrency: 'currencyCode',
2210
+ sendBusinessPartner: 'id',
2211
+ recvBusinessPartner: 'id',
2212
+ businessUnit: 'businessUnit',
2213
+ financialYear: 'financialYear',
2214
+ fromMonth: 'pOrder',
2215
+ toMonth: 'pMonth',
2216
+ fromDay: 'individualDate',
2217
+ toDay: 'individualDate',
2218
+ accountStatus: 'statusCode'
2219
+ };
2220
+
2221
+ private formatDateToDDMMYYYY(d: string | Date | null | undefined): string {
2222
+ if (!d) return '';
2223
+ const date = (typeof d === 'string' && d.length) ? new Date(d) : (d instanceof Date ? d : new Date(d));
2224
+ if (isNaN(date.getTime())) return '';
2225
+ const day = String(date.getDate()).padStart(2, '0');
2226
+ const month = String(date.getMonth() + 1).padStart(2, '0');
2227
+ const year = date.getFullYear();
2228
+ return `${day}/${month}/${year}`;
2229
+ }
2230
+
2231
+ /** helper to find item in the known lists by bindValue and return its bindLabel
2232
+ * improved: tries multiple fallback value keys so product lookup is robust */
2233
+ private lookupFromListByField(field: string, scalarValue: any): string {
2234
+ const bindLabel = this.fieldBindLabelMap[field];
2235
+ const bindValue = this.fieldBindValueMap[field];
2236
+
2237
+ // choose candidate list based on field
2238
+ let list: any[] | undefined;
2239
+ switch (field) {
2240
+ case 'client': list = this.clients1; break;
2241
+ case 'branch': list = this.branches; break;
2242
+ case 'product': list = this.products; break;
2243
+ case 'transactionProduct': list = this.transactionProducts; break;
2244
+ case 'transactionStatus':
2245
+ case 'transactionStatusSingleSelect': list = this.transactionStatuses; break;
2246
+ case 'userId': list = this.users; break;
2247
+ case 'sendBusinessPartner': list = this.sendBusinessPartnerAgents; break;
2248
+ case 'recvBusinessPartner': list = this.recvBusinessPartnerAgents; break;
2249
+ case 'businessUnit': list = this.businessUnits; break;
2250
+ case 'financialYear': list = this.financialYears; break;
2251
+ case 'fromMonth': list = this.fromMonths; break;
2252
+ case 'toMonth': list = this.toMonths; break;
2253
+ case 'fromDay': list = this.fromDays; break;
2254
+ case 'toDay': list = this.toDays; break;
2255
+ case 'accountStatus': list = this.accountStatuses; break;
2256
+ case 'sendCountry':
2257
+ case 'receiveCountry': list = this.countries; break;
2258
+ case 'currency':
2259
+ case 'sendCurrency':
2260
+ case 'receiveCurrency': list = this.currencies; break;
2261
+ default: list = undefined;
2262
+ }
2263
+
2264
+ // handle common 'All' sentinel
2265
+ if (scalarValue === 'All' || scalarValue === '' || scalarValue === null || scalarValue === undefined) return String(scalarValue || '');
2266
+
2267
+ if (list && list.length) {
2268
+ // try the configured bindValue key first
2269
+ if (bindValue) {
2270
+ const found = list.find((x: any) => String(x[bindValue]) === String(scalarValue));
2271
+ if (found) {
2272
+ if (bindLabel && found[bindLabel]) return found[bindLabel];
2273
+ return found.transactionStatusLabel || found.transactionStatus || found.name || found.productName || found.businessPartnerName || String(scalarValue);
2274
+ }
2275
+ }
2276
+
2277
+ // fallback: try matching on common keys in case shapes differ
2278
+ const commonKeys = ['productCode', 'code', 'id', 'value', 'currencyCode', 'statusCode'];
2279
+ for (const key of commonKeys) {
2280
+ const found2 = list.find((x: any) => x && x[key] !== undefined && String(x[key]) === String(scalarValue));
2281
+ if (found2) {
2282
+ const labelCandidate = bindLabel && found2[bindLabel] ? found2[bindLabel] : (found2.productName || found2.name || found2.transactionStatusLabel || found2.businessPartnerName);
2283
+ return labelCandidate || String(scalarValue);
2284
+ }
2285
+ }
2286
+
2287
+ // last attempt: if scalarValue equals a label in the list, return it
2288
+ if (bindLabel) {
2289
+ const found3 = list.find((x: any) => String(x[bindLabel]) === String(scalarValue));
2290
+ if (found3) return String(found3[bindLabel]);
2291
+ }
2292
+ }
2293
+
2294
+ // not found — return scalar as string
2295
+ return String(scalarValue);
2296
+ }
2297
+
2298
+ // --- lookup that prefers bindLabel when possible ---
2299
+ private getLookupDisplayValue(field: string, value: any): string {
2300
+ if (value === null || value === undefined || value === '') return '';
2301
+
2302
+ // Date handling
2303
+ if (field === 'fromDate' || field === 'toDate' || field === 'date' || field === 'valueDate') {
2304
+ return this.formatDateToDDMMYYYY(value);
2305
+ }
2306
+
2307
+ // Currencies: show "CODE - Name"
2308
+ if (['currency', 'sendCurrency', 'receiveCurrency'].includes(field)) {
2309
+ if (value === 'All') return 'All';
2310
+ if (typeof value === 'object') {
2311
+ const code = value.currencyCode || value.currency || '';
2312
+ const name = value.currency || '';
2313
+ return code ? `${code} - ${name}` : String(value);
2314
+ }
2315
+ const cur = this.currencies?.find((x: any) => x.currencyCode === value);
2316
+ return cur ? `${cur.currencyCode} - ${cur.currency}` : String(value);
2317
+ }
2318
+
2319
+ // If it's an array (multi-select), map each item
2320
+ if (Array.isArray(value)) {
2321
+ const mapped = value.map(v => {
2322
+ if (typeof v === 'object') {
2323
+ const bindLabel = this.fieldBindLabelMap[field];
2324
+ return bindLabel && v[bindLabel] ? v[bindLabel] : (v.transactionStatusLabel || v.statusName || v.productName || v.name || JSON.stringify(v));
2325
+ }
2326
+ return this.lookupFromListByField(field, v);
2327
+ });
2328
+ if (mapped.length === 1 && (mapped[0] === 'All' || mapped[0] === '')) return 'All';
2329
+ return mapped.join(', ');
2330
+ }
2331
+
2332
+ // If value is an object (single select returned object)
2333
+ if (typeof value === 'object') {
2334
+ // product special-case: product object might have productName/productCode
2335
+ if (field === 'product' || field === 'transactionProduct') {
2336
+ const pn = value.productName || value.name || value.label || value.display || value.product || value.transactionProduct;
2337
+ if (pn) return pn;
2338
+ // try common keys
2339
+ return value.productCode || value.code || value.id ? String(value.productCode || value.code || value.id) : JSON.stringify(value);
2340
+ }
2341
+
2342
+ const bindLabel = this.fieldBindLabelMap[field];
2343
+ if (bindLabel && value[bindLabel]) return value[bindLabel];
2344
+ return value.transactionStatus || value.name || value.businessPartnerName || JSON.stringify(value);
2345
+ }
2346
+
2347
+ // Scalar -> lookup in lists using bindValue -> return bindLabel
2348
+ // product special-case: if value === 'All' then return 'All'
2349
+ if ((field === 'product' || field === 'transactionProduct') && String(value) === 'All') return 'All';
2350
+
2351
+ return this.lookupFromListByField(field, value);
2352
+ }
2353
+
2354
+ /**
2355
+ * Returns search criteria array for the currently visible fields.
2356
+ * Output: [ ['Label:', 'Value'], ... ]
2357
+ */
2358
+ public getSearchCriteriaArray(): [string, string][] {
2359
+ if (!this.searchForm) return [];
2360
+
2361
+ const criteria: [string, string][] = [];
2362
+ const formValue = this.searchForm.value;
2363
+ const fields = this.visibleFields; // uses your getter
2364
+
2365
+ fields.forEach(field => {
2366
+ const label = this.fieldLabelMap[field] || (field + ':');
2367
+ const controlName = this.fieldToControlMap[field] || field;
2368
+ const value = formValue[controlName];
2369
+
2370
+ // dates
2371
+ if (controlName === 'fromDate' || controlName === 'toDate' || controlName === 'date' || controlName === 'valueDate') {
2372
+ criteria.push([label, this.formatDateToDDMMYYYY(value) || '']);
2373
+ return;
2374
+ }
2375
+
2376
+ // Use getLookupDisplayValue to produce the human-friendly string (handles arrays/objects/scalars)
2377
+ const display = this.getLookupDisplayValue(field, value);
2378
+
2379
+ criteria.push([label, display || '']);
2380
+ });
2381
+
2382
+ return criteria;
2383
+ }
2384
+
2385
+
2386
+
2387
+ }