@zeniai/client-epic-state 4.19.83 → 4.19.84-betaVR10

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 (116) hide show
  1. package/lib/entity/account/accountPayload.d.ts +2 -0
  2. package/lib/entity/account/accountPayload.js +2 -0
  3. package/lib/entity/account/accountState.d.ts +2 -0
  4. package/lib/entity/company/companyPayload.d.ts +13 -0
  5. package/lib/entity/company/companyPayload.js +21 -0
  6. package/lib/entity/company/companyStateTypes.d.ts +13 -0
  7. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  8. package/lib/entity/snackbar/snackbarTypes.js +1 -0
  9. package/lib/epic.d.ts +12 -1
  10. package/lib/epic.js +12 -1
  11. package/lib/esm/entity/account/accountPayload.js +2 -0
  12. package/lib/esm/entity/chargeCardTransaction/chargeCardTransactionPayload.js +2 -2
  13. package/lib/esm/entity/company/companyPayload.js +21 -0
  14. package/lib/esm/entity/snackbar/snackbarTypes.js +1 -0
  15. package/lib/esm/epic.js +12 -1
  16. package/lib/esm/index.js +13 -8
  17. package/lib/esm/view/companyView/epic/companyPassport/updateCompanyDetailsEpic.js +6 -0
  18. package/lib/esm/view/companyView/types/companyPassport/companyPassportLocalData.js +13 -0
  19. package/lib/esm/view/companyView/types/companyPassportViewPayload.js +55 -12
  20. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +28 -0
  21. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +49 -0
  22. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +40 -0
  23. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +47 -0
  24. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +61 -0
  25. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +34 -0
  26. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +57 -0
  27. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +78 -0
  28. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +7 -5
  29. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +59 -0
  30. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/triggerReviewTabRefetchEpic.js +2 -3
  31. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +24 -0
  32. package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -2
  33. package/lib/esm/view/expenseAutomationView/payload/missingReceiptsPayload.js +173 -1
  34. package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +412 -1
  35. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +20 -1
  36. package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +225 -1
  37. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +2 -1
  38. package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +10 -0
  39. package/lib/esm/view/expenseAutomationView/types/transactionsViewState.js +2 -1
  40. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewSelector.js +22 -4
  41. package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryDownloadSelector.js +2 -2
  42. package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistorySelector.js +2 -2
  43. package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailSelector.js +4 -1
  44. package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/fetchChargeCardRepaymentDetailEpic.js +2 -1
  45. package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/initiateChargeCardRepaymentEpic.js +1 -1
  46. package/lib/esm/view/spendManagement/commonSetup/epic/setup/updateBusinessVerificationDetailsEpic.js +67 -1
  47. package/lib/esm/view/spendManagement/commonSetup/epic/setup/updateSetupViewLocalStoreDataEpic.js +16 -2
  48. package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +15 -1
  49. package/lib/esm/view/spendManagement/commonSetup/types/businessVerification.js +148 -1
  50. package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
  51. package/lib/esm/zeniAPI.js +0 -2
  52. package/lib/index.d.ts +14 -9
  53. package/lib/index.js +90 -45
  54. package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
  55. package/lib/view/companyView/epic/companyPassport/updateCompanyDetailsEpic.js +6 -0
  56. package/lib/view/companyView/types/companyPassport/companyDetailsLocalData.d.ts +13 -0
  57. package/lib/view/companyView/types/companyPassport/companyPassportLocalData.js +13 -0
  58. package/lib/view/companyView/types/companyPassportViewPayload.d.ts +1 -1
  59. package/lib/view/companyView/types/companyPassportViewPayload.js +55 -12
  60. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.d.ts +15 -0
  61. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +32 -0
  62. package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.d.ts +7 -0
  63. package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +53 -0
  64. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.d.ts +8 -0
  65. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +44 -0
  66. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.d.ts +7 -0
  67. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +51 -0
  68. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.d.ts +8 -0
  69. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +65 -0
  70. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.d.ts +8 -0
  71. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +38 -0
  72. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.d.ts +9 -0
  73. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +62 -0
  74. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.d.ts +14 -0
  75. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +82 -0
  76. package/lib/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +7 -5
  77. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts +19 -0
  78. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +64 -0
  79. package/lib/view/expenseAutomationView/epics/transactionCategorization/triggerReviewTabRefetchEpic.js +2 -3
  80. package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.d.ts +7 -0
  81. package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +28 -0
  82. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  83. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -2
  84. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.d.ts +118 -0
  85. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.js +185 -0
  86. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +70 -3
  87. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +414 -2
  88. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +11 -3
  89. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +21 -2
  90. package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +69 -1
  91. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +1 -0
  92. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.d.ts +1 -1
  93. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +224 -0
  94. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +2 -1
  95. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +131 -0
  96. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +12 -1
  97. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +2 -1
  98. package/lib/view/expenseAutomationView/types/transactionsViewState.js +2 -1
  99. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.d.ts +1 -0
  100. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.js +22 -3
  101. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryDownloadSelector.js +2 -2
  102. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistorySelector.js +2 -2
  103. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailSelector.js +4 -1
  104. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/fetchChargeCardRepaymentDetailEpic.js +2 -1
  105. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/initiateChargeCardRepaymentEpic.d.ts +1 -1
  106. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/initiateChargeCardRepaymentEpic.js +1 -1
  107. package/lib/view/spendManagement/commonSetup/epic/setup/updateBusinessVerificationDetailsEpic.js +67 -1
  108. package/lib/view/spendManagement/commonSetup/epic/setup/updateSetupViewLocalStoreDataEpic.js +16 -2
  109. package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +14 -0
  110. package/lib/view/spendManagement/commonSetup/setupViewSelector.js +15 -1
  111. package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +14 -0
  112. package/lib/view/spendManagement/commonSetup/types/businessVerification.d.ts +43 -0
  113. package/lib/view/spendManagement/commonSetup/types/businessVerification.js +150 -0
  114. package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
  115. package/lib/zeniAPI.js +0 -2
  116. package/package.json +1 -1
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.searchTransactionsForManualMatchEpic = exports.MANUAL_TRANSACTION_SEARCH_AUTO_CATEGORIZED = void 0;
4
+ const rxjs_1 = require("rxjs");
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");
9
+ const responsePayload_1 = require("../../../../responsePayload");
10
+ const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
11
+ const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
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
+ /**
23
+ * No API for empty or 1-char queries; immediate merge so switchMap cancels any in-flight HTTP.
24
+ */
25
+ const newSearchTooShortOrClear$ = searchActions$.pipe((0, operators_1.filter)((a) => a.payload.pageToken == null &&
26
+ a.payload.query.trim().length < 2));
27
+ const newSearchDebounced$ = searchActions$.pipe((0, operators_1.filter)((a) => a.payload.pageToken == null &&
28
+ a.payload.query.trim().length >= 2), (0, operators_1.debounceTime)(300));
29
+ return (0, rxjs_1.merge)(pagination$, newSearchTooShortOrClear$, newSearchDebounced$).pipe((0, operators_1.switchMap)((action) => {
30
+ const { query, pageToken } = action.payload;
31
+ if (pageToken == null &&
32
+ query.trim().length < 2) {
33
+ return rxjs_1.EMPTY;
34
+ }
35
+ const state = state$.value;
36
+ const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload: { manualSearch, sortKey, sortOrder }, }, } = state;
37
+ const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
38
+ const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
39
+ if (selectedPeriod == null) {
40
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.searchTransactionsForManualMatchFailure)({
41
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Manual search requires a selected accounting period.'),
42
+ }));
43
+ }
44
+ const period = (0, timePeriod_1.convertToPeriod)(selectedPeriod);
45
+ const queryParam = {
46
+ start_date: period.start,
47
+ end_date: period.end,
48
+ auto_categorized: exports.MANUAL_TRANSACTION_SEARCH_AUTO_CATEGORIZED,
49
+ sort_by: (0, transactionsViewState_1.toTransactionsSortKey)(sortKey),
50
+ sort_order: sortOrder === 'ascending' ? 'asc' : 'desc',
51
+ page_token: pageToken ?? null,
52
+ page_size: manualSearch.pageSize,
53
+ search_text: query,
54
+ };
55
+ return zeniAPI
56
+ .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/transactions?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
57
+ .pipe((0, operators_1.mergeMap)((response) => {
58
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
59
+ const { transactions, next_page_token, total_count } = response.data;
60
+ const append = pageToken != null;
61
+ const results = transactions.map(missingReceiptsPayload_1.supportedTransactionPayloadToManualSearchResult);
62
+ const actionsOut = [
63
+ (0, transactionReducer_1.updateTransactions)(transactions, (value) => value.transaction_id, 'merge'),
64
+ (0, missingReceiptsViewReducer_1.searchTransactionsForManualMatchSuccess)({
65
+ append,
66
+ nextPageToken: next_page_token ?? null,
67
+ results,
68
+ totalCount: total_count,
69
+ }),
70
+ ];
71
+ return (0, rxjs_1.from)(actionsOut);
72
+ }
73
+ return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.searchTransactionsForManualMatchFailure)({
74
+ error: response.status,
75
+ }));
76
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.searchTransactionsForManualMatchFailure)({
77
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Search transactions for manual match errored: ' +
78
+ JSON.stringify(error)),
79
+ }))));
80
+ }));
81
+ };
82
+ exports.searchTransactionsForManualMatchEpic = searchTransactionsForManualMatchEpic;
@@ -15,11 +15,13 @@ const uploadMissingReceiptSuccessEpic = (actions$, state$) => actions$.pipe((0,
15
15
  updateActions.push((0, transactionReducer_1.updateTransaction)(transactionPayload.transaction_id, transactionPayload, updateType));
16
16
  if (currentTenant != null) {
17
17
  const monthEndChecksPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
18
- updateActions.push((0, monthEndCloseChecksViewReducer_1.fetchMonthEndCloseChecks)({
19
- tenantId: currentTenant.tenantId,
20
- period: monthEndChecksPeriod,
21
- refreshViewInBackground: true,
22
- }));
18
+ if (monthEndChecksPeriod != null) {
19
+ updateActions.push((0, monthEndCloseChecksViewReducer_1.fetchMonthEndCloseChecks)({
20
+ tenantId: currentTenant.tenantId,
21
+ period: monthEndChecksPeriod,
22
+ refreshViewInBackground: true,
23
+ }));
24
+ }
23
25
  }
24
26
  return (0, rxjs_1.from)(updateActions);
25
27
  }));
