@zeniai/client-epic-state 4.20.3-betaRD21 → 4.20.3-betaRD3

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 (214) hide show
  1. package/lib/commonPayloadTypes/subAccountView/reportBySubAccountPayload.d.ts +2 -0
  2. package/lib/commonStateTypes/coaBalance/coaBalancesFilterProjectView.d.ts +13 -0
  3. package/lib/commonStateTypes/coaBalance/coaBalancesFilterProjectView.js +9 -0
  4. package/lib/commonStateTypes/common.d.ts +1 -1
  5. package/lib/commonStateTypes/projectView/projectViewParentID.d.ts +5 -0
  6. package/lib/commonStateTypes/projectView/projectViewParentID.js +2 -0
  7. package/lib/commonStateTypes/viewAndReport/reportIDHelper.d.ts +1 -0
  8. package/lib/commonStateTypes/viewAndReport/reportIDHelper.js +3 -1
  9. package/lib/commonStateTypes/viewAndReport/viewAndReport.d.ts +2 -2
  10. package/lib/commonStateTypes/viewAndReport/viewAndReport.js +1 -1
  11. package/lib/entity/account/accountPayload.d.ts +0 -2
  12. package/lib/entity/account/accountReducer.d.ts +2 -5
  13. package/lib/entity/account/accountReducer.js +7 -10
  14. package/lib/entity/account/accountSelector.d.ts +7 -0
  15. package/lib/entity/account/accountSelector.js +4 -2
  16. package/lib/entity/account/accountState.d.ts +3 -1
  17. package/lib/entity/account/accountState.js +4 -1
  18. package/lib/entity/account/pickAndMergeForecastAccountReport.d.ts +1 -0
  19. package/lib/entity/account/subAccountSelector.d.ts +2 -0
  20. package/lib/entity/account/subAccountSelector.js +2 -0
  21. package/lib/entity/accountGroup/accountGroupSelector.d.ts +22 -0
  22. package/lib/entity/accountGroup/accountGroupState.d.ts +1 -1
  23. package/lib/entity/billPay/billTransaction/billTransactionState.d.ts +2 -2
  24. package/lib/entity/chargeCard/chargeCard.d.ts +1 -1
  25. package/lib/entity/class/classReducer.d.ts +4 -4
  26. package/lib/entity/class/classState.d.ts +1 -1
  27. package/lib/entity/depositAccountTransaction/depositAccountTransaction.d.ts +1 -1
  28. package/lib/entity/entityApprovalStatus/entityApprovalStatusState.d.ts +2 -2
  29. package/lib/entity/forecast/forecastState.d.ts +1 -1
  30. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +1 -1
  31. package/lib/entity/project/projectPayload.d.ts +13 -0
  32. package/lib/entity/project/projectPayload.js +30 -0
  33. package/lib/entity/project/projectReducer.d.ts +10 -0
  34. package/lib/entity/project/projectReducer.js +31 -0
  35. package/lib/entity/project/projectSelector.d.ts +5 -0
  36. package/lib/entity/project/projectSelector.js +12 -0
  37. package/lib/entity/project/projectState.d.ts +13 -0
  38. package/lib/entity/project/projectState.js +2 -0
  39. package/lib/entity/sectionAccountsView/sectionAccountsView.d.ts +1 -1
  40. package/lib/entity/sectionClassesViewV2/sectionClassesView.d.ts +1 -1
  41. package/lib/entity/sectionClassesViewV2/sectionClassesViewReducer.d.ts +2 -2
  42. package/lib/entity/sectionProjectView/sectionProjectView.d.ts +10 -0
  43. package/lib/entity/sectionProjectView/sectionProjectView.js +6 -0
  44. package/lib/entity/sectionProjectView/sectionProjectViewEpic.d.ts +6 -0
  45. package/lib/entity/sectionProjectView/sectionProjectViewEpic.js +56 -0
  46. package/lib/entity/sectionProjectView/sectionProjectViewHelper.d.ts +9 -0
  47. package/lib/entity/sectionProjectView/sectionProjectViewHelper.js +13 -0
  48. package/lib/entity/sectionProjectView/sectionProjectViewReducer.d.ts +15 -0
  49. package/lib/entity/sectionProjectView/sectionProjectViewReducer.js +50 -0
  50. package/lib/entity/sectionProjectView/sectionProjectViewSelector.d.ts +11 -0
  51. package/lib/entity/sectionProjectView/sectionProjectViewSelector.js +103 -0
  52. package/lib/entity/sectionProjectView/sectionProjectViewSelectorTypes.d.ts +16 -0
  53. package/lib/entity/sectionProjectView/sectionProjectViewSelectorTypes.js +2 -0
  54. package/lib/entity/sectionProjectView/sectionProjectViewState.d.ts +4 -0
  55. package/lib/entity/sectionProjectView/sectionProjectViewState.js +2 -0
  56. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  57. package/lib/entity/tenant/clearAllEpic.d.ts +5 -4
  58. package/lib/entity/tenant/clearAllEpic.js +6 -4
  59. package/lib/entity/tenant/tenantPayload.d.ts +1 -0
  60. package/lib/entity/tenant/tenantReducer.js +1 -0
  61. package/lib/entity/tenant/tenantSelector.d.ts +1 -0
  62. package/lib/entity/tenant/tenantSelector.js +9 -1
  63. package/lib/entity/tenant/tenantState.d.ts +1 -0
  64. package/lib/entity/transaction/payloadTypes/transactionPayload.js +0 -1
  65. package/lib/entity/userRole/userRoleType.d.ts +2 -2
  66. package/lib/epic.d.ts +4 -3
  67. package/lib/epic.js +4 -3
  68. package/lib/esm/commonStateTypes/coaBalance/coaBalancesFilterProjectView.js +5 -0
  69. package/lib/esm/commonStateTypes/projectView/projectViewParentID.js +1 -0
  70. package/lib/esm/commonStateTypes/viewAndReport/reportIDHelper.js +1 -0
  71. package/lib/esm/commonStateTypes/viewAndReport/viewAndReport.js +1 -1
  72. package/lib/esm/entity/account/accountReducer.js +6 -9
  73. package/lib/esm/entity/account/accountSelector.js +4 -2
  74. package/lib/esm/entity/account/accountState.js +4 -1
  75. package/lib/esm/entity/account/subAccountSelector.js +2 -0
  76. package/lib/esm/entity/project/projectPayload.js +26 -0
  77. package/lib/esm/entity/project/projectReducer.js +27 -0
  78. package/lib/esm/entity/project/projectSelector.js +8 -0
  79. package/lib/esm/entity/project/projectState.js +1 -0
  80. package/lib/esm/entity/sectionProjectView/sectionProjectView.js +3 -0
  81. package/lib/esm/entity/sectionProjectView/sectionProjectViewEpic.js +52 -0
  82. package/lib/esm/entity/sectionProjectView/sectionProjectViewHelper.js +9 -0
  83. package/lib/esm/entity/sectionProjectView/sectionProjectViewReducer.js +46 -0
  84. package/lib/esm/entity/sectionProjectView/sectionProjectViewSelector.js +96 -0
  85. package/lib/esm/entity/sectionProjectView/sectionProjectViewSelectorTypes.js +1 -0
  86. package/lib/esm/entity/sectionProjectView/sectionProjectViewState.js +1 -0
  87. package/lib/esm/entity/tenant/clearAllEpic.js +6 -4
  88. package/lib/esm/entity/tenant/tenantReducer.js +1 -0
  89. package/lib/esm/entity/tenant/tenantSelector.js +7 -0
  90. package/lib/esm/entity/transaction/payloadTypes/transactionPayload.js +0 -1
  91. package/lib/esm/epic.js +4 -3
  92. package/lib/esm/index.js +11 -15
  93. package/lib/esm/reducer.js +9 -6
  94. package/lib/esm/view/expenseAutomationView/epics/accountRecon/fetchReconciliationViewEpic.js +9 -4
  95. package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +1 -5
  96. package/lib/esm/view/expenseAutomationView/reducers/reconciliationViewReducer.js +3 -163
  97. package/lib/esm/view/expenseAutomationView/selectorTypes/reconciliationViewSelectorTypes.js +2 -1
  98. package/lib/esm/view/expenseAutomationView/selectors/reconciliationViewSelector.js +0 -112
  99. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +6 -10
  100. package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +0 -6
  101. package/lib/esm/view/financeStatement/financeStatementSelector.js +12 -1
  102. package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +2 -4
  103. package/lib/esm/view/profitAndLossProjectView/profitAndLossForTimeframeProjectViewEpic.js +45 -0
  104. package/lib/esm/view/profitAndLossProjectView/profitAndLossProjectViewEpic.js +30 -0
  105. package/lib/esm/view/profitAndLossProjectView/profitAndLossProjectViewPayload.js +1 -0
  106. package/lib/esm/view/profitAndLossProjectView/profitAndLossProjectViewReducer.js +113 -0
  107. package/lib/esm/view/profitAndLossProjectView/profitAndLossProjectViewSelector.js +66 -0
  108. package/lib/esm/view/profitAndLossProjectView/profitAndLossProjectViewSelectorTypes.js +1 -0
  109. package/lib/esm/view/profitAndLossProjectView/profitAndLossProjectViewState.js +1 -0
  110. package/lib/esm/view/reportsResync/reportsClassViewRefetchingEpic.js +4 -0
  111. package/lib/index.d.ts +14 -16
  112. package/lib/index.js +45 -65
  113. package/lib/reducer.d.ts +9 -6
  114. package/lib/reducer.js +9 -6
  115. package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
  116. package/lib/view/auditReportView/auditReportViewState.d.ts +1 -1
  117. package/lib/view/billPayCard/billPayCardSelector.d.ts +1 -1
  118. package/lib/view/cardBalance/cardBalanceSelector.d.ts +2 -1
  119. package/lib/view/cashBalance/cashBalanceSelector.d.ts +2 -1
  120. package/lib/view/cashInCashOut/cashInCashOutSelector.d.ts +1 -1
  121. package/lib/view/cashPosition/cashPositionSelector.d.ts +1 -1
  122. package/lib/view/companyView/types/cockpitTypes.d.ts +5 -6
  123. package/lib/view/dashboard/dashboardReducer.d.ts +2 -2
  124. package/lib/view/expenseAutomationView/epics/accountRecon/fetchReconciliationViewEpic.js +9 -4
  125. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  126. package/lib/view/expenseAutomationView/payload/reconciliationPayload.d.ts +0 -33
  127. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +1 -5
  128. package/lib/view/expenseAutomationView/reducers/reconciliationViewReducer.d.ts +4 -18
  129. package/lib/view/expenseAutomationView/reducers/reconciliationViewReducer.js +4 -164
  130. package/lib/view/expenseAutomationView/selectorTypes/reconciliationViewSelectorTypes.d.ts +2 -6
  131. package/lib/view/expenseAutomationView/selectorTypes/reconciliationViewSelectorTypes.js +2 -2
  132. package/lib/view/expenseAutomationView/selectors/reconciliationViewSelector.js +0 -112
  133. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +5 -9
  134. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +0 -3
  135. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +1 -8
  136. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +1 -1
  137. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +0 -13
  138. package/lib/view/financeStatement/financeStatementReducer.d.ts +1 -1
  139. package/lib/view/financeStatement/financeStatementSelector.d.ts +2 -0
  140. package/lib/view/financeStatement/financeStatementSelector.js +12 -1
  141. package/lib/view/globalMerchantView/globalMerchantViewReducer.d.ts +2 -2
  142. package/lib/view/onboardingView/cockpitView/types/onboardingCockpitViewTypes.d.ts +1 -1
  143. package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +2 -4
  144. package/lib/view/profitAndLossProjectView/profitAndLossForTimeframeProjectViewEpic.d.ts +8 -0
  145. package/lib/view/profitAndLossProjectView/profitAndLossForTimeframeProjectViewEpic.js +49 -0
  146. package/lib/view/profitAndLossProjectView/profitAndLossProjectViewEpic.d.ts +6 -0
  147. package/lib/view/profitAndLossProjectView/profitAndLossProjectViewEpic.js +34 -0
  148. package/lib/view/profitAndLossProjectView/profitAndLossProjectViewPayload.d.ts +33 -0
  149. package/lib/view/profitAndLossProjectView/profitAndLossProjectViewPayload.js +2 -0
  150. package/lib/view/profitAndLossProjectView/profitAndLossProjectViewReducer.d.ts +33 -0
  151. package/lib/view/profitAndLossProjectView/profitAndLossProjectViewReducer.js +117 -0
  152. package/lib/view/profitAndLossProjectView/profitAndLossProjectViewSelector.d.ts +9 -0
  153. package/lib/view/profitAndLossProjectView/profitAndLossProjectViewSelector.js +70 -0
  154. package/lib/view/profitAndLossProjectView/profitAndLossProjectViewSelectorTypes.d.ts +18 -0
  155. package/lib/view/profitAndLossProjectView/profitAndLossProjectViewSelectorTypes.js +2 -0
  156. package/lib/view/profitAndLossProjectView/profitAndLossProjectViewState.d.ts +22 -0
  157. package/lib/view/profitAndLossProjectView/profitAndLossProjectViewState.js +2 -0
  158. package/lib/view/reimbursementCard/reimbursementCardSelector.d.ts +1 -1
  159. package/lib/view/reportsResync/reportsClassViewRefetchingEpic.d.ts +2 -1
  160. package/lib/view/reportsResync/reportsClassViewRefetchingEpic.js +4 -0
  161. package/lib/view/reportsResync/reportsResyncReducer.d.ts +2 -2
  162. package/lib/view/reviewCompanyView/reviewCompanyViewState.d.ts +1 -1
  163. package/lib/view/spendManagement/billPay/billList/billListReducer.d.ts +1 -1
  164. package/lib/view/spendManagement/billPay/billList/billListState.d.ts +1 -1
  165. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetail.d.ts +1 -1
  166. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.d.ts +4 -4
  167. package/lib/view/spendManagement/reimbursement/remiListView/remiListReducer.d.ts +1 -1
  168. package/lib/view/spendManagement/reimbursement/remiListView/remiListState.d.ts +3 -3
  169. package/lib/view/subscriptionView/types/subscriptionTypes.d.ts +1 -1
  170. package/lib/view/tasksCard/tasksCardSelector.d.ts +1 -1
  171. package/lib/view/topEx/topExSelector.d.ts +1 -1
  172. package/package.json +1 -1
  173. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerPayload.d.ts +0 -44
  174. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +0 -55
  175. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerReducer.d.ts +0 -10
  176. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +0 -51
  177. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerSelector.d.ts +0 -48
  178. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerSelector.js +0 -66
  179. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerState.d.ts +0 -52
  180. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerState.js +0 -37
  181. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +0 -49
  182. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +0 -47
  183. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerSelector.js +0 -62
  184. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerState.js +0 -31
  185. package/lib/esm/view/aiAccountantView/aiAccountantViewPayload.js +0 -2
  186. package/lib/esm/view/aiAccountantView/aiAccountantViewReducer.js +0 -149
  187. package/lib/esm/view/aiAccountantView/aiAccountantViewSelector.js +0 -72
  188. package/lib/esm/view/aiAccountantView/aiAccountantViewState.js +0 -11
  189. package/lib/esm/view/aiAccountantView/epics/cancelAiAccountantOnboardingEpic.js +0 -46
  190. package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +0 -27
  191. package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +0 -47
  192. package/lib/esm/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +0 -52
  193. package/lib/esm/view/expenseAutomationView/epics/accountRecon/excludeAccountFromReconciliationEpic.js +0 -44
  194. package/lib/esm/view/expenseAutomationView/epics/accountRecon/includeAccountInReconciliationEpic.js +0 -44
  195. package/lib/view/aiAccountantView/aiAccountantViewPayload.d.ts +0 -31
  196. package/lib/view/aiAccountantView/aiAccountantViewPayload.js +0 -8
  197. package/lib/view/aiAccountantView/aiAccountantViewReducer.d.ts +0 -29
  198. package/lib/view/aiAccountantView/aiAccountantViewReducer.js +0 -153
  199. package/lib/view/aiAccountantView/aiAccountantViewSelector.d.ts +0 -14
  200. package/lib/view/aiAccountantView/aiAccountantViewSelector.js +0 -78
  201. package/lib/view/aiAccountantView/aiAccountantViewState.d.ts +0 -27
  202. package/lib/view/aiAccountantView/aiAccountantViewState.js +0 -13
  203. package/lib/view/aiAccountantView/epics/cancelAiAccountantOnboardingEpic.d.ts +0 -33
  204. package/lib/view/aiAccountantView/epics/cancelAiAccountantOnboardingEpic.js +0 -50
  205. package/lib/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.d.ts +0 -23
  206. package/lib/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +0 -31
  207. package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.d.ts +0 -33
  208. package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +0 -51
  209. package/lib/view/aiAccountantView/epics/triggerAiAccountantJobEpic.d.ts +0 -28
  210. package/lib/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +0 -56
  211. package/lib/view/expenseAutomationView/epics/accountRecon/excludeAccountFromReconciliationEpic.d.ts +0 -8
  212. package/lib/view/expenseAutomationView/epics/accountRecon/excludeAccountFromReconciliationEpic.js +0 -48
  213. package/lib/view/expenseAutomationView/epics/accountRecon/includeAccountInReconciliationEpic.d.ts +0 -9
  214. package/lib/view/expenseAutomationView/epics/accountRecon/includeAccountInReconciliationEpic.js +0 -48
