@zeniai/client-epic-state 4.19.83 → 4.19.84-betaVR1

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 (113) hide show
  1. package/lib/entity/account/accountPayload.d.ts +2 -0
  2. package/lib/entity/account/accountPayload.js +2 -0
  3. package/lib/entity/account/accountState.d.ts +2 -0
  4. package/lib/entity/company/companyPayload.d.ts +13 -0
  5. package/lib/entity/company/companyPayload.js +21 -0
  6. package/lib/entity/company/companyStateTypes.d.ts +13 -0
  7. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  8. package/lib/entity/snackbar/snackbarTypes.js +1 -0
  9. package/lib/epic.d.ts +12 -1
  10. package/lib/epic.js +12 -1
  11. package/lib/esm/entity/account/accountPayload.js +2 -0
  12. package/lib/esm/entity/chargeCardTransaction/chargeCardTransactionPayload.js +2 -2
  13. package/lib/esm/entity/company/companyPayload.js +21 -0
  14. package/lib/esm/entity/snackbar/snackbarTypes.js +1 -0
  15. package/lib/esm/epic.js +12 -1
  16. package/lib/esm/index.js +12 -8
  17. package/lib/esm/view/companyView/epic/companyPassport/updateCompanyDetailsEpic.js +6 -0
  18. package/lib/esm/view/companyView/types/companyPassport/companyPassportLocalData.js +13 -0
  19. package/lib/esm/view/companyView/types/companyPassportViewPayload.js +55 -12
  20. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +24 -0
  21. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +49 -0
  22. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +40 -0
  23. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +47 -0
  24. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +61 -0
  25. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +34 -0
  26. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +57 -0
  27. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +68 -0
  28. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +7 -5
  29. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +42 -0
  30. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/triggerReviewTabRefetchEpic.js +2 -3
  31. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +24 -0
  32. package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -2
  33. package/lib/esm/view/expenseAutomationView/payload/missingReceiptsPayload.js +147 -1
  34. package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +401 -1
  35. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +20 -1
  36. package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +224 -1
  37. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +2 -1
  38. package/lib/esm/view/expenseAutomationView/types/transactionsViewState.js +2 -1
  39. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewSelector.js +22 -4
  40. package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryDownloadSelector.js +2 -2
  41. package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistorySelector.js +2 -2
  42. package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailSelector.js +4 -1
  43. package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/fetchChargeCardRepaymentDetailEpic.js +2 -1
  44. package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/initiateChargeCardRepaymentEpic.js +1 -1
  45. package/lib/esm/view/spendManagement/commonSetup/epic/setup/updateBusinessVerificationDetailsEpic.js +67 -1
  46. package/lib/esm/view/spendManagement/commonSetup/epic/setup/updateSetupViewLocalStoreDataEpic.js +16 -2
  47. package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +15 -1
  48. package/lib/esm/view/spendManagement/commonSetup/types/businessVerification.js +148 -1
  49. package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
  50. package/lib/esm/zeniAPI.js +0 -2
  51. package/lib/index.d.ts +14 -9
  52. package/lib/index.js +87 -44
  53. package/lib/view/companyView/epic/companyPassport/updateCompanyDetailsEpic.js +6 -0
  54. package/lib/view/companyView/types/companyPassport/companyDetailsLocalData.d.ts +13 -0
  55. package/lib/view/companyView/types/companyPassport/companyPassportLocalData.js +13 -0
  56. package/lib/view/companyView/types/companyPassportViewPayload.d.ts +1 -1
  57. package/lib/view/companyView/types/companyPassportViewPayload.js +55 -12
  58. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.d.ts +15 -0
  59. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +28 -0
  60. package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.d.ts +7 -0
  61. package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +53 -0
  62. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.d.ts +8 -0
  63. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +44 -0
  64. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.d.ts +7 -0
  65. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +51 -0
  66. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.d.ts +8 -0
  67. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +65 -0
  68. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.d.ts +8 -0
  69. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +38 -0
  70. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.d.ts +9 -0
  71. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +62 -0
  72. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.d.ts +14 -0
  73. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +72 -0
  74. package/lib/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +7 -5
  75. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts +13 -0
  76. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +47 -0
  77. package/lib/view/expenseAutomationView/epics/transactionCategorization/triggerReviewTabRefetchEpic.js +2 -3
  78. package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.d.ts +7 -0
  79. package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +28 -0
  80. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  81. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -2
  82. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.d.ts +107 -0
  83. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.js +158 -0
  84. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +70 -3
  85. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +403 -2
  86. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +11 -3
  87. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +21 -2
  88. package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +69 -1
  89. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +1 -0
  90. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.d.ts +1 -1
  91. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +223 -0
  92. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +2 -1
  93. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +124 -0
  94. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +2 -1
  95. package/lib/view/expenseAutomationView/types/transactionsViewState.js +2 -1
  96. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.d.ts +1 -0
  97. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.js +22 -3
  98. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryDownloadSelector.js +2 -2
  99. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistorySelector.js +2 -2
  100. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailSelector.js +4 -1
  101. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/fetchChargeCardRepaymentDetailEpic.js +2 -1
  102. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/initiateChargeCardRepaymentEpic.d.ts +1 -1
  103. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/initiateChargeCardRepaymentEpic.js +1 -1
  104. package/lib/view/spendManagement/commonSetup/epic/setup/updateBusinessVerificationDetailsEpic.js +67 -1
  105. package/lib/view/spendManagement/commonSetup/epic/setup/updateSetupViewLocalStoreDataEpic.js +16 -2
  106. package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +14 -0
  107. package/lib/view/spendManagement/commonSetup/setupViewSelector.js +15 -1
  108. package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +14 -0
  109. package/lib/view/spendManagement/commonSetup/types/businessVerification.d.ts +43 -0
  110. package/lib/view/spendManagement/commonSetup/types/businessVerification.js +150 -0
  111. package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
  112. package/lib/zeniAPI.js +0 -2
  113. package/package.json +2 -2
