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