@zeniai/client-epic-state 4.19.84-betaVR9 → 4.19.84

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 (54) hide show
  1. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  2. package/lib/entity/snackbar/snackbarTypes.js +0 -1
  3. package/lib/epic.d.ts +1 -10
  4. package/lib/epic.js +1 -10
  5. package/lib/esm/entity/snackbar/snackbarTypes.js +0 -1
  6. package/lib/esm/epic.js +1 -10
  7. package/lib/esm/index.js +2 -4
  8. package/lib/esm/view/expenseAutomationView/payload/missingReceiptsPayload.js +1 -177
  9. package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +1 -412
  10. package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +1 -224
  11. package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +0 -6
  12. package/lib/esm/zeniAPI.js +2 -0
  13. package/lib/index.d.ts +3 -5
  14. package/lib/index.js +31 -64
  15. package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
  16. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  17. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.d.ts +0 -118
  18. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.js +0 -189
  19. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +3 -70
  20. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -414
  21. package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +1 -69
  22. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.d.ts +1 -1
  23. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +0 -223
  24. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +0 -129
  25. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +1 -7
  26. package/lib/zeniAPI.js +2 -0
  27. package/package.json +1 -1
  28. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +0 -28
  29. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +0 -49
  30. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +0 -40
  31. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +0 -47
  32. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +0 -61
  33. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +0 -34
  34. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +0 -57
  35. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +0 -78
  36. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +0 -59
  37. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.d.ts +0 -15
  38. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +0 -32
  39. package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.d.ts +0 -7
  40. package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +0 -53
  41. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.d.ts +0 -8
  42. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +0 -44
  43. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.d.ts +0 -7
  44. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +0 -51
  45. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.d.ts +0 -8
  46. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +0 -65
  47. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.d.ts +0 -8
  48. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +0 -38
  49. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.d.ts +0 -9
  50. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +0 -62
  51. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.d.ts +0 -14
  52. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +0 -82
  53. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts +0 -19
  54. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +0 -64
