@zeniai/client-epic-state 4.19.37-betaVR2 → 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.
Files changed (39) hide show
  1. package/lib/epic.d.ts +2 -1
  2. package/lib/epic.js +2 -1
  3. package/lib/esm/epic.js +2 -1
  4. package/lib/esm/index.js +2 -2
  5. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +4 -8
  6. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +2 -2
  7. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +6 -1
  8. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +7 -3
  9. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +36 -0
  10. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +24 -15
  11. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +65 -24
  12. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +32 -32
  13. package/lib/esm/view/expenseAutomationView/payload/missingReceiptsPayload.js +25 -18
  14. package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +108 -22
  15. package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +110 -13
  16. package/lib/index.d.ts +2 -2
  17. package/lib/index.js +36 -32
  18. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.d.ts +2 -5
  19. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +3 -7
  20. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +2 -2
  21. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +6 -1
  22. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +6 -2
  23. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.d.ts +8 -0
  24. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +43 -0
  25. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.d.ts +3 -2
  26. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +25 -12
  27. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.d.ts +11 -3
  28. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +63 -22
  29. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts +5 -7
  30. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +28 -28
  31. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.d.ts +17 -35
  32. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.js +27 -20
  33. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +20 -5
  34. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +110 -23
  35. package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +7 -1
  36. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +110 -13
  37. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +17 -2
  38. package/package.json +2 -2
  39. package/lib/tsconfig.typecheck.tsbuildinfo +0 -1
@@ -9,15 +9,11 @@ const bulkUploadReceiptsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0,
9
9
  const { files } = action.payload;
10
10
  const formData = new FormData();
11
11
  for (const file of files) {
12
- formData.append('files[]', file, file.name);
12
+ formData.append('files', file, file.name);
13
13
  }
14
14
  return zeniAPI
15
- .postFormDataWithProgress(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/bulk-upload`, formData)
16
- .pipe((0, operators_1.mergeMap)((event) => {
17
- if (event.type === 'progress') {
18
- return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.updateBulkUploadProgress)(event.percentage));
19
- }
20
- const response = event.data;
15
+ .postFormData(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/bulk-upload`, formData)
16
+ .pipe((0, operators_1.mergeMap)((response) => {
21
17
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
22
18
  return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.bulkUploadReceiptsSuccess)({
23
19
  batchId: response.data.batch_id,
@@ -15,7 +15,7 @@ const fetchBulkUploadBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.
15
15
  }));
16
16
  }
17
17
  return zeniAPI
18
- .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/receipts/batches/${currentBatchId}`)
18
+ .getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/${currentBatchId}`)
19
19
  .pipe((0, operators_1.mergeMap)((response) => {
20
20
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
21
21
  const actions = [];
@@ -23,7 +23,7 @@ const fetchBulkUploadBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.
23
23
  if (transactionPayloads.length > 0) {
24
24
  actions.push((0, transactionReducer_1.updateTransactions)(transactionPayloads, (value) => value.transaction_id));
25
25
  }
26
- actions.push((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsSuccess)((0, missingReceiptsPayload_1.toBatchDetails)(response.data)));
26
+ actions.push((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsSuccess)((0, missingReceiptsPayload_1.toBatchDetails)(response.data, zeniAPI.apiEndPoints.fileMicroServiceBaseUrl)));
27
27
  actions.push((0, missingReceiptsViewReducer_1.fetchBulkUploadBatches)(true));
28
28
  return (0, rxjs_1.from)(actions);
29
29
  }
@@ -23,8 +23,13 @@ const fetchBulkUploadBatchesEpic = (actions$, state$, zeniAPI) => actions$.pipe(
23
23
  }));
24
24
  }
25
25
  const period = (0, timePeriod_1.convertToPeriod)(selectedPeriod);
26
+ const queryParam = {
27
+ start_date: period.start,
28
+ end_date: period.end,
29
+ sort_order: 'desc',
30
+ };
26
31
  return zeniAPI
