@zeniai/client-epic-state 4.20.6 → 4.20.8

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 (178) hide show
  1. package/lib/commonStateTypes/coaBalance/additionalBalances/getSummationBalance.d.ts +1 -1
  2. package/lib/commonStateTypes/coaBalance/coaBalanceType.d.ts +2 -0
  3. package/lib/commonStateTypes/coaBalance/coaBalanceType.js +6 -0
  4. package/lib/commonStateTypes/currencyHelper.d.ts +3 -0
  5. package/lib/commonStateTypes/currencyHelper.js +6 -1
  6. package/lib/commonStateTypes/reduceFetchState.d.ts +9 -0
  7. package/lib/commonStateTypes/reduceFetchState.js +26 -0
  8. package/lib/entity/account/accountPayload.d.ts +2 -0
  9. package/lib/entity/account/accountPayload.js +2 -0
  10. package/lib/entity/account/accountState.d.ts +2 -0
  11. package/lib/entity/customer/customerState.d.ts +0 -2
  12. package/lib/entity/customer/customerState.js +0 -5
  13. package/lib/entity/depositAccount/depositAccount.d.ts +1 -1
  14. package/lib/entity/depositAccount/depositAccount.js +8 -1
  15. package/lib/entity/reimbursement/reimbursementPayload.d.ts +2 -0
  16. package/lib/entity/reimbursement/reimbursementPayload.js +7 -0
  17. package/lib/entity/reimbursement/reimbursementState.d.ts +2 -0
  18. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  19. package/lib/entity/snackbar/snackbarTypes.js +2 -0
  20. package/lib/entity/task/taskPayload.d.ts +1 -0
  21. package/lib/entity/task/taskPayload.js +1 -0
  22. package/lib/entity/task/taskState.d.ts +1 -0
  23. package/lib/entity/userGroups/userGroupsPayload.d.ts +7 -0
  24. package/lib/entity/userGroups/userGroupsPayload.js +10 -0
  25. package/lib/entity/userGroups/userGroupsReducer.d.ts +8 -0
  26. package/lib/entity/userGroups/userGroupsReducer.js +29 -0
  27. package/lib/entity/userGroups/userGroupsSelector.d.ts +4 -0
  28. package/lib/entity/userGroups/userGroupsSelector.js +12 -0
  29. package/lib/entity/userGroups/userGroupsState.d.ts +9 -0
  30. package/lib/entity/userGroups/userGroupsState.js +2 -0
  31. package/lib/epic.d.ts +15 -1
  32. package/lib/epic.js +15 -1
  33. package/lib/esm/commonStateTypes/coaBalance/coaBalanceType.js +5 -0
  34. package/lib/esm/commonStateTypes/currencyHelper.js +5 -0
  35. package/lib/esm/commonStateTypes/reduceFetchState.js +25 -0
  36. package/lib/esm/entity/account/accountPayload.js +2 -0
  37. package/lib/esm/entity/customer/customerState.js +1 -4
  38. package/lib/esm/entity/depositAccount/depositAccount.js +8 -1
  39. package/lib/esm/entity/reimbursement/reimbursementPayload.js +7 -0
  40. package/lib/esm/entity/snackbar/snackbarTypes.js +2 -0
  41. package/lib/esm/entity/task/taskPayload.js +1 -0
  42. package/lib/esm/entity/userGroups/userGroupsPayload.js +7 -0
  43. package/lib/esm/entity/userGroups/userGroupsReducer.js +25 -0
  44. package/lib/esm/entity/userGroups/userGroupsSelector.js +8 -0
  45. package/lib/esm/entity/userGroups/userGroupsState.js +1 -0
  46. package/lib/esm/epic.js +15 -1
  47. package/lib/esm/index.js +19 -10
  48. package/lib/esm/reducer.js +6 -0
  49. package/lib/esm/view/arAgingView/arAgingReport/arAgingReducer.js +1 -1
  50. package/lib/esm/view/arAgingView/arAgingReport/arAgingSelector.js +1 -1
  51. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadMatchResultToastEpic.js +33 -0
  52. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +29 -0
  53. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +49 -0
  54. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +40 -0
  55. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +49 -0
  56. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +61 -0
  57. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +33 -0
  58. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +56 -0
  59. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/refetchCompletedTransactionsOnBulkUploadSortEpic.js +12 -0
  60. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +98 -0
  61. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +71 -0
  62. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +7 -5
  63. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +86 -0
  64. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +24 -0
  65. package/lib/esm/view/expenseAutomationView/helpers/bulkUploadTiming.js +16 -0
  66. package/lib/esm/view/expenseAutomationView/helpers/rollingCalendarDateRangeInclusive.js +13 -0
  67. package/lib/esm/view/expenseAutomationView/payload/missingReceiptsPayload.js +198 -1
  68. package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +456 -2
  69. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +23 -1
  70. package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +245 -1
  71. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +2 -1
  72. package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +44 -0
  73. package/lib/esm/view/expenseAutomationView/types/transactionsViewState.js +2 -1
  74. package/lib/esm/view/financeStatement/financeStatementReducer.js +11 -8
  75. package/lib/esm/view/financeStatement/financeStatementSelector.js +24 -9
  76. package/lib/esm/view/profitAndLossClassesView/horizontalSectionEmptyBalancesSlice.js +17 -0
  77. package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +331 -0
  78. package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.js +9 -0
  79. package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesViewReducer.js +6 -1
  80. package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesViewSelector.js +2 -29
  81. package/lib/esm/view/profitAndLossClassesView/profitAndLossForTimeframeClassesViewEpic.js +7 -5
  82. package/lib/esm/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +262 -0
  83. package/lib/esm/view/reportUIOptions/updateReportUIOptionCOABalancesRangeEpic.js +9 -7
  84. package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
  85. package/lib/esm/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.js +1 -0
  86. package/lib/esm/view/taskManager/taskListView/taskListSelector.js +3 -1
  87. package/lib/esm/view/userGroupListView/userGroupListViewReducer.js +65 -0
  88. package/lib/esm/view/userGroupListView/userGroupListViewSelector.js +16 -0
  89. package/lib/esm/view/userGroupListView/userGroupListViewState.js +1 -0
  90. package/lib/esm/view/userListView/fetchUserListByTypeEpic.js +11 -0
  91. package/lib/esm/zeniAPI.js +0 -2
  92. package/lib/index.d.ts +20 -12
  93. package/lib/index.js +97 -34
  94. package/lib/reducer.d.ts +6 -0
  95. package/lib/reducer.js +6 -0
  96. package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
  97. package/lib/view/arAgingView/arAgingReport/arAgingReducer.js +2 -2
  98. package/lib/view/arAgingView/arAgingReport/arAgingSelector.js +5 -5
  99. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadMatchResultToastEpic.d.ts +13 -0
  100. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadMatchResultToastEpic.js +37 -0
  101. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.d.ts +18 -0
  102. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +33 -0
  103. package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.d.ts +7 -0
  104. package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +53 -0
  105. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.d.ts +8 -0
  106. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +44 -0
  107. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.d.ts +7 -0
  108. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +53 -0
  109. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.d.ts +8 -0
  110. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +65 -0
  111. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.d.ts +8 -0
  112. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +37 -0
  113. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.d.ts +9 -0
  114. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +61 -0
  115. package/lib/view/expenseAutomationView/epics/missingReceipts/refetchCompletedTransactionsOnBulkUploadSortEpic.d.ts +10 -0
  116. package/lib/view/expenseAutomationView/epics/missingReceipts/refetchCompletedTransactionsOnBulkUploadSortEpic.js +16 -0
  117. package/lib/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.d.ts +18 -0
  118. package/lib/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +102 -0
  119. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.d.ts +14 -0
  120. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +75 -0
  121. package/lib/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +7 -5
  122. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts +25 -0
  123. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +92 -0
  124. package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.d.ts +7 -0
  125. package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +28 -0
  126. package/lib/view/expenseAutomationView/helpers/bulkUploadTiming.d.ts +16 -0
  127. package/lib/view/expenseAutomationView/helpers/bulkUploadTiming.js +19 -0
  128. package/lib/view/expenseAutomationView/helpers/rollingCalendarDateRangeInclusive.d.ts +7 -0
  129. package/lib/view/expenseAutomationView/helpers/rollingCalendarDateRangeInclusive.js +16 -0
  130. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  131. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.d.ts +123 -0
  132. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.js +211 -0
  133. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +86 -3
  134. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +457 -2
  135. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +11 -3
  136. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +24 -2
  137. package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +70 -1
  138. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +1 -0
  139. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.d.ts +1 -1
  140. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +244 -0
  141. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +2 -1
  142. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +146 -0
  143. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +54 -1
  144. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +2 -1
  145. package/lib/view/expenseAutomationView/types/transactionsViewState.js +2 -1
  146. package/lib/view/financeStatement/financeStatementReducer.js +11 -8
  147. package/lib/view/financeStatement/financeStatementSelector.d.ts +2 -0
  148. package/lib/view/financeStatement/financeStatementSelector.js +24 -9
  149. package/lib/view/profitAndLossClassesView/horizontalSectionEmptyBalancesSlice.d.ts +9 -0
  150. package/lib/view/profitAndLossClassesView/horizontalSectionEmptyBalancesSlice.js +20 -0
  151. package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.d.ts +15 -0
  152. package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +335 -0
  153. package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.d.ts +111 -0
  154. package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.js +13 -0
  155. package/lib/view/profitAndLossClassesView/profitAndLossClassesViewReducer.d.ts +4 -2
  156. package/lib/view/profitAndLossClassesView/profitAndLossClassesViewReducer.js +7 -2
  157. package/lib/view/profitAndLossClassesView/profitAndLossClassesViewSelector.js +2 -29
  158. package/lib/view/profitAndLossClassesView/profitAndLossClassesViewState.d.ts +4 -0
  159. package/lib/view/profitAndLossClassesView/profitAndLossForTimeframeClassesViewEpic.js +7 -5
  160. package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.d.ts +6 -0
  161. package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +265 -0
  162. package/lib/view/reportUIOptions/updateReportUIOptionCOABalancesRangeEpic.js +8 -6
  163. package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
  164. package/lib/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.d.ts +1 -0
  165. package/lib/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.js +1 -0
  166. package/lib/view/taskManager/taskListView/taskListSelector.d.ts +2 -0
  167. package/lib/view/taskManager/taskListView/taskListSelector.js +3 -1
  168. package/lib/view/userGroupListView/userGroupListViewReducer.d.ts +23 -0
  169. package/lib/view/userGroupListView/userGroupListViewReducer.js +69 -0
  170. package/lib/view/userGroupListView/userGroupListViewSelector.d.ts +7 -0
  171. package/lib/view/userGroupListView/userGroupListViewSelector.js +20 -0
  172. package/lib/view/userGroupListView/userGroupListViewState.d.ts +8 -0
  173. package/lib/view/userGroupListView/userGroupListViewState.js +2 -0
  174. package/lib/view/userListView/fetchUserListByTypeEpic.d.ts +3 -1
  175. package/lib/view/userListView/fetchUserListByTypeEpic.js +11 -0
  176. package/lib/view/userListView/userListViewPayload.d.ts +2 -0
  177. package/lib/zeniAPI.js +0 -2
  178. package/package.json +3 -3
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.restoreBulkUploadAutomatchingOnMountEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const responsePayload_1 = require("../../../../responsePayload");
7
+ const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
8
+ const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
9
+ const bulkUploadTiming_1 = require("../../helpers/bulkUploadTiming");
10
+ const rollingCalendarDateRangeInclusive_1 = require("../../helpers/rollingCalendarDateRangeInclusive");
11
+ const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
12
+ const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
13
+ /**
14
+ * On missing-receipts entry / period switch, hydrate the automatching banner for the logged-in
15
+ * user without relying on UI-driven list fetches (the Missing tab does not fetch the batch list
16
+ * while `phase === 'idle'`). Flow:
17
+ * 1. Call `GET /1.0/batches` (rolling 30-day window).
18
+ * 2. Emit `fetchBulkUploadBatchesSuccess` so `batchListByPeriod` is populated for the selected
19
+ * period (prevents a duplicate list fetch when the user switches to the Unmatched tab).
20
+ * 3. For each `processing|pending` row, call `GET /1.0/batches/:id` in order; for the first row
21
+ * whose details `user_id` matches the logged-in user and whose status is still
22
+ * pending/processing, dispatch `restoreBulkUploadMatchingState` and stop.
23
+ */
24
+ const restoreBulkUploadAutomatchingOnMountEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.restoreBulkUploadAutomatchingOnMount.match), (0, operators_1.mergeMap)(() => {
25
+ const state = state$.value;
26
+ const { expenseAutomationMissingReceiptsViewState: { bulkUpload }, expenseAutomationViewState: { selectedPeriodByTenantId }, } = state;
27
+ if (bulkUpload.phase !== 'idle') {
28
+ return rxjs_1.EMPTY;
29
+ }
30
+ if (bulkUpload.batchListFetchState.fetchState === 'In-Progress') {
31
+ return rxjs_1.EMPTY;
32
+ }
33
+ const loggedInUserId = state.tenantState.loggedInUser?.userId;
34
+ if (loggedInUserId == null) {
35
+ return rxjs_1.EMPTY;
36
+ }
37
+ const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
38
+ const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
39
+ if (selectedPeriod == null) {
40
+ return rxjs_1.EMPTY;
41
+ }
42
+ const { end, start } = (0, rollingCalendarDateRangeInclusive_1.rollingCalendarDateRangeInclusive)(bulkUploadTiming_1.BULK_UPLOAD_BATCH_LIST_DATE_RANGE_DAYS);
43
+ const queryParam = {
44
+ start_date: start,
45
+ end_date: end,
46
+ sort_order: 'desc',
47
+ };
48
+ const listUrl = `${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches?query=${encodeURIComponent(JSON.stringify(queryParam))}`;
49
+ const detailsBaseUrl = `${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/`;
50
+ const periodId = (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod);
51
+ const alreadyCached = (bulkUpload.batchListByPeriod[periodId] ?? []).length > 0 &&
52
+ bulkUpload.batchListFetchState.fetchState === 'Completed';
53
+ const listSource = alreadyCached
54
+ ? (0, rxjs_1.of)(null)
55
+ : zeniAPI.getJSON(listUrl).pipe((0, operators_1.catchError)(() => (0, rxjs_1.of)(null)));
56
+ return listSource.pipe((0, operators_1.mergeMap)((listResponse) => {
57
+ const batchList = alreadyCached
58
+ ? bulkUpload.batchListByPeriod[periodId] ?? []
59
+ : listResponse != null &&
60
+ (0, responsePayload_1.isSuccessResponse)(listResponse) &&
61
+ listResponse.data != null
62
+ ? listResponse.data.batches.map(missingReceiptsPayload_1.toBatchListItem)
63
+ : null;
64
+ if (batchList == null) {
65
+ return rxjs_1.EMPTY;
66
+ }
67
+ const successAction = alreadyCached
68
+ ? null
69
+ : (0, missingReceiptsViewReducer_1.fetchBulkUploadBatchesSuccess)({
70
+ batchList,
71
+ selectedPeriod,
72
+ });
73
+ const processingBatches = batchList.filter((b) => {
74
+ const status = b.status.toLowerCase();
75
+ return status === 'processing' || status === 'pending';
76
+ });
77
+ const restoreStream = (0, rxjs_1.from)(processingBatches).pipe((0, operators_1.concatMap)((batch) => zeniAPI
78
+ .getJSON(`${detailsBaseUrl}${batch.batchId}`)
79
+ .pipe((0, operators_1.mergeMap)((response) => {
80
+ if (!(0, responsePayload_1.isSuccessResponse)(response) || response.data == null) {
81
+ return rxjs_1.EMPTY;
82
+ }
83
+ const data = response.data;
84
+ const detailsUserId = data.user_id;
85
+ if (detailsUserId == null ||
86
+ detailsUserId !== loggedInUserId) {
87
+ return rxjs_1.EMPTY;
88
+ }
89
+ if (!(0, missingReceiptsPayload_1.isBatchDetailsStatusPendingOrProcessing)(data.status)) {
90
+ return rxjs_1.EMPTY;
91
+ }
92
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.restoreBulkUploadMatchingState)({
93
+ batchId: batch.batchId,
94
+ totalFiles: batch.totalFiles,
95
+ }));
96
+ }), (0, operators_1.catchError)(() => rxjs_1.EMPTY))), (0, operators_1.take)(1));
97
+ return successAction != null
98
+ ? (0, rxjs_1.concat)((0, rxjs_1.of)(successAction), restoreStream)
99
+ : restoreStream;
100
+ }));
101
+ }));
102
+ exports.restoreBulkUploadAutomatchingOnMountEpic = restoreBulkUploadAutomatchingOnMountEpic;
@@ -0,0 +1,14 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
4
+ import { RootState } from '../../../../reducer';
5
+ import { ZeniAPI } from '../../../../zeniAPI';
6
+ import { searchTransactionsForManualMatch, searchTransactionsForManualMatchFailure, searchTransactionsForManualMatchSuccess } from '../../reducers/missingReceiptsViewReducer';
7
+ /**
8
+ * `auto_categorized` for manual transaction search (Unmatched).
9
+ * Backend contract TBD — align with `fetchTransactionCategorizationEpic` (`selectedTab === 'autoCategorized'`)
10
+ * when the expense-automation API documents the intended filter for this flow.
11
+ */
12
+ export declare const MANUAL_TRANSACTION_SEARCH_AUTO_CATEGORIZED = false;
13
+ export type ActionType = ReturnType<typeof searchTransactionsForManualMatch> | ReturnType<typeof searchTransactionsForManualMatchSuccess> | ReturnType<typeof searchTransactionsForManualMatchFailure> | ReturnType<typeof updateTransactions>;
14
+ export declare const searchTransactionsForManualMatchEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.searchTransactionsForManualMatchEpic = exports.MANUAL_TRANSACTION_SEARCH_AUTO_CATEGORIZED = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const transactionReducer_1 = require("../../../../entity/transaction/transactionReducer");
7
+ const responsePayload_1 = require("../../../../responsePayload");
8
+ const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
9
+ const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
10
+ const transactionsViewState_1 = require("../../types/transactionsViewState");
11
+ const rollingCalendarDateRangeInclusive_1 = require("../../helpers/rollingCalendarDateRangeInclusive");
12
+ /**
13
+ * `auto_categorized` for manual transaction search (Unmatched).
14
+ * Backend contract TBD — align with `fetchTransactionCategorizationEpic` (`selectedTab === 'autoCategorized'`)
15
+ * when the expense-automation API documents the intended filter for this flow.
16
+ */
17
+ exports.MANUAL_TRANSACTION_SEARCH_AUTO_CATEGORIZED = false;
18
+ /** Inclusive rolling window for manual match search (ignores accounting period picker). */
19
+ const MANUAL_SEARCH_TRANSACTION_DATE_RANGE_DAYS = 90;
20
+ const searchTransactionsForManualMatchEpic = (actions$, state$, zeniAPI) => {
21
+ const searchActions$ = actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.searchTransactionsForManualMatch.match));
22
+ const pagination$ = searchActions$.pipe((0, operators_1.filter)((action) => action.payload.pageToken != null));
23
+ /**
24
+ * No API for empty or 1-char queries; immediate merge so switchMap cancels any in-flight HTTP.
25
+ */
26
+ const newSearchTooShortOrClear$ = searchActions$.pipe((0, operators_1.filter)((action) => action.payload.pageToken == null &&
27
+ action.payload.query.trim().length < 2));
28
+ const newSearchDebounced$ = searchActions$.pipe((0, operators_1.filter)((action) => action.payload.pageToken == null &&
29
+ action.payload.query.trim().length >= 2), (0, operators_1.debounceTime)(300));
30
+ return (0, rxjs_1.merge)(pagination$, newSearchTooShortOrClear$, newSearchDebounced$).pipe((0, operators_1.switchMap)((action) => {
31
+ const { query, pageToken } = action.payload;
32
+ if (pageToken == null && query.trim().length < 2) {
33
+ return rxjs_1.EMPTY;
34
+ }
35
+ const state = state$.value;
36
+ const { expenseAutomationMissingReceiptsViewState: { bulkUpload: { manualSearch, sortKey, sortOrder }, }, } = state;
37
+ const { end, start } = (0, rollingCalendarDateRangeInclusive_1.rollingCalendarDateRangeInclusive)(MANUAL_SEARCH_TRANSACTION_DATE_RANGE_DAYS);
38
+ const queryParam = {
39
+ start_date: start,
40
+ end_date: end,
41
+ auto_categorized: exports.MANUAL_TRANSACTION_SEARCH_AUTO_CATEGORIZED,
42
+ sort_by: (0, transactionsViewState_1.toTransactionsSortKey)(sortKey),
43
+ sort_order: sortOrder === 'ascending' ? 'asc' : 'desc',
44
+ page_token: pageToken ?? null,
45
+ page_size: manualSearch.pageSize,
46
+ search_text: query,
47
+ };
48
+ return zeniAPI
49
+ .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/transactions?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
50
+ .pipe((0, operators_1.mergeMap)((response) => {
51
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
52
+ const { transactions, next_page_token, total_count } = response.data;
53
+ const append = pageToken != null;
54
+ const results = transactions.map(missingReceiptsPayload_1.supportedTransactionPayloadToManualSearchResult);
55
+ const actionsOut = [
56
+ (0, transactionReducer_1.updateTransactions)(transactions, (value) => value.transaction_id, 'merge'),
57
+ (0, missingReceiptsViewReducer_1.searchTransactionsForManualMatchSuccess)({
58
+ append,
59
+ nextPageToken: next_page_token ?? null,
60
+ results,
61
+ totalCount: total_count,
62
+ }),
63
+ ];
64
+ return (0, rxjs_1.from)(actionsOut);
65
+ }
66
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.searchTransactionsForManualMatchFailure)({
67
+ error: response.status,
68
+ }));
69
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.searchTransactionsForManualMatchFailure)({
70
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Search transactions for manual match errored: ' +
71
+ JSON.stringify(error)),
72
+ }))));
73
+ }));
74
+ };
75
+ exports.searchTransactionsForManualMatchEpic = searchTransactionsForManualMatchEpic;
@@ -15,11 +15,13 @@ const uploadMissingReceiptSuccessEpic = (actions$, state$) => actions$.pipe((0,
15
15
  updateActions.push((0, transactionReducer_1.updateTransaction)(transactionPayload.transaction_id, transactionPayload, updateType));
16
16
  if (currentTenant != null) {
17
17
  const monthEndChecksPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
18
- updateActions.push((0, monthEndCloseChecksViewReducer_1.fetchMonthEndCloseChecks)({
19
- tenantId: currentTenant.tenantId,
20
- period: monthEndChecksPeriod,
21
- refreshViewInBackground: true,
22
- }));
18
+ if (monthEndChecksPeriod != null) {
19
+ updateActions.push((0, monthEndCloseChecksViewReducer_1.fetchMonthEndCloseChecks)({
20
+ tenantId: currentTenant.tenantId,
21
+ period: monthEndChecksPeriod,
22
+ refreshViewInBackground: true,
23
+ }));
24
+ }
23
25
  }
24
26
  return (0, rxjs_1.from)(updateActions);
25
27
  }));