@@ -1,6 +1,37 @@
1
1
  import { createSlice } from '@reduxjs/toolkit';
2
2
  import { toMonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
3
+ export const getCompletedTransactionsCacheKey = (periodId, sortKey, sortOrder, subTab) => `completed-${subTab}-${sortKey}-${sortOrder === 'ascending' ? 'asc' : 'desc'}-${periodId}`;
4
+ export const initialBulkUploadState = {
5
+ batchDetailsById: {},
6
+ batchDetailsPaginationState: { fetchState: 'Not-Started', error: undefined },
7
+ batchListByPeriod: {},
8
+ batchListFetchState: { fetchState: 'Not-Started', error: undefined },
9
+ batchStatusById: {},
10
+ completedSubTab: 'all',
11
+ completedTransactionsByPeriod: {},
12
+ confirmMatchStatus: { fetchState: 'Not-Started', error: undefined },
13
+ currentBatchId: undefined,
14
+ currentResultsTab: 'unmatched',
15
+ failedBatchDetailIds: [],
16
+ manualSearchUiResetKey: 0,
17
+ manualSearch: {
18
+ fetchState: { fetchState: 'Not-Started', error: undefined },
19
+ isLoadingMore: false,
20
+ nextPageToken: null,
21
+ pageSize: 25,
22
+ results: [],
23
+ searchQuery: '',
24
+ totalCount: 0,
25
+ },
26
+ phase: 'idle',
27
+ sortKey: 'date',
28
+ sortOrder: 'descending',
29
+ uploadProgress: 0,
30
+ uploadStatus: { fetchState: 'Not-Started', error: undefined },
31
+ };
3
32
  export const initialState = {
33
+ bulkUpload: initialBulkUploadState,
34
+ pendingMissingReceiptsTabNavigation: null,
4
35
  uploadReceiptStatusById: {},
5
36
  refreshStatus: {
6
37
  fetchState: 'Not-Started',
@@ -120,7 +151,376 @@ const expenseAutomationMissingReceiptsView = createSlice({
120
151
  clearExpenseAutomationMissingReceiptsView(draft) {
121
152
  Object.assign(draft, initialState);
122
153
  },
154
+ // -- Bulk Upload Actions --
155
+ bulkUploadReceipts: {
156
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
157
+ reducer(draft, _action) {
158
+ draft.bulkUpload.phase = 'uploading';
159
+ draft.bulkUpload.uploadProgress = 0;
160
+ draft.bulkUpload.uploadStatus = {
161
+ fetchState: 'In-Progress',
162
+ error: undefined,
163
+ };
164
+ },
165
+ prepare(files) {
166
+ return { payload: { files } };
167
+ },
168
+ },
169
+ updateBulkUploadProgress(draft, action) {
170
+ draft.bulkUpload.uploadProgress = action.payload;
171
+ },
172
+ bulkUploadReceiptsSuccess(draft, action) {
173
+ draft.bulkUpload.currentBatchId = action.payload.batchId;
174
+ draft.bulkUpload.uploadStatus = {
175
+ fetchState: 'Completed',
176
+ error: undefined,
177
+ };
178
+ draft.bulkUpload.phase = 'matching';
179
+ },
180
+ bulkUploadReceiptsFailure(draft, action) {
181
+ draft.bulkUpload.uploadStatus = {
182
+ fetchState: 'Error',
183
+ error: action.payload.error,
184
+ };
185
+ draft.bulkUpload.phase = 'idle';
186
+ },
187
+ pusherBatchStatusUpdate(draft, action) {
188
+ const batchStatus = action.payload;
189
+ draft.bulkUpload.batchStatusById[batchStatus.batchId] = batchStatus;
190
+ /**
191
+ * Auto-matching banner (`phase === 'matching'`) must clear when the server reports this
192
+ * upload batch is done — otherwise the Missing tab keeps MatchingProgressBanner until
193
+ * batch-details APIs run; EmailUploadBanner should show again for the next upload.
194
+ */
195
+ if (batchStatus.status === 'completed' &&
196
+ draft.bulkUpload.phase === 'matching' &&
197
+ draft.bulkUpload.currentBatchId === batchStatus.batchId) {
198
+ draft.bulkUpload.phase = 'completed';
199
+ }
200
+ },
201
+ requestMissingReceiptsTabNavigation(draft, action) {
202
+ draft.pendingMissingReceiptsTabNavigation = action.payload.tab;
203
+ },
204
+ clearMissingReceiptsTabNavigation(draft) {
205
+ draft.pendingMissingReceiptsTabNavigation = null;
206
+ },
207
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
208
+ fetchBulkUploadBatchDetails(_draft) {
209
+ // trigger epic, no state change needed
210
+ },
211
+ fetchBulkUploadBatchDetailsSuccess(draft, action) {
212
+ const details = action.payload;
213
+ draft.bulkUpload.batchDetailsById[details.batchId] = details;
214
+ draft.bulkUpload.phase = 'completed';
215
+ },
216
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
217
+ fetchBulkUploadBatchDetailsFailure(draft, _action) {
218
+ draft.bulkUpload.phase = 'completed';
219
+ },
220
+ storeBatchDetails(draft, action) {
221
+ const details = action.payload;
222
+ draft.bulkUpload.batchDetailsById[details.batchId] = details;
223
+ /**
224
+ * Multi-batch fetch paths use `storeBatchDetails` (not `fetchBulkUploadBatchDetailsSuccess`).
225
+ * Without this, `phase` stays `matching` after upload forever and the Unmatched tab keeps
226
+ * showing the skeleton (`bulkUploadPhase === 'matching'` in web-components).
227
+ */
228
+ if (draft.bulkUpload.phase === 'matching' &&
229
+ draft.bulkUpload.currentBatchId === details.batchId) {
230
+ draft.bulkUpload.phase = 'completed';
231
+ }
232
+ },
233
+ batchDetailFetchFailed(draft, action) {
234
+ const { batchId } = action.payload;
235
+ if (!draft.bulkUpload.failedBatchDetailIds.includes(batchId)) {
236
+ draft.bulkUpload.failedBatchDetailIds.push(batchId);
237
+ }
238
+ if (draft.bulkUpload.phase === 'matching' &&
239
+ draft.bulkUpload.currentBatchId === batchId) {
240
+ draft.bulkUpload.phase = 'completed';
241
+ }
242
+ },
243
+ setInitialBatchDetailsLoading(draft) {
244
+ draft.bulkUpload.batchDetailsPaginationState = {
245
+ fetchState: 'In-Progress',
246
+ error: undefined,
247
+ };
248
+ },
249
+ fetchMoreBatchDetails(_draft) {
250
+ _draft.bulkUpload.batchDetailsPaginationState = {
251
+ fetchState: 'In-Progress',
252
+ error: undefined,
253
+ };
254
+ },
255
+ fetchMoreBatchDetailsComplete(draft) {
256
+ draft.bulkUpload.batchDetailsPaginationState = {
257
+ fetchState: 'Completed',
258
+ error: undefined,
259
+ };
260
+ const currentId = draft.bulkUpload.currentBatchId;
261
+ const currentDetails = currentId != null
262
+ ? draft.bulkUpload.batchDetailsById[currentId]
263
+ : undefined;
264
+ if (draft.bulkUpload.phase === 'matching' &&
265
+ currentId != null &&
266
+ currentDetails?.status === 'completed') {
267
+ draft.bulkUpload.phase = 'completed';
268
+ }
269
+ },
270
+ fetchMoreBatchDetailsFailure(draft, action) {
271
+ draft.bulkUpload.batchDetailsPaginationState = {
272
+ fetchState: 'Error',
273
+ error: action.payload.error,
274
+ };
275
+ },
276
+ fetchBulkUploadBatches: {
277
+ reducer(draft, action) {
278
+ if (action.payload.invalidateBatchDetailsCache === true) {
279
+ draft.bulkUpload.batchDetailsById = {};
280
+ draft.bulkUpload.failedBatchDetailIds = [];
281
+ }
282
+ draft.bulkUpload.batchListFetchState = {
283
+ fetchState: 'In-Progress',
284
+ error: undefined,
285
+ };
286
+ },
287
+ prepare(input) {
288
+ if (input === true || input === false) {
289
+ return {
290
+ payload: {
291
+ cacheOverride: input === true,
292
+ invalidateBatchDetailsCache: false,
293
+ },
294
+ };
295
+ }
296
+ const o = input ?? {};
297
+ return {
298
+ payload: {
299
+ cacheOverride: o.cacheOverride === true,
300
+ invalidateBatchDetailsCache: o.invalidateBatchDetailsCache === true,
301
+ },
302
+ };
303
+ },
304
+ },
305
+ fetchBulkUploadBatchesSuccess(draft, action) {
306
+ const periodId = toMonthYearPeriodId(action.payload.selectedPeriod);
307
+ draft.bulkUpload.batchListByPeriod[periodId] = action.payload.batchList;
308
+ draft.bulkUpload.batchListFetchState = {
309
+ fetchState: 'Completed',
310
+ error: undefined,
311
+ };
312
+ /**
313
+ * When the multi-batch-details epic has nothing to fetch (e.g. list rows not `completed`
314
+ * yet, or details already present), `phase` can stay `matching` even though we already
315
+ * have completed details for `currentBatchId` (from polling / Pusher). Sync so the UI can
316
+ * dismiss the Unmatched skeleton.
317
+ */
318
+ const currentId = draft.bulkUpload.currentBatchId;
319
+ if (draft.bulkUpload.phase === 'matching' &&
320
+ currentId != null) {
321
+ const existing = draft.bulkUpload.batchDetailsById[currentId];
322
+ if (existing?.status === 'completed') {
323
+ draft.bulkUpload.phase = 'completed';
324
+ }
325
+ }
326
+ },
327
+ fetchBulkUploadBatchesFailure(draft, action) {
328
+ draft.bulkUpload.batchListFetchState = {
329
+ fetchState: 'Error',
330
+ error: action.payload.error,
331
+ };
332
+ },
333
+ confirmBulkUploadMatch: {
334
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
335
+ reducer(draft, _action) {
336
+ draft.bulkUpload.confirmMatchStatus = {
337
+ fetchState: 'In-Progress',
338
+ error: undefined,
339
+ };
340
+ },
341
+ prepare(batchId, attachmentId, transactionId, transactionType, fileName) {
342
+ return { payload: { batchId, attachmentId, transactionId, transactionType, fileName } };
343
+ },
344
+ },
345
+ confirmBulkUploadMatchSuccess(draft, action) {
346
+ const { batchId, attachmentId, transactionId } = action.payload;
347
+ draft.bulkUpload.confirmMatchStatus = {
348
+ fetchState: 'Completed',
349
+ error: undefined,
350
+ };
351
+ const details = draft.bulkUpload.batchDetailsById[batchId];
352
+ if (details != null) {
353
+ const file = details.files.find((f) => f.attachmentId === attachmentId);
354
+ if (file != null) {
355
+ const originalStatus = file.status;
356
+ file.status = 'matched';
357
+ file.matchedTransactionId = transactionId;
358
+ file.candidates = undefined;
359
+ details.summary.matched += 1;
360
+ if (originalStatus === 'no_match') {
361
+ details.summary.noMatch = Math.max(0, details.summary.noMatch - 1);
362
+ }
363
+ else {
364
+ details.summary.possibleMatches = Math.max(0, details.summary.possibleMatches - 1);
365
+ }
366
+ }
367
+ }
368
+ draft.bulkUpload.manualSearch = initialBulkUploadState.manualSearch;
369
+ draft.bulkUpload.manualSearchUiResetKey += 1;
370
+ },
371
+ confirmBulkUploadMatchFailure(draft, action) {
372
+ draft.bulkUpload.confirmMatchStatus = {
373
+ fetchState: 'Error',
374
+ error: action.payload.error,
375
+ };
376
+ },
377
+ setBulkUploadResultsTab(draft, action) {
378
+ draft.bulkUpload.currentResultsTab = action.payload;
379
+ },
380
+ setBulkUploadCompletedSubTab(draft, action) {
381
+ draft.bulkUpload.completedSubTab = action.payload;
382
+ },
383
+ setBulkUploadSortConfig(draft, action) {
384
+ draft.bulkUpload.sortKey = action.payload.sortKey;
385
+ draft.bulkUpload.sortOrder = action.payload.sortOrder;
386
+ },
387
+ clearBulkUpload(draft) {
388
+ Object.assign(draft.bulkUpload, initialBulkUploadState);
389
+ draft.pendingMissingReceiptsTabNavigation = null;
390
+ },
391
+ searchTransactionsForManualMatch: {
392
+ reducer(draft, action) {
393
+ const { query, pageToken } = action.payload;
394
+ const isLoadMore = pageToken != null;
395
+ draft.bulkUpload.manualSearch.searchQuery = query;
396
+ if (isLoadMore) {
397
+ draft.bulkUpload.manualSearch.isLoadingMore = true;
398
+ }
399
+ else {
400
+ draft.bulkUpload.manualSearch.isLoadingMore = false;
401
+ draft.bulkUpload.manualSearch.results = [];
402
+ draft.bulkUpload.manualSearch.nextPageToken = null;
403
+ draft.bulkUpload.manualSearch.totalCount = 0;
404
+ draft.bulkUpload.manualSearch.fetchState = {
405
+ fetchState: 'In-Progress',
406
+ error: undefined,
407
+ };
408
+ }
409
+ },
410
+ prepare(query, pageToken) {
411
+ return { payload: { query, pageToken: pageToken ?? undefined } };
412
+ },
413
+ },
414
+ searchTransactionsForManualMatchSuccess(draft, action) {
415
+ const { append, nextPageToken, results, totalCount } = action.payload;
416
+ if (append) {
417
+ const merged = [...draft.bulkUpload.manualSearch.results, ...results];
418
+ const byId = new Map(merged.map((r) => [r.transactionId, r]));
419
+ draft.bulkUpload.manualSearch.results = Array.from(byId.values());
420
+ }
421
+ else {
422
+ draft.bulkUpload.manualSearch.results = results;
423
+ }
424
+ draft.bulkUpload.manualSearch.nextPageToken = nextPageToken;
425
+ draft.bulkUpload.manualSearch.totalCount = totalCount;
426
+ draft.bulkUpload.manualSearch.isLoadingMore = false;
427
+ draft.bulkUpload.manualSearch.fetchState = {
428
+ fetchState: 'Completed',
429
+ error: undefined,
430
+ };
431
+ },
432
+ searchTransactionsForManualMatchFailure(draft, action) {
433
+ draft.bulkUpload.manualSearch.isLoadingMore = false;
434
+ draft.bulkUpload.manualSearch.fetchState = {
435
+ fetchState: 'Error',
436
+ error: action.payload.error,
437
+ };
438
+ },
439
+ clearManualSearchResults(draft) {
440
+ draft.bulkUpload.manualSearch = initialBulkUploadState.manualSearch;
441
+ draft.bulkUpload.manualSearchUiResetKey += 1;
442
+ },
443
+ acknowledgeBulkUploadConfirmMatchComplete(draft) {
444
+ draft.bulkUpload.confirmMatchStatus = {
445
+ fetchState: 'Not-Started',
446
+ error: undefined,
447
+ };
448
+ },
449
+ // -- Completed Transactions Actions --
450
+ fetchCompletedTransactions: {
451
+ reducer(draft, action) {
452
+ const { pageToken } = action.payload;
453
+ if (pageToken != null) {
454
+ const periods = draft.bulkUpload.completedTransactionsByPeriod;
455
+ for (const entry of Object.values(periods)) {
456
+ if (entry.nextPageToken === pageToken) {
457
+ entry.fetchState = {
458
+ fetchState: 'In-Progress',
459
+ error: undefined,
460
+ };
461
+ break;
462
+ }
463
+ }
464
+ }
465
+ },
466
+ prepare(pageToken, cacheOverride) {
467
+ return { payload: { pageToken, cacheOverride } };
468
+ },
469
+ },
470
+ fetchCompletedTransactionsSuccess(draft, action) {
471
+ const { transactionIds, nextPageToken, totalCount, selectedPeriod, isInitialLoad } = action.payload;
472
+ const periodId = toMonthYearPeriodId(selectedPeriod);
473
+ const cacheKey = getCompletedTransactionsCacheKey(periodId, draft.bulkUpload.sortKey, draft.bulkUpload.sortOrder, draft.bulkUpload.completedSubTab);
474
+ if (isInitialLoad) {
475
+ draft.bulkUpload.completedTransactionsByPeriod[cacheKey] = {
476
+ transactionIds,
477
+ nextPageToken,
478
+ totalCount,
479
+ fetchState: { fetchState: 'Completed', error: undefined },
480
+ };
481
+ }
482
+ else {
483
+ const existing = draft.bulkUpload.completedTransactionsByPeriod[cacheKey];
484
+ if (existing != null) {
485
+ existing.transactionIds.push(...transactionIds);
486
+ existing.nextPageToken = nextPageToken;
487
+ existing.totalCount = totalCount;
488
+ existing.fetchState = { fetchState: 'Completed', error: undefined };
489
+ }
490
+ else {
491
+ draft.bulkUpload.completedTransactionsByPeriod[cacheKey] = {
492
+ transactionIds,
493
+ nextPageToken,
494
+ totalCount,
495
+ fetchState: { fetchState: 'Completed', error: undefined },
496
+ };
497
+ }
498
+ }
499
+ },
500
+ fetchCompletedTransactionsFailure(draft, action) {
501
+ const periodId = toMonthYearPeriodId(action.payload.selectedPeriod);
502
+ const cacheKey = getCompletedTransactionsCacheKey(periodId, draft.bulkUpload.sortKey, draft.bulkUpload.sortOrder, draft.bulkUpload.completedSubTab);
503
+ const existing = draft.bulkUpload.completedTransactionsByPeriod[cacheKey];
504
+ if (existing != null) {
505
+ existing.fetchState = {
506
+ fetchState: 'Error',
507
+ error: action.payload.error,
508
+ };
509
+ }
510
+ else {
511
+ draft.bulkUpload.completedTransactionsByPeriod[cacheKey] = {
512
+ fetchState: { fetchState: 'Error', error: action.payload.error },
513
+ nextPageToken: null,
514
+ totalCount: 0,
515
+ transactionIds: [],
516
+ };
517
+ }
518
+ },
123
519
  },
124
520
  });
125
- export const { fetchMissingReceipts, fetchMissingReceiptsSuccess, fetchMissingReceiptsFailure, uploadMissingReceiptSuccess, updateMissingReceiptUploadState, updateMissingReceiptsUIState, markMissingReceiptAsDone, clearExpenseAutomationMissingReceiptsView, } = expenseAutomationMissingReceiptsView.actions;
521
+ export const { fetchMissingReceipts, fetchMissingReceiptsSuccess, fetchMissingReceiptsFailure, uploadMissingReceiptSuccess, updateMissingReceiptUploadState, updateMissingReceiptsUIState, markMissingReceiptAsDone, clearExpenseAutomationMissingReceiptsView,
522
+ // Bulk Upload
523
+ bulkUploadReceipts, updateBulkUploadProgress, bulkUploadReceiptsSuccess, bulkUploadReceiptsFailure, pusherBatchStatusUpdate, requestMissingReceiptsTabNavigation, clearMissingReceiptsTabNavigation, fetchBulkUploadBatchDetails, fetchBulkUploadBatchDetailsSuccess, fetchBulkUploadBatchDetailsFailure, storeBatchDetails, batchDetailFetchFailed, setInitialBatchDetailsLoading, fetchMoreBatchDetails, fetchMoreBatchDetailsComplete, fetchMoreBatchDetailsFailure, fetchBulkUploadBatches, fetchBulkUploadBatchesSuccess, fetchBulkUploadBatchesFailure, confirmBulkUploadMatch, confirmBulkUploadMatchSuccess, confirmBulkUploadMatchFailure, setBulkUploadResultsTab, setBulkUploadCompletedSubTab, setBulkUploadSortConfig, clearBulkUpload, searchTransactionsForManualMatch, searchTransactionsForManualMatchSuccess, searchTransactionsForManualMatchFailure, clearManualSearchResults, acknowledgeBulkUploadConfirmMatchComplete,
524
+ // Completed Transactions
525
+ fetchCompletedTransactions, fetchCompletedTransactionsSuccess, fetchCompletedTransactionsFailure, } = expenseAutomationMissingReceiptsView.actions;
126
526
  export default expenseAutomationMissingReceiptsView.reducer;
@@ -36,6 +36,7 @@ export const initialTransactionTabViewState = {
36
36
  transactionIdsBySelectedPeriod: {},
37
37
  selectedCheckBoxTransactionIds: [],
38
38
  transactionIdsWithUnsavedData: [],
39
+ uploadReceiptStatusById: {},
39
40
  selectedTransactionId: undefined,
40
41
  selectedTransactionLineId: undefined,
41
42
  };
@@ -699,6 +700,24 @@ const expenseAutomationTransactionsView = createSlice({
699
700
  clearExpenseAutomationTransactionsView(draft) {
700
701
  Object.assign(draft, initialState);
701
702
  },
703
+ updateTransactionCategorizationUploadReceiptState: {
704
+ reducer(draft, action) {
705
+ const { transactionId, fetchStatus, selectedTab } = action.payload;
706
+ draft.transactionCategorizationView[selectedTab].uploadReceiptStatusById[transactionId] = fetchStatus;
707
+ },
708
+ prepare(selectedTab, transactionId, fetchStatus) {
709
+ return { payload: { selectedTab, transactionId, fetchStatus } };
710
+ },
711
+ },
712
+ uploadTransactionCategorizationReceiptSuccess: {
713
+ reducer(draft, action) {
714
+ const { transactionPayload, selectedTab } = action.payload;
715
+ draft.transactionCategorizationView[selectedTab].uploadReceiptStatusById[transactionPayload.transaction_id] = { fetchState: 'Completed', error: undefined };
716
+ },
717
+ prepare(selectedTab, transactionPayload, updateType = 'merge') {
718
+ return { payload: { selectedTab, transactionPayload, updateType } };
719
+ },
720
+ },
702
721
  syncTransactionCategorizationFromDetailSave: {
703
722
  prepare(transactionId, updatedTransaction, pendingReviewLineIds, uncategorizedIncomeExpense, isUncategorizedExpenseCategoryEnabled) {
704
723
  return {
@@ -770,5 +789,5 @@ const expenseAutomationTransactionsView = createSlice({
770
789
  },
771
790
  },
772
791
  });
773
- export const { fetchTransactionCategorization, updateTransactionCategorizationUIState, initializeTransactionCategorizationViewLocalData, saveTransactionCategorizationLocalData, fetchTransactionCategorizationFailure, saveTransactionCategorization, updateTransactionCategorization, updateCurrentSelectedTransactionCategorizationTab, updateTransactionCategorizationSaveStatus, markTransactionAsNotMiscategorized, updateStatusForTransactionNotMiscategorizedUpdateForCategorization, updateSelectedVendorForTransaction, updateSelectedCustomerForTransaction, setAllItemsToCategoryClassInLocalDataForCategorization, updateTotalCountForTransactionCategorization, fetchTransactionCategorizationSuccess, resetOtherTabsFetchState, fetchTransactionCategorizationView, updateSelectedCheckboxTransactionIds, clearExpenseAutomationTransactionsViewPerTabView, clearExpenseAutomationTransactionsView, setEntityRecommendationForLineIdsForCategorization, updateSelectedTransactionId, syncTransactionCategorizationFromDetailSave, backgroundRefetchReviewTab, } = expenseAutomationTransactionsView.actions;
792
+ export const { fetchTransactionCategorization, updateTransactionCategorizationUIState, initializeTransactionCategorizationViewLocalData, saveTransactionCategorizationLocalData, fetchTransactionCategorizationFailure, saveTransactionCategorization, updateTransactionCategorization, updateCurrentSelectedTransactionCategorizationTab, updateTransactionCategorizationSaveStatus, markTransactionAsNotMiscategorized, updateStatusForTransactionNotMiscategorizedUpdateForCategorization, updateSelectedVendorForTransaction, updateSelectedCustomerForTransaction, setAllItemsToCategoryClassInLocalDataForCategorization, updateTotalCountForTransactionCategorization, fetchTransactionCategorizationSuccess, resetOtherTabsFetchState, fetchTransactionCategorizationView, updateSelectedCheckboxTransactionIds, clearExpenseAutomationTransactionsViewPerTabView, clearExpenseAutomationTransactionsView, setEntityRecommendationForLineIdsForCategorization, updateSelectedTransactionId, syncTransactionCategorizationFromDetailSave, backgroundRefetchReviewTab, updateTransactionCategorizationUploadReceiptState, uploadTransactionCategorizationReceiptSuccess, } = expenseAutomationTransactionsView.actions;
774
793
  export default expenseAutomationTransactionsView.reducer;