27
- .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/receipts/batches?start_date=${period.start}&end_date=${period.end}`)
32
+ .getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
28
33
  .pipe((0, operators_1.mergeMap)((response) => {
29
34
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
30
35
  return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchesSuccess)({
@@ -15,8 +15,12 @@ const fetchCompletedTransactionsEpic = (actions$, state$, zeniAPI) => actions$.p
15
15
  const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
16
16
  const periodId = (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod);
17
17
  const isInitialLoad = action.payload.pageToken == null;
18
- const existingData = bulkUpload.completedTransactionsByPeriod[periodId];
19
- if (isInitialLoad && existingData != null && existingData.transactionIds.length > 0) {
18
+ const cacheKey = (0, missingReceiptsViewReducer_1.getCompletedTransactionsCacheKey)(periodId, bulkUpload.sortKey, bulkUpload.sortOrder, bulkUpload.completedSubTab);
19
+ const existingData = bulkUpload.completedTransactionsByPeriod[cacheKey];
20
+ if (isInitialLoad &&
21
+ action.payload.cacheOverride !== true &&
22
+ existingData != null &&
23
+ existingData.transactionIds.length > 0) {
20
24
  return (0, rxjs_1.from)([]);
21
25
  }
22
26
  const period = (0, timePeriod_1.convertToPeriod)(selectedPeriod);
@@ -0,0 +1,8 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
4
+ import { RootState } from '../../../../reducer';
5
+ import { ZeniAPI } from '../../../../zeniAPI';
6
+ import { batchDetailFetchFailed, fetchBulkUploadBatchesSuccess, fetchMoreBatchDetails, fetchMoreBatchDetailsComplete, fetchMoreBatchDetailsFailure, setInitialBatchDetailsLoading, storeBatchDetails } from '../../reducers/missingReceiptsViewReducer';
7
+ export type ActionType = ReturnType<typeof fetchBulkUploadBatchesSuccess> | ReturnType<typeof fetchMoreBatchDetails> | ReturnType<typeof fetchMoreBatchDetailsComplete> | ReturnType<typeof fetchMoreBatchDetailsFailure> | ReturnType<typeof batchDetailFetchFailed> | ReturnType<typeof setInitialBatchDetailsLoading> | ReturnType<typeof storeBatchDetails> | ReturnType<typeof updateTransactions>;
8
+ export declare const fetchMoreBatchDetailsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fetchMoreBatchDetailsEpic = void 0;
7
+ const orderBy_1 = __importDefault(require("lodash/orderBy"));
8
+ const rxjs_1 = require("rxjs");
9
+ const operators_1 = require("rxjs/operators");
10
+ const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
11
+ const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
12
+ const responsePayload_1 = require("../../../../responsePayload");
13
+ const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
14
+ const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
15
+ const fetchMultipleBatchDetailsEpic_1 = require("./fetchMultipleBatchDetailsEpic");
16
+ const MORE_BATCH_PAGE_SIZE = 4;
17
+ const fetchMoreBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchMoreBatchDetails.match),
18
+ /** One page at a time — avoids duplicate loads if IO + scroll fallback both fire. */
19
+ (0, operators_1.exhaustMap)(() => {
20
+ const state = state$.value;
21
+ const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload }, } = state;
22
+ const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
23
+ const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
24
+ if (selectedPeriod == null) {
25
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchMoreBatchDetailsComplete)());
26
+ }
27
+ const periodId = (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod);
28
+ const batchList = bulkUpload.batchListByPeriod[periodId] ?? [];
29
+ const failedIds = new Set(bulkUpload.failedBatchDetailIds);
30
+ const unfetchedBatches = batchList.filter((batch) => (0, missingReceiptsPayload_1.isBatchListStatusCompleted)(batch.status) &&
31
+ bulkUpload.batchDetailsById[batch.batchId] == null &&
32
+ !failedIds.has(batch.batchId));
33
+ const unfetchedBatchIds = (0, orderBy_1.default)(unfetchedBatches, (b) => new Date(b.createdAt).valueOf(), 'asc').map((batch) => batch.batchId);
34
+ if (unfetchedBatchIds.length === 0) {
35
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchMoreBatchDetailsComplete)());
36
+ }
37
+ const nextPage = unfetchedBatchIds.slice(0, MORE_BATCH_PAGE_SIZE);
38
+ return (0, rxjs_1.concat)((0, fetchMultipleBatchDetailsEpic_1.fetchBatchDetailsByIds)(nextPage, zeniAPI), (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchMoreBatchDetailsComplete)())).pipe((0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchMoreBatchDetailsFailure)({
39
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch more batch details errored out: ' +
40
+ JSON.stringify(error)),
41
+ }))));
42
+ }));
43
+ exports.fetchMoreBatchDetailsEpic = fetchMoreBatchDetailsEpic;
@@ -3,6 +3,7 @@ import { Observable } from 'rxjs';
3
3
  import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
4
4
  import { RootState } from '../../../../reducer';
5
5
  import { ZeniAPI } from '../../../../zeniAPI';
6
- import { fetchBulkUploadBatchesSuccess, storeBatchDetails } from '../../reducers/missingReceiptsViewReducer';
7
- export type ActionType = ReturnType<typeof fetchBulkUploadBatchesSuccess> | ReturnType<typeof updateTransactions> | ReturnType<typeof storeBatchDetails>;
6
+ import { batchDetailFetchFailed, fetchBulkUploadBatchesSuccess, fetchMoreBatchDetailsComplete, setInitialBatchDetailsLoading, storeBatchDetails } from '../../reducers/missingReceiptsViewReducer';
7
+ export type ActionType = ReturnType<typeof fetchBulkUploadBatchesSuccess> | ReturnType<typeof updateTransactions> | ReturnType<typeof storeBatchDetails> | ReturnType<typeof batchDetailFetchFailed> | ReturnType<typeof setInitialBatchDetailsLoading> | ReturnType<typeof fetchMoreBatchDetailsComplete>;
8
+ export declare function fetchBatchDetailsByIds(batchIds: string[], zeniAPI: ZeniAPI): Observable<ActionType>;
8
9
  export declare const fetchMultipleBatchDetailsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -1,24 +1,24 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.fetchMultipleBatchDetailsEpic = void 0;
7
+ exports.fetchBatchDetailsByIds = fetchBatchDetailsByIds;
8
+ const orderBy_1 = __importDefault(require("lodash/orderBy"));
4
9
  const rxjs_1 = require("rxjs");
5
10
  const operators_1 = require("rxjs/operators");
6
11
  const transactionReducer_1 = require("../../../../entity/transaction/transactionReducer");
7
12
  const responsePayload_1 = require("../../../../responsePayload");
8
13
  const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
9
14
  const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
10
- const fetchMultipleBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchBulkUploadBatchesSuccess.match), (0, operators_1.mergeMap)((action) => {
11
- const batchList = action.payload.batchList;
12
- const { batchDetailsById } = state$.value.expenseAutomationMissingReceiptsViewState.bulkUpload;
13
- const completedBatchIds = batchList
14
- .filter((batch) => batch.status === 'completed' &&
15
- batchDetailsById[batch.batchId] == null)
16
- .map((batch) => batch.batchId);
17
- if (completedBatchIds.length === 0) {
15
+ const INITIAL_BATCH_PAGE_SIZE = 4;
16
+ function fetchBatchDetailsByIds(batchIds, zeniAPI) {
17
+ if (batchIds.length === 0) {
18
18
  return rxjs_1.EMPTY;
19
19
  }
20
- return (0, rxjs_1.from)(completedBatchIds).pipe((0, operators_1.mergeMap)((batchId) => zeniAPI
21
- .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/receipts/batches/${batchId}`)
20
+ return (0, rxjs_1.from)(batchIds).pipe((0, operators_1.mergeMap)((batchId) => zeniAPI
21
+ .getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/${batchId}`)
22
22
  .pipe((0, operators_1.mergeMap)((response) => {
23
23
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
24
24
  const actions = [];
@@ -26,14 +26,27 @@ const fetchMultipleBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.pi
26
26
  if (transactionPayloads.length > 0) {
27
27
  actions.push((0, transactionReducer_1.updateTransactions)(transactionPayloads, (value) => value.transaction_id));
28
28
  }
29
- actions.push((0, missingReceiptsViewReducer_1.storeBatchDetails)((0, missingReceiptsPayload_1.toBatchDetails)(response.data)));
29
+ actions.push((0, missingReceiptsViewReducer_1.storeBatchDetails)((0, missingReceiptsPayload_1.toBatchDetails)(response.data, zeniAPI.apiEndPoints.fileMicroServiceBaseUrl)));
30
30
  return (0, rxjs_1.from)(actions);
31
31
  }
32
32
  return rxjs_1.EMPTY;
33
33
  }), (0, operators_1.catchError)((error) => {
34
34
  console.error(`Failed to fetch batch details for ${batchId}:`, (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch batch details errored out: ' +
35
35
  JSON.stringify(error)));
36
- return rxjs_1.EMPTY;
36
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.batchDetailFetchFailed)({ batchId }));
37
37
  })), 5));
38
+ }
39
+ const fetchMultipleBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchBulkUploadBatchesSuccess.match), (0, operators_1.mergeMap)((action) => {
40
+ const batchList = action.payload.batchList;
41
+ const { batchDetailsById } = state$.value.expenseAutomationMissingReceiptsViewState.bulkUpload;
42
+ /** Oldest first — matches primary-batch selection in missingReceiptsSelector (chronological). */
43
+ const completedBatchesMissingDetails = batchList.filter((batch) => (0, missingReceiptsPayload_1.isBatchListStatusCompleted)(batch.status) &&
44
+ batchDetailsById[batch.batchId] == null);
45
+ const completedBatchIds = (0, orderBy_1.default)(completedBatchesMissingDetails, (b) => new Date(b.createdAt).valueOf(), 'asc').map((batch) => batch.batchId);
46
+ const batchIdsToFetch = completedBatchIds.slice(0, INITIAL_BATCH_PAGE_SIZE);
47
+ if (batchIdsToFetch.length === 0) {
48
+ return rxjs_1.EMPTY;
49
+ }
50
+ return (0, rxjs_1.concat)((0, rxjs_1.of)((0, missingReceiptsViewReducer_1.setInitialBatchDetailsLoading)()), fetchBatchDetailsByIds(batchIdsToFetch, zeniAPI), (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchMoreBatchDetailsComplete)()));
38
51
  }));
39
52
  exports.fetchMultipleBatchDetailsEpic = fetchMultipleBatchDetailsEpic;
@@ -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
- export type ActionType = ReturnType<typeof searchTransactionsForManualMatch> | ReturnType<typeof searchTransactionsForManualMatchSuccess> | ReturnType<typeof searchTransactionsForManualMatchFailure>;
6
- export declare const searchTransactionsForManualMatchEpic: (actions$: ActionsObservable<ActionType>, _state$: unknown, zeniAPI: ZeniAPI) => Observable<ActionType>;
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>;
@@ -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 searchTransactionsForManualMatchEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.searchTransactionsForManualMatch.match), (0, operators_1.debounceTime)(300), (0, operators_1.switchMap)((action) => {
10
- const { query } = action.payload;
11
- const searchQuery = JSON.stringify({
12
- search_text: query,
13
- search_fields: ['date', 'amount', 'vendor_name'],
14
- });
15
- const encodedQuery = encodeURIComponent(searchQuery);
16
- return zeniAPI
17
- .getJSON(`${zeniAPI.apiEndPoints.searchMicroServiceBaseUrl}/1.0/transaction-search?query=${encodedQuery}`)
18
- .pipe((0, operators_1.switchMap)((response) => {
19
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
20
- const results = response.data.transactions.map(missingReceiptsPayload_1.toManualSearchResult);
21
- return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.searchTransactionsForManualMatchSuccess)(results));
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
- return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.searchTransactionsForManualMatchFailure)({
24
- error: response.status,
25
- }));
26
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.searchTransactionsForManualMatchFailure)({
27
- error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Search transactions for manual match errored: ' +
28
- JSON.stringify(error)),
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;
@@ -1,15 +1,13 @@
1
1
  import { ActionsObservable, StateObservable } from 'redux-observable';
2
2
  import { Observable } from 'rxjs';
3
+ import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
3
4
  import { RootState } from '../../../../reducer';
4
5
  import { ZeniAPI } from '../../../../zeniAPI';
5
- import { bulkUploadReceiptsSuccess, clearBulkUpload, fetchBulkUploadBatchDetails, pusherBatchStatusUpdate, updateBulkUploadBatchStatus } from '../../reducers/missingReceiptsViewReducer';
6
- export type ActionType = ReturnType<typeof bulkUploadReceiptsSuccess> | ReturnType<typeof updateBulkUploadBatchStatus> | ReturnType<typeof pusherBatchStatusUpdate> | ReturnType<typeof fetchBulkUploadBatchDetails> | ReturnType<typeof clearBulkUpload>;
6
+ import { bulkUploadReceiptsSuccess, clearBulkUpload, fetchBulkUploadBatchDetailsSuccess, fetchBulkUploadBatches, pusherBatchStatusUpdate, requestMissingReceiptsTabNavigation } from '../../reducers/missingReceiptsViewReducer';
7
+ export type ActionType = ReturnType<typeof bulkUploadReceiptsSuccess> | ReturnType<typeof pusherBatchStatusUpdate> | ReturnType<typeof fetchBulkUploadBatchDetailsSuccess> | ReturnType<typeof fetchBulkUploadBatches> | ReturnType<typeof requestMissingReceiptsTabNavigation> | ReturnType<typeof updateTransactions> | ReturnType<typeof clearBulkUpload>;
7
8
  /**
8
- * Watches batch status using two strategies:
9
- * 1. Pusher (primary): Reacts to `pusherBatchStatusUpdate` dispatched by the UI layer
10
- * when a Pusher event arrives. Immediately fetches full details on completion.
11
- * 2. Polling (fallback): Starts a relaxed 10s poll after upload success as a safety net
12
- * in case the Pusher event is missed. Stops on completion or `clearBulkUpload`.
9
+ * On Pusher batch completion: refresh batch list (then fetchMultipleBatchDetailsEpic runs),
10
+ * and request switching to the Unmatched tab. Debounced to reduce duplicate refreshes.
13
11
  */
14
12
  export declare const pusherBatchStatusCompletionEpic: (actions$: ActionsObservable<ActionType>) => Observable<ActionType>;
15
13
  export declare const pollBulkUploadBatchStatusEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -3,44 +3,44 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.pollBulkUploadBatchStatusEpic = exports.pusherBatchStatusCompletionEpic = void 0;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
+ const transactionReducer_1 = require("../../../../entity/transaction/transactionReducer");
6
7
  const responsePayload_1 = require("../../../../responsePayload");
7
8
  const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
8
9
  const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
10
+ /** First poll after upload; then interval while batch not resolved via Pusher or API. */
11
+ const FALLBACK_FIRST_DELAY_MS = 30000;
12
+ const FALLBACK_POLL_INTERVAL_MS = 10000;
13
+ function isBatchDetailsCompletedStatus(status) {
14
+ return status.toLowerCase() === 'completed';
15
+ }
9
16
  /**
10
- * Watches batch status using two strategies:
11
- * 1. Pusher (primary): Reacts to `pusherBatchStatusUpdate` dispatched by the UI layer
12
- * when a Pusher event arrives. Immediately fetches full details on completion.
13
- * 2. Polling (fallback): Starts a relaxed 10s poll after upload success as a safety net
14
- * in case the Pusher event is missed. Stops on completion or `clearBulkUpload`.
17
+ * On Pusher batch completion: refresh batch list (then fetchMultipleBatchDetailsEpic runs),
18
+ * and request switching to the Unmatched tab. Debounced to reduce duplicate refreshes.
15
19
  */
16
- // Pusher-driven: when Pusher delivers a completed status, fetch details
17
- const pusherBatchStatusCompletionEpic = (actions$) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.pusherBatchStatusUpdate.match), (0, operators_1.filter)((action) => action.payload.status === 'completed'), (0, operators_1.mergeMap)(() => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetails)())));
20
+ const pusherBatchStatusCompletionEpic = (actions$) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.pusherBatchStatusUpdate.match), (0, operators_1.filter)((action) => action.payload.status === 'completed'), (0, operators_1.debounceTime)(300), (0, operators_1.mergeMap)(() => (0, rxjs_1.from)([
21
+ (0, missingReceiptsViewReducer_1.fetchBulkUploadBatches)(true),
22
+ (0, missingReceiptsViewReducer_1.requestMissingReceiptsTabNavigation)({ tab: 'unmatched' }),
23
+ ])));
18
24
  exports.pusherBatchStatusCompletionEpic = pusherBatchStatusCompletionEpic;
19
- // Polling fallback: relaxed interval as safety net
20
- const FALLBACK_POLL_INTERVAL_MS = 10000;
21
- const pollBulkUploadBatchStatusEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.bulkUploadReceiptsSuccess.match), (0, operators_1.switchMap)((action) => {
25
+ const pollBulkUploadBatchStatusEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.bulkUploadReceiptsSuccess.match), (0, operators_1.mergeMap)((action) => {
22
26
  const { batchId } = action.payload;
23
- return (0, rxjs_1.timer)(0, FALLBACK_POLL_INTERVAL_MS).pipe((0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)((a) => missingReceiptsViewReducer_1.clearBulkUpload.match(a) ||
24
- (missingReceiptsViewReducer_1.pusherBatchStatusUpdate.match(a) &&
25
- a.payload.status === 'completed')))), (0, operators_1.switchMap)(() => zeniAPI
26
- .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/receipts/batches/${batchId}/status`)
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
28
+ .getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/${batchId}`)
27
29
  .pipe((0, operators_1.mergeMap)((response) => {
28
30
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
29
- const batchStatus = (0, missingReceiptsPayload_1.toBatchStatus)(response.data);
30
- const actions = [
31
- (0, missingReceiptsViewReducer_1.updateBulkUploadBatchStatus)(batchStatus),
32
- ];
33
- if (batchStatus.status === 'completed') {
34
- actions.push((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetails)());
31
+ if (isBatchDetailsCompletedStatus(response.data.status)) {
32
+ const actions = [];
33
+ const transactionPayloads = (0, missingReceiptsPayload_1.extractTransactionPayloadsFromBatchFiles)(response.data.files);
34
+ if (transactionPayloads.length > 0) {
35
+ actions.push((0, transactionReducer_1.updateTransactions)(transactionPayloads, (value) => value.transaction_id));
36
+ }
37
+ actions.push((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsSuccess)((0, missingReceiptsPayload_1.toBatchDetails)(response.data, zeniAPI.apiEndPoints.fileMicroServiceBaseUrl)));
38
+ actions.push((0, missingReceiptsViewReducer_1.fetchBulkUploadBatches)(true));
39
+ actions.push((0, missingReceiptsViewReducer_1.requestMissingReceiptsTabNavigation)({ tab: 'unmatched' }));
40
+ return (0, rxjs_1.from)(actions);
35
41
  }
36
- return actions;
37
- }
38
- return [];
39
- }), (0, operators_1.catchError)(() => (0, rxjs_1.of)()))), (0, operators_1.takeWhile)((action) => {
40
- if (missingReceiptsViewReducer_1.fetchBulkUploadBatchDetails.match(action)) {
41
- return false;
42
42
  }
43
- return true;
44
- }, true));
43
+ return rxjs_1.EMPTY;
44
+ }), (0, operators_1.catchError)(() => (0, rxjs_1.of)()))));
45
45
  }));
46
46
  exports.pollBulkUploadBatchStatusEpic = pollBulkUploadBatchStatusEpic;
@@ -1,7 +1,8 @@
1
+ import { URLPayload } from '../../../commonPayloadTypes/urlPayload';
1
2
  import { TransactionPayload } from '../../../entity/transaction/payloadTypes/transactionPayload';
2
3
  import { SupportedTransactionPayload } from '../../../entity/transaction/transactionState';
3
4
  import { ZeniAPIResponse } from '../../../responsePayload';
4
- import type { BatchDetails, BatchFile, BatchListItem, BatchStatus, BatchSummary, ManualSearchResult } from '../types/missingReceiptsViewState';
5
+ import type { BatchDetails, BatchFile, BatchListItem, BatchSummary, ManualSearchResult } from '../types/missingReceiptsViewState';
5
6
  export interface MissingReceiptsQueryPayload {
6
7
  end_date: string;
7
8
  is_attachment_missing_only: boolean;
@@ -15,21 +16,17 @@ interface MissingReceiptsPayload {
15
16
  transactions: TransactionPayload[];
16
17
  }
17
18
  export type MissingReceiptsResponse = ZeniAPIResponse<MissingReceiptsPayload>;
19
+ export interface BatchListQueryPayload {
20
+ end_date: string;
21
+ sort_order: string;
22
+ start_date: string;
23
+ }
18
24
  export interface BulkUploadResponsePayload {
19
25
  batch_id: string;
20
26
  status: string;
21
27
  total_files: number;
22
28
  }
23
29
  export type BulkUploadResponse = ZeniAPIResponse<BulkUploadResponsePayload>;
24
- export interface BatchStatusResponsePayload {
25
- batch_id: string;
26
- progress: {
27
- processed: number;
28
- total: number;
29
- };
30
- status: string;
31
- }
32
- export type BatchStatusResponse = ZeniAPIResponse<BatchStatusResponsePayload>;
33
30
  export interface BatchListResponsePayload {
34
31
  batches: BatchListItemPayload[];
35
32
  }
@@ -47,11 +44,11 @@ export type BatchListResponse = ZeniAPIResponse<BatchListResponsePayload>;
47
44
  export interface MatchedTransactionPayload {
48
45
  amount: number;
49
46
  currency_code: string;
50
- transaction_date: string;
47
+ transaction_date: string | null;
51
48
  transaction_id: string;
52
49
  vendor_name: string;
53
50
  transaction_type?: string;
54
- vendor_logo?: string;
51
+ vendor_logo?: URLPayload | null;
55
52
  }
56
53
  export interface MatchCandidatePayload extends MatchedTransactionPayload {
57
54
  match_score: number;
@@ -59,10 +56,11 @@ export interface MatchCandidatePayload extends MatchedTransactionPayload {
59
56
  export interface BatchFilePayload {
60
57
  attachment_id: string;
61
58
  file_id: string;
62
- file_preview_url: string;
59
+ file_preview_url: string | null;
63
60
  filename: string;
64
61
  status: string;
65
62
  candidates?: MatchCandidatePayload[];
63
+ match_source?: string;
66
64
  matched_transaction?: MatchedTransactionPayload;
67
65
  }
68
66
  export interface BatchDetailsResponsePayload {
@@ -79,31 +77,15 @@ export interface BatchDetailsResponsePayload {
79
77
  };
80
78
  }
81
79
  export type BatchDetailsResponse = ZeniAPIResponse<BatchDetailsResponsePayload>;
82
- export declare function toBatchFile(payload: BatchFilePayload): BatchFile;
80
+ export declare function toBatchFile(payload: BatchFilePayload, filesEndPoint?: string): BatchFile;
83
81
  export declare function extractTransactionPayloadsFromBatchFiles(files: BatchFilePayload[]): SupportedTransactionPayload[];
84
82
  export declare function toBatchSummary(payload: BatchDetailsResponsePayload['summary']): BatchSummary;
85
- export declare function toBatchStatus(payload: BatchStatusResponsePayload): BatchStatus;
86
- export declare function toBatchDetails(payload: BatchDetailsResponsePayload): BatchDetails;
83
+ export declare function toBatchDetails(payload: BatchDetailsResponsePayload, filesEndPoint?: string): BatchDetails;
84
+ /** Batch list `status` is a string from the API — compare case-insensitively. */
85
+ export declare function isBatchListStatusCompleted(status: string): boolean;
87
86
  export declare function toBatchListItem(payload: BatchListItemPayload): BatchListItem;
88
- export interface TransactionSearchQueryPayload {
89
- search_text: string;
90
- search_fields?: string[];
91
- }
92
- export interface TransactionSearchItemPayload {
93
- amount: number;
94
- currency: string;
95
- entity_id: string;
96
- memo: string;
97
- transaction_date: string;
98
- transaction_id: string;
99
- transaction_type: string;
100
- vendor_name: string;
101
- }
102
- export interface TransactionSearchResponsePayload {
103
- transactions: TransactionSearchItemPayload[];
104
- }
105
- export type TransactionSearchResponse = ZeniAPIResponse<TransactionSearchResponsePayload>;
106
- 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;
107
89
  export interface CompletedTransactionsQueryPayload {
108
90
  end_date?: string;
109
91
  match_type?: string;
@@ -3,21 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toBatchFile = toBatchFile;
4
4
  exports.extractTransactionPayloadsFromBatchFiles = extractTransactionPayloadsFromBatchFiles;
5
5
  exports.toBatchSummary = toBatchSummary;
6
- exports.toBatchStatus = toBatchStatus;
7
6
  exports.toBatchDetails = toBatchDetails;
7
+ exports.isBatchListStatusCompleted = isBatchListStatusCompleted;
8
8
  exports.toBatchListItem = toBatchListItem;
9
- exports.toManualSearchResult = toManualSearchResult;
9
+ exports.supportedTransactionPayloadToManualSearchResult = supportedTransactionPayloadToManualSearchResult;
10
+ const urlPayload_1 = require("../../../commonPayloadTypes/urlPayload");
11
+ const transactionPayload_1 = require("../../../entity/transaction/payloadTypes/transactionPayload");
10
12
  // -- Converter functions --
11
- function toBatchFile(payload) {
13
+ function toBatchFile(payload, filesEndPoint) {
12
14
  return {
13
15
  attachmentId: payload.attachment_id,
14
16
  candidates: payload.candidates?.map((c) => ({
15
17
  transactionId: c.transaction_id,
16
18
  matchScore: c.match_score,
17
19
  })),
20
+ fileDownloadUrl: payload.file_id != null && filesEndPoint != null
21
+ ? `${filesEndPoint}/1.0/files/${payload.file_id}?query=${encodeURIComponent(JSON.stringify({ download_file: true }))}`
22
+ : null,
18
23
  fileId: payload.file_id,
19
24
  filePreviewUrl: payload.file_preview_url,
20
25
  filename: payload.filename,
26
+ matchSource: payload.match_source,
21
27
  matchedTransactionId: payload.matched_transaction?.transaction_id,
22
28
  status: payload.status,
23
29
  };
@@ -48,11 +54,12 @@ function extractTransactionPayloadsFromBatchFiles(files) {
48
54
  function matchedTransactionPayloadToSupportedTransactionPayload(payload) {
49
55
  return {
50
56
  transaction_id: payload.transaction_id,
51
- transaction_type: payload.transaction_type,
52
- transaction_date: payload.transaction_date,
57
+ transaction_type: payload.transaction_type ?? 'expense',
58
+ transaction_date: payload.transaction_date ?? '',
53
59
  currency_code: payload.currency_code,
54
60
  total_amount: payload.amount,
55
61
  vendor_name: payload.vendor_name,
62
+ logo: payload.vendor_logo == null ? undefined : (0, urlPayload_1.toURL)(payload.vendor_logo),
56
63
  };
57
64
  }
58
65
  function toBatchSummary(payload) {
@@ -64,22 +71,19 @@ function toBatchSummary(payload) {
64
71
  total: payload.total,
65
72
  };
66
73
  }
67
- function toBatchStatus(payload) {
68
- return {
69
- batchId: payload.batch_id,
70
- progress: payload.progress,
71
- status: payload.status,
72
- };
73
- }
74
- function toBatchDetails(payload) {
74
+ function toBatchDetails(payload, filesEndPoint) {
75
75
  return {
76
76
  batchId: payload.batch_id,
77
77
  createdAt: payload.created_at,
78
- files: payload.files.map(toBatchFile),
78
+ files: payload.files.map((f) => toBatchFile(f, filesEndPoint)),
79
79
  status: payload.status,
80
80
  summary: toBatchSummary(payload.summary),
81
81
  };
82
82
  }
83
+ /** Batch list `status` is a string from the API — compare case-insensitively. */
84
+ function isBatchListStatusCompleted(status) {
85
+ return status.toLowerCase() === 'completed';
86
+ }
83
87
  function toBatchListItem(payload) {
84
88
  return {
85
89
  batchId: payload.batch_id,
@@ -92,15 +96,18 @@ function toBatchListItem(payload) {
92
96
  totalFiles: payload.total_files,
93
97
  };
94
98
  }
95
- function toManualSearchResult(payload) {
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);
96
102
  return {
97
- amount: payload.amount,
98
- currencyCode: payload.currency,
99
- entityId: payload.entity_id,
100
- memo: payload.memo,
103
+ amount: amountPayload.amount,
104
+ currencyCode: amountPayload.currencyCode,
105
+ entityId: payload.vendor_id ?? payload.customer_id ?? '',
106
+ memo: payload.transaction_memo ?? '',
101
107
  transactionDate: payload.transaction_date,
102
108
  transactionId: payload.transaction_id,
103
109
  transactionType: payload.transaction_type,
104
- vendorName: payload.vendor_name,
110
+ vendorName: payload.vendor_name ?? '',
111
+ vendorLogo: (0, urlPayload_1.toURL)(payload.logo)?.href,
105
112
  };
106
113
  }