@@ -0,0 +1,19 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
4
+ import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
5
+ import { RootState } from '../../../../reducer';
6
+ import { ZeniAPI } from '../../../../zeniAPI';
7
+ import { bulkUploadReceiptsSuccess, clearBulkUpload, fetchBulkUploadBatchDetailsSuccess, fetchBulkUploadBatches, pusherBatchStatusUpdate, requestMissingReceiptsTabNavigation } from '../../reducers/missingReceiptsViewReducer';
8
+ export type ActionType = ReturnType<typeof bulkUploadReceiptsSuccess> | ReturnType<typeof pusherBatchStatusUpdate> | ReturnType<typeof fetchBulkUploadBatchDetailsSuccess> | ReturnType<typeof fetchBulkUploadBatches> | ReturnType<typeof requestMissingReceiptsTabNavigation> | ReturnType<typeof updateTransactions> | ReturnType<typeof clearBulkUpload> | ReturnType<typeof openSnackbar>;
9
+ /**
10
+ * On Pusher batch completion: refresh batch list (then fetchMultipleBatchDetailsEpic runs),
11
+ * and request switching to the Unmatched tab. Debounced to reduce duplicate refreshes.
12
+ */
13
+ export declare const pusherBatchStatusCompletionEpic: (actions$: ActionsObservable<ActionType>) => Observable<ActionType>;
14
+ /**
15
+ * Fallback polling when Pusher is slow or unavailable. Network errors on a poll tick show one
16
+ * error snackbar per upload session (first failure only) so the user is not spammed every
17
+ * interval; Pusher or a later successful poll still completes the flow.
18
+ */
19
+ export declare const pollBulkUploadBatchStatusEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pollBulkUploadBatchStatusEpic = exports.pusherBatchStatusCompletionEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
7
+ const transactionReducer_1 = require("../../../../entity/transaction/transactionReducer");
8
+ const responsePayload_1 = require("../../../../responsePayload");
9
+ const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
10
+ const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
11
+ /** First poll after upload; then interval while batch not resolved via Pusher or API. */
12
+ const FALLBACK_FIRST_DELAY_MS = 30000;
13
+ const FALLBACK_POLL_INTERVAL_MS = 10000;
14
+ /**
15
+ * On Pusher batch completion: refresh batch list (then fetchMultipleBatchDetailsEpic runs),
16
+ * and request switching to the Unmatched tab. Debounced to reduce duplicate refreshes.
17
+ */
18
+ 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)([
19
+ (0, missingReceiptsViewReducer_1.fetchBulkUploadBatches)({
20
+ cacheOverride: true,
21
+ invalidateBatchDetailsCache: true,
22
+ }),
23
+ (0, missingReceiptsViewReducer_1.requestMissingReceiptsTabNavigation)({ tab: 'unmatched' }),
24
+ ])));
25
+ exports.pusherBatchStatusCompletionEpic = pusherBatchStatusCompletionEpic;
26
+ /**
27
+ * Fallback polling when Pusher is slow or unavailable. Network errors on a poll tick show one
28
+ * error snackbar per upload session (first failure only) so the user is not spammed every
29
+ * interval; Pusher or a later successful poll still completes the flow.
30
+ */
31
+ const pollBulkUploadBatchStatusEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.bulkUploadReceiptsSuccess.match), (0, operators_1.mergeMap)((action) => {
32
+ const { batchId } = action.payload;
33
+ let pollErrorNotified = false;
34
+ 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
35
+ .getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/${batchId}`)
36
+ .pipe((0, operators_1.mergeMap)((response) => {
37
+ /** Same batch-details URL; polls until `status` is completed (Pusher may win first). */
38
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
39
+ if ((0, missingReceiptsPayload_1.isBatchDetailsApiStatusCompleted)(response.data.status)) {
40
+ const actions = [];
41
+ const transactionPayloads = (0, missingReceiptsPayload_1.extractTransactionPayloadsFromBatchFiles)(response.data.files);
42
+ if (transactionPayloads.length > 0) {
43
+ actions.push((0, transactionReducer_1.updateTransactions)(transactionPayloads, (value) => value.transaction_id));
44
+ }
45
+ actions.push((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsSuccess)((0, missingReceiptsPayload_1.toBatchDetails)(response.data, zeniAPI.apiEndPoints.fileMicroServiceBaseUrl)));
46
+ actions.push((0, missingReceiptsViewReducer_1.fetchBulkUploadBatches)({ cacheOverride: true }));
47
+ actions.push((0, missingReceiptsViewReducer_1.requestMissingReceiptsTabNavigation)({ tab: 'unmatched' }));
48
+ return (0, rxjs_1.from)(actions);
49
+ }
50
+ }
51
+ return rxjs_1.EMPTY;
52
+ }), (0, operators_1.catchError)(() => {
53
+ if (!pollErrorNotified) {
54
+ pollErrorNotified = true;
55
+ return (0, rxjs_1.of)((0, snackbarReducer_1.openSnackbar)({
56
+ messageSection: 'receipts_upload',
57
+ messageText: 'failed',
58
+ type: 'error',
59
+ }));
60
+ }
61
+ return rxjs_1.EMPTY;
62
+ }))));
63
+ }));
64
+ exports.pollBulkUploadBatchStatusEpic = pollBulkUploadBatchStatusEpic;
@@ -7,15 +7,14 @@ const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
7
7
  const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
8
8
  const transactionsViewReducer_1 = require("../../reducers/transactionsViewReducer");
9
9
  const triggerReviewTabRefetchEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(transactionsViewReducer_1.syncTransactionCategorizationFromDetailSave.match), (0, operators_1.mergeMap)((action) => {
10
- const { pendingReviewLineIds, transactionId, isUncategorizedExpenseCategoryEnabled } = action.payload;
10
+ const { pendingReviewLineIds, transactionId, isUncategorizedExpenseCategoryEnabled, } = action.payload;
11
11
  if (pendingReviewLineIds.length === 0) {
12
12
  return rxjs_1.EMPTY;
13
13
  }
14
14
  const state = state$.value;
15
15
  // Only trigger when the transaction was auto-only (not in review tab after reducer ran)
16
16
  const reviewLocalData = state.expenseAutomationTransactionsViewState
17
- .transactionCategorizationView.review
18
- .transactionReviewLocalDataById[transactionId.id];
17
+ .transactionCategorizationView.review.transactionReviewLocalDataById[transactionId.id];
19
18
  if (reviewLocalData != null) {
20
19
  return rxjs_1.EMPTY;
21
20
  }
@@ -0,0 +1,7 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { updateTransaction } from '../../../../entity/transaction/transactionReducer';
3
+ import { RootState } from '../../../../reducer';
4
+ import { fetchMonthEndCloseChecks } from '../../../monthEndCloseChecksView/monthEndCloseChecksViewReducer';
5
+ import { uploadTransactionCategorizationReceiptSuccess } from '../../reducers/transactionsViewReducer';
6
+ export type ActionType = ReturnType<typeof uploadTransactionCategorizationReceiptSuccess> | ReturnType<typeof fetchMonthEndCloseChecks> | ReturnType<typeof updateTransaction>;
7
+ export declare const uploadTransactionReceiptSuccessEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => import("rxjs").Observable<ActionType>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uploadTransactionReceiptSuccessEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
7
+ const transactionReducer_1 = require("../../../../entity/transaction/transactionReducer");
8
+ const monthEndCloseChecksViewReducer_1 = require("../../../monthEndCloseChecksView/monthEndCloseChecksViewReducer");
9
+ const transactionsViewReducer_1 = require("../../reducers/transactionsViewReducer");
10
+ const uploadTransactionReceiptSuccessEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(transactionsViewReducer_1.uploadTransactionCategorizationReceiptSuccess.match), (0, operators_1.mergeMap)((action) => {
11
+ const { transactionPayload, updateType } = action.payload;
12
+ const updateActions = [];
13
+ const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state$.value);
14
+ const selectedPeriodByTenantId = state$.value.expenseAutomationViewState.selectedPeriodByTenantId;
15
+ updateActions.push((0, transactionReducer_1.updateTransaction)(transactionPayload.transaction_id, transactionPayload, updateType));
16
+ if (currentTenant != null) {
17
+ const monthEndChecksPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
18
+ if (monthEndChecksPeriod != null) {
19
+ updateActions.push((0, monthEndCloseChecksViewReducer_1.fetchMonthEndCloseChecks)({
20
+ tenantId: currentTenant.tenantId,
21
+ period: monthEndChecksPeriod,
22
+ refreshViewInBackground: true,
23
+ }));
24
+ }
25
+ }
26
+ return (0, rxjs_1.from)(updateActions);
27
+ }));
28
+ exports.uploadTransactionReceiptSuccessEpic = uploadTransactionReceiptSuccessEpic;
@@ -37,7 +37,7 @@ export declare const getLineItemsByTransactionsIdsFromResponse: (transactions: S
37
37
  export declare const getLineItemsByTransactionIdsFromLocalData: (transactionLocalData: TransactionReviewLocalDataSelectorView[], selectedTab: TransactionsTab) => Record<ID, string[]>;
38
38
  export declare const mergeTabSpecificLineItems: (currentTabSpecificLineItems: TabSpecificLineItems, selectedTab: TransactionsTab, newLineItems: TabSpecificLineItems) => TabSpecificLineItems;
39
39
  export declare const getSnackbarMessageForTransactionReview: (updatedCount: number, failedCount: number, categorizedCount: number) => {
40
- messageSection: "common" | "transactionDetails_updatingPastTransactions" | "transactionDetails_transactionUpdated" | "cockpit_month_end_email_sent" | "cockpit_month_end_email_save" | "cockpit_month_end_email_attachment_upload" | "je_bill_link" | "je_posted" | "audit_score_updated" | "people_invite_people" | "people_invite_multiple_people" | "people_delete_person" | "people_update_person" | "reimbursement_updated" | "reimbursement_deleted" | "reimbursement_cancelled_deleted" | "reimbursement_cancelled" | "reimbursement_approved" | "reimbursement_rejected" | "reimbursement_sent_for_approval" | "account_added" | "business_verification_save" | "business_verification_submit" | "business_verification_from_bills_submit" | "plaid_connection" | "unlink_deposit_account" | "reimbursement_setup" | "reimbursement_approval_create" | "reimbursement_duplicate_approval_create" | "reimbursement_approval_update" | "reimbursement_duplicate_approval_update" | "reimbursement_approval_delete" | "reimbursement_create_mileage" | "reimbursement_update_mileage" | "reimbursement_accept_term" | "reimbursement_accept_employee_term" | "reimbursement_bulk_submit" | "reimbursement_bulk_processed" | "bill_pay_setup" | "zeni_accounts_setup" | "bill_pay_approval_create" | "bill_pay_duplicate_approval_create" | "bill_pay_approval_update" | "bill_pay_duplicate_approval_update" | "bill_pay_approval_delete" | "bill_pay_updated" | "bill_pay_deleted" | "bill_pay_cancelled_deleted" | "bill_pay_cancelled" | "bill_pay_approved" | "real_time_approver_added" | "bill_pay_rejected" | "bill_pay_sent_for_approval" | "bill_pay_accept_term" | "bill_pay_bulk_submit" | "bill_pay_bulk_processed" | "bill_pay_refund" | "bill_pay_retry" | "bill_pay_marked_as_paid" | "zeni_account_accept_term" | "update_vendor" | "data_refresh_update" | "delete_bank_account" | "create_bank_account" | "create_bank_account_ach" | "create_bank_account_wire" | "create_bank_account_international" | "transfer_money" | "update_zeni_account_nickname" | "create_checking_account" | "deposit_check" | "create_vendor" | "onboarding_customer_view" | "onboarding_customer_view_complete" | "onboarding_customer_identity_verification_save" | "onboarding_customer_identity_verification_submit" | "onboarding_customer_business_verification_save" | "onboarding_customer_business_verification_submit" | "retry_bank_account_connection" | "dashboard_invite_sent" | "onboarding_info_saved" | "approve_original_merchant" | "approve_global_merchant" | "reject_global_merchant" | "create_global_merchant" | "fetch_global_merchant_no_recommendation" | "save_vendor_renamed" | "save_vendor_sent_for_review" | "save_vendor_marked_as_employee" | "save_vendor_marked_as_local_contractor" | "charge_card_setup" | "charge_card_accept_term" | "charge_card_receipt_upload" | "charge_card_resend_invite" | "charge_card_revoke_invite" | "charge_card_update_limit" | "charge_cards_update_limit" | "close_charge_card" | "lock_charge_card" | "lock_charge_card_card_user" | "lock_charge_cards" | "unlock_charge_card" | "unlock_charge_card_card_user" | "unlock_charge_cards" | "close_charge_cards" | "revoke_invite_charge_cards" | "charge_card_express_interest" | "create_schedule" | "save_schedule" | "delete_schedule" | "ignore_schedule" | "save_task_detail" | "fetch_task_detail" | "delete_task" | "archive_task" | "create_tag" | "delete_tag" | "update_charge_card" | "update_charge_card_name" | "update_charge_card_name_card_user" | "issue_charge_card" | "issue_charge_cards" | "notification_settings_saved" | "referral_invite_sent" | "notification_mark_as_read" | "mark_as_complete_schedule" | "cancel_journal_entry" | "settings_accounting_accounts_updated" | "create_card_setup" | "confirm_card_setup" | "add_card_payment_source" | "fetch_payment_sources" | "task_assigned_toast_notification" | "task_due_tomorrow_toast_notification" | "task_deleted_toast_notification" | "task_archived_toast_notification" | "task_overdue_toast_notification" | "task_overdue_toast_notification_creator" | "task_notification_count" | "task_activities_toast_notification" | "task_created_toast_notification" | "task_group_creation_success" | "task_group_deletion_success" | "task_group_update_success" | "primary_funding_account_updated" | "task_time_spent_validation" | "missing_receipts_attachment" | "flux_analysis_unreviewed" | "flux_analysis_reviewed" | "receipts_upload" | "billing_address_view" | "express_pay_submit" | "exclude_transaction" | "reconcile" | "save_reconcile_for_later" | "recon_transaction_categorize" | "recon_transaction_match" | "update_debit_card_pin_attempt" | "set_debit_card_pin" | "ai_cfo_create_session_and_submit" | "ai_cfo_chat_session_deleted" | "charge_card_auto_pay_enable" | "charge_card_auto_pay_disable" | "treasury_setup" | "treasury_accept_term" | "treasury_transfer_money" | "treasury_transfer_money_failed" | "treasury_update_portfolio_allocation" | "send_email_magic_link_to_user" | "complete_profile_done" | "reports_resync" | "invalid_phone_number" | "transactions_categorized_updated_failed" | "transaction_categorized_updated_failed" | "transactionsCategorized_transactionsUpdated" | "transactionsCategorized_transactionUpdated" | "transactionCategorized_transactionsUpdated" | "transactionCategorized_transactionUpdated" | "transactionsCategorized_transactionsFailed" | "transactionsCategorized_transactionFailed" | "transactionCategorized_transactionsFailed" | "transactionCategorized_transactionFailed" | "transactionsUpdated_transactionsFailed" | "transactionsUpdated_transactionFailed" | "transactionUpdated_transactionsFailed" | "transactionUpdated_transactionFailed" | "transactionsCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionsUpdated_transactionFailed" | "transactionsCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionUpdated_transactionFailed" | "transactionCategorized_transactionsUpdated_transactionFailed" | "transactionCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionUpdated_transactionFailed";
40
+ messageSection: "common" | "transactionDetails_updatingPastTransactions" | "transactionDetails_transactionUpdated" | "cockpit_month_end_email_sent" | "cockpit_month_end_email_save" | "cockpit_month_end_email_attachment_upload" | "je_bill_link" | "je_posted" | "audit_score_updated" | "people_invite_people" | "people_invite_multiple_people" | "people_delete_person" | "people_update_person" | "reimbursement_updated" | "reimbursement_deleted" | "reimbursement_cancelled_deleted" | "reimbursement_cancelled" | "reimbursement_approved" | "reimbursement_rejected" | "reimbursement_sent_for_approval" | "account_added" | "business_verification_save" | "business_verification_submit" | "business_verification_from_bills_submit" | "plaid_connection" | "unlink_deposit_account" | "reimbursement_setup" | "reimbursement_approval_create" | "reimbursement_duplicate_approval_create" | "reimbursement_approval_update" | "reimbursement_duplicate_approval_update" | "reimbursement_approval_delete" | "reimbursement_create_mileage" | "reimbursement_update_mileage" | "reimbursement_accept_term" | "reimbursement_accept_employee_term" | "reimbursement_bulk_submit" | "reimbursement_bulk_processed" | "bill_pay_setup" | "zeni_accounts_setup" | "bill_pay_approval_create" | "bill_pay_duplicate_approval_create" | "bill_pay_approval_update" | "bill_pay_duplicate_approval_update" | "bill_pay_approval_delete" | "bill_pay_updated" | "bill_pay_deleted" | "bill_pay_cancelled_deleted" | "bill_pay_cancelled" | "bill_pay_approved" | "real_time_approver_added" | "bill_pay_rejected" | "bill_pay_sent_for_approval" | "bill_pay_accept_term" | "bill_pay_bulk_submit" | "bill_pay_bulk_processed" | "bill_pay_refund" | "bill_pay_retry" | "bill_pay_marked_as_paid" | "zeni_account_accept_term" | "update_vendor" | "data_refresh_update" | "delete_bank_account" | "create_bank_account" | "create_bank_account_ach" | "create_bank_account_wire" | "create_bank_account_international" | "transfer_money" | "update_zeni_account_nickname" | "create_checking_account" | "deposit_check" | "create_vendor" | "onboarding_customer_view" | "onboarding_customer_view_complete" | "onboarding_customer_identity_verification_save" | "onboarding_customer_identity_verification_submit" | "onboarding_customer_business_verification_save" | "onboarding_customer_business_verification_submit" | "retry_bank_account_connection" | "dashboard_invite_sent" | "onboarding_info_saved" | "approve_original_merchant" | "approve_global_merchant" | "reject_global_merchant" | "create_global_merchant" | "fetch_global_merchant_no_recommendation" | "save_vendor_renamed" | "save_vendor_sent_for_review" | "save_vendor_marked_as_employee" | "save_vendor_marked_as_local_contractor" | "charge_card_setup" | "charge_card_accept_term" | "charge_card_receipt_upload" | "charge_card_resend_invite" | "charge_card_revoke_invite" | "charge_card_update_limit" | "charge_cards_update_limit" | "close_charge_card" | "lock_charge_card" | "lock_charge_card_card_user" | "lock_charge_cards" | "unlock_charge_card" | "unlock_charge_card_card_user" | "unlock_charge_cards" | "close_charge_cards" | "revoke_invite_charge_cards" | "charge_card_express_interest" | "create_schedule" | "save_schedule" | "delete_schedule" | "ignore_schedule" | "save_task_detail" | "fetch_task_detail" | "delete_task" | "archive_task" | "create_tag" | "delete_tag" | "update_charge_card" | "update_charge_card_name" | "update_charge_card_name_card_user" | "issue_charge_card" | "issue_charge_cards" | "notification_settings_saved" | "referral_invite_sent" | "notification_mark_as_read" | "mark_as_complete_schedule" | "cancel_journal_entry" | "settings_accounting_accounts_updated" | "create_card_setup" | "confirm_card_setup" | "add_card_payment_source" | "fetch_payment_sources" | "task_assigned_toast_notification" | "task_due_tomorrow_toast_notification" | "task_deleted_toast_notification" | "task_archived_toast_notification" | "task_overdue_toast_notification" | "task_overdue_toast_notification_creator" | "task_notification_count" | "task_activities_toast_notification" | "task_created_toast_notification" | "task_group_creation_success" | "task_group_deletion_success" | "task_group_update_success" | "primary_funding_account_updated" | "task_time_spent_validation" | "missing_receipts_attachment" | "flux_analysis_unreviewed" | "flux_analysis_reviewed" | "receipt_match" | "receipts_upload" | "billing_address_view" | "express_pay_submit" | "exclude_transaction" | "reconcile" | "save_reconcile_for_later" | "recon_transaction_categorize" | "recon_transaction_match" | "update_debit_card_pin_attempt" | "set_debit_card_pin" | "ai_cfo_create_session_and_submit" | "ai_cfo_chat_session_deleted" | "charge_card_auto_pay_enable" | "charge_card_auto_pay_disable" | "treasury_setup" | "treasury_accept_term" | "treasury_transfer_money" | "treasury_transfer_money_failed" | "treasury_update_portfolio_allocation" | "send_email_magic_link_to_user" | "complete_profile_done" | "reports_resync" | "invalid_phone_number" | "transactions_categorized_updated_failed" | "transaction_categorized_updated_failed" | "transactionsCategorized_transactionsUpdated" | "transactionsCategorized_transactionUpdated" | "transactionCategorized_transactionsUpdated" | "transactionCategorized_transactionUpdated" | "transactionsCategorized_transactionsFailed" | "transactionsCategorized_transactionFailed" | "transactionCategorized_transactionsFailed" | "transactionCategorized_transactionFailed" | "transactionsUpdated_transactionsFailed" | "transactionsUpdated_transactionFailed" | "transactionUpdated_transactionsFailed" | "transactionUpdated_transactionFailed" | "transactionsCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionsUpdated_transactionFailed" | "transactionsCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionUpdated_transactionFailed" | "transactionCategorized_transactionsUpdated_transactionFailed" | "transactionCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionUpdated_transactionFailed";
41
41
  messageText: "notification" | "success" | "failed";
42
42
  type: "error" | "success" | "info";
43
43
  variables: {
@@ -46,8 +46,8 @@ const filterAutoTabLineItems = (tabView, transactionId, updatedTransaction) => {
46
46
  if (localData == null) {
47
47
  return;
48
48
  }
49
- const currentAutoLineIds = localData.transactionReviewLocalData.tabSpecificLineItems
50
- .autoCategorized ?? [];
49
+ const currentAutoLineIds = localData.transactionReviewLocalData.tabSpecificLineItems.autoCategorized ??
50
+ [];
51
51
  const linesById = new Map(updatedTransaction.lines?.map((l) => [l.id, l]));
52
52
  const retainedLineIds = currentAutoLineIds.filter((lineId) => {
53
53
  const line = linesById.get(lineId);
@@ -1,5 +1,9 @@
1
+ import { URLPayload } from '../../../commonPayloadTypes/urlPayload';
1
2
  import { TransactionPayload } from '../../../entity/transaction/payloadTypes/transactionPayload';
3
+ import { SupportedTransactionPayload } from '../../../entity/transaction/transactionState';
2
4
  import { ZeniAPIResponse } from '../../../responsePayload';
5
+ import type { MonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
6
+ import type { BatchDetails, BatchFile, BatchFileStatus, BatchListItem, BatchStatus, BatchSummary, ManualSearchResult } from '../types/missingReceiptsViewState';
3
7
  export interface MissingReceiptsQueryPayload {
4
8
  end_date: string;
5
9
  is_attachment_missing_only: boolean;
@@ -13,4 +17,118 @@ interface MissingReceiptsPayload {
13
17
  transactions: TransactionPayload[];
14
18
  }
15
19
  export type MissingReceiptsResponse = ZeniAPIResponse<MissingReceiptsPayload>;
20
+ export interface BatchListQueryPayload {
21
+ end_date: string;
22
+ sort_order: string;
23
+ start_date: string;
24
+ }
25
+ export interface BulkUploadResponsePayload {
26
+ batch_id: string;
27
+ status: string;
28
+ total_files: number;
29
+ }
30
+ export type BulkUploadResponse = ZeniAPIResponse<BulkUploadResponsePayload>;
31
+ export interface BatchListResponsePayload {
32
+ batches: BatchListItemPayload[];
33
+ }
34
+ export interface BatchListItemPayload {
35
+ batch_id: string;
36
+ created_at: string;
37
+ failed_count: number;
38
+ matched_count: number;
39
+ no_match_count: number;
40
+ possible_matches_count: number;
41
+ status: string;
42
+ total_files: number;
43
+ }
44
+ export type BatchListResponse = ZeniAPIResponse<BatchListResponsePayload>;
45
+ export interface MatchedTransactionPayload {
46
+ amount: number;
47
+ currency_code: string;
48
+ transaction_date: string | null;
49
+ transaction_id: string;
50
+ vendor_name: string;
51
+ transaction_type?: string;
52
+ vendor_logo?: URLPayload | null;
53
+ }
54
+ export interface MatchCandidatePayload extends MatchedTransactionPayload {
55
+ match_score: number;
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
+ export interface BatchFilePayload {
63
+ attachment_id: string;
64
+ file_id: string;
65
+ file_preview_url: string | null;
66
+ filename: string;
67
+ status: string;
68
+ candidates?: MatchCandidatePayload[];
69
+ match_source?: string;
70
+ matched_transaction?: MatchedTransactionPayload;
71
+ }
72
+ export interface BatchDetailsResponsePayload {
73
+ batch_id: string;
74
+ created_at: string;
75
+ files: BatchFilePayload[];
76
+ status: string;
77
+ summary: {
78
+ failed: number;
79
+ matched: number;
80
+ no_match: number;
81
+ possible_matches: number;
82
+ total: number;
83
+ };
84
+ }
85
+ 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
+ export declare function toBatchFile(payload: BatchFilePayload, filesEndPoint?: string): BatchFile;
93
+ export declare function extractTransactionPayloadsFromBatchFiles(files: BatchFilePayload[]): SupportedTransactionPayload[];
94
+ export declare function toBatchSummary(payload: BatchDetailsResponsePayload['summary']): BatchSummary;
95
+ export declare function toBatchDetails(payload: BatchDetailsResponsePayload, filesEndPoint?: string): BatchDetails;
96
+ /** Batch list `status` is a string from the API — compare case-insensitively. */
97
+ export declare function isBatchListStatusCompleted(status: string): boolean;
98
+ /**
99
+ * Subset of the get-all-batches (`/batches?query=...`) list that is eligible for
100
+ * `GET /batches/:batchId` details fetches. The stored list may include pending, failed, or other
101
+ * statuses for UI; only `completed` rows should trigger batch-details requests.
102
+ */
103
+ export declare function filterBatchListItemsForBatchDetailsFetch(batches: BatchListItem[]): BatchListItem[];
104
+ /**
105
+ * Batch details API response `status` field — only completed payloads should be stored from
106
+ * multi-batch fetch paths (list can be briefly stale vs. live processing state).
107
+ */
108
+ export declare function isBatchDetailsApiStatusCompleted(status: string): boolean;
109
+ export declare function findBatchListItemForBatchId(batchListByPeriod: Record<MonthYearPeriodId, BatchListItem[]>, batchId: string): BatchListItem | undefined;
110
+ /**
111
+ * Whether it is appropriate to call `GET .../batches/:id` for details.
112
+ * Skips when live batch status or batch list row indicates the batch is not completed yet.
113
+ * When status is unknown in both sources, allows the request (e.g. dispatch before list refresh).
114
+ */
115
+ export declare function shouldFetchBatchDetailsForBatchId(batchStatusById: Record<string, BatchStatus>, batchListByPeriod: Record<MonthYearPeriodId, BatchListItem[]>, batchId: string): boolean;
116
+ export declare function toBatchListItem(payload: BatchListItemPayload): BatchListItem;
117
+ /** Maps expense-automation transaction rows to manual-search list rows (Unmatched tab). */
118
+ export declare function supportedTransactionPayloadToManualSearchResult(payload: SupportedTransactionPayload): ManualSearchResult;
119
+ export interface CompletedTransactionsQueryPayload {
120
+ end_date?: string;
121
+ match_type?: string;
122
+ page_size?: number;
123
+ page_token?: string | null;
124
+ sort_by?: string;
125
+ sort_order?: string;
126
+ start_date?: string;
127
+ }
128
+ export interface CompletedTransactionsResponsePayload {
129
+ next_page_token: string | null;
130
+ total_count: number;
131
+ transactions: SupportedTransactionPayload[];
132
+ }
133
+ export type CompletedTransactionsResponse = ZeniAPIResponse<CompletedTransactionsResponsePayload>;
16
134
  export {};
@@ -1,2 +1,187 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseBatchFileStatus = parseBatchFileStatus;
4
+ exports.toBatchFile = toBatchFile;
5
+ exports.extractTransactionPayloadsFromBatchFiles = extractTransactionPayloadsFromBatchFiles;
6
+ exports.toBatchSummary = toBatchSummary;
7
+ exports.toBatchDetails = toBatchDetails;
8
+ exports.isBatchListStatusCompleted = isBatchListStatusCompleted;
9
+ exports.filterBatchListItemsForBatchDetailsFetch = filterBatchListItemsForBatchDetailsFetch;
10
+ exports.isBatchDetailsApiStatusCompleted = isBatchDetailsApiStatusCompleted;
11
+ exports.findBatchListItemForBatchId = findBatchListItemForBatchId;
12
+ exports.shouldFetchBatchDetailsForBatchId = shouldFetchBatchDetailsForBatchId;
13
+ exports.toBatchListItem = toBatchListItem;
14
+ exports.supportedTransactionPayloadToManualSearchResult = supportedTransactionPayloadToManualSearchResult;
15
+ const urlPayload_1 = require("../../../commonPayloadTypes/urlPayload");
16
+ const transactionPayload_1 = require("../../../entity/transaction/payloadTypes/transactionPayload");
17
+ // -- Converter functions --
18
+ /**
19
+ * Maps batch-details API `files[].status` strings to canonical {@link BatchFileStatus}.
20
+ * Legacy aliases are supported during rollout; unknown strings map to `failed` so Redux never
21
+ * holds untyped status values.
22
+ */
23
+ function parseBatchFileStatus(raw) {
24
+ const s = raw.trim().toLowerCase().replace(/-/g, '_');
25
+ switch (s) {
26
+ case 'exact_match':
27
+ case 'matched':
28
+ return 'exact_match';
29
+ case 'possible_matches':
30
+ case 'possible_match':
31
+ case 'possiblematch':
32
+ case 'un_matched':
33
+ case 'unmatched':
34
+ return 'possible_matches';
35
+ case 'no_match':
36
+ case 'nomatch':
37
+ return 'no_match';
38
+ case 'failed':
39
+ return 'failed';
40
+ default:
41
+ return 'failed';
42
+ }
43
+ }
44
+ function toBatchFile(payload, filesEndPoint) {
45
+ return {
46
+ attachmentId: payload.attachment_id,
47
+ candidates: payload.candidates?.map((c) => ({
48
+ transactionId: c.transaction_id,
49
+ matchScore: c.match_score,
50
+ })),
51
+ fileDownloadUrl: payload.file_id != null && filesEndPoint != null
52
+ ? `${filesEndPoint}/1.0/files/${payload.file_id}?query=${encodeURIComponent(JSON.stringify({ download_file: true }))}`
53
+ : null,
54
+ fileId: payload.file_id,
55
+ filePreviewUrl: payload.file_preview_url,
56
+ filename: payload.filename,
57
+ matchSource: payload.match_source,
58
+ matchedTransactionId: payload.matched_transaction?.transaction_id,
59
+ status: parseBatchFileStatus(payload.status),
60
+ };
61
+ }
62
+ function extractTransactionPayloadsFromBatchFiles(files) {
63
+ const seen = new Set();
64
+ const payloads = [];
65
+ for (const file of files) {
66
+ if (file.matched_transaction != null) {
67
+ const id = file.matched_transaction.transaction_id;
68
+ if (!seen.has(id)) {
69
+ seen.add(id);
70
+ payloads.push(matchedTransactionPayloadToSupportedTransactionPayload(file.matched_transaction));
71
+ }
72
+ }
73
+ if (file.candidates != null) {
74
+ for (const candidate of file.candidates) {
75
+ const id = candidate.transaction_id;
76
+ if (!seen.has(id)) {
77
+ seen.add(id);
78
+ payloads.push(matchedTransactionPayloadToSupportedTransactionPayload(candidate));
79
+ }
80
+ }
81
+ }
82
+ }
83
+ return payloads;
84
+ }
85
+ function matchedTransactionPayloadToSupportedTransactionPayload(payload) {
86
+ return {
87
+ transaction_id: payload.transaction_id,
88
+ transaction_type: payload.transaction_type ?? 'expense',
89
+ transaction_date: payload.transaction_date ?? '',
90
+ currency_code: payload.currency_code,
91
+ total_amount: payload.amount,
92
+ vendor_name: payload.vendor_name,
93
+ logo: payload.vendor_logo == null ? undefined : (0, urlPayload_1.toURL)(payload.vendor_logo),
94
+ };
95
+ }
96
+ function toBatchSummary(payload) {
97
+ return {
98
+ failed: payload.failed,
99
+ matched: payload.matched,
100
+ noMatch: payload.no_match,
101
+ possibleMatches: payload.possible_matches,
102
+ total: payload.total,
103
+ };
104
+ }
105
+ function toBatchDetails(payload, filesEndPoint) {
106
+ return {
107
+ batchId: payload.batch_id,
108
+ createdAt: payload.created_at,
109
+ files: payload.files.map((f) => toBatchFile(f, filesEndPoint)),
110
+ status: payload.status,
111
+ summary: toBatchSummary(payload.summary),
112
+ };
113
+ }
114
+ /** Batch list `status` is a string from the API — compare case-insensitively. */
115
+ function isBatchListStatusCompleted(status) {
116
+ return status.toLowerCase() === 'completed';
117
+ }
118
+ /**
119
+ * Subset of the get-all-batches (`/batches?query=...`) list that is eligible for
120
+ * `GET /batches/:batchId` details fetches. The stored list may include pending, failed, or other
121
+ * statuses for UI; only `completed` rows should trigger batch-details requests.
122
+ */
123
+ function filterBatchListItemsForBatchDetailsFetch(batches) {
124
+ return batches.filter((b) => isBatchListStatusCompleted(b.status));
125
+ }
126
+ /**
127
+ * Batch details API response `status` field — only completed payloads should be stored from
128
+ * multi-batch fetch paths (list can be briefly stale vs. live processing state).
129
+ */
130
+ function isBatchDetailsApiStatusCompleted(status) {
131
+ return status.toLowerCase() === 'completed';
132
+ }
133
+ function findBatchListItemForBatchId(batchListByPeriod, batchId) {
134
+ for (const list of Object.values(batchListByPeriod)) {
135
+ const found = list.find((b) => b.batchId === batchId);
136
+ if (found != null) {
137
+ return found;
138
+ }
139
+ }
140
+ return undefined;
141
+ }
142
+ /**
143
+ * Whether it is appropriate to call `GET .../batches/:id` for details.
144
+ * Skips when live batch status or batch list row indicates the batch is not completed yet.
145
+ * When status is unknown in both sources, allows the request (e.g. dispatch before list refresh).
146
+ */
147
+ function shouldFetchBatchDetailsForBatchId(batchStatusById, batchListByPeriod, batchId) {
148
+ const live = batchStatusById[batchId]?.status;
149
+ if (live === 'completed') {
150
+ return true;
151
+ }
152
+ if (live === 'pending' || live === 'processing') {
153
+ return false;
154
+ }
155
+ const listItem = findBatchListItemForBatchId(batchListByPeriod, batchId);
156
+ if (listItem != null && !isBatchListStatusCompleted(listItem.status)) {
157
+ return false;
158
+ }
159
+ return true;
160
+ }
161
+ function toBatchListItem(payload) {
162
+ return {
163
+ batchId: payload.batch_id,
164
+ createdAt: payload.created_at,
165
+ failedCount: payload.failed_count,
166
+ matchedCount: payload.matched_count,
167
+ noMatchCount: payload.no_match_count,
168
+ possibleMatchesCount: payload.possible_matches_count,
169
+ status: payload.status,
170
+ totalFiles: payload.total_files,
171
+ };
172
+ }
173
+ /** Maps expense-automation transaction rows to manual-search list rows (Unmatched tab). */
174
+ function supportedTransactionPayloadToManualSearchResult(payload) {
175
+ const amountPayload = (0, transactionPayload_1.getTransactionPayloadAmount)(payload);
176
+ return {
177
+ amount: amountPayload.amount,
178
+ currencyCode: amountPayload.currencyCode,
179
+ entityId: payload.vendor_id ?? payload.customer_id ?? '',
180
+ memo: payload.transaction_memo ?? '',
181
+ transactionDate: payload.transaction_date,
182
+ transactionId: payload.transaction_id,
183
+ transactionType: payload.transaction_type,
184
+ vendorName: payload.vendor_name ?? '',
185
+ vendorLogo: (0, urlPayload_1.toURL)(payload.logo)?.href,
186
+ };
187
+ }