@@ -1,43 +1,10 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.fetchCompletedTransactionsFailure = exports.fetchCompletedTransactionsSuccess = exports.fetchCompletedTransactions = exports.acknowledgeBulkUploadConfirmMatchComplete = exports.clearManualSearchResults = exports.searchTransactionsForManualMatchFailure = exports.searchTransactionsForManualMatchSuccess = exports.searchTransactionsForManualMatch = exports.clearBulkUpload = exports.setBulkUploadSortConfig = exports.setBulkUploadCompletedSubTab = exports.setBulkUploadResultsTab = exports.confirmBulkUploadMatchFailure = exports.confirmBulkUploadMatchSuccess = exports.confirmBulkUploadMatch = exports.fetchBulkUploadBatchesFailure = exports.fetchBulkUploadBatchesSuccess = exports.fetchBulkUploadBatches = exports.fetchMoreBatchDetailsFailure = exports.fetchMoreBatchDetailsComplete = exports.fetchMoreBatchDetails = exports.setInitialBatchDetailsLoading = exports.batchDetailFetchFailed = exports.storeBatchDetails = exports.fetchBulkUploadBatchDetailsFailure = exports.fetchBulkUploadBatchDetailsSuccess = exports.fetchBulkUploadBatchDetails = exports.clearMissingReceiptsTabNavigation = exports.requestMissingReceiptsTabNavigation = exports.pusherBatchStatusUpdate = exports.bulkUploadReceiptsFailure = exports.bulkUploadReceiptsSuccess = exports.updateBulkUploadProgress = exports.bulkUploadReceipts = exports.clearExpenseAutomationMissingReceiptsView = exports.markMissingReceiptAsDone = exports.updateMissingReceiptsUIState = exports.updateMissingReceiptUploadState = exports.uploadMissingReceiptSuccess = exports.fetchMissingReceiptsFailure = exports.fetchMissingReceiptsSuccess = exports.fetchMissingReceipts = exports.initialState = exports.initialBulkUploadState = exports.getCompletedTransactionsCacheKey = void 0;
4
+ exports.clearExpenseAutomationMissingReceiptsView = exports.markMissingReceiptAsDone = exports.updateMissingReceiptsUIState = exports.updateMissingReceiptUploadState = exports.uploadMissingReceiptSuccess = exports.fetchMissingReceiptsFailure = exports.fetchMissingReceiptsSuccess = exports.fetchMissingReceipts = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
7
- const missingReceiptsViewState_1 = require("../types/missingReceiptsViewState");
8
- const getCompletedTransactionsCacheKey = (periodId, sortKey, sortOrder, subTab) => `completed-${subTab}-${sortKey}-${sortOrder === 'ascending' ? 'asc' : 'desc'}-${periodId}`;
9
- exports.getCompletedTransactionsCacheKey = getCompletedTransactionsCacheKey;
10
- exports.initialBulkUploadState = {
11
- batchDetailsById: {},
12
- batchDetailsPaginationState: { fetchState: 'Not-Started', error: undefined },
13
- batchListByPeriod: {},
14
- batchListFetchState: { fetchState: 'Not-Started', error: undefined },
15
- batchStatusById: {},
16
- completedSubTab: 'all',
17
- completedTransactionsByPeriod: {},
18
- confirmMatchStatus: { fetchState: 'Not-Started', error: undefined },
19
- currentBatchId: undefined,
20
- currentResultsTab: 'unmatched',
21
- failedBatchDetailIds: [],
22
- manualSearchUiResetKey: 0,
23
- manualSearch: {
24
- fetchState: { fetchState: 'Not-Started', error: undefined },
25
- isLoadingMore: false,
26
- nextPageToken: null,
27
- pageSize: 25,
28
- results: [],
29
- searchQuery: '',
30
- totalCount: 0,
31
- },
32
- phase: 'idle',
33
- sortKey: 'date',
34
- sortOrder: 'descending',
35
- uploadProgress: 0,
36
- uploadStatus: { fetchState: 'Not-Started', error: undefined },
37
- };
38
7
  exports.initialState = {
39
- bulkUpload: exports.initialBulkUploadState,
40
- pendingMissingReceiptsTabNavigation: null,
41
8
  uploadReceiptStatusById: {},
42
9
  refreshStatus: {
43
10
  fetchState: 'Not-Started',
@@ -157,386 +124,7 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
157
124
  clearExpenseAutomationMissingReceiptsView(draft) {
158
125
  Object.assign(draft, exports.initialState);
159
126
  },
160
- // -- Bulk Upload Actions --
161
- bulkUploadReceipts: {
162
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
163
- reducer(draft, _action) {
164
- draft.bulkUpload.phase = 'uploading';
165
- draft.bulkUpload.uploadProgress = 0;
166
- draft.bulkUpload.uploadStatus = {
167
- fetchState: 'In-Progress',
168
- error: undefined,
169
- };
170
- },
171
- prepare(files) {
172
- return { payload: { files } };
173
- },
174
- },
175
- updateBulkUploadProgress(draft, action) {
176
- draft.bulkUpload.uploadProgress = action.payload;
177
- },
178
- bulkUploadReceiptsSuccess(draft, action) {
179
- draft.bulkUpload.currentBatchId = action.payload.batchId;
180
- draft.bulkUpload.uploadStatus = {
181
- fetchState: 'Completed',
182
- error: undefined,
183
- };
184
- draft.bulkUpload.phase = 'matching';
185
- },
186
- bulkUploadReceiptsFailure(draft, action) {
187
- draft.bulkUpload.uploadStatus = {
188
- fetchState: 'Error',
189
- error: action.payload.error,
190
- };
191
- draft.bulkUpload.phase = 'idle';
192
- },
193
- pusherBatchStatusUpdate(draft, action) {
194
- const batchStatus = action.payload;
195
- draft.bulkUpload.batchStatusById[batchStatus.batchId] = batchStatus;
196
- /**
197
- * Auto-matching banner (`phase === 'matching'`) must clear when the server reports this
198
- * upload batch is done — otherwise the Missing tab keeps MatchingProgressBanner until
199
- * batch-details APIs run; EmailUploadBanner should show again for the next upload.
200
- */
201
- if (batchStatus.status === 'completed' &&
202
- draft.bulkUpload.phase === 'matching' &&
203
- draft.bulkUpload.currentBatchId === batchStatus.batchId) {
204
- draft.bulkUpload.phase = 'completed';
205
- }
206
- },
207
- requestMissingReceiptsTabNavigation(draft, action) {
208
- draft.pendingMissingReceiptsTabNavigation = action.payload.tab;
209
- },
210
- clearMissingReceiptsTabNavigation(draft) {
211
- draft.pendingMissingReceiptsTabNavigation = null;
212
- },
213
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
214
- fetchBulkUploadBatchDetails(_draft) {
215
- // trigger epic, no state change needed
216
- },
217
- fetchBulkUploadBatchDetailsSuccess(draft, action) {
218
- const details = action.payload;
219
- draft.bulkUpload.batchDetailsById[details.batchId] = details;
220
- draft.bulkUpload.phase = 'completed';
221
- },
222
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
223
- fetchBulkUploadBatchDetailsFailure(draft, _action) {
224
- draft.bulkUpload.phase = 'completed';
225
- },
226
- storeBatchDetails(draft, action) {
227
- const details = action.payload;
228
- draft.bulkUpload.batchDetailsById[details.batchId] = details;
229
- /**
230
- * Multi-batch fetch paths use `storeBatchDetails` (not `fetchBulkUploadBatchDetailsSuccess`).
231
- * Without this, `phase` stays `matching` after upload forever and the Unmatched tab keeps
232
- * showing the skeleton (`bulkUploadPhase === 'matching'` in web-components).
233
- */
234
- if (draft.bulkUpload.phase === 'matching' &&
235
- draft.bulkUpload.currentBatchId === details.batchId) {
236
- draft.bulkUpload.phase = 'completed';
237
- }
238
- },
239
- batchDetailFetchFailed(draft, action) {
240
- const { batchId } = action.payload;
241
- if (!draft.bulkUpload.failedBatchDetailIds.includes(batchId)) {
242
- draft.bulkUpload.failedBatchDetailIds.push(batchId);
243
- }
244
- if (draft.bulkUpload.phase === 'matching' &&
245
- draft.bulkUpload.currentBatchId === batchId) {
246
- draft.bulkUpload.phase = 'completed';
247
- }
248
- },
249
- setInitialBatchDetailsLoading(draft) {
250
- draft.bulkUpload.batchDetailsPaginationState = {
251
- fetchState: 'In-Progress',
252
- error: undefined,
253
- };
254
- },
255
- fetchMoreBatchDetails(_draft) {
256
- _draft.bulkUpload.batchDetailsPaginationState = {
257
- fetchState: 'In-Progress',
258
- error: undefined,
259
- };
260
- },
261
- fetchMoreBatchDetailsComplete(draft) {
262
- draft.bulkUpload.batchDetailsPaginationState = {
263
- fetchState: 'Completed',
264
- error: undefined,
265
- };
266
- const currentId = draft.bulkUpload.currentBatchId;
267
- const currentDetails = currentId != null
268
- ? draft.bulkUpload.batchDetailsById[currentId]
269
- : undefined;
270
- if (draft.bulkUpload.phase === 'matching' &&
271
- currentId != null &&
272
- currentDetails?.status === 'completed') {
273
- draft.bulkUpload.phase = 'completed';
274
- }
275
- },
276
- fetchMoreBatchDetailsFailure(draft, action) {
277
- draft.bulkUpload.batchDetailsPaginationState = {
278
- fetchState: 'Error',
279
- error: action.payload.error,
280
- };
281
- },
282
- fetchBulkUploadBatches: {
283
- reducer(draft, action) {
284
- if (action.payload.invalidateBatchDetailsCache === true) {
285
- draft.bulkUpload.batchDetailsById = {};
286
- draft.bulkUpload.failedBatchDetailIds = [];
287
- }
288
- draft.bulkUpload.batchListFetchState = {
289
- fetchState: 'In-Progress',
290
- error: undefined,
291
- };
292
- },
293
- prepare(input) {
294
- const o = input ?? {};
295
- return {
296
- payload: {
297
- cacheOverride: o.cacheOverride === true,
298
- invalidateBatchDetailsCache: o.invalidateBatchDetailsCache === true,
299
- },
300
- };
301
- },
302
- },
303
- fetchBulkUploadBatchesSuccess(draft, action) {
304
- const periodId = (0, timePeriod_1.toMonthYearPeriodId)(action.payload.selectedPeriod);
305
- draft.bulkUpload.batchListByPeriod[periodId] = action.payload.batchList;
306
- draft.bulkUpload.batchListFetchState = {
307
- fetchState: 'Completed',
308
- error: undefined,
309
- };
310
- /**
311
- * When the multi-batch-details epic has nothing to fetch (e.g. list rows not `completed`
312
- * yet, or details already present), `phase` can stay `matching` even though we already
313
- * have completed details for `currentBatchId` (from polling / Pusher). Sync so the UI can
314
- * dismiss the Unmatched skeleton.
315
- */
316
- const currentId = draft.bulkUpload.currentBatchId;
317
- if (draft.bulkUpload.phase === 'matching' &&
318
- currentId != null) {
319
- const existing = draft.bulkUpload.batchDetailsById[currentId];
320
- if (existing?.status === 'completed') {
321
- draft.bulkUpload.phase = 'completed';
322
- }
323
- }
324
- },
325
- fetchBulkUploadBatchesFailure(draft, action) {
326
- draft.bulkUpload.batchListFetchState = {
327
- fetchState: 'Error',
328
- error: action.payload.error,
329
- };
330
- },
331
- confirmBulkUploadMatch: {
332
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
333
- reducer(draft, _action) {
334
- draft.bulkUpload.confirmMatchStatus = {
335
- fetchState: 'In-Progress',
336
- error: undefined,
337
- };
338
- },
339
- prepare(batchId, attachmentId, transactionId, transactionType, fileName) {
340
- return { payload: { batchId, attachmentId, transactionId, transactionType, fileName } };
341
- },
342
- },
343
- confirmBulkUploadMatchSuccess(draft, action) {
344
- const { batchId, attachmentId, transactionId } = action.payload;
345
- draft.bulkUpload.confirmMatchStatus = {
346
- fetchState: 'Completed',
347
- error: undefined,
348
- };
349
- const details = draft.bulkUpload.batchDetailsById[batchId];
350
- if (details != null) {
351
- const file = details.files.find((f) => f.attachmentId === attachmentId);
352
- if (file != null) {
353
- const originalStatus = file.status;
354
- file.status = 'matched';
355
- file.matchedTransactionId = transactionId;
356
- file.candidates = undefined;
357
- details.summary.matched += 1;
358
- if (originalStatus === 'no_match') {
359
- details.summary.noMatch = Math.max(0, details.summary.noMatch - 1);
360
- }
361
- else if (originalStatus === 'un_matched') {
362
- details.summary.possibleMatches = Math.max(0, details.summary.possibleMatches - 1);
363
- }
364
- }
365
- }
366
- draft.bulkUpload.manualSearch = exports.initialBulkUploadState.manualSearch;
367
- draft.bulkUpload.manualSearchUiResetKey += 1;
368
- },
369
- confirmBulkUploadMatchFailure(draft, action) {
370
- draft.bulkUpload.confirmMatchStatus = {
371
- fetchState: 'Error',
372
- error: action.payload.error,
373
- };
374
- },
375
- setBulkUploadResultsTab(draft, action) {
376
- draft.bulkUpload.currentResultsTab = action.payload;
377
- },
378
- setBulkUploadCompletedSubTab(draft, action) {
379
- draft.bulkUpload.completedSubTab = action.payload;
380
- },
381
- setBulkUploadSortConfig(draft, action) {
382
- draft.bulkUpload.sortKey = action.payload.sortKey;
383
- draft.bulkUpload.sortOrder = action.payload.sortOrder;
384
- },
385
- clearBulkUpload(draft) {
386
- Object.assign(draft.bulkUpload, exports.initialBulkUploadState);
387
- draft.pendingMissingReceiptsTabNavigation = null;
388
- },
389
- searchTransactionsForManualMatch: {
390
- reducer(draft, action) {
391
- const { query, pageToken } = action.payload;
392
- const isLoadMore = pageToken != null;
393
- const trimmed = query.trim();
394
- /**
395
- * Cleared or too-short query: no API (see epic). Reset fully (no In-Progress).
396
- * Only bump `manualSearchUiResetKey` when clearing a real search — not when the UI
397
- * dispatches `""` on every keystroke while length is below MIN (web-components always sends
398
- * `onSearch("")` in that case), or ReceiptCard remounts and the input loses focus.
399
- */
400
- if (!isLoadMore &&
401
- trimmed.length < missingReceiptsViewState_1.MIN_MANUAL_TRANSACTION_SEARCH_LENGTH) {
402
- const hadActiveSearch = draft.bulkUpload.manualSearch.searchQuery.trim().length >=
403
- missingReceiptsViewState_1.MIN_MANUAL_TRANSACTION_SEARCH_LENGTH ||
404
- draft.bulkUpload.manualSearch.results.length > 0;
405
- draft.bulkUpload.manualSearch = exports.initialBulkUploadState.manualSearch;
406
- if (hadActiveSearch) {
407
- draft.bulkUpload.manualSearchUiResetKey += 1;
408
- }
409
- return;
410
- }
411
- draft.bulkUpload.manualSearch.searchQuery = query;
412
- if (isLoadMore) {
413
- draft.bulkUpload.manualSearch.isLoadingMore = true;
414
- }
415
- else {
416
- draft.bulkUpload.manualSearch.isLoadingMore = false;
417
- draft.bulkUpload.manualSearch.results = [];
418
- draft.bulkUpload.manualSearch.nextPageToken = null;
419
- draft.bulkUpload.manualSearch.totalCount = 0;
420
- draft.bulkUpload.manualSearch.fetchState = {
421
- fetchState: 'In-Progress',
422
- error: undefined,
423
- };
424
- }
425
- },
426
- prepare(query, pageToken) {
427
- return { payload: { query, pageToken: pageToken ?? undefined } };
428
- },
429
- },
430
- searchTransactionsForManualMatchSuccess(draft, action) {
431
- const { append, nextPageToken, results, totalCount } = action.payload;
432
- if (append) {
433
- const merged = [...draft.bulkUpload.manualSearch.results, ...results];
434
- const byId = new Map(merged.map((r) => [r.transactionId, r]));
435
- draft.bulkUpload.manualSearch.results = Array.from(byId.values());
436
- }
437
- else {
438
- draft.bulkUpload.manualSearch.results = results;
439
- }
440
- draft.bulkUpload.manualSearch.nextPageToken = nextPageToken;
441
- draft.bulkUpload.manualSearch.totalCount = totalCount;
442
- draft.bulkUpload.manualSearch.isLoadingMore = false;
443
- draft.bulkUpload.manualSearch.fetchState = {
444
- fetchState: 'Completed',
445
- error: undefined,
446
- };
447
- },
448
- searchTransactionsForManualMatchFailure(draft, action) {
449
- draft.bulkUpload.manualSearch.isLoadingMore = false;
450
- draft.bulkUpload.manualSearch.fetchState = {
451
- fetchState: 'Error',
452
- error: action.payload.error,
453
- };
454
- },
455
- clearManualSearchResults(draft) {
456
- draft.bulkUpload.manualSearch = exports.initialBulkUploadState.manualSearch;
457
- draft.bulkUpload.manualSearchUiResetKey += 1;
458
- },
459
- acknowledgeBulkUploadConfirmMatchComplete(draft) {
460
- draft.bulkUpload.confirmMatchStatus = {
461
- fetchState: 'Not-Started',
462
- error: undefined,
463
- };
464
- },
465
- // -- Completed Transactions Actions --
466
- fetchCompletedTransactions: {
467
- reducer(draft, action) {
468
- const { pageToken } = action.payload;
469
- if (pageToken != null) {
470
- const periods = draft.bulkUpload.completedTransactionsByPeriod;
471
- for (const entry of Object.values(periods)) {
472
- if (entry.nextPageToken === pageToken) {
473
- entry.fetchState = {
474
- fetchState: 'In-Progress',
475
- error: undefined,
476
- };
477
- break;
478
- }
479
- }
480
- }
481
- },
482
- prepare(pageToken, cacheOverride) {
483
- return { payload: { pageToken, cacheOverride } };
484
- },
485
- },
486
- fetchCompletedTransactionsSuccess(draft, action) {
487
- const { transactionIds, nextPageToken, totalCount, selectedPeriod, isInitialLoad } = action.payload;
488
- const periodId = (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod);
489
- const cacheKey = (0, exports.getCompletedTransactionsCacheKey)(periodId, draft.bulkUpload.sortKey, draft.bulkUpload.sortOrder, draft.bulkUpload.completedSubTab);
490
- if (isInitialLoad) {
491
- draft.bulkUpload.completedTransactionsByPeriod[cacheKey] = {
492
- transactionIds,
493
- nextPageToken,
494
- totalCount,
495
- fetchState: { fetchState: 'Completed', error: undefined },
496
- };
497
- }
498
- else {
499
- const existing = draft.bulkUpload.completedTransactionsByPeriod[cacheKey];
500
- if (existing != null) {
501
- existing.transactionIds.push(...transactionIds);
502
- existing.nextPageToken = nextPageToken;
503
- existing.totalCount = totalCount;
504
- existing.fetchState = { fetchState: 'Completed', error: undefined };
505
- }
506
- else {
507
- draft.bulkUpload.completedTransactionsByPeriod[cacheKey] = {
508
- transactionIds,
509
- nextPageToken,
510
- totalCount,
511
- fetchState: { fetchState: 'Completed', error: undefined },
512
- };
513
- }
514
- }
515
- },
516
- fetchCompletedTransactionsFailure(draft, action) {
517
- const periodId = (0, timePeriod_1.toMonthYearPeriodId)(action.payload.selectedPeriod);
518
- const cacheKey = (0, exports.getCompletedTransactionsCacheKey)(periodId, draft.bulkUpload.sortKey, draft.bulkUpload.sortOrder, draft.bulkUpload.completedSubTab);
519
- const existing = draft.bulkUpload.completedTransactionsByPeriod[cacheKey];
520
- if (existing != null) {
521
- existing.fetchState = {
522
- fetchState: 'Error',
523
- error: action.payload.error,
524
- };
525
- }
526
- else {
527
- draft.bulkUpload.completedTransactionsByPeriod[cacheKey] = {
528
- fetchState: { fetchState: 'Error', error: action.payload.error },
529
- nextPageToken: null,
530
- totalCount: 0,
531
- transactionIds: [],
532
- };
533
- }
534
- },
535
127
  },
536
128
  });
