@zeniai/client-epic-state 4.19.37-betaVR14 → 4.19.37-betaVR15

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.
@@ -55,14 +55,19 @@ export function getExpenseAutomationMissingReceiptsView(state) {
55
55
  const batchList = monthYearPeriodId != null
56
56
  ? bulkUpload.batchListByPeriod[monthYearPeriodId] ?? []
57
57
  : [];
58
- const completedBatchesSorted = orderBy(batchList.filter((b) => b.status === 'completed'), (b) => b.createdAt, 'desc');
59
- const effectiveCurrentBatchId = bulkUpload.currentBatchId ?? completedBatchesSorted[0]?.batchId;
60
- const currentBatchDetails = effectiveCurrentBatchId != null
61
- ? bulkUpload.batchDetailsById[effectiveCurrentBatchId]
58
+ /** Completed batches in the same order as the batches API (batchList). First = primary "Unmatched" batch. */
59
+ const completedBatchesInApiOrder = batchList.filter((b) => b.status === 'completed');
60
+ const firstCompletedBatchId = completedBatchesInApiOrder[0]?.batchId;
61
+ /** During upload/matching, the in-flight batch may not appear in batchList yet — prefer currentBatchId. */
62
+ const unmatchedSectionBatchId = bulkUpload.phase === 'matching' || bulkUpload.phase === 'uploading'
63
+ ? bulkUpload.currentBatchId ?? firstCompletedBatchId
64
+ : firstCompletedBatchId;
65
+ const currentBatchDetails = unmatchedSectionBatchId != null
66
+ ? bulkUpload.batchDetailsById[unmatchedSectionBatchId]
62
67
  : undefined;
63
68
  const resolvedFiles = currentBatchDetails?.files.map((file) => resolveBatchFile(file, currentBatchDetails.batchId, transactionState));
64
69
  const failedIds = new Set(bulkUpload.failedBatchDetailIds);
65
- const hasMoreBatchDetails = completedBatchesSorted.some((b) => bulkUpload.batchDetailsById[b.batchId] == null &&
70
+ const hasMoreBatchDetails = completedBatchesInApiOrder.some((b) => bulkUpload.batchDetailsById[b.batchId] == null &&
66
71
  !failedIds.has(b.batchId));
67
72
  const getSortValue = (file) => {
68
73
  const t = file.matchedTransaction;
@@ -102,7 +107,7 @@ export function getExpenseAutomationMissingReceiptsView(state) {
102
107
  }
103
108
  : { total: 0, processed: 0, percentage: 0 };
104
109
  const batchListFetchState = bulkUpload.batchListFetchState;
105
- const pastBatches = batchList.filter((b) => b.batchId !== effectiveCurrentBatchId);
110
+ const pastBatches = completedBatchesInApiOrder.filter((b) => b.batchId !== unmatchedSectionBatchId);
106
111
  const pastUnmatchedFiles = pastBatches.flatMap((b) => {
107
112
  const details = bulkUpload.batchDetailsById[b.batchId];
108
113
  if (details == null) {
@@ -61,14 +61,19 @@ function getExpenseAutomationMissingReceiptsView(state) {
61
61
  const batchList = monthYearPeriodId != null
62
62
  ? bulkUpload.batchListByPeriod[monthYearPeriodId] ?? []
63
63
  : [];
64
- const completedBatchesSorted = (0, orderBy_1.default)(batchList.filter((b) => b.status === 'completed'), (b) => b.createdAt, 'desc');
65
- const effectiveCurrentBatchId = bulkUpload.currentBatchId ?? completedBatchesSorted[0]?.batchId;
66
- const currentBatchDetails = effectiveCurrentBatchId != null
67
- ? bulkUpload.batchDetailsById[effectiveCurrentBatchId]
64
+ /** Completed batches in the same order as the batches API (batchList). First = primary "Unmatched" batch. */
65
+ const completedBatchesInApiOrder = batchList.filter((b) => b.status === 'completed');
66
+ const firstCompletedBatchId = completedBatchesInApiOrder[0]?.batchId;
67
+ /** During upload/matching, the in-flight batch may not appear in batchList yet — prefer currentBatchId. */
68
+ const unmatchedSectionBatchId = bulkUpload.phase === 'matching' || bulkUpload.phase === 'uploading'
69
+ ? bulkUpload.currentBatchId ?? firstCompletedBatchId
70
+ : firstCompletedBatchId;
71
+ const currentBatchDetails = unmatchedSectionBatchId != null
72
+ ? bulkUpload.batchDetailsById[unmatchedSectionBatchId]
68
73
  : undefined;
69
74
  const resolvedFiles = currentBatchDetails?.files.map((file) => resolveBatchFile(file, currentBatchDetails.batchId, transactionState));
70
75
  const failedIds = new Set(bulkUpload.failedBatchDetailIds);
71
- const hasMoreBatchDetails = completedBatchesSorted.some((b) => bulkUpload.batchDetailsById[b.batchId] == null &&
76
+ const hasMoreBatchDetails = completedBatchesInApiOrder.some((b) => bulkUpload.batchDetailsById[b.batchId] == null &&
72
77
  !failedIds.has(b.batchId));
73
78
  const getSortValue = (file) => {
74
79
  const t = file.matchedTransaction;
@@ -108,7 +113,7 @@ function getExpenseAutomationMissingReceiptsView(state) {
108
113
  }
109
114
  : { total: 0, processed: 0, percentage: 0 };
110
115
  const batchListFetchState = bulkUpload.batchListFetchState;
111
- const pastBatches = batchList.filter((b) => b.batchId !== effectiveCurrentBatchId);
116
+ const pastBatches = completedBatchesInApiOrder.filter((b) => b.batchId !== unmatchedSectionBatchId);
112
117
  const pastUnmatchedFiles = pastBatches.flatMap((b) => {
113
118
  const details = bulkUpload.batchDetailsById[b.batchId];
114
119
  if (details == null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.19.37-betaVR14",
3
+ "version": "4.19.37-betaVR15",
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",