@@ -1,11 +0,0 @@
1
- import { stringToUnion } from '../../commonStateTypes/stringToUnion';
2
- const ALL_AI_ACCOUNTANT_SORT_KEYS = [
3
- 'companyName',
4
- 'status',
5
- 'bookcloseDate',
6
- 'latestTraining',
7
- 'latestSync',
8
- 'accuracy',
9
- ];
10
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
- const toAiAccountantSortKeyType = (v) => stringToUnion(v, ALL_AI_ACCOUNTANT_SORT_KEYS);
@@ -1,46 +0,0 @@
1
- import { from } from 'rxjs';
2
- import { catchError, filter, mergeMap } from 'rxjs/operators';
3
- import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
4
- import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
5
- import { cancelAiAccountantOnboarding, cancelAiAccountantOnboardingFailure, cancelAiAccountantOnboardingSuccess, fetchAiAccountantCustomers, } from '../aiAccountantViewReducer';
6
- export const cancelAiAccountantOnboardingEpic = (actions$, _, zeniAPI) => actions$.pipe(filter(cancelAiAccountantOnboarding.match), mergeMap((action) => {
7
- const { tenantId, companyId } = action.payload;
8
- const base = `${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels`;
9
- const url = `${base}/ai-accountant/cancel-onboarding`;
10
- return zeniAPI
11
- .postAndGetJSON(url, {
12
- tenant_id: tenantId,
13
- company_id: companyId,
14
- })
15
- .pipe(mergeMap((response) => {
16
- if (isSuccessResponse(response)) {
17
- return from([
18
- cancelAiAccountantOnboardingSuccess(tenantId),
19
- fetchAiAccountantCustomers(),
20
- openSnackbar({
21
- messageSection: 'common',
22
- messageText: 'success',
23
- type: 'success',
24
- }),
25
- ]);
26
- }
27
- else {
28
- return from([
29
- cancelAiAccountantOnboardingFailure(tenantId, response.status),
30
- openSnackbar({
31
- messageSection: 'common',
32
- messageText: 'failed',
33
- type: 'error',
34
- }),
35
- ]);
36
- }
37
- }), catchError((error) => from([
38
- cancelAiAccountantOnboardingFailure(tenantId, createZeniAPIStatus('Unexpected error', 'AI Accountant cancel onboarding failed: ' +
39
- JSON.stringify(error))),
40
- openSnackbar({
41
- messageSection: 'common',
42
- messageText: 'failed',
43
- type: 'error',
44
- }),
45
- ])));
46
- }));
@@ -1,27 +0,0 @@
1
- import { from, of } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { updateAiAccountantCustomers as updateAiAccountantCustomerEntities } from '../../../entity/aiAccountantCustomer/aiAccountantCustomerReducer';
4
- import { updateAllUsers } from '../../../entity/user/userReducer';
5
- import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
6
- import { fetchAiAccountantCustomers, updateAiAccountantCustomers, updateAiAccountantCustomersFailure, } from '../aiAccountantViewReducer';
7
- export const fetchAiAccountantCustomersEpic = (actions$, _, zeniAPI) => actions$.pipe(filter(fetchAiAccountantCustomers.match), switchMap(() => {
8
- const base = `${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels`;
9
- const url = `${base}/ai-accountant/customers`;
10
- return zeniAPI
11
- .getJSON(url)
12
- .pipe(mergeMap((response) => {
13
- if (isSuccessResponse(response)) {
14
- const customers = response.data?.customers ?? [];
15
- const users = response.data?.users ?? [];
16
- return from([
17
- updateAiAccountantCustomerEntities(customers),
18
- updateAllUsers({ users }),
19
- updateAiAccountantCustomers(customers),
20
- ]);
21
- }
22
- else {
23
- return of(updateAiAccountantCustomersFailure(response.status));
24
- }
25
- }), catchError((error) => of(updateAiAccountantCustomersFailure(createZeniAPIStatus('Unexpected error', 'AI Accountant customers fetch failed: ' +
26
- JSON.stringify(error))))));
27
- }));
@@ -1,47 +0,0 @@
1
- import { from, of } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { updateAiAccountantJobs as updateAiAccountantJobEntities } from '../../../entity/aiAccountantCustomer/aiAccountantCustomerReducer';
4
- import { updateAllUsers } from '../../../entity/user/userReducer';
5
- import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
6
- import { fetchAiAccountantJobs, updateAiAccountantJobs, updateAiAccountantJobsFailure, } from '../aiAccountantViewReducer';
7
- export const fetchAiAccountantJobsEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchAiAccountantJobs.match), switchMap((action) => {
8
- const { tenantId, fetchNextPage } = action.payload;
9
- const rootState = state$.value;
10
- const customerView = rootState.aiAccountantViewState.customersByTenantId[tenantId];
11
- const pageToken = fetchNextPage && customerView?.jobsPageToken != null
12
- ? customerView.jobsPageToken
13
- : null;
14
- const params = new URLSearchParams({
15
- page_size: '50',
16
- tenant_id: tenantId,
17
- });
18
- if (pageToken != null) {
19
- params.set('page_token', pageToken);
20
- }
21
- const base = `${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels`;
22
- const url = `${base}/ai-accountant/jobs?${params.toString()}`;
23
- return zeniAPI
24
- .getJSON(url)
25
- .pipe(mergeMap((response) => {
26
- if (isSuccessResponse(response)) {
27
- const jobs = response.data?.jobs ?? [];
28
- const users = response.data?.users ?? [];
29
- const nextPageToken = response.data?.next_page_token ?? null;
30
- return from([
31
- updateAllUsers({ users }),
32
- updateAiAccountantJobEntities(tenantId, jobs, fetchNextPage),
33
- updateAiAccountantJobs(tenantId, nextPageToken),
34
- ]);
35
- }
36
- else {
37
- return of(updateAiAccountantJobsFailure({
38
- tenantId,
39
- error: response.status,
40
- }));
41
- }
42
- }), catchError((error) => of(updateAiAccountantJobsFailure({
43
- tenantId,
44
- error: createZeniAPIStatus('Unexpected error', 'AI Accountant jobs fetch failed: ' +
45
- JSON.stringify(error)),
46
- }))));
47
- }));
@@ -1,52 +0,0 @@
1
- import { from } from 'rxjs';
2
- import { catchError, filter, mergeMap } from 'rxjs/operators';
3
- import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
4
- import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
5
- import { fetchAiAccountantCustomers, triggerAiAccountantJob, triggerAiAccountantJobFailure, triggerAiAccountantJobSuccess, } from '../aiAccountantViewReducer';
6
- export const triggerAiAccountantJobEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(triggerAiAccountantJob.match), mergeMap((action) => {
7
- const { operationType, startDate, endDate } = action.payload;
8
- const rootState = state$.value;
9
- const selectedTenantIds = rootState.aiAccountantViewState.selectedTenantIdsForJobTrigger;
10
- const base = `${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels`;
11
- const url = `${base}/ai-accountant/jobs`;
12
- return zeniAPI
13
- .postAndGetJSON(url, {
14
- tenant_ids: selectedTenantIds,
15
- operation_type: operationType,
16
- params: {
17
- start_date: startDate,
18
- end_date: endDate,
19
- },
20
- })
21
- .pipe(mergeMap((response) => {
22
- if (isSuccessResponse(response)) {
23
- return from([
24
- triggerAiAccountantJobSuccess(),
25
- fetchAiAccountantCustomers(),
26
- openSnackbar({
27
- messageSection: 'common',
28
- messageText: 'success',
29
- type: 'success',
30
- }),
31
- ]);
32
- }
33
- else {
34
- return from([
35
- triggerAiAccountantJobFailure(response.status),
36
- openSnackbar({
37
- messageSection: 'common',
38
- messageText: 'failed',
39
- type: 'error',
40
- }),
41
- ]);
42
- }
43
- }), catchError((error) => from([
44
- triggerAiAccountantJobFailure(createZeniAPIStatus('Unexpected error', 'AI Accountant trigger job failed: ' +
45
- JSON.stringify(error))),
46
- openSnackbar({
47
- messageSection: 'common',
48
- messageText: 'failed',
49
- type: 'error',
50
- }),
51
- ])));
52
- }));
@@ -1,44 +0,0 @@
1
- import { of } from 'rxjs';
2
- import { catchError, filter, mergeMap } from 'rxjs/operators';
3
- import { changeAccountKey } from '../../../../entity/account/accountReducer';
4
- import { getAccountKey } from '../../../../entity/account/accountState';
5
- import { getAccountReconByAccountIdAndSelectedPeriod } from '../../../../entity/accountRecon/accountReconSelector';
6
- import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
7
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
8
- import { excludeAccountFromReconciliation, excludeAccountFromReconciliationFailure, excludeAccountFromReconciliationSuccess, } from '../../reducers/reconciliationViewReducer';
9
- export const excludeAccountFromReconciliationEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(excludeAccountFromReconciliation.match), mergeMap((action) => {
10
- const { accountId } = action.payload;
11
- const state = state$.value;
12
- const currentTenant = getCurrentTenant(state);
13
- const selectedPeriod = state.expenseAutomationViewState.selectedPeriodByTenantId[currentTenant.tenantId];
14
- const reconciliationData = getAccountReconByAccountIdAndSelectedPeriod(state, accountId, selectedPeriod);
15
- const payload = {
16
- account_id: accountId,
17
- bank_balance: reconciliationData?.balance?.amount ?? null,
18
- cleared_balance: reconciliationData?.clearedBalance?.amount ?? null,
19
- variance: reconciliationData?.variance?.amount ?? null,
20
- };
21
- const apiUrl = `${zeniAPI.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation/excluded-accounts`;
22
- return zeniAPI
23
- .postAndGetJSON(apiUrl, payload)
24
- .pipe(mergeMap((response) => {
25
- if (isSuccessResponse(response)) {
26
- const newAccountKey = getAccountKey('excluded_account_reconciliation', accountId);
27
- const oldAccountKey = getAccountKey('account_reconciliation', accountId);
28
- return of(excludeAccountFromReconciliationSuccess({
29
- account: response.data?.excluded_account ?? undefined,
30
- selectedPeriod,
31
- }), changeAccountKey({
32
- oldKey: oldAccountKey,
33
- newKey: newAccountKey,
34
- }));
35
- }
36
- else {
37
- return of(excludeAccountFromReconciliationFailure({
38
- error: response.status,
39
- }));
40
- }
41
- }), catchError((error) => of(excludeAccountFromReconciliationFailure({
42
- error: createZeniAPIStatus('Unexpected Error', `Exclude account from reconciliation REST API call errored out ${JSON.stringify(error)}`),
43
- }))));
44
- }));
@@ -1,44 +0,0 @@
1
- import { of } from 'rxjs';
2
- import { catchError, filter, mergeMap } from 'rxjs/operators';
3
- import { convertToPeriod } from '../../../../commonStateTypes/timePeriod';
4
- import { changeAccountKey } from '../../../../entity/account/accountReducer';
5
- import { getAccountKey } from '../../../../entity/account/accountState';
6
- import { updateAccountRecon } from '../../../../entity/accountRecon/accountReconReducer';
7
- import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
8
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
9
- import { includeAccountInReconciliation, includeAccountInReconciliationFailure, includeAccountInReconciliationSuccess, } from '../../reducers/reconciliationViewReducer';
10
- export const includeAccountInReconciliationEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(includeAccountInReconciliation.match), mergeMap((action) => {
11
- const { accountId } = action.payload;
12
- const state = state$.value;
13
- const currentTenant = getCurrentTenant(state);
14
- const selectedPeriod = state.expenseAutomationViewState.selectedPeriodByTenantId[currentTenant.tenantId];
15
- const period = convertToPeriod(selectedPeriod, true);
16
- const query = JSON.stringify({
17
- start_date: period.start,
18
- end_date: period.end,
19
- });
20
- const apiUrl = `${zeniAPI.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation/excluded-accounts/${accountId}?query=${encodeURIComponent(query)}`;
21
- return zeniAPI
22
- .deleteAndGetJSON(apiUrl)
23
- .pipe(mergeMap((response) => {
24
- if (isSuccessResponse(response) && response.data != null) {
25
- const reconciliation = response.data.reconciliation;
26
- const oldAccountKey = getAccountKey('excluded_account_reconciliation', reconciliation.account_id);
27
- const newAccountKey = getAccountKey('account_reconciliation', reconciliation.account_id);
28
- return of(updateAccountRecon(selectedPeriod, [reconciliation]), includeAccountInReconciliationSuccess({
29
- reconciliation,
30
- selectedPeriod,
31
- }), changeAccountKey({
32
- oldKey: oldAccountKey,
33
- newKey: newAccountKey,
34
- }));
35
- }
36
- else {
37
- return of(includeAccountInReconciliationFailure({
38
- error: response.status,
39
- }));
40
- }
41
- }), catchError((error) => of(includeAccountInReconciliationFailure({
42
- error: createZeniAPIStatus('Unexpected Error', `Include account in reconciliation REST API call errored out ${JSON.stringify(error)}`),
43
- }))));
44
- }));
@@ -1,31 +0,0 @@
1
- import { ZeniAPIResponse } from '../../responsePayload';
2
- export { AiAccountantCustomerPayload, AiAccountantEnrollmentPayload, AiAccountantJobPayload, toAiAccountantCustomer, toAiAccountantEnrollment, toAiAccountantJob, } from '../../entity/aiAccountantCustomer/aiAccountantCustomerPayload';
3
- import type { AiAccountantCustomerPayload, AiAccountantJobPayload } from '../../entity/aiAccountantCustomer/aiAccountantCustomerPayload';
4
- import { UserPayload } from '../../entity/user/userPayload';
5
- export interface AiAccountantCustomersResponseData {
6
- customers: AiAccountantCustomerPayload[];
7
- users: UserPayload[];
8
- }
9
- export interface AiAccountantJobsResponseData {
10
- jobs: AiAccountantJobPayload[];
11
- page_size: number;
12
- users: UserPayload[];
13
- next_page_token?: string | null;
14
- }
15
- export interface AiAccountantTriggerJobResponseData {
16
- job_ids: string[];
17
- queued_count: number;
18
- skipped?: Array<{
19
- reason: string;
20
- tenant_id: string;
21
- }>;
22
- }
23
- export interface AiAccountantCancelOnboardingResponseData {
24
- cancelled_jobs: string[];
25
- ok: boolean;
26
- workflow_cancelled: boolean;
27
- }
28
- export type AiAccountantCustomersResponse = ZeniAPIResponse<AiAccountantCustomersResponseData>;
29
- export type AiAccountantJobsResponse = ZeniAPIResponse<AiAccountantJobsResponseData>;
30
- export type AiAccountantTriggerJobResponse = ZeniAPIResponse<AiAccountantTriggerJobResponseData>;
31
- export type AiAccountantCancelOnboardingResponse = ZeniAPIResponse<AiAccountantCancelOnboardingResponseData>;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toAiAccountantJob = exports.toAiAccountantEnrollment = exports.toAiAccountantCustomer = void 0;
4
- // Re-export entity payload types and mapping functions.
5
- var aiAccountantCustomerPayload_1 = require("../../entity/aiAccountantCustomer/aiAccountantCustomerPayload");
6
- Object.defineProperty(exports, "toAiAccountantCustomer", { enumerable: true, get: function () { return aiAccountantCustomerPayload_1.toAiAccountantCustomer; } });
7
- Object.defineProperty(exports, "toAiAccountantEnrollment", { enumerable: true, get: function () { return aiAccountantCustomerPayload_1.toAiAccountantEnrollment; } });
8
- Object.defineProperty(exports, "toAiAccountantJob", { enumerable: true, get: function () { return aiAccountantCustomerPayload_1.toAiAccountantJob; } });
@@ -1,29 +0,0 @@
1
- import { AiAccountantCustomerPayload } from '../../entity/aiAccountantCustomer/aiAccountantCustomerPayload';
2
- import { ID } from '../../commonStateTypes/common';
3
- import { ZeniAPIStatus } from '../../responsePayload';
4
- import { AiAccountantUIState, AiAccountantViewState } from './aiAccountantViewState';
5
- export declare const initialAiAccountantViewState: AiAccountantViewState;
6
- export declare const cancelAiAccountantOnboarding: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[companyId: string, tenantId: string], {
7
- companyId: string;
8
- tenantId: string;
9
- }, "aiAccountantView/cancelAiAccountantOnboarding", never, never>, cancelAiAccountantOnboardingFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[tenantId: string, error: ZeniAPIStatus<Record<string, unknown>>], {
10
- tenantId: string;
11
- error: ZeniAPIStatus<Record<string, unknown>>;
12
- }, "aiAccountantView/cancelAiAccountantOnboardingFailure", never, never>, cancelAiAccountantOnboardingSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[tenantId: string], {
13
- tenantId: string;
14
- }, "aiAccountantView/cancelAiAccountantOnboardingSuccess", never, never>, clearAiAccountantView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"aiAccountantView/clearAiAccountantView">, fetchAiAccountantCustomers: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"aiAccountantView/fetchAiAccountantCustomers">, fetchAiAccountantJobs: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[tenantId: string, fetchNextPage?: boolean | undefined], {
15
- tenantId: string;
16
- fetchNextPage: boolean;
17
- }, "aiAccountantView/fetchAiAccountantJobs", never, never>, setSelectedTenantIdsForJobTrigger: import("@reduxjs/toolkit").ActionCreatorWithPayload<string[], "aiAccountantView/setSelectedTenantIdsForJobTrigger">, triggerAiAccountantJob: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[operationType: "onboard" | "offboard" | "retrain" | "full_pipeline" | "cancel_onboarding", startDate: string, endDate: string], {
18
- operationType: "onboard" | "offboard" | "retrain" | "full_pipeline" | "cancel_onboarding";
19
- startDate: string;
20
- endDate: string;
21
- }, "aiAccountantView/triggerAiAccountantJob", never, never>, triggerAiAccountantJobFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "aiAccountantView/triggerAiAccountantJobFailure">, triggerAiAccountantJobSuccess: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"aiAccountantView/triggerAiAccountantJobSuccess">, updateAiAccountantCustomers: import("@reduxjs/toolkit").ActionCreatorWithPayload<AiAccountantCustomerPayload[], "aiAccountantView/updateAiAccountantCustomers">, updateAiAccountantCustomersFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "aiAccountantView/updateAiAccountantCustomersFailure">, updateAiAccountantJobs: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[tenantId: string, nextPageToken?: string | null | undefined], {
22
- tenantId: string;
23
- nextPageToken: string | null;
24
- }, "aiAccountantView/updateAiAccountantJobs", never, never>, updateAiAccountantJobsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
25
- error: ZeniAPIStatus;
26
- tenantId: ID;
27
- }, "aiAccountantView/updateAiAccountantJobsFailure">, updateAiAccountantUIState: import("@reduxjs/toolkit").ActionCreatorWithPayload<Partial<AiAccountantUIState>, "aiAccountantView/updateAiAccountantUIState">;
28
- declare const _default: import("redux").Reducer<AiAccountantViewState>;
29
- export default _default;
@@ -1,153 +0,0 @@
1
- "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.updateAiAccountantUIState = exports.updateAiAccountantJobsFailure = exports.updateAiAccountantJobs = exports.updateAiAccountantCustomersFailure = exports.updateAiAccountantCustomers = exports.triggerAiAccountantJobSuccess = exports.triggerAiAccountantJobFailure = exports.triggerAiAccountantJob = exports.setSelectedTenantIdsForJobTrigger = exports.fetchAiAccountantJobs = exports.fetchAiAccountantCustomers = exports.clearAiAccountantView = exports.cancelAiAccountantOnboardingSuccess = exports.cancelAiAccountantOnboardingFailure = exports.cancelAiAccountantOnboarding = exports.initialAiAccountantViewState = void 0;
5
- const toolkit_1 = require("@reduxjs/toolkit");
6
- exports.initialAiAccountantViewState = {
7
- customersByTenantId: {},
8
- customersFetchStatus: { fetchState: 'Not-Started' },
9
- selectedTenantIdsForJobTrigger: [],
10
- triggerJobStatus: { fetchState: 'Not-Started' },
11
- uiState: {
12
- filterText: '',
13
- filters: {},
14
- selectedCustomerTenantId: '',
15
- sortKey: 'companyName',
16
- sortOrder: 'ascending',
17
- },
18
- };
19
- const aiAccountantView = (0, toolkit_1.createSlice)({
20
- name: 'aiAccountantView',
21
- initialState: exports.initialAiAccountantViewState,
22
- reducers: {
23
- // ── Customers ──
24
- fetchAiAccountantCustomers(draft) {
25
- draft.customersFetchStatus = { fetchState: 'In-Progress' };
26
- },
27
- updateAiAccountantCustomers(draft, action) {
28
- draft.customersByTenantId = toCustomersByTenantId(action.payload, draft.customersByTenantId);
29
- draft.customersFetchStatus = { fetchState: 'Completed' };
30
- },
31
- updateAiAccountantCustomersFailure(draft, action) {
32
- draft.customersFetchStatus = {
33
- fetchState: 'Error',
34
- error: action.payload,
35
- };
36
- },
37
- // ── Jobs ──
38
- fetchAiAccountantJobs: {
39
- reducer(draft, action) {
40
- const customerView = draft.customersByTenantId[action.payload.tenantId];
41
- if (customerView != null) {
42
- customerView.jobsFetchStatus = { fetchState: 'In-Progress' };
43
- }
44
- },
45
- prepare(tenantId, fetchNextPage) {
46
- return { payload: { tenantId, fetchNextPage: fetchNextPage ?? false } };
47
- },
48
- },
49
- updateAiAccountantJobs: {
50
- reducer(draft, action) {
51
- const customerView = draft.customersByTenantId[action.payload.tenantId];
52
- if (customerView != null) {
53
- customerView.jobsFetchStatus = { fetchState: 'Completed' };
54
- customerView.jobsPageToken = action.payload.nextPageToken;
55
- }
56
- },
57
- prepare(tenantId, nextPageToken) {
58
- return { payload: { tenantId, nextPageToken: nextPageToken ?? null } };
59
- },
60
- },
61
- updateAiAccountantJobsFailure(draft, action) {
62
- const customerView = draft.customersByTenantId[action.payload.tenantId];
63
- if (customerView != null) {
64
- customerView.jobsFetchStatus = {
65
- fetchState: 'Error',
66
- error: action.payload.error,
67
- };
68
- }
69
- },
70
- setSelectedTenantIdsForJobTrigger(draft, action) {
71
- draft.selectedTenantIdsForJobTrigger = action.payload;
72
- },
73
- // ── Trigger Job ──
74
- triggerAiAccountantJob: {
75
- reducer(draft,
76
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
77
- _action) {
78
- draft.triggerJobStatus = { fetchState: 'In-Progress' };
79
- },
80
- prepare(operationType, startDate, endDate) {
81
- return { payload: { operationType, startDate, endDate } };
82
- },
83
- },
84
- triggerAiAccountantJobSuccess(draft) {
85
- draft.triggerJobStatus = { fetchState: 'Completed' };
86
- },
87
- triggerAiAccountantJobFailure(draft, action) {
88
- draft.triggerJobStatus = { fetchState: 'Error', error: action.payload };
89
- },
90
- // ── Cancel Onboarding ──
91
- cancelAiAccountantOnboarding: {
92
- reducer(draft, action) {
93
- const customerView = draft.customersByTenantId[action.payload.tenantId];
94
- if (customerView != null) {
95
- customerView.cancelOnboardingStatus = { fetchState: 'In-Progress' };
96
- }
97
- },
98
- prepare(companyId, tenantId) {
99
- return { payload: { companyId, tenantId } };
100
- },
101
- },
102
- cancelAiAccountantOnboardingSuccess: {
103
- reducer(draft, action) {
104
- const customerView = draft.customersByTenantId[action.payload.tenantId];
105
- if (customerView != null) {
106
- customerView.cancelOnboardingStatus = { fetchState: 'Completed' };
107
- }
108
- },
109
- prepare(tenantId) {
110
- return { payload: { tenantId } };
111
- },
112
- },
113
- cancelAiAccountantOnboardingFailure: {
114
- reducer(draft, action) {
115
- const customerView = draft.customersByTenantId[action.payload.tenantId];
116
- if (customerView != null) {
117
- customerView.cancelOnboardingStatus = {
118
- fetchState: 'Error',
119
- error: action.payload.error,
120
- };
121
- }
122
- },
123
- prepare(tenantId, error) {
124
- return { payload: { tenantId, error } };
125
- },
126
- },
127
- // ── UI State ──
128
- updateAiAccountantUIState(draft, action) {
129
- Object.assign(draft.uiState, action.payload);
130
- },
131
- // ── Clear ──
132
- clearAiAccountantView() {
133
- return exports.initialAiAccountantViewState;
134
- },
135
- },
136
- });
137
- _a = aiAccountantView.actions, exports.cancelAiAccountantOnboarding = _a.cancelAiAccountantOnboarding, exports.cancelAiAccountantOnboardingFailure = _a.cancelAiAccountantOnboardingFailure, exports.cancelAiAccountantOnboardingSuccess = _a.cancelAiAccountantOnboardingSuccess, exports.clearAiAccountantView = _a.clearAiAccountantView, exports.fetchAiAccountantCustomers = _a.fetchAiAccountantCustomers, exports.fetchAiAccountantJobs = _a.fetchAiAccountantJobs, exports.setSelectedTenantIdsForJobTrigger = _a.setSelectedTenantIdsForJobTrigger, exports.triggerAiAccountantJob = _a.triggerAiAccountantJob, exports.triggerAiAccountantJobFailure = _a.triggerAiAccountantJobFailure, exports.triggerAiAccountantJobSuccess = _a.triggerAiAccountantJobSuccess, exports.updateAiAccountantCustomers = _a.updateAiAccountantCustomers, exports.updateAiAccountantCustomersFailure = _a.updateAiAccountantCustomersFailure, exports.updateAiAccountantJobs = _a.updateAiAccountantJobs, exports.updateAiAccountantJobsFailure = _a.updateAiAccountantJobsFailure, exports.updateAiAccountantUIState = _a.updateAiAccountantUIState;
138
- exports.default = aiAccountantView.reducer;
139
- // ── Helpers ──
140
- const toCustomersByTenantId = (customers, existing) => {
141
- const result = {};
142
- for (const payload of customers) {
143
- const tenantId = payload.tenant_id;
144
- const existingState = existing[tenantId];
145
- result[tenantId] = existingState ?? {
146
- cancelOnboardingStatus: { fetchState: 'Not-Started' },
147
- jobsFetchStatus: { fetchState: 'Not-Started' },
148
- jobsPageToken: null,
149
- tenantId,
150
- };
151
- }
152
- return result;
153
- };
@@ -1,14 +0,0 @@
1
- import { FetchStateAndError } from '../../commonStateTypes/common';
2
- import { SelectorView } from '../../commonStateTypes/viewAndReport/viewAndReport';
3
- import { AiAccountantCustomerView } from '../../entity/aiAccountantCustomer/aiAccountantCustomerSelector';
4
- import { RootState } from '../../reducer';
5
- import { AiAccountantCustomerViewState, AiAccountantUIState } from './aiAccountantViewState';
6
- export interface AiAccountantCockpitView extends SelectorView {
7
- averageAccuracy: number;
8
- customers: AiAccountantCustomerView[];
9
- customerViewStateByTenantId: Record<string, AiAccountantCustomerViewState>;
10
- selectedCustomersForJobTrigger: AiAccountantCustomerView[];
11
- triggerJobStatus: FetchStateAndError;
12
- uiState: AiAccountantUIState;
13
- }
14
- export declare const getAiAccountantCockpitView: (state: RootState) => AiAccountantCockpitView;
@@ -1,78 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getAiAccountantCockpitView = void 0;
7
- const toolkit_1 = require("@reduxjs/toolkit");
8
- const orderBy_1 = __importDefault(require("lodash/orderBy"));
9
- const aiAccountantCustomerSelector_1 = require("../../entity/aiAccountantCustomer/aiAccountantCustomerSelector");
10
- exports.getAiAccountantCockpitView = (0, toolkit_1.createSelector)((state) => state.aiAccountantViewState, (state) => state.aiAccountantCustomerState, (state) => state.userState, (viewState, customerEntityState, userState) => {
11
- const { customersByTenantId, customersFetchStatus, selectedTenantIdsForJobTrigger, triggerJobStatus, uiState, } = viewState;
12
- const allCustomers = (0, aiAccountantCustomerSelector_1.getAiAccountantCustomers)(customerEntityState, userState);
13
- let filteredCustomers = allCustomers;
14
- // Text filter
15
- const trimmedFilterText = uiState.filterText.trim();
16
- if (trimmedFilterText.length > 0) {
17
- const query = trimmedFilterText.toLowerCase();
18
- filteredCustomers = filteredCustomers.filter((customer) => customer.companyName.toLowerCase().includes(query) ||
19
- customer.tenantId.toLowerCase().includes(query));
20
- }
21
- // Cockpit filters (e.g. enrollmentStatus)
22
- const enrollmentStatusFilter = uiState.filters.categories?.find((category) => category.field === 'enrollmentStatus');
23
- if (enrollmentStatusFilter != null &&
24
- enrollmentStatusFilter.values.length > 0) {
25
- const selectedStatuses = enrollmentStatusFilter.values.map(String);
26
- const isEqual = enrollmentStatusFilter.matchingOperator === 'equal';
27
- filteredCustomers = filteredCustomers.filter((customer) => {
28
- const status = customer.enrollment?.status ?? 'unknown';
29
- const matches = selectedStatuses.includes(status);
30
- return isEqual ? matches : !matches;
31
- });
32
- }
33
- // Sorting
34
- const sortedCustomers = getSortedCustomers(filteredCustomers, uiState.sortKey, uiState.sortOrder);
35
- const selectedCustomersForJobTrigger = allCustomers.filter((customer) => selectedTenantIdsForJobTrigger.includes(customer.tenantId));
36
- return {
37
- averageAccuracy: calcOverallAverageAccuracy(allCustomers),
38
- fetchState: customersFetchStatus.fetchState,
39
- error: customersFetchStatus.error,
40
- customers: sortedCustomers,
41
- customerViewStateByTenantId: customersByTenantId,
42
- selectedCustomersForJobTrigger,
43
- triggerJobStatus,
44
- uiState,
45
- };
46
- });
47
- // ── Helpers ──
48
- const getSortedCustomers = (customers, sortKey, sortOrder) => {
49
- const direction = sortOrder === 'ascending' ? 'asc' : 'desc';
50
- return (0, orderBy_1.default)(customers, (customer) => {
51
- switch (sortKey) {
52
- case 'companyName':
53
- return customer.companyName.toLowerCase();
54
- case 'status':
55
- return (customer.enrollment?.status ?? 'unknown').toLowerCase();
56
- case 'bookcloseDate':
57
- return customer.bookcloseDate?.valueOf() ?? 0;
58
- case 'latestTraining':
59
- return customer.enrollment?.latestTraining?.valueOf() ?? 0;
60
- case 'latestSync':
61
- return customer.enrollment?.latestTransactionSync?.valueOf() ?? 0;
62
- case 'accuracy':
63
- return customer.averageAccuracy;
64
- default:
65
- return customer.companyName.toLowerCase();
66
- }
67
- }, direction);
68
- };
69
- const calcOverallAverageAccuracy = (customers) => {
70
- const customerAccuracies = customers
71
- .map((customer) => customer.averageAccuracy)
72
- .filter((accuracy) => accuracy > 0);
73
- if (customerAccuracies.length === 0) {
74
- return 0;
75
- }
76
- return (customerAccuracies.reduce((sum, accuracy) => sum + accuracy, 0) /
77
- customerAccuracies.length);
78
- };
@@ -1,27 +0,0 @@
1
- import { FetchStateAndError, ID } from '../../commonStateTypes/common';
2
- import { SortOrder } from '../../commonStateTypes/selectorTypes/sortOrderTypes';
3
- import { CockpitFilters } from '../companyView/types/cockpitTypes';
4
- export type { AiAccountantCustomer, AiAccountantEnrollment, AiAccountantEnrollmentStatus, AiAccountantJob, AiAccountantJobStatus, AiAccountantOperationType, } from '../../entity/aiAccountantCustomer/aiAccountantCustomerState';
5
- declare const toAiAccountantSortKeyType: (v: string) => "status" | "companyName" | "bookcloseDate" | "accuracy" | "latestTraining" | "latestSync";
6
- export type AiAccountantSortKey = ReturnType<typeof toAiAccountantSortKeyType>;
7
- export type AiAccountantFilterCategoryField = 'enrollmentStatus';
8
- export interface AiAccountantUIState {
9
- filters: CockpitFilters;
10
- filterText: string;
11
- selectedCustomerTenantId: string;
12
- sortKey: AiAccountantSortKey;
13
- sortOrder: SortOrder;
14
- }
15
- export interface AiAccountantCustomerViewState {
16
- cancelOnboardingStatus: FetchStateAndError;
17
- jobsFetchStatus: FetchStateAndError;
18
- jobsPageToken: string | null;
19
- tenantId: ID;
20
- }
21
- export interface AiAccountantViewState {
22
- customersByTenantId: Record<ID, AiAccountantCustomerViewState>;
23
- customersFetchStatus: FetchStateAndError;
24
- selectedTenantIdsForJobTrigger: ID[];
25
- triggerJobStatus: FetchStateAndError;
26
- uiState: AiAccountantUIState;
27
- }
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
4
- const ALL_AI_ACCOUNTANT_SORT_KEYS = [
5
- 'companyName',
6
- 'status',
7
- 'bookcloseDate',
8
- 'latestTraining',
9
- 'latestSync',
10
- 'accuracy',
11
- ];
12
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
13
- const toAiAccountantSortKeyType = (v) => (0, stringToUnion_1.stringToUnion)(v, ALL_AI_ACCOUNTANT_SORT_KEYS);