537
- _a = expenseAutomationMissingReceiptsView.actions, exports.fetchMissingReceipts = _a.fetchMissingReceipts, exports.fetchMissingReceiptsSuccess = _a.fetchMissingReceiptsSuccess, exports.fetchMissingReceiptsFailure = _a.fetchMissingReceiptsFailure, exports.uploadMissingReceiptSuccess = _a.uploadMissingReceiptSuccess, exports.updateMissingReceiptUploadState = _a.updateMissingReceiptUploadState, exports.updateMissingReceiptsUIState = _a.updateMissingReceiptsUIState, exports.markMissingReceiptAsDone = _a.markMissingReceiptAsDone, exports.clearExpenseAutomationMissingReceiptsView = _a.clearExpenseAutomationMissingReceiptsView,
538
- // Bulk Upload
539
- exports.bulkUploadReceipts = _a.bulkUploadReceipts, exports.updateBulkUploadProgress = _a.updateBulkUploadProgress, exports.bulkUploadReceiptsSuccess = _a.bulkUploadReceiptsSuccess, exports.bulkUploadReceiptsFailure = _a.bulkUploadReceiptsFailure, exports.pusherBatchStatusUpdate = _a.pusherBatchStatusUpdate, exports.requestMissingReceiptsTabNavigation = _a.requestMissingReceiptsTabNavigation, exports.clearMissingReceiptsTabNavigation = _a.clearMissingReceiptsTabNavigation, exports.fetchBulkUploadBatchDetails = _a.fetchBulkUploadBatchDetails, exports.fetchBulkUploadBatchDetailsSuccess = _a.fetchBulkUploadBatchDetailsSuccess, exports.fetchBulkUploadBatchDetailsFailure = _a.fetchBulkUploadBatchDetailsFailure, exports.storeBatchDetails = _a.storeBatchDetails, exports.batchDetailFetchFailed = _a.batchDetailFetchFailed, exports.setInitialBatchDetailsLoading = _a.setInitialBatchDetailsLoading, exports.fetchMoreBatchDetails = _a.fetchMoreBatchDetails, exports.fetchMoreBatchDetailsComplete = _a.fetchMoreBatchDetailsComplete, exports.fetchMoreBatchDetailsFailure = _a.fetchMoreBatchDetailsFailure, exports.fetchBulkUploadBatches = _a.fetchBulkUploadBatches, exports.fetchBulkUploadBatchesSuccess = _a.fetchBulkUploadBatchesSuccess, exports.fetchBulkUploadBatchesFailure = _a.fetchBulkUploadBatchesFailure, exports.confirmBulkUploadMatch = _a.confirmBulkUploadMatch, exports.confirmBulkUploadMatchSuccess = _a.confirmBulkUploadMatchSuccess, exports.confirmBulkUploadMatchFailure = _a.confirmBulkUploadMatchFailure, exports.setBulkUploadResultsTab = _a.setBulkUploadResultsTab, exports.setBulkUploadCompletedSubTab = _a.setBulkUploadCompletedSubTab, exports.setBulkUploadSortConfig = _a.setBulkUploadSortConfig, exports.clearBulkUpload = _a.clearBulkUpload, exports.searchTransactionsForManualMatch = _a.searchTransactionsForManualMatch, exports.searchTransactionsForManualMatchSuccess = _a.searchTransactionsForManualMatchSuccess, exports.searchTransactionsForManualMatchFailure = _a.searchTransactionsForManualMatchFailure, exports.clearManualSearchResults = _a.clearManualSearchResults, exports.acknowledgeBulkUploadConfirmMatchComplete = _a.acknowledgeBulkUploadConfirmMatchComplete,
540
- // Completed Transactions
541
- exports.fetchCompletedTransactions = _a.fetchCompletedTransactions, exports.fetchCompletedTransactionsSuccess = _a.fetchCompletedTransactionsSuccess, exports.fetchCompletedTransactionsFailure = _a.fetchCompletedTransactionsFailure;
129
+ _a = expenseAutomationMissingReceiptsView.actions, exports.fetchMissingReceipts = _a.fetchMissingReceipts, exports.fetchMissingReceiptsSuccess = _a.fetchMissingReceiptsSuccess, exports.fetchMissingReceiptsFailure = _a.fetchMissingReceiptsFailure, exports.uploadMissingReceiptSuccess = _a.uploadMissingReceiptSuccess, exports.updateMissingReceiptUploadState = _a.updateMissingReceiptUploadState, exports.updateMissingReceiptsUIState = _a.updateMissingReceiptsUIState, exports.markMissingReceiptAsDone = _a.markMissingReceiptAsDone, exports.clearExpenseAutomationMissingReceiptsView = _a.clearExpenseAutomationMissingReceiptsView;
542
130
  exports.default = expenseAutomationMissingReceiptsView.reducer;