@@ -0,0 +1,25 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
4
+ import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
5
+ import { RootState } from '../../../../reducer';
6
+ import { ZeniAPI } from '../../../../zeniAPI';
7
+ import { bulkUploadAutomatchingTimedOut, bulkUploadReceiptsSuccess, clearBulkUpload, fetchBulkUploadBatchDetailsSuccess, fetchBulkUploadBatches, pusherBatchStatusUpdate, requestMissingReceiptsTabNavigation, restoreBulkUploadMatchingState } from '../../reducers/missingReceiptsViewReducer';
8
+ export type ActionType = ReturnType<typeof bulkUploadReceiptsSuccess> | ReturnType<typeof restoreBulkUploadMatchingState> | ReturnType<typeof pusherBatchStatusUpdate> | ReturnType<typeof fetchBulkUploadBatchDetailsSuccess> | ReturnType<typeof fetchBulkUploadBatches> | ReturnType<typeof requestMissingReceiptsTabNavigation> | ReturnType<typeof updateTransactions> | ReturnType<typeof clearBulkUpload> | ReturnType<typeof openSnackbar> | ReturnType<typeof bulkUploadAutomatchingTimedOut>;
9
+ /**
10
+ * On Pusher batch completion: refresh batch list (then fetchMultipleBatchDetailsEpic runs),
11
+ * and request switching to the Unmatched tab. Debounced to reduce duplicate refreshes.
12
+ */
13
+ export declare const pusherBatchStatusCompletionEpic: (actions$: ActionsObservable<ActionType>) => Observable<ActionType>;
14
+ /**
15
+ * If Pusher and batch-details are delayed beyond {@link BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS},
16
+ * force `phase` to `completed` (dismiss automatching banner) and refresh the batch list.
17
+ * Cancels when the batch completes normally, bulk state is cleared, or another upload supersedes.
18
+ */
19
+ export declare const bulkUploadAutomatchingTimeoutEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
20
+ /**
21
+ * Fallback polling when Pusher is slow or unavailable. Network errors on a poll tick show one
22
+ * error snackbar per upload session (first failure only) so the user is not spammed every
23
+ * interval; Pusher or a later successful poll still completes the flow.
24
+ */
25
+ export declare const pollBulkUploadBatchStatusEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pollBulkUploadBatchStatusEpic = exports.bulkUploadAutomatchingTimeoutEpic = exports.pusherBatchStatusCompletionEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
7
+ const transactionReducer_1 = require("../../../../entity/transaction/transactionReducer");
8
+ const responsePayload_1 = require("../../../../responsePayload");
9
+ const bulkUploadTiming_1 = require("../../helpers/bulkUploadTiming");
10
+ const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
11
+ const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
12
+ /** First poll after upload; then interval while batch not resolved via Pusher or API. */
13
+ const FALLBACK_FIRST_DELAY_MS = 30000;
14
+ /** Shorter first poll for restored sessions — batch may already be near completion. */
15
+ const RESTORE_FIRST_DELAY_MS = 5000;
16
+ const FALLBACK_POLL_INTERVAL_MS = 10000;
17
+ /**
18
+ * On Pusher batch completion: refresh batch list (then fetchMultipleBatchDetailsEpic runs),
19
+ * and request switching to the Unmatched tab. Debounced to reduce duplicate refreshes.
20
+ */
21
+ const pusherBatchStatusCompletionEpic = (actions$) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.pusherBatchStatusUpdate.match), (0, operators_1.filter)((action) => action.payload.status === 'completed'), (0, operators_1.debounceTime)(300), (0, operators_1.mergeMap)(() => (0, rxjs_1.from)([
22
+ (0, missingReceiptsViewReducer_1.fetchBulkUploadBatches)({
23
+ cacheOverride: true,
24
+ invalidateBatchDetailsCache: true,
25
+ }),
26
+ (0, missingReceiptsViewReducer_1.requestMissingReceiptsTabNavigation)({ tab: 'unmatched' }),
27
+ ])));
28
+ exports.pusherBatchStatusCompletionEpic = pusherBatchStatusCompletionEpic;
29
+ /**
30
+ * If Pusher and batch-details are delayed beyond {@link BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS},
31
+ * force `phase` to `completed` (dismiss automatching banner) and refresh the batch list.
32
+ * Cancels when the batch completes normally, bulk state is cleared, or another upload supersedes.
33
+ */
34
+ const bulkUploadAutomatchingTimeoutEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)((action) => missingReceiptsViewReducer_1.bulkUploadReceiptsSuccess.match(action) ||
35
+ missingReceiptsViewReducer_1.restoreBulkUploadMatchingState.match(action)), (0, operators_1.mergeMap)((action) => {
36
+ const { batchId } = action.payload;
37
+ return (0, rxjs_1.timer)(bulkUploadTiming_1.BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS).pipe((0, operators_1.mergeMap)(() => {
38
+ const bulk = state$.value.expenseAutomationMissingReceiptsViewState.bulkUpload;
39
+ if (bulk.phase !== 'matching' || bulk.currentBatchId !== batchId) {
40
+ return rxjs_1.EMPTY;
41
+ }
42
+ return (0, rxjs_1.from)([
43
+ (0, missingReceiptsViewReducer_1.bulkUploadAutomatchingTimedOut)(batchId),
44
+ (0, missingReceiptsViewReducer_1.fetchBulkUploadBatches)({ cacheOverride: true }),
45
+ ]);
46
+ }), (0, operators_1.takeUntil)((0, rxjs_1.merge)(actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.clearBulkUpload.match)), actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.pusherBatchStatusUpdate.match), (0, operators_1.filter)((a) => a.payload.batchId === batchId &&
47
+ a.payload.status === 'completed')), actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsSuccess.match), (0, operators_1.filter)((a) => a.payload.batchId === batchId)))));
48
+ }));
49
+ exports.bulkUploadAutomatchingTimeoutEpic = bulkUploadAutomatchingTimeoutEpic;
50
+ /**
51
+ * Fallback polling when Pusher is slow or unavailable. Network errors on a poll tick show one
52
+ * error snackbar per upload session (first failure only) so the user is not spammed every
53
+ * interval; Pusher or a later successful poll still completes the flow.
54
+ */
55
+ const pollBulkUploadBatchStatusEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)((action) => missingReceiptsViewReducer_1.bulkUploadReceiptsSuccess.match(action) ||
56
+ missingReceiptsViewReducer_1.restoreBulkUploadMatchingState.match(action)), (0, operators_1.mergeMap)((action) => {
57
+ const { batchId } = action.payload;
58
+ let pollErrorNotified = false;
59
+ const firstDelay = missingReceiptsViewReducer_1.restoreBulkUploadMatchingState.match(action)
60
+ ? RESTORE_FIRST_DELAY_MS
61
+ : FALLBACK_FIRST_DELAY_MS;
62
+ return (0, rxjs_1.timer)(firstDelay, FALLBACK_POLL_INTERVAL_MS).pipe((0, operators_1.takeUntil)((0, rxjs_1.merge)(actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.clearBulkUpload.match)), actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.pusherBatchStatusUpdate.match), (0, operators_1.filter)((action) => action.payload.batchId === batchId)), actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsSuccess.match), (0, operators_1.filter)((action) => action.payload.batchId === batchId)), actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.bulkUploadAutomatchingTimedOut.match), (0, operators_1.filter)((action) => action.payload.batchId === batchId)))), (0, operators_1.switchMap)(() => zeniAPI
63
+ .getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/${batchId}`)
64
+ .pipe((0, operators_1.mergeMap)((response) => {
65
+ /** Same batch-details URL; polls until `status` is completed (Pusher may win first). */
66
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
67
+ if ((0, missingReceiptsPayload_1.isBatchDetailsApiStatusCompleted)(response.data.status)) {
68
+ const actions = [];
69
+ const transactionPayloads = (0, missingReceiptsPayload_1.extractTransactionPayloadsFromBatchFiles)(response.data.files);
70
+ if (transactionPayloads.length > 0) {
71
+ actions.push((0, transactionReducer_1.updateTransactions)(transactionPayloads, (value) => value.transaction_id));
72
+ }
73
+ actions.push((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsSuccess)((0, missingReceiptsPayload_1.toBatchDetails)(response.data, zeniAPI.apiEndPoints.fileMicroServiceBaseUrl)));
74
+ actions.push((0, missingReceiptsViewReducer_1.fetchBulkUploadBatches)({ cacheOverride: true }));
75
+ actions.push((0, missingReceiptsViewReducer_1.requestMissingReceiptsTabNavigation)({ tab: 'unmatched' }));
76
+ return (0, rxjs_1.from)(actions);
77
+ }
78
+ }
79
+ return rxjs_1.EMPTY;
80
+ }), (0, operators_1.catchError)(() => {
81
+ if (!pollErrorNotified) {
82
+ pollErrorNotified = true;
83
+ return (0, rxjs_1.of)((0, snackbarReducer_1.openSnackbar)({
84
+ messageSection: 'receipts_upload',
85
+ messageText: 'failed',
86
+ type: 'error',
87
+ }));
88
+ }
89
+ return rxjs_1.EMPTY;
90
+ }))));
91
+ }));
92
+ exports.pollBulkUploadBatchStatusEpic = pollBulkUploadBatchStatusEpic;
@@ -0,0 +1,7 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { updateTransaction } from '../../../../entity/transaction/transactionReducer';
3
+ import { RootState } from '../../../../reducer';
4
+ import { fetchMonthEndCloseChecks } from '../../../monthEndCloseChecksView/monthEndCloseChecksViewReducer';
5
+ import { uploadTransactionCategorizationReceiptSuccess } from '../../reducers/transactionsViewReducer';
6
+ export type ActionType = ReturnType<typeof uploadTransactionCategorizationReceiptSuccess> | ReturnType<typeof fetchMonthEndCloseChecks> | ReturnType<typeof updateTransaction>;
7
+ export declare const uploadTransactionReceiptSuccessEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => import("rxjs").Observable<ActionType>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uploadTransactionReceiptSuccessEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
7
+ const transactionReducer_1 = require("../../../../entity/transaction/transactionReducer");
8
+ const monthEndCloseChecksViewReducer_1 = require("../../../monthEndCloseChecksView/monthEndCloseChecksViewReducer");
9
+ const transactionsViewReducer_1 = require("../../reducers/transactionsViewReducer");
10
+ const uploadTransactionReceiptSuccessEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(transactionsViewReducer_1.uploadTransactionCategorizationReceiptSuccess.match), (0, operators_1.mergeMap)((action) => {
11
+ const { transactionPayload, updateType } = action.payload;
12
+ const updateActions = [];
13
+ const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state$.value);
14
+ const selectedPeriodByTenantId = state$.value.expenseAutomationViewState.selectedPeriodByTenantId;
15
+ updateActions.push((0, transactionReducer_1.updateTransaction)(transactionPayload.transaction_id, transactionPayload, updateType));
16
+ if (currentTenant != null) {
17
+ const monthEndChecksPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
18
+ if (monthEndChecksPeriod != null) {
19
+ updateActions.push((0, monthEndCloseChecksViewReducer_1.fetchMonthEndCloseChecks)({
20
+ tenantId: currentTenant.tenantId,
21
+ period: monthEndChecksPeriod,
22
+ refreshViewInBackground: true,
23
+ }));
24
+ }
25
+ }
26
+ return (0, rxjs_1.from)(updateActions);
27
+ }));
28
+ exports.uploadTransactionReceiptSuccessEpic = uploadTransactionReceiptSuccessEpic;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * After upload API success, hold the bar at 100% this long before transitioning to matching,
3
+ * so the fill animation can complete without an abrupt swap to the auto-matching banner.
4
+ */
5
+ export declare const BULK_UPLOAD_BAR_COMPLETE_HOLD_MS = 400;
6
+ /**
7
+ * Max wall-clock wait for Pusher + batch-details resolution after upload. If exceeded, we stop
8
+ * fallback polling, clear the automatching banner (`phase` → completed), and refresh batch list.
9
+ */
10
+ export declare const BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS = 300000;
11
+ /**
12
+ * Rolling window (in days) for the bulk-upload batch list API. Period-agnostic — the batch list
13
+ * ignores the accounting month picker. Shared between the regular batch-list fetch and the
14
+ * restore-on-mount hydration so both flows always query the same window.
15
+ */
16
+ export declare const BULK_UPLOAD_BATCH_LIST_DATE_RANGE_DAYS = 30;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BULK_UPLOAD_BATCH_LIST_DATE_RANGE_DAYS = exports.BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS = exports.BULK_UPLOAD_BAR_COMPLETE_HOLD_MS = void 0;
4
+ /**
5
+ * After upload API success, hold the bar at 100% this long before transitioning to matching,
6
+ * so the fill animation can complete without an abrupt swap to the auto-matching banner.
7
+ */
8
+ exports.BULK_UPLOAD_BAR_COMPLETE_HOLD_MS = 400;
9
+ /**
10
+ * Max wall-clock wait for Pusher + batch-details resolution after upload. If exceeded, we stop
11
+ * fallback polling, clear the automatching banner (`phase` → completed), and refresh batch list.
12
+ */
13
+ exports.BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS = 300000;
14
+ /**
15
+ * Rolling window (in days) for the bulk-upload batch list API. Period-agnostic — the batch list
16
+ * ignores the accounting month picker. Shared between the regular batch-list fetch and the
17
+ * restore-on-mount hydration so both flows always query the same window.
18
+ */
19
+ exports.BULK_UPLOAD_BATCH_LIST_DATE_RANGE_DAYS = 30;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Local calendar dates from (end − (days − 1)) through end, inclusive.
3
+ */
4
+ export declare function rollingCalendarDateRangeInclusive(days: number): {
5
+ end: string;
6
+ start: string;
7
+ };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rollingCalendarDateRangeInclusive = rollingCalendarDateRangeInclusive;
4
+ const formatZeniDateFY_1 = require("../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY");
5
+ const zeniDayJS_1 = require("../../../zeniDayJS");
6
+ /**
7
+ * Local calendar dates from (end − (days − 1)) through end, inclusive.
8
+ */
9
+ function rollingCalendarDateRangeInclusive(days) {
10
+ const end = (0, zeniDayJS_1.dateNow)().startOf('day');
11
+ const start = end.subtract(days - 1, 'day');
12
+ return {
13
+ end: end.format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT),
14
+ start: start.format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT),
15
+ };
16
+ }
@@ -37,7 +37,7 @@ export declare const getLineItemsByTransactionsIdsFromResponse: (transactions: S
37
37
  export declare const getLineItemsByTransactionIdsFromLocalData: (transactionLocalData: TransactionReviewLocalDataSelectorView[], selectedTab: TransactionsTab) => Record<ID, string[]>;
38
38
  export declare const mergeTabSpecificLineItems: (currentTabSpecificLineItems: TabSpecificLineItems, selectedTab: TransactionsTab, newLineItems: TabSpecificLineItems) => TabSpecificLineItems;
39
39
  export declare const getSnackbarMessageForTransactionReview: (updatedCount: number, failedCount: number, categorizedCount: number) => {
40
- messageSection: "common" | "transactionDetails_updatingPastTransactions" | "transactionDetails_transactionUpdated" | "cockpit_month_end_email_sent" | "cockpit_month_end_email_save" | "cockpit_month_end_email_attachment_upload" | "je_bill_link" | "je_posted" | "audit_score_updated" | "people_invite_people" | "people_invite_multiple_people" | "people_delete_person" | "people_update_person" | "reimbursement_updated" | "reimbursement_deleted" | "reimbursement_cancelled_deleted" | "reimbursement_cancelled" | "reimbursement_approved" | "reimbursement_rejected" | "reimbursement_sent_for_approval" | "account_added" | "business_verification_save" | "business_verification_submit" | "business_verification_from_bills_submit" | "plaid_connection" | "unlink_deposit_account" | "reimbursement_setup" | "reimbursement_approval_create" | "reimbursement_duplicate_approval_create" | "reimbursement_approval_update" | "reimbursement_duplicate_approval_update" | "reimbursement_approval_delete" | "reimbursement_create_mileage" | "reimbursement_update_mileage" | "reimbursement_accept_term" | "reimbursement_accept_employee_term" | "reimbursement_bulk_submit" | "reimbursement_bulk_processed" | "bill_pay_setup" | "zeni_accounts_setup" | "bill_pay_approval_create" | "bill_pay_duplicate_approval_create" | "bill_pay_approval_update" | "bill_pay_duplicate_approval_update" | "bill_pay_approval_delete" | "bill_pay_updated" | "bill_pay_deleted" | "bill_pay_cancelled_deleted" | "bill_pay_cancelled" | "bill_pay_approved" | "real_time_approver_added" | "bill_pay_rejected" | "bill_pay_sent_for_approval" | "bill_pay_accept_term" | "bill_pay_bulk_submit" | "bill_pay_bulk_processed" | "bill_pay_refund" | "bill_pay_retry" | "bill_pay_marked_as_paid" | "zeni_account_accept_term" | "update_vendor" | "data_refresh_update" | "delete_bank_account" | "create_bank_account" | "create_bank_account_ach" | "create_bank_account_wire" | "create_bank_account_international" | "transfer_money" | "update_zeni_account_nickname" | "create_checking_account" | "deposit_check" | "create_vendor" | "onboarding_customer_view" | "onboarding_customer_view_complete" | "onboarding_customer_identity_verification_save" | "onboarding_customer_identity_verification_submit" | "onboarding_customer_business_verification_save" | "onboarding_customer_business_verification_submit" | "retry_bank_account_connection" | "dashboard_invite_sent" | "onboarding_info_saved" | "approve_original_merchant" | "approve_global_merchant" | "reject_global_merchant" | "create_global_merchant" | "fetch_global_merchant_no_recommendation" | "save_vendor_renamed" | "save_vendor_sent_for_review" | "save_vendor_marked_as_employee" | "save_vendor_marked_as_local_contractor" | "charge_card_setup" | "charge_card_accept_term" | "charge_card_receipt_upload" | "charge_card_resend_invite" | "charge_card_revoke_invite" | "charge_card_update_limit" | "charge_cards_update_limit" | "close_charge_card" | "lock_charge_card" | "lock_charge_card_card_user" | "lock_charge_cards" | "unlock_charge_card" | "unlock_charge_card_card_user" | "unlock_charge_cards" | "close_charge_cards" | "revoke_invite_charge_cards" | "charge_card_express_interest" | "create_schedule" | "save_schedule" | "delete_schedule" | "ignore_schedule" | "save_task_detail" | "fetch_task_detail" | "delete_task" | "archive_task" | "create_tag" | "delete_tag" | "update_charge_card" | "update_charge_card_name" | "update_charge_card_name_card_user" | "issue_charge_card" | "issue_charge_cards" | "notification_settings_saved" | "referral_invite_sent" | "notification_mark_as_read" | "mark_as_complete_schedule" | "cancel_journal_entry" | "settings_accounting_accounts_updated" | "create_card_setup" | "confirm_card_setup" | "add_card_payment_source" | "fetch_payment_sources" | "task_assigned_toast_notification" | "task_due_tomorrow_toast_notification" | "task_deleted_toast_notification" | "task_archived_toast_notification" | "task_overdue_toast_notification" | "task_overdue_toast_notification_creator" | "task_notification_count" | "task_activities_toast_notification" | "task_created_toast_notification" | "task_group_creation_success" | "task_group_deletion_success" | "task_group_update_success" | "primary_funding_account_updated" | "task_time_spent_validation" | "missing_receipts_attachment" | "flux_analysis_unreviewed" | "flux_analysis_reviewed" | "receipts_upload" | "billing_address_view" | "express_pay_submit" | "exclude_transaction" | "reconcile" | "save_reconcile_for_later" | "recon_transaction_categorize" | "recon_transaction_match" | "update_debit_card_pin_attempt" | "set_debit_card_pin" | "ai_cfo_create_session_and_submit" | "ai_cfo_chat_session_deleted" | "charge_card_auto_pay_enable" | "charge_card_auto_pay_disable" | "treasury_setup" | "treasury_accept_term" | "treasury_transfer_money" | "treasury_transfer_money_failed" | "treasury_update_portfolio_allocation" | "send_email_magic_link_to_user" | "complete_profile_done" | "reports_resync" | "invalid_phone_number" | "transactions_categorized_updated_failed" | "transaction_categorized_updated_failed" | "transactionsCategorized_transactionsUpdated" | "transactionsCategorized_transactionUpdated" | "transactionCategorized_transactionsUpdated" | "transactionCategorized_transactionUpdated" | "transactionsCategorized_transactionsFailed" | "transactionsCategorized_transactionFailed" | "transactionCategorized_transactionsFailed" | "transactionCategorized_transactionFailed" | "transactionsUpdated_transactionsFailed" | "transactionsUpdated_transactionFailed" | "transactionUpdated_transactionsFailed" | "transactionUpdated_transactionFailed" | "transactionsCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionsUpdated_transactionFailed" | "transactionsCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionUpdated_transactionFailed" | "transactionCategorized_transactionsUpdated_transactionFailed" | "transactionCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionUpdated_transactionFailed";
40
+ messageSection: "common" | "transactionDetails_updatingPastTransactions" | "transactionDetails_transactionUpdated" | "cockpit_month_end_email_sent" | "cockpit_month_end_email_save" | "cockpit_month_end_email_attachment_upload" | "je_bill_link" | "je_posted" | "audit_score_updated" | "people_invite_people" | "people_invite_multiple_people" | "people_delete_person" | "people_update_person" | "reimbursement_updated" | "reimbursement_deleted" | "reimbursement_cancelled_deleted" | "reimbursement_cancelled" | "reimbursement_approved" | "reimbursement_rejected" | "reimbursement_sent_for_approval" | "account_added" | "business_verification_save" | "business_verification_submit" | "business_verification_from_bills_submit" | "plaid_connection" | "unlink_deposit_account" | "reimbursement_setup" | "reimbursement_approval_create" | "reimbursement_duplicate_approval_create" | "reimbursement_approval_update" | "reimbursement_duplicate_approval_update" | "reimbursement_approval_delete" | "reimbursement_create_mileage" | "reimbursement_update_mileage" | "reimbursement_accept_term" | "reimbursement_accept_employee_term" | "reimbursement_bulk_submit" | "reimbursement_bulk_processed" | "bill_pay_setup" | "zeni_accounts_setup" | "bill_pay_approval_create" | "bill_pay_duplicate_approval_create" | "bill_pay_approval_update" | "bill_pay_duplicate_approval_update" | "bill_pay_approval_delete" | "bill_pay_updated" | "bill_pay_deleted" | "bill_pay_cancelled_deleted" | "bill_pay_cancelled" | "bill_pay_approved" | "real_time_approver_added" | "bill_pay_rejected" | "bill_pay_sent_for_approval" | "bill_pay_accept_term" | "bill_pay_bulk_submit" | "bill_pay_bulk_processed" | "bill_pay_refund" | "bill_pay_retry" | "bill_pay_marked_as_paid" | "zeni_account_accept_term" | "update_vendor" | "data_refresh_update" | "delete_bank_account" | "create_bank_account" | "create_bank_account_ach" | "create_bank_account_wire" | "create_bank_account_international" | "transfer_money" | "update_zeni_account_nickname" | "create_checking_account" | "deposit_check" | "create_vendor" | "onboarding_customer_view" | "onboarding_customer_view_complete" | "onboarding_customer_identity_verification_save" | "onboarding_customer_identity_verification_submit" | "onboarding_customer_business_verification_save" | "onboarding_customer_business_verification_submit" | "retry_bank_account_connection" | "dashboard_invite_sent" | "onboarding_info_saved" | "approve_original_merchant" | "approve_global_merchant" | "reject_global_merchant" | "create_global_merchant" | "fetch_global_merchant_no_recommendation" | "save_vendor_renamed" | "save_vendor_sent_for_review" | "save_vendor_marked_as_employee" | "save_vendor_marked_as_local_contractor" | "charge_card_setup" | "charge_card_accept_term" | "charge_card_receipt_upload" | "charge_card_resend_invite" | "charge_card_revoke_invite" | "charge_card_update_limit" | "charge_cards_update_limit" | "close_charge_card" | "lock_charge_card" | "lock_charge_card_card_user" | "lock_charge_cards" | "unlock_charge_card" | "unlock_charge_card_card_user" | "unlock_charge_cards" | "close_charge_cards" | "revoke_invite_charge_cards" | "charge_card_express_interest" | "create_schedule" | "save_schedule" | "delete_schedule" | "ignore_schedule" | "save_task_detail" | "fetch_task_detail" | "delete_task" | "archive_task" | "create_tag" | "delete_tag" | "update_charge_card" | "update_charge_card_name" | "update_charge_card_name_card_user" | "issue_charge_card" | "issue_charge_cards" | "notification_settings_saved" | "referral_invite_sent" | "notification_mark_as_read" | "mark_as_complete_schedule" | "cancel_journal_entry" | "settings_accounting_accounts_updated" | "create_card_setup" | "confirm_card_setup" | "add_card_payment_source" | "fetch_payment_sources" | "task_assigned_toast_notification" | "task_due_tomorrow_toast_notification" | "task_deleted_toast_notification" | "task_archived_toast_notification" | "task_overdue_toast_notification" | "task_overdue_toast_notification_creator" | "task_notification_count" | "task_activities_toast_notification" | "task_created_toast_notification" | "task_group_creation_success" | "task_group_deletion_success" | "task_group_update_success" | "primary_funding_account_updated" | "task_time_spent_validation" | "missing_receipts_attachment" | "flux_analysis_unreviewed" | "flux_analysis_reviewed" | "receipt_match" | "receipts_upload" | "receipts_bulk_match" | "billing_address_view" | "express_pay_submit" | "exclude_transaction" | "reconcile" | "save_reconcile_for_later" | "recon_transaction_categorize" | "recon_transaction_match" | "update_debit_card_pin_attempt" | "set_debit_card_pin" | "ai_cfo_create_session_and_submit" | "ai_cfo_chat_session_deleted" | "charge_card_auto_pay_enable" | "charge_card_auto_pay_disable" | "treasury_setup" | "treasury_accept_term" | "treasury_transfer_money" | "treasury_transfer_money_failed" | "treasury_update_portfolio_allocation" | "send_email_magic_link_to_user" | "complete_profile_done" | "reports_resync" | "invalid_phone_number" | "transactions_categorized_updated_failed" | "transaction_categorized_updated_failed" | "transactionsCategorized_transactionsUpdated" | "transactionsCategorized_transactionUpdated" | "transactionCategorized_transactionsUpdated" | "transactionCategorized_transactionUpdated" | "transactionsCategorized_transactionsFailed" | "transactionsCategorized_transactionFailed" | "transactionCategorized_transactionsFailed" | "transactionCategorized_transactionFailed" | "transactionsUpdated_transactionsFailed" | "transactionsUpdated_transactionFailed" | "transactionUpdated_transactionsFailed" | "transactionUpdated_transactionFailed" | "transactionsCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionsUpdated_transactionFailed" | "transactionsCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionUpdated_transactionFailed" | "transactionCategorized_transactionsUpdated_transactionFailed" | "transactionCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionUpdated_transactionFailed";
41
41
  messageText: "notification" | "success" | "failed";
42
42
  type: "error" | "success" | "info";
43
43
  variables: {
@@ -1,5 +1,9 @@
1
+ import { URLPayload } from '../../../commonPayloadTypes/urlPayload';
2
+ import type { MonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
1
3
  import { TransactionPayload } from '../../../entity/transaction/payloadTypes/transactionPayload';
4
+ import { SupportedTransactionPayload } from '../../../entity/transaction/transactionState';
2
5
  import { ZeniAPIResponse } from '../../../responsePayload';
6
+ import { type BatchDetails, type BatchFile, type BatchFileStatus, type BatchListItem, type BatchStatus, type BatchSummary, type ManualSearchResult } from '../types/missingReceiptsViewState';
3
7
  export interface MissingReceiptsQueryPayload {
4
8
  end_date: string;
5
9
  is_attachment_missing_only: boolean;
@@ -13,4 +17,123 @@ interface MissingReceiptsPayload {
13
17
  transactions: TransactionPayload[];
14
18
  }
15
19
  export type MissingReceiptsResponse = ZeniAPIResponse<MissingReceiptsPayload>;
20
+ export interface BatchListQueryPayload {
21
+ end_date: string;
22
+ sort_order: string;
23
+ start_date: string;
24
+ }
25
+ export interface BulkUploadResponsePayload {
26
+ batch_id: string;
27
+ status: string;
28
+ total_files: number;
29
+ }
30
+ export type BulkUploadResponse = ZeniAPIResponse<BulkUploadResponsePayload>;
31
+ export interface BatchListResponsePayload {
32
+ batches: BatchListItemPayload[];
33
+ }
34
+ export interface BatchListItemPayload {
35
+ batch_id: string;
36
+ created_at: string;
37
+ failed_count: number;
38
+ matched_count: number;
39
+ no_match_count: number;
40
+ possible_matches_count: number;
41
+ status: string;
42
+ total_files: number;
43
+ user_id: string;
44
+ }
45
+ export type BatchListResponse = ZeniAPIResponse<BatchListResponsePayload>;
46
+ export interface MatchedTransactionPayload {
47
+ amount: number;
48
+ currency_code: string;
49
+ transaction_date: string | null;
50
+ transaction_id: string;
51
+ vendor_name: string;
52
+ transaction_type?: string;
53
+ vendor_logo?: URLPayload | null;
54
+ }
55
+ export interface MatchCandidatePayload extends MatchedTransactionPayload {
56
+ match_score: number;
57
+ }
58
+ /**
59
+ * Wire payload for a batch file row. `status` may use legacy aliases (`matched`, `un_matched`,
60
+ * `possible_match`, `possible_matches`, etc.) until the backend is fully migrated; canonical
61
+ * values are applied in {@link parseBatchFileStatus} via {@link toBatchFile}.
62
+ */
63
+ export interface BatchFilePayload {
64
+ attachment_id: string;
65
+ file_id: string;
66
+ file_preview_url: string | null;
67
+ filename: string;
68
+ status: string;
69
+ candidates?: MatchCandidatePayload[];
70
+ match_source?: string;
71
+ matched_transaction?: MatchedTransactionPayload;
72
+ }
73
+ export interface BatchDetailsResponsePayload {
74
+ batch_id: string;
75
+ created_at: string;
76
+ files: BatchFilePayload[];
77
+ status: string;
78
+ summary: {
79
+ failed: number;
80
+ matched: number;
81
+ no_match: number;
82
+ possible_matches: number;
83
+ total: number;
84
+ };
85
+ /** Uploader — used to scope automatching UI to the user who submitted the batch. */
86
+ user_id?: string;
87
+ }
88
+ export type BatchDetailsResponse = ZeniAPIResponse<BatchDetailsResponsePayload>;
89
+ /**
90
+ * Maps batch-details API `files[].status` strings to canonical {@link BatchFileStatus}.
91
+ * Legacy aliases are supported during rollout; unknown strings map to `failed` so Redux never
92
+ * holds untyped status values.
93
+ */
94
+ export declare function parseBatchFileStatus(raw: string): BatchFileStatus;
95
+ export declare function toBatchFile(payload: BatchFilePayload, filesEndPoint?: string): BatchFile;
96
+ export declare function extractTransactionPayloadsFromBatchFiles(files: BatchFilePayload[]): SupportedTransactionPayload[];
97
+ export declare function toBatchSummary(payload: BatchDetailsResponsePayload['summary']): BatchSummary;
98
+ export declare function toBatchDetails(payload: BatchDetailsResponsePayload, filesEndPoint?: string): BatchDetails;
99
+ /** Batch is still in-flight for automatching (GET /batches/:id while not completed). */
100
+ export declare function isBatchDetailsStatusPendingOrProcessing(status: string): boolean;
101
+ /** Batch list `status` is a string from the API — compare case-insensitively. */
102
+ export declare function isBatchListStatusCompleted(status: string): boolean;
103
+ /**
104
+ * Subset of the get-all-batches (`/batches?query=...`) list that is eligible for
105
+ * `GET /batches/:batchId` details fetches. The stored list may include pending, failed, or other
106
+ * statuses for UI; only `completed` rows should trigger batch-details requests.
107
+ */
108
+ export declare function filterBatchListItemsForBatchDetailsFetch(batches: BatchListItem[]): BatchListItem[];
109
+ /**
110
+ * Batch details API response `status` field — only completed payloads should be stored from
111
+ * multi-batch fetch paths (list can be briefly stale vs. live processing state).
112
+ */
113
+ export declare function isBatchDetailsApiStatusCompleted(status: string): boolean;
114
+ export declare function findBatchListItemForBatchId(batchListByPeriod: Record<MonthYearPeriodId, BatchListItem[]>, batchId: string): BatchListItem | undefined;
115
+ /**
116
+ * Whether it is appropriate to call `GET .../batches/:id` for details.
117
+ * Skips when live batch status or batch list row indicates the batch is not completed yet.
118
+ * When status is unknown in both sources, allows the request (e.g. dispatch before list refresh).
119
+ */
120
+ export declare function shouldFetchBatchDetailsForBatchId(batchStatusById: Record<string, BatchStatus>, batchListByPeriod: Record<MonthYearPeriodId, BatchListItem[]>, batchId: string): boolean;
121
+ export declare function toBatchListItem(payload: BatchListItemPayload): BatchListItem;
122
+ /** Maps expense-automation transaction rows to manual-search list rows (Unmatched tab). */
123
+ export declare function supportedTransactionPayloadToManualSearchResult(payload: SupportedTransactionPayload): ManualSearchResult;
124
+ export interface CompletedTransactionsQueryPayload {
125
+ end_date?: string;
126
+ match_type?: string;
127
+ page_size?: number;
128
+ page_token?: string | null;
129
+ sort_by?: string;
130
+ sort_order?: string;
131
+ start_date?: string;
132
+ }
133
+ export interface CompletedTransactionsResponsePayload {
134
+ next_page_token: string | null;
135
+ total_count: number;
136
+ transactions: SupportedTransactionPayload[];
137
+ }
138
+ export type CompletedTransactionsResponse = ZeniAPIResponse<CompletedTransactionsResponsePayload>;
16
139
  export {};