@zeniai/client-epic-state 4.19.37-betaVR19 → 4.19.37-betaVR21
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/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +65 -24
- package/lib/esm/view/expenseAutomationView/payload/missingReceiptsPayload.js +10 -6
- package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +35 -9
- package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +11 -1
- package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.d.ts +11 -3
- package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +63 -22
- package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.d.ts +2 -19
- package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.js +11 -7
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +8 -2
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +35 -9
- package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +11 -1
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +7 -0
- package/package.json +1 -1
|
@@ -1,27 +1,68 @@
|
|
|
1
|
-
import { of } from 'rxjs';
|
|
2
|
-
import { catchError, debounceTime, filter, switchMap } from 'rxjs/operators';
|
|
1
|
+
import { from, merge, of } from 'rxjs';
|
|
2
|
+
import { catchError, debounceTime, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
|
+
import { convertToPeriod } from '../../../../commonStateTypes/timePeriod';
|
|
4
|
+
import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
|
|
5
|
+
import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
|
|
3
6
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
4
|
-
import {
|
|
7
|
+
import { supportedTransactionPayloadToManualSearchResult } from '../../payload/missingReceiptsPayload';
|
|
5
8
|
import { searchTransactionsForManualMatch, searchTransactionsForManualMatchFailure, searchTransactionsForManualMatchSuccess, } from '../../reducers/missingReceiptsViewReducer';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
import { toTransactionsSortKey } from '../../types/transactionsViewState';
|
|
10
|
+
/**
|
|
11
|
+
* `auto_categorized` for manual transaction search (Unmatched).
|
|
12
|
+
* Backend contract TBD — align with `fetchTransactionCategorizationEpic` (`selectedTab === 'autoCategorized'`)
|
|
13
|
+
* when the expense-automation API documents the intended filter for this flow.
|
|
14
|
+
*/
|
|
15
|
+
export const MANUAL_TRANSACTION_SEARCH_AUTO_CATEGORIZED = false;
|
|
16
|
+
export const searchTransactionsForManualMatchEpic = (actions$, state$, zeniAPI) => {
|
|
17
|
+
const searchActions$ = actions$.pipe(filter(searchTransactionsForManualMatch.match));
|
|
18
|
+
const pagination$ = searchActions$.pipe(filter((a) => a.payload.pageToken != null));
|
|
19
|
+
const newSearch$ = searchActions$.pipe(filter((a) => a.payload.pageToken == null), debounceTime(300));
|
|
20
|
+
return merge(pagination$, newSearch$).pipe(switchMap((action) => {
|
|
21
|
+
const { query, pageToken } = action.payload;
|
|
22
|
+
const state = state$.value;
|
|
23
|
+
const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload: { manualSearch, sortKey, sortOrder }, }, } = state;
|
|
24
|
+
const currentTenant = getCurrentTenant(state);
|
|
25
|
+
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
26
|
+
if (selectedPeriod == null) {
|
|
27
|
+
return of(searchTransactionsForManualMatchFailure({
|
|
28
|
+
error: createZeniAPIStatus('Unexpected Error', 'Manual search requires a selected accounting period.'),
|
|
29
|
+
}));
|
|
19
30
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
const period = convertToPeriod(selectedPeriod);
|
|
32
|
+
const queryParam = {
|
|
33
|
+
start_date: period.start,
|
|
34
|
+
end_date: period.end,
|
|
35
|
+
auto_categorized: MANUAL_TRANSACTION_SEARCH_AUTO_CATEGORIZED,
|
|
36
|
+
sort_by: toTransactionsSortKey(sortKey),
|
|
37
|
+
sort_order: sortOrder === 'ascending' ? 'asc' : 'desc',
|
|
38
|
+
page_token: pageToken ?? null,
|
|
39
|
+
page_size: manualSearch.pageSize,
|
|
40
|
+
search_text: query,
|
|
41
|
+
};
|
|
42
|
+
return zeniAPI
|
|
43
|
+
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/transactions?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
44
|
+
.pipe(mergeMap((response) => {
|
|
45
|
+
if (isSuccessResponse(response) && response.data != null) {
|
|
46
|
+
const { transactions, next_page_token, total_count } = response.data;
|
|
47
|
+
const append = pageToken != null;
|
|
48
|
+
const results = transactions.map(supportedTransactionPayloadToManualSearchResult);
|
|
49
|
+
const actionsOut = [
|
|
50
|
+
updateTransactions(transactions, (value) => value.transaction_id, 'merge'),
|
|
51
|
+
searchTransactionsForManualMatchSuccess({
|
|
52
|
+
append,
|
|
53
|
+
nextPageToken: next_page_token ?? null,
|
|
54
|
+
results,
|
|
55
|
+
totalCount: total_count,
|
|
56
|
+
}),
|
|
57
|
+
];
|
|
58
|
+
return from(actionsOut);
|
|
59
|
+
}
|
|
60
|
+
return of(searchTransactionsForManualMatchFailure({
|
|
61
|
+
error: response.status,
|
|
62
|
+
}));
|
|
63
|
+
}), catchError((error) => of(searchTransactionsForManualMatchFailure({
|
|
64
|
+
error: createZeniAPIStatus('Unexpected Error', 'Search transactions for manual match errored: ' +
|
|
65
|
+
JSON.stringify(error)),
|
|
66
|
+
}))));
|
|
67
|
+
}));
|
|
68
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { toURL } from '../../../commonPayloadTypes/urlPayload';
|
|
2
|
+
import { getTransactionPayloadAmount, } from '../../../entity/transaction/payloadTypes/transactionPayload';
|
|
2
3
|
// -- Converter functions --
|
|
3
4
|
export function toBatchFile(payload, filesEndPoint) {
|
|
4
5
|
return {
|
|
@@ -86,15 +87,18 @@ export function toBatchListItem(payload) {
|
|
|
86
87
|
totalFiles: payload.total_files,
|
|
87
88
|
};
|
|
88
89
|
}
|
|
89
|
-
|
|
90
|
+
/** Maps expense-automation transaction rows to manual-search list rows (Unmatched tab). */
|
|
91
|
+
export function supportedTransactionPayloadToManualSearchResult(payload) {
|
|
92
|
+
const amountPayload = getTransactionPayloadAmount(payload);
|
|
90
93
|
return {
|
|
91
|
-
amount:
|
|
92
|
-
currencyCode:
|
|
93
|
-
entityId: payload.
|
|
94
|
-
memo: payload.
|
|
94
|
+
amount: amountPayload.amount,
|
|
95
|
+
currencyCode: amountPayload.currencyCode,
|
|
96
|
+
entityId: payload.vendor_id ?? payload.customer_id ?? '',
|
|
97
|
+
memo: payload.transaction_memo ?? '',
|
|
95
98
|
transactionDate: payload.transaction_date,
|
|
96
99
|
transactionId: payload.transaction_id,
|
|
97
100
|
transactionType: payload.transaction_type,
|
|
98
|
-
vendorName: payload.vendor_name,
|
|
101
|
+
vendorName: payload.vendor_name ?? '',
|
|
102
|
+
vendorLogo: toURL(payload.logo)?.href,
|
|
99
103
|
};
|
|
100
104
|
}
|
|
@@ -15,8 +15,12 @@ export const initialBulkUploadState = {
|
|
|
15
15
|
failedBatchDetailIds: [],
|
|
16
16
|
manualSearch: {
|
|
17
17
|
fetchState: { fetchState: 'Not-Started', error: undefined },
|
|
18
|
+
isLoadingMore: false,
|
|
19
|
+
nextPageToken: null,
|
|
20
|
+
pageSize: 25,
|
|
18
21
|
results: [],
|
|
19
22
|
searchQuery: '',
|
|
23
|
+
totalCount: 0,
|
|
20
24
|
},
|
|
21
25
|
phase: 'idle',
|
|
22
26
|
sortKey: 'date',
|
|
@@ -342,25 +346,47 @@ const expenseAutomationMissingReceiptsView = createSlice({
|
|
|
342
346
|
},
|
|
343
347
|
searchTransactionsForManualMatch: {
|
|
344
348
|
reducer(draft, action) {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
349
|
+
const { query, pageToken } = action.payload;
|
|
350
|
+
const isLoadMore = pageToken != null;
|
|
351
|
+
draft.bulkUpload.manualSearch.searchQuery = query;
|
|
352
|
+
if (isLoadMore) {
|
|
353
|
+
draft.bulkUpload.manualSearch.isLoadingMore = true;
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
draft.bulkUpload.manualSearch.isLoadingMore = false;
|
|
357
|
+
draft.bulkUpload.manualSearch.results = [];
|
|
358
|
+
draft.bulkUpload.manualSearch.nextPageToken = null;
|
|
359
|
+
draft.bulkUpload.manualSearch.totalCount = 0;
|
|
360
|
+
draft.bulkUpload.manualSearch.fetchState = {
|
|
361
|
+
fetchState: 'In-Progress',
|
|
362
|
+
error: undefined,
|
|
363
|
+
};
|
|
364
|
+
}
|
|
351
365
|
},
|
|
352
|
-
prepare(query) {
|
|
353
|
-
return { payload: { query } };
|
|
366
|
+
prepare(query, pageToken) {
|
|
367
|
+
return { payload: { query, pageToken: pageToken ?? undefined } };
|
|
354
368
|
},
|
|
355
369
|
},
|
|
356
370
|
searchTransactionsForManualMatchSuccess(draft, action) {
|
|
357
|
-
|
|
371
|
+
const { append, nextPageToken, results, totalCount } = action.payload;
|
|
372
|
+
if (append) {
|
|
373
|
+
const merged = [...draft.bulkUpload.manualSearch.results, ...results];
|
|
374
|
+
const byId = new Map(merged.map((r) => [r.transactionId, r]));
|
|
375
|
+
draft.bulkUpload.manualSearch.results = Array.from(byId.values());
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
draft.bulkUpload.manualSearch.results = results;
|
|
379
|
+
}
|
|
380
|
+
draft.bulkUpload.manualSearch.nextPageToken = nextPageToken;
|
|
381
|
+
draft.bulkUpload.manualSearch.totalCount = totalCount;
|
|
382
|
+
draft.bulkUpload.manualSearch.isLoadingMore = false;
|
|
358
383
|
draft.bulkUpload.manualSearch.fetchState = {
|
|
359
384
|
fetchState: 'Completed',
|
|
360
385
|
error: undefined,
|
|
361
386
|
};
|
|
362
387
|
},
|
|
363
388
|
searchTransactionsForManualMatchFailure(draft, action) {
|
|
389
|
+
draft.bulkUpload.manualSearch.isLoadingMore = false;
|
|
364
390
|
draft.bulkUpload.manualSearch.fetchState = {
|
|
365
391
|
fetchState: 'Error',
|
|
366
392
|
error: action.payload.error,
|
|
@@ -148,6 +148,13 @@ export function getExpenseAutomationMissingReceiptsView(state) {
|
|
|
148
148
|
summary: currentBatchDetails.summary,
|
|
149
149
|
}
|
|
150
150
|
: undefined;
|
|
151
|
+
const manualSearchResults = bulkUpload.manualSearch.results.map((r) => {
|
|
152
|
+
const t = getSupportedTransactionById(transactionState, r.transactionId);
|
|
153
|
+
return {
|
|
154
|
+
...r,
|
|
155
|
+
vendorLogo: r.vendorLogo ?? t?.logo?.href,
|
|
156
|
+
};
|
|
157
|
+
});
|
|
151
158
|
return {
|
|
152
159
|
fetchState,
|
|
153
160
|
error,
|
|
@@ -185,7 +192,10 @@ export function getExpenseAutomationMissingReceiptsView(state) {
|
|
|
185
192
|
confirmMatchStatus: bulkUpload.confirmMatchStatus,
|
|
186
193
|
hasMoreBatchDetails,
|
|
187
194
|
batchDetailsPaginationState: bulkUpload.batchDetailsPaginationState,
|
|
188
|
-
manualSearch:
|
|
195
|
+
manualSearch: {
|
|
196
|
+
...bulkUpload.manualSearch,
|
|
197
|
+
results: manualSearchResults,
|
|
198
|
+
},
|
|
189
199
|
uploadProgress: bulkUpload.uploadProgress,
|
|
190
200
|
},
|
|
191
201
|
};
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import { ActionsObservable } from 'redux-observable';
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
+
import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
|
|
4
|
+
import { RootState } from '../../../../reducer';
|
|
3
5
|
import { ZeniAPI } from '../../../../zeniAPI';
|
|
4
6
|
import { searchTransactionsForManualMatch, searchTransactionsForManualMatchFailure, searchTransactionsForManualMatchSuccess } from '../../reducers/missingReceiptsViewReducer';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
/**
|
|
8
|
+
* `auto_categorized` for manual transaction search (Unmatched).
|
|
9
|
+
* Backend contract TBD — align with `fetchTransactionCategorizationEpic` (`selectedTab === 'autoCategorized'`)
|
|
10
|
+
* when the expense-automation API documents the intended filter for this flow.
|
|
11
|
+
*/
|
|
12
|
+
export declare const MANUAL_TRANSACTION_SEARCH_AUTO_CATEGORIZED = false;
|
|
13
|
+
export type ActionType = ReturnType<typeof searchTransactionsForManualMatch> | ReturnType<typeof searchTransactionsForManualMatchSuccess> | ReturnType<typeof searchTransactionsForManualMatchFailure> | ReturnType<typeof updateTransactions>;
|
|
14
|
+
export declare const searchTransactionsForManualMatchEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js
CHANGED
|
@@ -1,31 +1,72 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.searchTransactionsForManualMatchEpic = void 0;
|
|
3
|
+
exports.searchTransactionsForManualMatchEpic = exports.MANUAL_TRANSACTION_SEARCH_AUTO_CATEGORIZED = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
|
|
7
|
+
const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
|
|
8
|
+
const transactionReducer_1 = require("../../../../entity/transaction/transactionReducer");
|
|
6
9
|
const responsePayload_1 = require("../../../../responsePayload");
|
|
7
10
|
const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
|
|
8
11
|
const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
const transactionsViewState_1 = require("../../types/transactionsViewState");
|
|
13
|
+
/**
|
|
14
|
+
* `auto_categorized` for manual transaction search (Unmatched).
|
|
15
|
+
* Backend contract TBD — align with `fetchTransactionCategorizationEpic` (`selectedTab === 'autoCategorized'`)
|
|
16
|
+
* when the expense-automation API documents the intended filter for this flow.
|
|
17
|
+
*/
|
|
18
|
+
exports.MANUAL_TRANSACTION_SEARCH_AUTO_CATEGORIZED = false;
|
|
19
|
+
const searchTransactionsForManualMatchEpic = (actions$, state$, zeniAPI) => {
|
|
20
|
+
const searchActions$ = actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.searchTransactionsForManualMatch.match));
|
|
21
|
+
const pagination$ = searchActions$.pipe((0, operators_1.filter)((a) => a.payload.pageToken != null));
|
|
22
|
+
const newSearch$ = searchActions$.pipe((0, operators_1.filter)((a) => a.payload.pageToken == null), (0, operators_1.debounceTime)(300));
|
|
23
|
+
return (0, rxjs_1.merge)(pagination$, newSearch$).pipe((0, operators_1.switchMap)((action) => {
|
|
24
|
+
const { query, pageToken } = action.payload;
|
|
25
|
+
const state = state$.value;
|
|
26
|
+
const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload: { manualSearch, sortKey, sortOrder }, }, } = state;
|
|
27
|
+
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
|
|
28
|
+
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
29
|
+
if (selectedPeriod == null) {
|
|
30
|
+
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.searchTransactionsForManualMatchFailure)({
|
|
31
|
+
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Manual search requires a selected accounting period.'),
|
|
32
|
+
}));
|
|
22
33
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
const period = (0, timePeriod_1.convertToPeriod)(selectedPeriod);
|
|
35
|
+
const queryParam = {
|
|
36
|
+
start_date: period.start,
|
|
37
|
+
end_date: period.end,
|
|
38
|
+
auto_categorized: exports.MANUAL_TRANSACTION_SEARCH_AUTO_CATEGORIZED,
|
|
39
|
+
sort_by: (0, transactionsViewState_1.toTransactionsSortKey)(sortKey),
|
|
40
|
+
sort_order: sortOrder === 'ascending' ? 'asc' : 'desc',
|
|
41
|
+
page_token: pageToken ?? null,
|
|
42
|
+
page_size: manualSearch.pageSize,
|
|
43
|
+
search_text: query,
|
|
44
|
+
};
|
|
45
|
+
return zeniAPI
|
|
46
|
+
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/transactions?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
47
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
48
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
49
|
+
const { transactions, next_page_token, total_count } = response.data;
|
|
50
|
+
const append = pageToken != null;
|
|
51
|
+
const results = transactions.map(missingReceiptsPayload_1.supportedTransactionPayloadToManualSearchResult);
|
|
52
|
+
const actionsOut = [
|
|
53
|
+
(0, transactionReducer_1.updateTransactions)(transactions, (value) => value.transaction_id, 'merge'),
|
|
54
|
+
(0, missingReceiptsViewReducer_1.searchTransactionsForManualMatchSuccess)({
|
|
55
|
+
append,
|
|
56
|
+
nextPageToken: next_page_token ?? null,
|
|
57
|
+
results,
|
|
58
|
+
totalCount: total_count,
|
|
59
|
+
}),
|
|
60
|
+
];
|
|
61
|
+
return (0, rxjs_1.from)(actionsOut);
|
|
62
|
+
}
|
|
63
|
+
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.searchTransactionsForManualMatchFailure)({
|
|
64
|
+
error: response.status,
|
|
65
|
+
}));
|
|
66
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.searchTransactionsForManualMatchFailure)({
|
|
67
|
+
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Search transactions for manual match errored: ' +
|
|
68
|
+
JSON.stringify(error)),
|
|
69
|
+
}))));
|
|
70
|
+
}));
|
|
71
|
+
};
|
|
31
72
|
exports.searchTransactionsForManualMatchEpic = searchTransactionsForManualMatchEpic;
|
|
@@ -84,25 +84,8 @@ export declare function toBatchDetails(payload: BatchDetailsResponsePayload, fil
|
|
|
84
84
|
/** Batch list `status` is a string from the API — compare case-insensitively. */
|
|
85
85
|
export declare function isBatchListStatusCompleted(status: string): boolean;
|
|
86
86
|
export declare function toBatchListItem(payload: BatchListItemPayload): BatchListItem;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
search_fields?: string[];
|
|
90
|
-
}
|
|
91
|
-
export interface TransactionSearchItemPayload {
|
|
92
|
-
amount: number;
|
|
93
|
-
currency: string;
|
|
94
|
-
entity_id: string;
|
|
95
|
-
memo: string;
|
|
96
|
-
transaction_date: string;
|
|
97
|
-
transaction_id: string;
|
|
98
|
-
transaction_type: string;
|
|
99
|
-
vendor_name: string;
|
|
100
|
-
}
|
|
101
|
-
export interface TransactionSearchResponsePayload {
|
|
102
|
-
transactions: TransactionSearchItemPayload[];
|
|
103
|
-
}
|
|
104
|
-
export type TransactionSearchResponse = ZeniAPIResponse<TransactionSearchResponsePayload>;
|
|
105
|
-
export declare function toManualSearchResult(payload: TransactionSearchItemPayload): ManualSearchResult;
|
|
87
|
+
/** Maps expense-automation transaction rows to manual-search list rows (Unmatched tab). */
|
|
88
|
+
export declare function supportedTransactionPayloadToManualSearchResult(payload: SupportedTransactionPayload): ManualSearchResult;
|
|
106
89
|
export interface CompletedTransactionsQueryPayload {
|
|
107
90
|
end_date?: string;
|
|
108
91
|
match_type?: string;
|
|
@@ -6,8 +6,9 @@ exports.toBatchSummary = toBatchSummary;
|
|
|
6
6
|
exports.toBatchDetails = toBatchDetails;
|
|
7
7
|
exports.isBatchListStatusCompleted = isBatchListStatusCompleted;
|
|
8
8
|
exports.toBatchListItem = toBatchListItem;
|
|
9
|
-
exports.
|
|
9
|
+
exports.supportedTransactionPayloadToManualSearchResult = supportedTransactionPayloadToManualSearchResult;
|
|
10
10
|
const urlPayload_1 = require("../../../commonPayloadTypes/urlPayload");
|
|
11
|
+
const transactionPayload_1 = require("../../../entity/transaction/payloadTypes/transactionPayload");
|
|
11
12
|
// -- Converter functions --
|
|
12
13
|
function toBatchFile(payload, filesEndPoint) {
|
|
13
14
|
return {
|
|
@@ -95,15 +96,18 @@ function toBatchListItem(payload) {
|
|
|
95
96
|
totalFiles: payload.total_files,
|
|
96
97
|
};
|
|
97
98
|
}
|
|
98
|
-
|
|
99
|
+
/** Maps expense-automation transaction rows to manual-search list rows (Unmatched tab). */
|
|
100
|
+
function supportedTransactionPayloadToManualSearchResult(payload) {
|
|
101
|
+
const amountPayload = (0, transactionPayload_1.getTransactionPayloadAmount)(payload);
|
|
99
102
|
return {
|
|
100
|
-
amount:
|
|
101
|
-
currencyCode:
|
|
102
|
-
entityId: payload.
|
|
103
|
-
memo: payload.
|
|
103
|
+
amount: amountPayload.amount,
|
|
104
|
+
currencyCode: amountPayload.currencyCode,
|
|
105
|
+
entityId: payload.vendor_id ?? payload.customer_id ?? '',
|
|
106
|
+
memo: payload.transaction_memo ?? '',
|
|
104
107
|
transactionDate: payload.transaction_date,
|
|
105
108
|
transactionId: payload.transaction_id,
|
|
106
109
|
transactionType: payload.transaction_type,
|
|
107
|
-
vendorName: payload.vendor_name,
|
|
110
|
+
vendorName: payload.vendor_name ?? '',
|
|
111
|
+
vendorLogo: (0, urlPayload_1.toURL)(payload.logo)?.href,
|
|
108
112
|
};
|
|
109
113
|
}
|
|
@@ -67,9 +67,15 @@ export declare const fetchMissingReceipts: import("@reduxjs/toolkit").ActionCrea
|
|
|
67
67
|
}, "expenseAutomationMissingReceiptsView/confirmBulkUploadMatchFailure">, setBulkUploadResultsTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<BulkUploadResultsTab, "expenseAutomationMissingReceiptsView/setBulkUploadResultsTab">, setBulkUploadCompletedSubTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<CompletedSubTab, "expenseAutomationMissingReceiptsView/setBulkUploadCompletedSubTab">, setBulkUploadSortConfig: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
68
68
|
sortKey: BulkUploadSortKey;
|
|
69
69
|
sortOrder: SortOrder;
|
|
70
|
-
}, "expenseAutomationMissingReceiptsView/setBulkUploadSortConfig">, clearBulkUpload: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationMissingReceiptsView/clearBulkUpload">, searchTransactionsForManualMatch: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[query: string], {
|
|
70
|
+
}, "expenseAutomationMissingReceiptsView/setBulkUploadSortConfig">, clearBulkUpload: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationMissingReceiptsView/clearBulkUpload">, searchTransactionsForManualMatch: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[query: string, pageToken?: string | null | undefined], {
|
|
71
71
|
query: string;
|
|
72
|
-
|
|
72
|
+
pageToken: string | undefined;
|
|
73
|
+
}, "expenseAutomationMissingReceiptsView/searchTransactionsForManualMatch", never, never>, searchTransactionsForManualMatchSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
74
|
+
append: boolean;
|
|
75
|
+
nextPageToken: string | null;
|
|
76
|
+
results: ManualSearchResult[];
|
|
77
|
+
totalCount: number;
|
|
78
|
+
}, "expenseAutomationMissingReceiptsView/searchTransactionsForManualMatchSuccess">, searchTransactionsForManualMatchFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
73
79
|
error: ZeniAPIStatus;
|
|
74
80
|
}, "expenseAutomationMissingReceiptsView/searchTransactionsForManualMatchFailure">, clearManualSearchResults: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationMissingReceiptsView/clearManualSearchResults">, fetchCompletedTransactions: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[pageToken?: string | undefined, cacheOverride?: boolean | undefined], {
|
|
75
81
|
pageToken: string | undefined;
|
|
@@ -20,8 +20,12 @@ exports.initialBulkUploadState = {
|
|
|
20
20
|
failedBatchDetailIds: [],
|
|
21
21
|
manualSearch: {
|
|
22
22
|
fetchState: { fetchState: 'Not-Started', error: undefined },
|
|
23
|
+
isLoadingMore: false,
|
|
24
|
+
nextPageToken: null,
|
|
25
|
+
pageSize: 25,
|
|
23
26
|
results: [],
|
|
24
27
|
searchQuery: '',
|
|
28
|
+
totalCount: 0,
|
|
25
29
|
},
|
|
26
30
|
phase: 'idle',
|
|
27
31
|
sortKey: 'date',
|
|
@@ -347,25 +351,47 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
|
|
|
347
351
|
},
|
|
348
352
|
searchTransactionsForManualMatch: {
|
|
349
353
|
reducer(draft, action) {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
354
|
+
const { query, pageToken } = action.payload;
|
|
355
|
+
const isLoadMore = pageToken != null;
|
|
356
|
+
draft.bulkUpload.manualSearch.searchQuery = query;
|
|
357
|
+
if (isLoadMore) {
|
|
358
|
+
draft.bulkUpload.manualSearch.isLoadingMore = true;
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
draft.bulkUpload.manualSearch.isLoadingMore = false;
|
|
362
|
+
draft.bulkUpload.manualSearch.results = [];
|
|
363
|
+
draft.bulkUpload.manualSearch.nextPageToken = null;
|
|
364
|
+
draft.bulkUpload.manualSearch.totalCount = 0;
|
|
365
|
+
draft.bulkUpload.manualSearch.fetchState = {
|
|
366
|
+
fetchState: 'In-Progress',
|
|
367
|
+
error: undefined,
|
|
368
|
+
};
|
|
369
|
+
}
|
|
356
370
|
},
|
|
357
|
-
prepare(query) {
|
|
358
|
-
return { payload: { query } };
|
|
371
|
+
prepare(query, pageToken) {
|
|
372
|
+
return { payload: { query, pageToken: pageToken ?? undefined } };
|
|
359
373
|
},
|
|
360
374
|
},
|
|
361
375
|
searchTransactionsForManualMatchSuccess(draft, action) {
|
|
362
|
-
|
|
376
|
+
const { append, nextPageToken, results, totalCount } = action.payload;
|
|
377
|
+
if (append) {
|
|
378
|
+
const merged = [...draft.bulkUpload.manualSearch.results, ...results];
|
|
379
|
+
const byId = new Map(merged.map((r) => [r.transactionId, r]));
|
|
380
|
+
draft.bulkUpload.manualSearch.results = Array.from(byId.values());
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
draft.bulkUpload.manualSearch.results = results;
|
|
384
|
+
}
|
|
385
|
+
draft.bulkUpload.manualSearch.nextPageToken = nextPageToken;
|
|
386
|
+
draft.bulkUpload.manualSearch.totalCount = totalCount;
|
|
387
|
+
draft.bulkUpload.manualSearch.isLoadingMore = false;
|
|
363
388
|
draft.bulkUpload.manualSearch.fetchState = {
|
|
364
389
|
fetchState: 'Completed',
|
|
365
390
|
error: undefined,
|
|
366
391
|
};
|
|
367
392
|
},
|
|
368
393
|
searchTransactionsForManualMatchFailure(draft, action) {
|
|
394
|
+
draft.bulkUpload.manualSearch.isLoadingMore = false;
|
|
369
395
|
draft.bulkUpload.manualSearch.fetchState = {
|
|
370
396
|
fetchState: 'Error',
|
|
371
397
|
error: action.payload.error,
|
|
@@ -154,6 +154,13 @@ function getExpenseAutomationMissingReceiptsView(state) {
|
|
|
154
154
|
summary: currentBatchDetails.summary,
|
|
155
155
|
}
|
|
156
156
|
: undefined;
|
|
157
|
+
const manualSearchResults = bulkUpload.manualSearch.results.map((r) => {
|
|
158
|
+
const t = (0, transactionSelector_1.getSupportedTransactionById)(transactionState, r.transactionId);
|
|
159
|
+
return {
|
|
160
|
+
...r,
|
|
161
|
+
vendorLogo: r.vendorLogo ?? t?.logo?.href,
|
|
162
|
+
};
|
|
163
|
+
});
|
|
157
164
|
return {
|
|
158
165
|
fetchState,
|
|
159
166
|
error,
|
|
@@ -191,7 +198,10 @@ function getExpenseAutomationMissingReceiptsView(state) {
|
|
|
191
198
|
confirmMatchStatus: bulkUpload.confirmMatchStatus,
|
|
192
199
|
hasMoreBatchDetails,
|
|
193
200
|
batchDetailsPaginationState: bulkUpload.batchDetailsPaginationState,
|
|
194
|
-
manualSearch:
|
|
201
|
+
manualSearch: {
|
|
202
|
+
...bulkUpload.manualSearch,
|
|
203
|
+
results: manualSearchResults,
|
|
204
|
+
},
|
|
195
205
|
uploadProgress: bulkUpload.uploadProgress,
|
|
196
206
|
},
|
|
197
207
|
};
|
|
@@ -86,11 +86,18 @@ export interface ManualSearchResult {
|
|
|
86
86
|
transactionId: ID;
|
|
87
87
|
transactionType: string;
|
|
88
88
|
vendorName: string;
|
|
89
|
+
/** Present when API/merged transaction state supplies a logo URL. */
|
|
90
|
+
vendorLogo?: string;
|
|
89
91
|
}
|
|
90
92
|
export interface ManualSearchState {
|
|
91
93
|
fetchState: FetchStateAndError;
|
|
94
|
+
/** True while appending the next page (initial search uses fetchState only). */
|
|
95
|
+
isLoadingMore: boolean;
|
|
96
|
+
nextPageToken: string | null;
|
|
97
|
+
pageSize: number;
|
|
92
98
|
results: ManualSearchResult[];
|
|
93
99
|
searchQuery: string;
|
|
100
|
+
totalCount: number;
|
|
94
101
|
}
|
|
95
102
|
export type CompletedTransactionsMatchType = 'all' | 'ai_accountant' | 'manual';
|
|
96
103
|
export interface CompletedTransactionsState {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.19.37-
|
|
3
|
+
"version": "4.19.37-betaVR21",
|
|
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",
|