@@ -1,77 +1,9 @@
1
1
  import { CompletionStatusType, FetchStateAndError, ID } from '../../../commonStateTypes/common';
2
2
  import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport';
3
3
  import { SupportedTransaction } from '../../../entity/transaction/transactionState';
4
- import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
5
- import type { BatchFileStatus, BatchListItem, BatchStatus, BulkUploadPhase, BulkUploadResultsTab, BulkUploadSortKey, CompletedSubTab, ManualSearchState, MatchSource, MissingReceiptsViewUIState } from '../types/missingReceiptsViewState';
6
- export interface CompletedTransactionsSelectorData {
7
- fetchState: FetchStateAndError;
8
- nextPageToken: string | null;
9
- totalCount: number;
10
- transactions: SupportedTransaction[];
11
- }
12
- export interface ResolvedCandidate {
13
- matchScore: number;
14
- transaction: SupportedTransaction;
15
- }
16
- export interface ResolvedBatchFile {
17
- attachmentId: ID;
18
- batchId: ID;
19
- fileDownloadUrl: string | null;
20
- fileId: ID;
21
- filename: string;
22
- filePreviewUrl: string | null;
23
- status: BatchFileStatus;
24
- candidates?: ResolvedCandidate[];
25
- matchedTransaction?: SupportedTransaction;
26
- matchSource?: MatchSource;
27
- }
28
- export interface BulkUploadSelectorData {
29
- batchDetails: ResolvedBatchDetails | undefined;
30
- batchDetailsPaginationState: FetchStateAndError;
31
- batchList: BatchListItem[];
32
- batchListFetchState: FetchStateAndError;
33
- batchStatus: BatchStatus | undefined;
34
- completedSubTab: CompletedSubTab;
35
- completedTransactions: CompletedTransactionsSelectorData;
36
- confirmMatchStatus: FetchStateAndError;
37
- currentResultsTab: BulkUploadResultsTab;
38
- hasMoreBatchDetails: boolean;
39
- manualSearch: ManualSearchState;
40
- /** Bumps when manual search state is cleared — remount manual search inputs. */
41
- manualSearchUiResetKey: number;
42
- matchedFiles: ResolvedBatchFile[];
43
- pastBatches: BatchListItem[];
44
- pastUnmatchedFiles: ResolvedBatchFile[];
45
- phase: BulkUploadPhase;
46
- progress: {
47
- percentage: number;
48
- processed: number;
49
- total: number;
50
- };
51
- sortKey: BulkUploadSortKey;
52
- sortOrder: SortOrder;
53
- unmatchedFiles: ResolvedBatchFile[];
54
- uploadProgress: number;
55
- uploadStatus: FetchStateAndError;
56
- }
57
- export interface ResolvedBatchDetails {
58
- batchId: ID;
59
- createdAt: string;
60
- files: ResolvedBatchFile[];
61
- status: string;
62
- summary: {
63
- failed: number;
64
- matched: number;
65
- noMatch: number;
66
- possibleMatches: number;
67
- total: number;
68
- };
69
- }
4
+ import { MissingReceiptsViewUIState } from '../types/missingReceiptsViewState';
70
5
  export interface ExpenseAutomationMissingReceiptsViewSelector extends SelectorView {
71
- bulkUpload: BulkUploadSelectorData;
72
6
  completionStatus: CompletionStatusType;
73
- /** When set, UI should switch bulk-upload sub-tab once (e.g. Unmatched on batch completion). */
74
- pendingMissingReceiptsTabNavigation: BulkUploadResultsTab | null;
75
7
  refreshStatus: FetchStateAndError;
76
8
  transactions: SupportedTransaction[];
77
9
  uiState: MissingReceiptsViewUIState;
@@ -1,3 +1,3 @@
1
1
  import { RootState } from '../../../reducer';
2
- import type { ExpenseAutomationMissingReceiptsViewSelector } from '../selectorTypes/missingReceiptsSelectorTypes';
2
+ import { ExpenseAutomationMissingReceiptsViewSelector } from '../selectorTypes/missingReceiptsSelectorTypes';
3
3
  export declare function getExpenseAutomationMissingReceiptsView(state: RootState): ExpenseAutomationMissingReceiptsViewSelector;