@zeniai/client-epic-state 4.19.37-betaVR18 → 4.19.37-betaVR2

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 (36) hide show
  1. package/lib/epic.d.ts +1 -2
  2. package/lib/epic.js +1 -2
  3. package/lib/esm/epic.js +1 -2
  4. package/lib/esm/index.js +2 -2
  5. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +8 -4
  6. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +2 -2
  7. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +1 -6
  8. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +3 -7
  9. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +15 -24
  10. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +32 -32
  11. package/lib/esm/view/expenseAutomationView/payload/missingReceiptsPayload.js +12 -15
  12. package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +13 -51
  13. package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +12 -99
  14. package/lib/index.d.ts +2 -2
  15. package/lib/index.js +32 -36
  16. package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
  17. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.d.ts +5 -2
  18. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +7 -3
  19. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +2 -2
  20. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +1 -6
  21. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +2 -6
  22. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.d.ts +2 -3
  23. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +12 -25
  24. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts +7 -5
  25. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +28 -28
  26. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.d.ts +16 -15
  27. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.js +13 -16
  28. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +3 -12
  29. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +14 -53
  30. package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +1 -7
  31. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +12 -99
  32. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +2 -10
  33. package/package.json +2 -2
  34. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +0 -36
  35. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.d.ts +0 -8
  36. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +0 -43
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.fetchCompletedTransactionsFailure = exports.fetchCompletedTransactionsSuccess = exports.fetchCompletedTransactions = 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.fetchCompletedTransactionsFailure = exports.fetchCompletedTransactionsSuccess = exports.fetchCompletedTransactions = 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.storeBatchDetails = exports.fetchBulkUploadBatchDetailsFailure = exports.fetchBulkUploadBatchDetailsSuccess = exports.fetchBulkUploadBatchDetails = exports.pusherBatchStatusUpdate = exports.updateBulkUploadBatchStatus = 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 = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
7
- const getCompletedTransactionsCacheKey = (periodId, sortKey, sortOrder, subTab) => `completed-${subTab}-${sortKey}-${sortOrder === 'ascending' ? 'asc' : 'desc'}-${periodId}`;
8
- exports.getCompletedTransactionsCacheKey = getCompletedTransactionsCacheKey;
9
7
  exports.initialBulkUploadState = {
10
8
  batchDetailsById: {},
11
- batchDetailsPaginationState: { fetchState: 'Not-Started', error: undefined },
12
9
  batchListByPeriod: {},
13
10
  batchListFetchState: { fetchState: 'Not-Started', error: undefined },
14
11
  batchStatusById: {},
@@ -17,7 +14,6 @@ exports.initialBulkUploadState = {
17
14
  confirmMatchStatus: { fetchState: 'Not-Started', error: undefined },
18
15
  currentBatchId: undefined,
19
16
  currentResultsTab: 'unmatched',
20
- failedBatchDetailIds: [],
21
17
  manualSearch: {
22
18
  fetchState: { fetchState: 'Not-Started', error: undefined },
23
19
  results: [],
@@ -31,7 +27,6 @@ exports.initialBulkUploadState = {
31
27
  };
32
28
  exports.initialState = {
33
29
  bulkUpload: exports.initialBulkUploadState,
34
- pendingMissingReceiptsTabNavigation: null,
35
30
  uploadReceiptStatusById: {},
36
31
  refreshStatus: {
37
32
  fetchState: 'Not-Started',
@@ -184,15 +179,13 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
184
179
  };
185
180
  draft.bulkUpload.phase = 'idle';
186
181
  },
187
- pusherBatchStatusUpdate(draft, action) {
182
+ updateBulkUploadBatchStatus(draft, action) {
188
183
  const batchStatus = action.payload;
189
184
  draft.bulkUpload.batchStatusById[batchStatus.batchId] = batchStatus;
190
185
  },
191
- requestMissingReceiptsTabNavigation(draft, action) {
192
- draft.pendingMissingReceiptsTabNavigation = action.payload.tab;
193
- },
194
- clearMissingReceiptsTabNavigation(draft) {
195
- draft.pendingMissingReceiptsTabNavigation = null;
186
+ pusherBatchStatusUpdate(draft, action) {
187
+ const batchStatus = action.payload;
188
+ draft.bulkUpload.batchStatusById[batchStatus.batchId] = batchStatus;
196
189
  },
197
190
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
198
191
  fetchBulkUploadBatchDetails(_draft) {
@@ -211,36 +204,6 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
211
204
  const details = action.payload;
212
205
  draft.bulkUpload.batchDetailsById[details.batchId] = details;
213
206
  },
214
- batchDetailFetchFailed(draft, action) {
215
- const { batchId } = action.payload;
216
- if (!draft.bulkUpload.failedBatchDetailIds.includes(batchId)) {
217
- draft.bulkUpload.failedBatchDetailIds.push(batchId);
218
- }
219
- },
220
- setInitialBatchDetailsLoading(draft) {
221
- draft.bulkUpload.batchDetailsPaginationState = {
222
- fetchState: 'In-Progress',
223
- error: undefined,
224
- };
225
- },
226
- fetchMoreBatchDetails(_draft) {
227
- _draft.bulkUpload.batchDetailsPaginationState = {
228
- fetchState: 'In-Progress',
229
- error: undefined,
230
- };
231
- },
232
- fetchMoreBatchDetailsComplete(draft) {
233
- draft.bulkUpload.batchDetailsPaginationState = {
234
- fetchState: 'Completed',
235
- error: undefined,
236
- };
237
- },
238
- fetchMoreBatchDetailsFailure(draft, action) {
239
- draft.bulkUpload.batchDetailsPaginationState = {
240
- fetchState: 'Error',
241
- error: action.payload.error,
242
- };
243
- },
244
207
  fetchBulkUploadBatches: {
245
208
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
246
209
  reducer(draft, _action) {
@@ -314,6 +277,7 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
314
277
  },
315
278
  setBulkUploadCompletedSubTab(draft, action) {
316
279
  draft.bulkUpload.completedSubTab = action.payload;
280
+ draft.bulkUpload.completedTransactionsByPeriod = {};
317
281
  },
318
282
  setBulkUploadSortConfig(draft, action) {
319
283
  draft.bulkUpload.sortKey = action.payload.sortKey;
@@ -321,7 +285,6 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
321
285
  },
322
286
  clearBulkUpload(draft) {
323
287
  Object.assign(draft.bulkUpload, exports.initialBulkUploadState);
324
- draft.pendingMissingReceiptsTabNavigation = null;
325
288
  },
326
289
  searchTransactionsForManualMatch: {
327
290
  reducer(draft, action) {
@@ -369,16 +332,15 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
369
332
  }
370
333
  }
371
334
  },
372
- prepare(pageToken, cacheOverride) {
373
- return { payload: { pageToken, cacheOverride } };
335
+ prepare(pageToken) {
336
+ return { payload: { pageToken } };
374
337
  },
375
338
  },
376
339
  fetchCompletedTransactionsSuccess(draft, action) {
377
340
  const { transactionIds, nextPageToken, totalCount, selectedPeriod, isInitialLoad } = action.payload;
378
341
  const periodId = (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod);
379
- const cacheKey = (0, exports.getCompletedTransactionsCacheKey)(periodId, draft.bulkUpload.sortKey, draft.bulkUpload.sortOrder, draft.bulkUpload.completedSubTab);
380
342
  if (isInitialLoad) {
381
- draft.bulkUpload.completedTransactionsByPeriod[cacheKey] = {
343
+ draft.bulkUpload.completedTransactionsByPeriod[periodId] = {
382
344
  transactionIds,
383
345
  nextPageToken,
384
346
  totalCount,
@@ -386,7 +348,7 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
386
348
  };
387
349
  }
388
350
  else {
389
- const existing = draft.bulkUpload.completedTransactionsByPeriod[cacheKey];
351
+ const existing = draft.bulkUpload.completedTransactionsByPeriod[periodId];
390
352
  if (existing != null) {
391
353
  existing.transactionIds.push(...transactionIds);
392
354
  existing.nextPageToken = nextPageToken;
@@ -394,7 +356,7 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
394
356
  existing.fetchState = { fetchState: 'Completed', error: undefined };
395
357
  }
396
358
  else {
397
- draft.bulkUpload.completedTransactionsByPeriod[cacheKey] = {
359
+ draft.bulkUpload.completedTransactionsByPeriod[periodId] = {
398
360
  transactionIds,
399
361
  nextPageToken,
400
362
  totalCount,
@@ -405,8 +367,7 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
405
367
  },
406
368
  fetchCompletedTransactionsFailure(draft, action) {
407
369
  const periodId = (0, timePeriod_1.toMonthYearPeriodId)(action.payload.selectedPeriod);
408
- const cacheKey = (0, exports.getCompletedTransactionsCacheKey)(periodId, draft.bulkUpload.sortKey, draft.bulkUpload.sortOrder, draft.bulkUpload.completedSubTab);
409
- const existing = draft.bulkUpload.completedTransactionsByPeriod[cacheKey];
370
+ const existing = draft.bulkUpload.completedTransactionsByPeriod[periodId];
410
371
  if (existing != null) {
411
372
  existing.fetchState = {
412
373
  fetchState: 'Error',
@@ -414,7 +375,7 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
414
375
  };
415
376
  }
416
377
  else {
417
- draft.bulkUpload.completedTransactionsByPeriod[cacheKey] = {
378
+ draft.bulkUpload.completedTransactionsByPeriod[periodId] = {
418
379
  fetchState: { fetchState: 'Error', error: action.payload.error },
419
380
  nextPageToken: null,
420
381
  totalCount: 0,
@@ -426,7 +387,7 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
426
387
  });
427
388
  _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,
428
389
  // Bulk Upload
429
- 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,
390
+ exports.bulkUploadReceipts = _a.bulkUploadReceipts, exports.updateBulkUploadProgress = _a.updateBulkUploadProgress, exports.bulkUploadReceiptsSuccess = _a.bulkUploadReceiptsSuccess, exports.bulkUploadReceiptsFailure = _a.bulkUploadReceiptsFailure, exports.updateBulkUploadBatchStatus = _a.updateBulkUploadBatchStatus, exports.pusherBatchStatusUpdate = _a.pusherBatchStatusUpdate, exports.fetchBulkUploadBatchDetails = _a.fetchBulkUploadBatchDetails, exports.fetchBulkUploadBatchDetailsSuccess = _a.fetchBulkUploadBatchDetailsSuccess, exports.fetchBulkUploadBatchDetailsFailure = _a.fetchBulkUploadBatchDetailsFailure, exports.storeBatchDetails = _a.storeBatchDetails, 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,
430
391
  // Completed Transactions
431
392
  exports.fetchCompletedTransactions = _a.fetchCompletedTransactions, exports.fetchCompletedTransactionsSuccess = _a.fetchCompletedTransactionsSuccess, exports.fetchCompletedTransactionsFailure = _a.fetchCompletedTransactionsFailure;
432
393
  exports.default = expenseAutomationMissingReceiptsView.reducer;
@@ -15,11 +15,9 @@ export interface ResolvedCandidate {
15
15
  }
16
16
  export interface ResolvedBatchFile {
17
17
  attachmentId: ID;
18
- batchId: ID;
19
- fileDownloadUrl: string | null;
20
18
  fileId: ID;
21
19
  filename: string;
22
- filePreviewUrl: string | null;
20
+ filePreviewUrl: string;
23
21
  status: BatchFileStatus;
24
22
  candidates?: ResolvedCandidate[];
25
23
  matchedTransaction?: SupportedTransaction;
@@ -27,7 +25,6 @@ export interface ResolvedBatchFile {
27
25
  }
28
26
  export interface BulkUploadSelectorData {
29
27
  batchDetails: ResolvedBatchDetails | undefined;
30
- batchDetailsPaginationState: FetchStateAndError;
31
28
  batchList: BatchListItem[];
32
29
  batchListFetchState: FetchStateAndError;
33
30
  batchStatus: BatchStatus | undefined;
@@ -35,7 +32,6 @@ export interface BulkUploadSelectorData {
35
32
  completedTransactions: CompletedTransactionsSelectorData;
36
33
  confirmMatchStatus: FetchStateAndError;
37
34
  currentResultsTab: BulkUploadResultsTab;
38
- hasMoreBatchDetails: boolean;
39
35
  manualSearch: ManualSearchState;
40
36
  matchedFiles: ResolvedBatchFile[];
41
37
  pastBatches: BatchListItem[];
@@ -68,8 +64,6 @@ export interface ResolvedBatchDetails {
68
64
  export interface ExpenseAutomationMissingReceiptsViewSelector extends SelectorView {
69
65
  bulkUpload: BulkUploadSelectorData;
70
66
  completionStatus: CompletionStatusType;
71
- /** When set, UI should switch bulk-upload sub-tab once (e.g. Unmatched on batch completion). */
72
- pendingMissingReceiptsTabNavigation: BulkUploadResultsTab | null;
73
67
  refreshStatus: FetchStateAndError;
74
68
  transactions: SupportedTransaction[];
75
69
  uiState: MissingReceiptsViewUIState;
@@ -9,8 +9,6 @@ const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
9
9
  const tenantSelector_1 = require("../../../entity/tenant/tenantSelector");
10
10
  const transactionSelector_1 = require("../../../entity/transaction/transactionSelector");
11
11
  const expenseAutomationViewSelectorTypes_1 = require("../selectorTypes/expenseAutomationViewSelectorTypes");
12
- const missingReceiptsPayload_1 = require("../payload/missingReceiptsPayload");
13
- const missingReceiptsViewReducer_1 = require("../reducers/missingReceiptsViewReducer");
14
12
  function getExpenseAutomationMissingReceiptsView(state) {
15
13
  const { expenseAutomationMissingReceiptsViewState, expenseAutomationViewState, transactionState, monthEndCloseChecksState, } = state;
16
14
  const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
@@ -55,34 +53,14 @@ function getExpenseAutomationMissingReceiptsView(state) {
55
53
  const completionStatus = missingReceiptsCompletionStatus != null
56
54
  ? missingReceiptsCompletionStatus
57
55
  : 'incomplete';
58
- const { bulkUpload, pendingMissingReceiptsTabNavigation, } = expenseAutomationMissingReceiptsViewState;
56
+ const { bulkUpload } = expenseAutomationMissingReceiptsViewState;
59
57
  const currentBatchStatus = bulkUpload.currentBatchId != null
60
58
  ? bulkUpload.batchStatusById[bulkUpload.currentBatchId]
61
59
  : undefined;
62
- const batchList = monthYearPeriodId != null
63
- ? bulkUpload.batchListByPeriod[monthYearPeriodId] ?? []
64
- : [];
65
- /** API returns newest-first (`sort_order: desc`); primary batch uses oldest-first order. */
66
- const batchListChronological = (0, orderBy_1.default)(batchList, (b) => new Date(b.createdAt).valueOf(), 'asc');
67
- /**
68
- * Primary "Unmatched" batch = first completed batch in chronological order, preferring the
69
- * first batch that still has un_matched/no_match work when any completed batch has such work.
70
- * Batches without details yet: wait if the list row still reports unmatched work; otherwise skip
71
- * so we do not block the whole tab while older rows are not fetched yet.
72
- */
73
- const primaryBatchIdFromDetailsOrder = getPrimaryBatchIdFromBatchListOrder(batchListChronological, bulkUpload.batchDetailsById, bulkUpload.failedBatchDetailIds);
74
- /** During upload/matching, the in-flight batch may not appear in batchList yet — prefer currentBatchId. */
75
- const unmatchedSectionBatchId = bulkUpload.phase === 'matching' || bulkUpload.phase === 'uploading'
76
- ? bulkUpload.currentBatchId ?? primaryBatchIdFromDetailsOrder
77
- : primaryBatchIdFromDetailsOrder;
78
- const completedBatchesInApiOrder = batchList.filter((b) => (0, missingReceiptsPayload_1.isBatchListStatusCompleted)(b.status));
79
- const currentBatchDetails = unmatchedSectionBatchId != null
80
- ? bulkUpload.batchDetailsById[unmatchedSectionBatchId]
60
+ const currentBatchDetails = bulkUpload.currentBatchId != null
61
+ ? bulkUpload.batchDetailsById[bulkUpload.currentBatchId]
81
62
  : undefined;
82
- const resolvedFiles = currentBatchDetails?.files.map((file) => resolveBatchFile(file, currentBatchDetails.batchId, transactionState));
83
- const failedIds = new Set(bulkUpload.failedBatchDetailIds);
84
- const hasMoreBatchDetails = completedBatchesInApiOrder.some((b) => bulkUpload.batchDetailsById[b.batchId] == null &&
85
- !failedIds.has(b.batchId));
63
+ const resolvedFiles = currentBatchDetails?.files.map((file) => resolveBatchFile(file, transactionState));
86
64
  const getSortValue = (file) => {
87
65
  const t = file.matchedTransaction;
88
66
  if (t == null) {
@@ -120,14 +98,11 @@ function getExpenseAutomationMissingReceiptsView(state) {
120
98
  : 0,
121
99
  }
122
100
  : { total: 0, processed: 0, percentage: 0 };
101
+ const batchList = monthYearPeriodId != null
102
+ ? bulkUpload.batchListByPeriod[monthYearPeriodId] ?? []
103
+ : [];
123
104
  const batchListFetchState = bulkUpload.batchListFetchState;
124
- /**
125
- * When primary batch is not resolved yet, still aggregate unmatched files from every batch
126
- * that has details loaded (otherwise past is empty and receipts vanish from the UI).
127
- */
128
- const pastBatches = unmatchedSectionBatchId != null
129
- ? batchList.filter((b) => b.batchId !== unmatchedSectionBatchId)
130
- : batchList;
105
+ const pastBatches = batchList.filter((b) => b.batchId !== bulkUpload.currentBatchId);
131
106
  const pastUnmatchedFiles = pastBatches.flatMap((b) => {
132
107
  const details = bulkUpload.batchDetailsById[b.batchId];
133
108
  if (details == null) {
@@ -135,13 +110,10 @@ function getExpenseAutomationMissingReceiptsView(state) {
135
110
  }
136
111
  return details.files
137
112
  .filter((f) => f.status === 'un_matched' || f.status === 'no_match')
138
- .map((f) => resolveBatchFile(f, b.batchId, transactionState));
113
+ .map((f) => resolveBatchFile(f, transactionState));
139
114
  });
140
- const completedTransactionsCacheKey = monthYearPeriodId != null
141
- ? (0, missingReceiptsViewReducer_1.getCompletedTransactionsCacheKey)(monthYearPeriodId, bulkUpload.sortKey, bulkUpload.sortOrder, bulkUpload.completedSubTab)
142
- : undefined;
143
- const completedTransactionsForPeriod = completedTransactionsCacheKey != null
144
- ? bulkUpload.completedTransactionsByPeriod[completedTransactionsCacheKey]
115
+ const completedTransactionsForPeriod = monthYearPeriodId != null
116
+ ? bulkUpload.completedTransactionsByPeriod[monthYearPeriodId]
145
117
  : undefined;
146
118
  const completedTransactionIds = completedTransactionsForPeriod?.transactionIds ?? [];
147
119
  const resolvedCompletedTransactions = (0, transactionSelector_1.getSupportedTransactionsByIds)(transactionState, completedTransactionIds);
@@ -162,7 +134,6 @@ function getExpenseAutomationMissingReceiptsView(state) {
162
134
  refreshStatus,
163
135
  transactions: sortedTransactions,
164
136
  completionStatus,
165
- pendingMissingReceiptsTabNavigation: pendingMissingReceiptsTabNavigation ?? null,
166
137
  bulkUpload: {
167
138
  phase: bulkUpload.phase,
168
139
  uploadStatus: bulkUpload.uploadStatus,
@@ -189,68 +160,12 @@ function getExpenseAutomationMissingReceiptsView(state) {
189
160
  pastBatches,
190
161
  pastUnmatchedFiles,
191
162
  confirmMatchStatus: bulkUpload.confirmMatchStatus,
192
- hasMoreBatchDetails,
193
- batchDetailsPaginationState: bulkUpload.batchDetailsPaginationState,
194
163
  manualSearch: bulkUpload.manualSearch,
195
164
  uploadProgress: bulkUpload.uploadProgress,
196
165
  },
197
166
  };
198
167
  }
199
- function batchDetailsHasUnmatchedWork(details) {
200
- return details.files.some((f) => f.status === 'un_matched' || f.status === 'no_match');
201
- }
202
- /** List row summary before batch details load — aligns with unmatched / possible-match work. */
203
- function batchListItemHasUnmatchedWork(batch) {
204
- return batch.noMatchCount > 0 || batch.possibleMatchesCount > 0;
205
- }
206
- /**
207
- * `batchList` must be in chronological order (oldest first). Picks the primary batch for the
208
- * top "Unmatched" section. Skips failed detail fetches.
209
- *
210
- * If details are not loaded for an older batch but the list row reports no unmatched work, we
211
- * skip that batch so newer batches with loaded details can be primary (avoids an empty tab when
212
- * the first fetch page only loaded newer batches). If the list reports unmatched work but details
213
- * are still loading, we wait (undefined) so primary order stays correct once details arrive.
214
- */
215
- function getPrimaryBatchIdFromBatchListOrder(batchListChronological, batchDetailsById, failedBatchDetailIds) {
216
- const failedIds = new Set(failedBatchDetailIds);
217
- const anyCompletedBatchHasUnmatchedWork = batchListChronological.some((b) => {
218
- if (failedIds.has(b.batchId)) {
219
- return false;
220
- }
221
- const d = batchDetailsById[b.batchId];
222
- if (d != null &&
223
- d.status === 'completed' &&
224
- batchDetailsHasUnmatchedWork(d)) {
225
- return true;
226
- }
227
- return d == null && batchListItemHasUnmatchedWork(b);
228
- });
229
- for (const batch of batchListChronological) {
230
- if (failedIds.has(batch.batchId)) {
231
- continue;
232
- }
233
- const details = batchDetailsById[batch.batchId];
234
- if (details == null) {
235
- if (batchListItemHasUnmatchedWork(batch)) {
236
- return undefined;
237
- }
238
- continue;
239
- }
240
- if (details.status !== 'completed') {
241
- continue;
242
- }
243
- if (anyCompletedBatchHasUnmatchedWork) {
244
- if (batchDetailsHasUnmatchedWork(details)) {
245
- return batch.batchId;
246
- }
247
- continue;
248
- }
249
- return batch.batchId;
250
- }
251
- return undefined;
252
- }
253
- function resolveBatchFile(file, batchId, transactionState) {
168
+ function resolveBatchFile(file, transactionState) {
254
169
  const matchedTransaction = file.matchedTransactionId != null
255
170
  ? (0, transactionSelector_1.getSupportedTransactionById)(transactionState, file.matchedTransactionId)
256
171
  : undefined;
@@ -264,8 +179,6 @@ function resolveBatchFile(file, batchId, transactionState) {
264
179
  .filter((c) => c != null);
265
180
  return {
266
181
  attachmentId: file.attachmentId,
267
- batchId,
268
- fileDownloadUrl: file.fileDownloadUrl,
269
182
  fileId: file.fileId,
270
183
  filename: file.filename,
271
184
  filePreviewUrl: file.filePreviewUrl,
@@ -36,10 +36,9 @@ export interface MatchCandidate {
36
36
  }
37
37
  export interface BatchFile {
38
38
  attachmentId: ID;
39
- fileDownloadUrl: string | null;
40
39
  fileId: ID;
41
40
  filename: string;
42
- filePreviewUrl: string | null;
41
+ filePreviewUrl: string;
43
42
  status: BatchFileStatus;
44
43
  candidates?: CandidateRef[];
45
44
  matchedTransactionId?: ID;
@@ -101,15 +100,13 @@ export interface CompletedTransactionsState {
101
100
  }
102
101
  export interface BulkUploadState {
103
102
  batchDetailsById: Record<ID, BatchDetails>;
104
- batchDetailsPaginationState: FetchStateAndError;
105
103
  batchListByPeriod: Record<MonthYearPeriodId, BatchListItem[]>;
106
104
  batchListFetchState: FetchStateAndError;
107
105
  batchStatusById: Record<ID, BatchStatus>;
108
106
  completedSubTab: CompletedSubTab;
109
- completedTransactionsByPeriod: Record<string, CompletedTransactionsState>;
107
+ completedTransactionsByPeriod: Record<MonthYearPeriodId, CompletedTransactionsState>;
110
108
  confirmMatchStatus: FetchStateAndError;
111
109
  currentResultsTab: BulkUploadResultsTab;
112
- failedBatchDetailIds: ID[];
113
110
  manualSearch: ManualSearchState;
114
111
  phase: BulkUploadPhase;
115
112
  sortKey: BulkUploadSortKey;
@@ -120,11 +117,6 @@ export interface BulkUploadState {
120
117
  }
121
118
  export interface MissingReceiptsViewState extends FetchedState {
122
119
  bulkUpload: BulkUploadState;
123
- /**
124
- * When set, the app shell should switch the Missing Receipts sub-tab (e.g. to Unmatched)
125
- * once, then clear via `clearMissingReceiptsTabNavigation`.
126
- */
127
- pendingMissingReceiptsTabNavigation: BulkUploadResultsTab | null;
128
120
  refreshStatus: FetchStateAndError;
129
121
  transactionIdsBySelectedPeriod: Record<MonthYearPeriodId, ID[]>;
130
122
  uiState: MissingReceiptsViewUIState;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.19.37-betaVR18",
3
+ "version": "4.19.37-betaVR2",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",
@@ -111,7 +111,7 @@
111
111
  "find-dead-code": "ts-prune | grep -v '(used in module)'",
112
112
  "find-unused-exports": "ts-unused-exports ./tsconfig.json",
113
113
  "circular-dependency": "npx madge --circular --extensions ts ./src",
114
- "build": "concurrently --kill-others-on-fail --handle-input \"echo 'Running ESLint...' && eslint . --ext .js,.jsx,.ts,.tsx\" \"echo 'TypeScript build in progress...' && time tsc && echo 'ESM build...' && tsc -p tsconfig.esm.json\"",
114
+ "build": "concurrently --kill-others-on-fail --handle-input \"echo 'Running ESLint...' && eslint . --ext .js,.jsx,.ts,.tsx\" \"echo 'TypeScript build in progress...' && time tsc && echo 'ESM build...' && tsc -p tsconfig.esm.json\" \"echo 'Running tests and typecheck...' && pnpm test\" && rimraf \"lib/**/__mocks__\" \"lib/**/__testHelpers__\"",
115
115
  "only-build": "eslint . --ext .js,.jsx,.ts,.tsx && time tsc && tsc -p tsconfig.esm.json && rimraf \"lib/**/__mocks__\" \"lib/**/__testHelpers__\"",
116
116
  "format": "prettier --write --ignore-unknown \"src/**/*\" && pnpm lint",
117
117
  "format-watch": "(git diff --name-only --diff-filter=ACM && git ls-files --others --exclude-standard) | grep -E '\\.(ts|tsx)$' | xargs prettier --write",
@@ -1,36 +0,0 @@
1
- import orderBy from 'lodash/orderBy';
2
- import { concat, of } from 'rxjs';
3
- import { catchError, exhaustMap, filter } from 'rxjs/operators';
4
- import { toMonthYearPeriodId } from '../../../../commonStateTypes/timePeriod';
5
- import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
6
- import { createZeniAPIStatus } from '../../../../responsePayload';
7
- import { isBatchListStatusCompleted } from '../../payload/missingReceiptsPayload';
8
- import { fetchMoreBatchDetails, fetchMoreBatchDetailsComplete, fetchMoreBatchDetailsFailure, } from '../../reducers/missingReceiptsViewReducer';
9
- import { fetchBatchDetailsByIds } from './fetchMultipleBatchDetailsEpic';
10
- const MORE_BATCH_PAGE_SIZE = 4;
11
- export const fetchMoreBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchMoreBatchDetails.match),
12
- /** One page at a time — avoids duplicate loads if IO + scroll fallback both fire. */
13
- exhaustMap(() => {
14
- const state = state$.value;
15
- const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload }, } = state;
16
- const currentTenant = getCurrentTenant(state);
17
- const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
18
- if (selectedPeriod == null) {
19
- return of(fetchMoreBatchDetailsComplete());
20
- }
21
- const periodId = toMonthYearPeriodId(selectedPeriod);
22
- const batchList = bulkUpload.batchListByPeriod[periodId] ?? [];
23
- const failedIds = new Set(bulkUpload.failedBatchDetailIds);
24
- const unfetchedBatches = batchList.filter((batch) => isBatchListStatusCompleted(batch.status) &&
25
- bulkUpload.batchDetailsById[batch.batchId] == null &&
26
- !failedIds.has(batch.batchId));
27
- const unfetchedBatchIds = orderBy(unfetchedBatches, (b) => new Date(b.createdAt).valueOf(), 'asc').map((batch) => batch.batchId);
28
- if (unfetchedBatchIds.length === 0) {
29
- return of(fetchMoreBatchDetailsComplete());
30
- }
31
- const nextPage = unfetchedBatchIds.slice(0, MORE_BATCH_PAGE_SIZE);
32
- return concat(fetchBatchDetailsByIds(nextPage, zeniAPI), of(fetchMoreBatchDetailsComplete())).pipe(catchError((error) => of(fetchMoreBatchDetailsFailure({
33
- error: createZeniAPIStatus('Unexpected Error', 'Fetch more batch details errored out: ' +
34
- JSON.stringify(error)),
35
- }))));
36
- }));
@@ -1,8 +0,0 @@
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 { batchDetailFetchFailed, fetchBulkUploadBatchesSuccess, fetchMoreBatchDetails, fetchMoreBatchDetailsComplete, fetchMoreBatchDetailsFailure, setInitialBatchDetailsLoading, storeBatchDetails } from '../../reducers/missingReceiptsViewReducer';
7
- export type ActionType = ReturnType<typeof fetchBulkUploadBatchesSuccess> | ReturnType<typeof fetchMoreBatchDetails> | ReturnType<typeof fetchMoreBatchDetailsComplete> | ReturnType<typeof fetchMoreBatchDetailsFailure> | ReturnType<typeof batchDetailFetchFailed> | ReturnType<typeof setInitialBatchDetailsLoading> | ReturnType<typeof storeBatchDetails> | ReturnType<typeof updateTransactions>;
8
- export declare const fetchMoreBatchDetailsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -1,43 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.fetchMoreBatchDetailsEpic = void 0;
7
- const orderBy_1 = __importDefault(require("lodash/orderBy"));
8
- const rxjs_1 = require("rxjs");
9
- const operators_1 = require("rxjs/operators");
10
- const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
11
- const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
12
- const responsePayload_1 = require("../../../../responsePayload");
13
- const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
14
- const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
15
- const fetchMultipleBatchDetailsEpic_1 = require("./fetchMultipleBatchDetailsEpic");
16
- const MORE_BATCH_PAGE_SIZE = 4;
17
- const fetchMoreBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchMoreBatchDetails.match),
18
- /** One page at a time — avoids duplicate loads if IO + scroll fallback both fire. */
19
- (0, operators_1.exhaustMap)(() => {
20
- const state = state$.value;
21
- const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload }, } = state;
22
- const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
23
- const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
24
- if (selectedPeriod == null) {
25
- return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchMoreBatchDetailsComplete)());
26
- }
27
- const periodId = (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod);
28
- const batchList = bulkUpload.batchListByPeriod[periodId] ?? [];
29
- const failedIds = new Set(bulkUpload.failedBatchDetailIds);
30
- const unfetchedBatches = batchList.filter((batch) => (0, missingReceiptsPayload_1.isBatchListStatusCompleted)(batch.status) &&
31
- bulkUpload.batchDetailsById[batch.batchId] == null &&
32
- !failedIds.has(batch.batchId));
33
- const unfetchedBatchIds = (0, orderBy_1.default)(unfetchedBatches, (b) => new Date(b.createdAt).valueOf(), 'asc').map((batch) => batch.batchId);
34
- if (unfetchedBatchIds.length === 0) {
35
- return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchMoreBatchDetailsComplete)());
36
- }
37
- const nextPage = unfetchedBatchIds.slice(0, MORE_BATCH_PAGE_SIZE);
38
- return (0, rxjs_1.concat)((0, fetchMultipleBatchDetailsEpic_1.fetchBatchDetailsByIds)(nextPage, zeniAPI), (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchMoreBatchDetailsComplete)())).pipe((0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchMoreBatchDetailsFailure)({
39
- error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch more batch details errored out: ' +
40
- JSON.stringify(error)),
41
- }))));
42
- }));
43
- exports.fetchMoreBatchDetailsEpic = fetchMoreBatchDetailsEpic;