@zeniai/client-epic-state 4.19.84-betaVR16 → 4.19.84-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.
- package/lib/epic.js +1 -1
- package/lib/esm/epic.js +2 -2
- package/lib/esm/index.js +3 -7
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +5 -10
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +1 -1
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +1 -1
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +4 -14
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +3 -43
- package/lib/esm/view/expenseAutomationView/payload/missingReceiptsPayload.js +10 -52
- package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +22 -54
- package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +35 -57
- package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +0 -39
- package/lib/index.d.ts +3 -4
- package/lib/index.js +33 -48
- package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.d.ts +0 -3
- package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +3 -8
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +1 -1
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +1 -1
- package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +3 -13
- package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts +2 -14
- package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +3 -44
- package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.d.ts +1 -12
- package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.js +10 -53
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +5 -11
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +22 -54
- package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +35 -57
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +9 -27
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +1 -49
- package/package.json +1 -1
- package/lib/esm/view/expenseAutomationView/bulkUploadTiming.js +0 -10
- package/lib/view/expenseAutomationView/bulkUploadTiming.d.ts +0 -10
- package/lib/view/expenseAutomationView/bulkUploadTiming.js +0 -13
package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pollBulkUploadBatchStatusEpic = exports.
|
|
3
|
+
exports.pollBulkUploadBatchStatusEpic = exports.pusherBatchStatusCompletionEpic = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
|
|
7
6
|
const transactionReducer_1 = require("../../../../entity/transaction/transactionReducer");
|
|
8
7
|
const responsePayload_1 = require("../../../../responsePayload");
|
|
9
|
-
const bulkUploadTiming_1 = require("../../bulkUploadTiming");
|
|
10
8
|
const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
|
|
11
9
|
const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
12
10
|
/** First poll after upload; then interval while batch not resolved via Pusher or API. */
|
|
@@ -24,38 +22,9 @@ const pusherBatchStatusCompletionEpic = (actions$) => actions$.pipe((0, operator
|
|
|
24
22
|
(0, missingReceiptsViewReducer_1.requestMissingReceiptsTabNavigation)({ tab: 'unmatched' }),
|
|
25
23
|
])));
|
|
26
24
|
exports.pusherBatchStatusCompletionEpic = pusherBatchStatusCompletionEpic;
|
|
27
|
-
/**
|
|
28
|
-
* If Pusher and batch-details are delayed beyond {@link BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS},
|
|
29
|
-
* force `phase` to `completed` (dismiss automatching banner) and refresh the batch list.
|
|
30
|
-
* Cancels when the batch completes normally, bulk state is cleared, or another upload supersedes.
|
|
31
|
-
*/
|
|
32
|
-
const bulkUploadAutomatchingTimeoutEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.bulkUploadReceiptsSuccess.match), (0, operators_1.mergeMap)((action) => {
|
|
33
|
-
const { batchId } = action.payload;
|
|
34
|
-
return (0, rxjs_1.timer)(bulkUploadTiming_1.BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS).pipe((0, operators_1.mergeMap)(() => {
|
|
35
|
-
const bulk = state$.value.expenseAutomationMissingReceiptsViewState.bulkUpload;
|
|
36
|
-
if (bulk.phase !== 'matching' ||
|
|
37
|
-
bulk.currentBatchId !== batchId) {
|
|
38
|
-
return rxjs_1.EMPTY;
|
|
39
|
-
}
|
|
40
|
-
// eslint-disable-next-line no-console
|
|
41
|
-
console.warn('[bulk-upload] Automatching wait exceeded timeout; releasing UI', { batchId });
|
|
42
|
-
return (0, rxjs_1.from)([
|
|
43
|
-
(0, missingReceiptsViewReducer_1.bulkUploadAutomatchingTimedOut)(batchId),
|
|
44
|
-
(0, missingReceiptsViewReducer_1.fetchBulkUploadBatches)({ cacheOverride: true }),
|
|
45
|
-
]);
|
|
46
|
-
}), (0, operators_1.takeUntil)((0, rxjs_1.merge)(actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.clearBulkUpload.match)), actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.pusherBatchStatusUpdate.match), (0, operators_1.filter)((a) => a.payload.batchId === batchId &&
|
|
47
|
-
a.payload.status === 'completed')), actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsSuccess.match), (0, operators_1.filter)((a) => a.payload.batchId === batchId)))));
|
|
48
|
-
}));
|
|
49
|
-
exports.bulkUploadAutomatchingTimeoutEpic = bulkUploadAutomatchingTimeoutEpic;
|
|
50
|
-
/**
|
|
51
|
-
* Fallback polling when Pusher is slow or unavailable. Network errors on a poll tick show one
|
|
52
|
-
* error snackbar per upload session (first failure only) so the user is not spammed every
|
|
53
|
-
* interval; Pusher or a later successful poll still completes the flow.
|
|
54
|
-
*/
|
|
55
25
|
const pollBulkUploadBatchStatusEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.bulkUploadReceiptsSuccess.match), (0, operators_1.mergeMap)((action) => {
|
|
56
26
|
const { batchId } = action.payload;
|
|
57
|
-
|
|
58
|
-
return (0, rxjs_1.timer)(FALLBACK_FIRST_DELAY_MS, FALLBACK_POLL_INTERVAL_MS).pipe((0, operators_1.takeUntil)((0, rxjs_1.merge)(actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.clearBulkUpload.match)), actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.pusherBatchStatusUpdate.match), (0, operators_1.filter)((action) => action.payload.batchId === batchId)), actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsSuccess.match), (0, operators_1.filter)((action) => action.payload.batchId === batchId)), actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.bulkUploadAutomatchingTimedOut.match), (0, operators_1.filter)((action) => action.payload.batchId === batchId)))), (0, operators_1.switchMap)(() => zeniAPI
|
|
27
|
+
return (0, rxjs_1.timer)(FALLBACK_FIRST_DELAY_MS, FALLBACK_POLL_INTERVAL_MS).pipe((0, operators_1.takeUntil)((0, rxjs_1.merge)(actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.clearBulkUpload.match)), actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.pusherBatchStatusUpdate.match), (0, operators_1.filter)((a) => a.payload.batchId === batchId)), actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsSuccess.match), (0, operators_1.filter)((a) => a.payload.batchId === batchId)))), (0, operators_1.switchMap)(() => zeniAPI
|
|
59
28
|
.getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/${batchId}`)
|
|
60
29
|
.pipe((0, operators_1.mergeMap)((response) => {
|
|
61
30
|
/** Same batch-details URL; polls until `status` is completed (Pusher may win first). */
|
|
@@ -73,16 +42,6 @@ const pollBulkUploadBatchStatusEpic = (actions$, _state$, zeniAPI) => actions$.p
|
|
|
73
42
|
}
|
|
74
43
|
}
|
|
75
44
|
return rxjs_1.EMPTY;
|
|
76
|
-
}), (0, operators_1.catchError)(() =>
|
|
77
|
-
if (!pollErrorNotified) {
|
|
78
|
-
pollErrorNotified = true;
|
|
79
|
-
return (0, rxjs_1.of)((0, snackbarReducer_1.openSnackbar)({
|
|
80
|
-
messageSection: 'receipts_upload',
|
|
81
|
-
messageText: 'failed',
|
|
82
|
-
type: 'error',
|
|
83
|
-
}));
|
|
84
|
-
}
|
|
85
|
-
return rxjs_1.EMPTY;
|
|
86
|
-
}))));
|
|
45
|
+
}), (0, operators_1.catchError)(() => (0, rxjs_1.of)()))));
|
|
87
46
|
}));
|
|
88
47
|
exports.pollBulkUploadBatchStatusEpic = pollBulkUploadBatchStatusEpic;
|
|
@@ -3,7 +3,7 @@ import { TransactionPayload } from '../../../entity/transaction/payloadTypes/tra
|
|
|
3
3
|
import { SupportedTransactionPayload } from '../../../entity/transaction/transactionState';
|
|
4
4
|
import { ZeniAPIResponse } from '../../../responsePayload';
|
|
5
5
|
import type { MonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
|
|
6
|
-
import {
|
|
6
|
+
import type { BatchDetails, BatchFile, BatchListItem, BatchStatus, BatchSummary, ManualSearchResult } from '../types/missingReceiptsViewState';
|
|
7
7
|
export interface MissingReceiptsQueryPayload {
|
|
8
8
|
end_date: string;
|
|
9
9
|
is_attachment_missing_only: boolean;
|
|
@@ -54,11 +54,6 @@ export interface MatchedTransactionPayload {
|
|
|
54
54
|
export interface MatchCandidatePayload extends MatchedTransactionPayload {
|
|
55
55
|
match_score: number;
|
|
56
56
|
}
|
|
57
|
-
/**
|
|
58
|
-
* Wire payload for a batch file row. `status` may use legacy aliases (`matched`, `un_matched`,
|
|
59
|
-
* `possible_match`, `possible_matches`, etc.) until the backend is fully migrated; canonical
|
|
60
|
-
* values are applied in {@link parseBatchFileStatus} via {@link toBatchFile}.
|
|
61
|
-
*/
|
|
62
57
|
export interface BatchFilePayload {
|
|
63
58
|
attachment_id: string;
|
|
64
59
|
file_id: string;
|
|
@@ -83,12 +78,6 @@ export interface BatchDetailsResponsePayload {
|
|
|
83
78
|
};
|
|
84
79
|
}
|
|
85
80
|
export type BatchDetailsResponse = ZeniAPIResponse<BatchDetailsResponsePayload>;
|
|
86
|
-
/**
|
|
87
|
-
* Maps batch-details API `files[].status` strings to canonical {@link BatchFileStatus}.
|
|
88
|
-
* Legacy aliases are supported during rollout; unknown strings map to `failed` so Redux never
|
|
89
|
-
* holds untyped status values.
|
|
90
|
-
*/
|
|
91
|
-
export declare function parseBatchFileStatus(raw: string): BatchFileStatus;
|
|
92
81
|
export declare function toBatchFile(payload: BatchFilePayload, filesEndPoint?: string): BatchFile;
|
|
93
82
|
export declare function extractTransactionPayloadsFromBatchFiles(files: BatchFilePayload[]): SupportedTransactionPayload[];
|
|
94
83
|
export declare function toBatchSummary(payload: BatchDetailsResponsePayload['summary']): BatchSummary;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseBatchFileStatus = parseBatchFileStatus;
|
|
4
3
|
exports.toBatchFile = toBatchFile;
|
|
5
4
|
exports.extractTransactionPayloadsFromBatchFiles = extractTransactionPayloadsFromBatchFiles;
|
|
6
5
|
exports.toBatchSummary = toBatchSummary;
|
|
@@ -13,42 +12,14 @@ exports.shouldFetchBatchDetailsForBatchId = shouldFetchBatchDetailsForBatchId;
|
|
|
13
12
|
exports.toBatchListItem = toBatchListItem;
|
|
14
13
|
exports.supportedTransactionPayloadToManualSearchResult = supportedTransactionPayloadToManualSearchResult;
|
|
15
14
|
const urlPayload_1 = require("../../../commonPayloadTypes/urlPayload");
|
|
16
|
-
const amount_1 = require("../../../commonStateTypes/amount");
|
|
17
15
|
const transactionPayload_1 = require("../../../entity/transaction/payloadTypes/transactionPayload");
|
|
18
|
-
const missingReceiptsViewState_1 = require("../types/missingReceiptsViewState");
|
|
19
16
|
// -- Converter functions --
|
|
20
|
-
/**
|
|
21
|
-
* Maps batch-details API `files[].status` strings to canonical {@link BatchFileStatus}.
|
|
22
|
-
* Legacy aliases are supported during rollout; unknown strings map to `failed` so Redux never
|
|
23
|
-
* holds untyped status values.
|
|
24
|
-
*/
|
|
25
|
-
function parseBatchFileStatus(raw) {
|
|
26
|
-
const normalizedStatus = raw.trim().toLowerCase().replace(/-/g, '_');
|
|
27
|
-
switch (normalizedStatus) {
|
|
28
|
-
case 'exact_match':
|
|
29
|
-
case 'matched':
|
|
30
|
-
return 'exact_match';
|
|
31
|
-
case 'possible_matches':
|
|
32
|
-
case 'possible_match':
|
|
33
|
-
case 'possiblematch':
|
|
34
|
-
case 'un_matched':
|
|
35
|
-
case 'unmatched':
|
|
36
|
-
return 'possible_matches';
|
|
37
|
-
case 'no_match':
|
|
38
|
-
case 'nomatch':
|
|
39
|
-
return 'no_match';
|
|
40
|
-
case 'failed':
|
|
41
|
-
return 'failed';
|
|
42
|
-
default:
|
|
43
|
-
return 'failed';
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
17
|
function toBatchFile(payload, filesEndPoint) {
|
|
47
18
|
return {
|
|
48
19
|
attachmentId: payload.attachment_id,
|
|
49
|
-
candidates: payload.candidates?.map((
|
|
50
|
-
transactionId:
|
|
51
|
-
matchScore:
|
|
20
|
+
candidates: payload.candidates?.map((c) => ({
|
|
21
|
+
transactionId: c.transaction_id,
|
|
22
|
+
matchScore: c.match_score,
|
|
52
23
|
})),
|
|
53
24
|
fileDownloadUrl: payload.file_id != null && filesEndPoint != null
|
|
54
25
|
? `${filesEndPoint}/1.0/files/${payload.file_id}?query=${encodeURIComponent(JSON.stringify({ download_file: true }))}`
|
|
@@ -56,11 +27,9 @@ function toBatchFile(payload, filesEndPoint) {
|
|
|
56
27
|
fileId: payload.file_id,
|
|
57
28
|
filePreviewUrl: payload.file_preview_url,
|
|
58
29
|
filename: payload.filename,
|
|
59
|
-
matchSource: payload.match_source
|
|
60
|
-
? (0, missingReceiptsViewState_1.toMatchSource)(payload.match_source)
|
|
61
|
-
: undefined,
|
|
30
|
+
matchSource: payload.match_source,
|
|
62
31
|
matchedTransactionId: payload.matched_transaction?.transaction_id,
|
|
63
|
-
status:
|
|
32
|
+
status: payload.status,
|
|
64
33
|
};
|
|
65
34
|
}
|
|
66
35
|
function extractTransactionPayloadsFromBatchFiles(files) {
|
|
@@ -110,8 +79,8 @@ function toBatchDetails(payload, filesEndPoint) {
|
|
|
110
79
|
return {
|
|
111
80
|
batchId: payload.batch_id,
|
|
112
81
|
createdAt: payload.created_at,
|
|
113
|
-
files: payload.files.map((
|
|
114
|
-
status:
|
|
82
|
+
files: payload.files.map((f) => toBatchFile(f, filesEndPoint)),
|
|
83
|
+
status: payload.status,
|
|
115
84
|
summary: toBatchSummary(payload.summary),
|
|
116
85
|
};
|
|
117
86
|
}
|
|
@@ -125,7 +94,7 @@ function isBatchListStatusCompleted(status) {
|
|
|
125
94
|
* statuses for UI; only `completed` rows should trigger batch-details requests.
|
|
126
95
|
*/
|
|
127
96
|
function filterBatchListItemsForBatchDetailsFetch(batches) {
|
|
128
|
-
return batches.filter((
|
|
97
|
+
return batches.filter((b) => isBatchListStatusCompleted(b.status));
|
|
129
98
|
}
|
|
130
99
|
/**
|
|
131
100
|
* Batch details API response `status` field — only completed payloads should be stored from
|
|
@@ -136,7 +105,7 @@ function isBatchDetailsApiStatusCompleted(status) {
|
|
|
136
105
|
}
|
|
137
106
|
function findBatchListItemForBatchId(batchListByPeriod, batchId) {
|
|
138
107
|
for (const list of Object.values(batchListByPeriod)) {
|
|
139
|
-
const found = list.find((
|
|
108
|
+
const found = list.find((b) => b.batchId === batchId);
|
|
140
109
|
if (found != null) {
|
|
141
110
|
return found;
|
|
142
111
|
}
|
|
@@ -174,21 +143,9 @@ function toBatchListItem(payload) {
|
|
|
174
143
|
totalFiles: payload.total_files,
|
|
175
144
|
};
|
|
176
145
|
}
|
|
177
|
-
/**
|
|
178
|
-
* Amount shown in the Unmatched tab manual-search list: **first line only** when `lines` exist.
|
|
179
|
-
* Falls back to transaction-level totals via {@link getTransactionPayloadAmount} when there is
|
|
180
|
-
* no line or no line amount (same currency fields as the rest of the transaction payload).
|
|
181
|
-
*/
|
|
182
|
-
function getManualSearchListAmountFromPayload(payload) {
|
|
183
|
-
const lineAmount = payload.lines?.[0]?.amount;
|
|
184
|
-
if (lineAmount != null) {
|
|
185
|
-
return (0, amount_1.toAmount)(lineAmount, payload.currency_code, payload.currency_symbol);
|
|
186
|
-
}
|
|
187
|
-
return (0, transactionPayload_1.getTransactionPayloadAmount)(payload);
|
|
188
|
-
}
|
|
189
146
|
/** Maps expense-automation transaction rows to manual-search list rows (Unmatched tab). */
|
|
190
147
|
function supportedTransactionPayloadToManualSearchResult(payload) {
|
|
191
|
-
const amountPayload =
|
|
148
|
+
const amountPayload = (0, transactionPayload_1.getTransactionPayloadAmount)(payload);
|
|
192
149
|
return {
|
|
193
150
|
amount: amountPayload.amount,
|
|
194
151
|
currencyCode: amountPayload.currencyCode,
|
|
@@ -5,13 +5,11 @@ import { MonthYearPeriod, TimePeriod } from '../../../commonStateTypes/timePerio
|
|
|
5
5
|
import { TransactionPayload } from '../../../entity/transaction/payloadTypes/transactionPayload';
|
|
6
6
|
import { SupportedTransactionPayload } from '../../../entity/transaction/transactionState';
|
|
7
7
|
import { ZeniAPIStatus } from '../../../responsePayload';
|
|
8
|
-
import {
|
|
8
|
+
import type { BatchDetails, BatchListItem, BatchStatus, BulkUploadResultsTab, BulkUploadSortKey, BulkUploadState, CompletedSubTab, ManualSearchResult, MissingReceiptsViewState, MissingReceiptsViewUIState } from '../types/missingReceiptsViewState';
|
|
9
9
|
import type { MonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
|
|
10
10
|
export declare const getCompletedTransactionsCacheKey: (periodId: MonthYearPeriodId, sortKey: BulkUploadSortKey, sortOrder: SortOrder, subTab: CompletedSubTab) => string;
|
|
11
11
|
export declare const initialBulkUploadState: BulkUploadState;
|
|
12
12
|
export declare const initialState: MissingReceiptsViewState;
|
|
13
|
-
/** Epic trigger only; batch-details fetch is handled in epics. */
|
|
14
|
-
export declare const fetchBulkUploadBatchDetails: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationMissingReceiptsView/fetchBulkUploadBatchDetails">;
|
|
15
13
|
export declare const fetchMissingReceipts: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[period: TimePeriod, minimumTransactionAmount: Amount, cacheOverride?: any, refreshViewInBackground?: any], {
|
|
16
14
|
period: TimePeriod;
|
|
17
15
|
minimumTransactionAmount: Amount;
|
|
@@ -38,15 +36,11 @@ export declare const fetchMissingReceipts: import("@reduxjs/toolkit").ActionCrea
|
|
|
38
36
|
batchId: ID;
|
|
39
37
|
}, "expenseAutomationMissingReceiptsView/bulkUploadReceiptsSuccess">, bulkUploadReceiptsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
40
38
|
error: ZeniAPIStatus;
|
|
41
|
-
}, "expenseAutomationMissingReceiptsView/bulkUploadReceiptsFailure">,
|
|
42
|
-
batchId: string;
|
|
43
|
-
}, "expenseAutomationMissingReceiptsView/bulkUploadAutomatchingTimedOut", never, never>, pusherBatchStatusUpdate: import("@reduxjs/toolkit").ActionCreatorWithPayload<BatchStatus, "expenseAutomationMissingReceiptsView/pusherBatchStatusUpdate">, requestMissingReceiptsTabNavigation: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
39
|
+
}, "expenseAutomationMissingReceiptsView/bulkUploadReceiptsFailure">, pusherBatchStatusUpdate: import("@reduxjs/toolkit").ActionCreatorWithPayload<BatchStatus, "expenseAutomationMissingReceiptsView/pusherBatchStatusUpdate">, requestMissingReceiptsTabNavigation: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
44
40
|
tab: BulkUploadResultsTab;
|
|
45
|
-
}, "expenseAutomationMissingReceiptsView/requestMissingReceiptsTabNavigation">, clearMissingReceiptsTabNavigation: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationMissingReceiptsView/clearMissingReceiptsTabNavigation">, fetchBulkUploadBatchDetailsSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<BatchDetails, "expenseAutomationMissingReceiptsView/fetchBulkUploadBatchDetailsSuccess">, fetchBulkUploadBatchDetailsFailure: import("@reduxjs/toolkit").
|
|
46
|
-
error: ZeniAPIStatus;
|
|
47
|
-
}], {
|
|
41
|
+
}, "expenseAutomationMissingReceiptsView/requestMissingReceiptsTabNavigation">, clearMissingReceiptsTabNavigation: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationMissingReceiptsView/clearMissingReceiptsTabNavigation">, fetchBulkUploadBatchDetails: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationMissingReceiptsView/fetchBulkUploadBatchDetails">, fetchBulkUploadBatchDetailsSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<BatchDetails, "expenseAutomationMissingReceiptsView/fetchBulkUploadBatchDetailsSuccess">, fetchBulkUploadBatchDetailsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
48
42
|
error: ZeniAPIStatus;
|
|
49
|
-
}, "expenseAutomationMissingReceiptsView/fetchBulkUploadBatchDetailsFailure"
|
|
43
|
+
}, "expenseAutomationMissingReceiptsView/fetchBulkUploadBatchDetailsFailure">, storeBatchDetails: import("@reduxjs/toolkit").ActionCreatorWithPayload<BatchDetails, "expenseAutomationMissingReceiptsView/storeBatchDetails">, batchDetailFetchFailed: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
50
44
|
batchId: ID;
|
|
51
45
|
}, "expenseAutomationMissingReceiptsView/batchDetailFetchFailed">, setInitialBatchDetailsLoading: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationMissingReceiptsView/setInitialBatchDetailsLoading">, fetchMoreBatchDetails: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationMissingReceiptsView/fetchMoreBatchDetails">, fetchMoreBatchDetailsComplete: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationMissingReceiptsView/fetchMoreBatchDetailsComplete">, fetchMoreBatchDetailsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
52
46
|
error: ZeniAPIStatus;
|
|
@@ -74,7 +68,7 @@ export declare const fetchMissingReceipts: import("@reduxjs/toolkit").ActionCrea
|
|
|
74
68
|
transactionId: ID;
|
|
75
69
|
}, "expenseAutomationMissingReceiptsView/confirmBulkUploadMatchSuccess">, confirmBulkUploadMatchFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
76
70
|
error: ZeniAPIStatus;
|
|
77
|
-
}, "expenseAutomationMissingReceiptsView/confirmBulkUploadMatchFailure">, setBulkUploadResultsTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<
|
|
71
|
+
}, "expenseAutomationMissingReceiptsView/confirmBulkUploadMatchFailure">, setBulkUploadResultsTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<BulkUploadResultsTab, "expenseAutomationMissingReceiptsView/setBulkUploadResultsTab">, setBulkUploadCompletedSubTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<CompletedSubTab, "expenseAutomationMissingReceiptsView/setBulkUploadCompletedSubTab">, setBulkUploadSortConfig: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
78
72
|
sortKey: BulkUploadSortKey;
|
|
79
73
|
sortOrder: SortOrder;
|
|
80
74
|
}, "expenseAutomationMissingReceiptsView/setBulkUploadSortConfig">, clearBulkUpload: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationMissingReceiptsView/clearBulkUpload">, searchTransactionsForManualMatch: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[query: string, pageToken?: string | null | undefined], {
|
|
@@ -1,10 +1,9 @@
|
|
|
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.
|
|
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;
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
6
|
const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
|
|
7
|
-
const missingReceiptsViewState_1 = require("../types/missingReceiptsViewState");
|
|
8
7
|
const getCompletedTransactionsCacheKey = (periodId, sortKey, sortOrder, subTab) => `completed-${subTab}-${sortKey}-${sortOrder === 'ascending' ? 'asc' : 'desc'}-${periodId}`;
|
|
9
8
|
exports.getCompletedTransactionsCacheKey = getCompletedTransactionsCacheKey;
|
|
10
9
|
exports.initialBulkUploadState = {
|
|
@@ -56,8 +55,6 @@ exports.initialState = {
|
|
|
56
55
|
return this.fetchState == 'Completed';
|
|
57
56
|
},
|
|
58
57
|
};
|
|
59
|
-
/** Epic trigger only; batch-details fetch is handled in epics. */
|
|
60
|
-
exports.fetchBulkUploadBatchDetails = (0, toolkit_1.createAction)('expenseAutomationMissingReceiptsView/fetchBulkUploadBatchDetails');
|
|
61
58
|
const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
|
|
62
59
|
name: 'expenseAutomationMissingReceiptsView',
|
|
63
60
|
initialState: exports.initialState,
|
|
@@ -161,7 +158,8 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
|
|
|
161
158
|
},
|
|
162
159
|
// -- Bulk Upload Actions --
|
|
163
160
|
bulkUploadReceipts: {
|
|
164
|
-
|
|
161
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
162
|
+
reducer(draft, _action) {
|
|
165
163
|
draft.bulkUpload.phase = 'uploading';
|
|
166
164
|
draft.bulkUpload.uploadProgress = 0;
|
|
167
165
|
draft.bulkUpload.uploadStatus = {
|
|
@@ -178,7 +176,6 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
|
|
|
178
176
|
},
|
|
179
177
|
bulkUploadReceiptsSuccess(draft, action) {
|
|
180
178
|
draft.bulkUpload.currentBatchId = action.payload.batchId;
|
|
181
|
-
draft.bulkUpload.uploadProgress = 100;
|
|
182
179
|
draft.bulkUpload.uploadStatus = {
|
|
183
180
|
fetchState: 'Completed',
|
|
184
181
|
error: undefined,
|
|
@@ -192,18 +189,6 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
|
|
|
192
189
|
};
|
|
193
190
|
draft.bulkUpload.phase = 'idle';
|
|
194
191
|
},
|
|
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
192
|
pusherBatchStatusUpdate(draft, action) {
|
|
208
193
|
const batchStatus = action.payload;
|
|
209
194
|
draft.bulkUpload.batchStatusById[batchStatus.batchId] = batchStatus;
|
|
@@ -224,18 +209,18 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
|
|
|
224
209
|
clearMissingReceiptsTabNavigation(draft) {
|
|
225
210
|
draft.pendingMissingReceiptsTabNavigation = null;
|
|
226
211
|
},
|
|
212
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
213
|
+
fetchBulkUploadBatchDetails(_draft) {
|
|
214
|
+
// trigger epic, no state change needed
|
|
215
|
+
},
|
|
227
216
|
fetchBulkUploadBatchDetailsSuccess(draft, action) {
|
|
228
217
|
const details = action.payload;
|
|
229
218
|
draft.bulkUpload.batchDetailsById[details.batchId] = details;
|
|
230
219
|
draft.bulkUpload.phase = 'completed';
|
|
231
220
|
},
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
},
|
|
236
|
-
prepare(payload) {
|
|
237
|
-
return { payload };
|
|
238
|
-
},
|
|
221
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
222
|
+
fetchBulkUploadBatchDetailsFailure(draft, _action) {
|
|
223
|
+
draft.bulkUpload.phase = 'completed';
|
|
239
224
|
},
|
|
240
225
|
storeBatchDetails(draft, action) {
|
|
241
226
|
const details = action.payload;
|
|
@@ -266,8 +251,8 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
|
|
|
266
251
|
error: undefined,
|
|
267
252
|
};
|
|
268
253
|
},
|
|
269
|
-
fetchMoreBatchDetails(
|
|
270
|
-
|
|
254
|
+
fetchMoreBatchDetails(_draft) {
|
|
255
|
+
_draft.bulkUpload.batchDetailsPaginationState = {
|
|
271
256
|
fetchState: 'In-Progress',
|
|
272
257
|
error: undefined,
|
|
273
258
|
};
|
|
@@ -305,11 +290,11 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
|
|
|
305
290
|
};
|
|
306
291
|
},
|
|
307
292
|
prepare(input) {
|
|
308
|
-
const
|
|
293
|
+
const o = input ?? {};
|
|
309
294
|
return {
|
|
310
295
|
payload: {
|
|
311
|
-
cacheOverride:
|
|
312
|
-
invalidateBatchDetailsCache:
|
|
296
|
+
cacheOverride: o.cacheOverride === true,
|
|
297
|
+
invalidateBatchDetailsCache: o.invalidateBatchDetailsCache === true,
|
|
313
298
|
},
|
|
314
299
|
};
|
|
315
300
|
},
|
|
@@ -343,7 +328,8 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
|
|
|
343
328
|
};
|
|
344
329
|
},
|
|
345
330
|
confirmBulkUploadMatch: {
|
|
346
|
-
|
|
331
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
332
|
+
reducer(draft, _action) {
|
|
347
333
|
draft.bulkUpload.confirmMatchStatus = {
|
|
348
334
|
fetchState: 'In-Progress',
|
|
349
335
|
error: undefined,
|
|
@@ -361,17 +347,17 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
|
|
|
361
347
|
};
|
|
362
348
|
const details = draft.bulkUpload.batchDetailsById[batchId];
|
|
363
349
|
if (details != null) {
|
|
364
|
-
const file = details.files.find((
|
|
350
|
+
const file = details.files.find((f) => f.attachmentId === attachmentId);
|
|
365
351
|
if (file != null) {
|
|
366
352
|
const originalStatus = file.status;
|
|
367
|
-
file.status = '
|
|
353
|
+
file.status = 'matched';
|
|
368
354
|
file.matchedTransactionId = transactionId;
|
|
369
355
|
file.candidates = undefined;
|
|
370
356
|
details.summary.matched += 1;
|
|
371
357
|
if (originalStatus === 'no_match') {
|
|
372
358
|
details.summary.noMatch = Math.max(0, details.summary.noMatch - 1);
|
|
373
359
|
}
|
|
374
|
-
else
|
|
360
|
+
else {
|
|
375
361
|
details.summary.possibleMatches = Math.max(0, details.summary.possibleMatches - 1);
|
|
376
362
|
}
|
|
377
363
|
}
|
|
@@ -403,24 +389,6 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
|
|
|
403
389
|
reducer(draft, action) {
|
|
404
390
|
const { query, pageToken } = action.payload;
|
|
405
391
|
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
392
|
draft.bulkUpload.manualSearch.searchQuery = query;
|
|
425
393
|
if (isLoadMore) {
|
|
426
394
|
draft.bulkUpload.manualSearch.isLoadingMore = true;
|
|
@@ -444,7 +412,7 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
|
|
|
444
412
|
const { append, nextPageToken, results, totalCount } = action.payload;
|
|
445
413
|
if (append) {
|
|
446
414
|
const merged = [...draft.bulkUpload.manualSearch.results, ...results];
|
|
447
|
-
const byId = new Map(merged.map((
|
|
415
|
+
const byId = new Map(merged.map((r) => [r.transactionId, r]));
|
|
448
416
|
draft.bulkUpload.manualSearch.results = Array.from(byId.values());
|
|
449
417
|
}
|
|
450
418
|
else {
|
|
@@ -549,7 +517,7 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
|
|
|
549
517
|
});
|
|
550
518
|
_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
519
|
// Bulk Upload
|
|
552
|
-
exports.bulkUploadReceipts = _a.bulkUploadReceipts, exports.updateBulkUploadProgress = _a.updateBulkUploadProgress, exports.bulkUploadReceiptsSuccess = _a.bulkUploadReceiptsSuccess, exports.bulkUploadReceiptsFailure = _a.bulkUploadReceiptsFailure, exports.
|
|
520
|
+
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,
|
|
553
521
|
// Completed Transactions
|
|
554
522
|
exports.fetchCompletedTransactions = _a.fetchCompletedTransactions, exports.fetchCompletedTransactionsSuccess = _a.fetchCompletedTransactionsSuccess, exports.fetchCompletedTransactionsFailure = _a.fetchCompletedTransactionsFailure;
|
|
555
523
|
exports.default = expenseAutomationMissingReceiptsView.reducer;
|