@zeniai/client-epic-state 4.20.7 → 4.20.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonStateTypes/coaBalance/additionalBalances/getSummationBalance.d.ts +1 -1
- package/lib/commonStateTypes/coaBalance/coaBalanceType.d.ts +2 -0
- package/lib/commonStateTypes/coaBalance/coaBalanceType.js +6 -0
- package/lib/commonStateTypes/currencyHelper.d.ts +3 -0
- package/lib/commonStateTypes/currencyHelper.js +6 -1
- package/lib/commonStateTypes/reduceFetchState.d.ts +9 -0
- package/lib/commonStateTypes/reduceFetchState.js +26 -0
- package/lib/entity/account/accountPayload.d.ts +2 -0
- package/lib/entity/account/accountPayload.js +2 -0
- package/lib/entity/account/accountState.d.ts +2 -0
- package/lib/entity/customer/customerState.d.ts +0 -2
- package/lib/entity/customer/customerState.js +0 -5
- package/lib/entity/depositAccount/depositAccount.d.ts +1 -1
- package/lib/entity/depositAccount/depositAccount.js +8 -1
- package/lib/entity/reimbursement/reimbursementPayload.d.ts +2 -0
- package/lib/entity/reimbursement/reimbursementPayload.js +7 -0
- package/lib/entity/reimbursement/reimbursementState.d.ts +2 -0
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +2 -0
- package/lib/entity/task/taskPayload.d.ts +1 -0
- package/lib/entity/task/taskPayload.js +1 -0
- package/lib/entity/task/taskState.d.ts +1 -0
- package/lib/entity/userGroups/userGroupsPayload.d.ts +7 -0
- package/lib/entity/userGroups/userGroupsPayload.js +10 -0
- package/lib/entity/userGroups/userGroupsReducer.d.ts +8 -0
- package/lib/entity/userGroups/userGroupsReducer.js +29 -0
- package/lib/entity/userGroups/userGroupsSelector.d.ts +4 -0
- package/lib/entity/userGroups/userGroupsSelector.js +12 -0
- package/lib/entity/userGroups/userGroupsState.d.ts +9 -0
- package/lib/entity/userGroups/userGroupsState.js +2 -0
- package/lib/epic.d.ts +15 -1
- package/lib/epic.js +15 -1
- package/lib/esm/commonStateTypes/coaBalance/coaBalanceType.js +5 -0
- package/lib/esm/commonStateTypes/currencyHelper.js +5 -0
- package/lib/esm/commonStateTypes/reduceFetchState.js +25 -0
- package/lib/esm/entity/account/accountPayload.js +2 -0
- package/lib/esm/entity/customer/customerState.js +1 -4
- package/lib/esm/entity/depositAccount/depositAccount.js +8 -1
- package/lib/esm/entity/reimbursement/reimbursementPayload.js +7 -0
- package/lib/esm/entity/snackbar/snackbarTypes.js +2 -0
- package/lib/esm/entity/task/taskPayload.js +1 -0
- package/lib/esm/entity/userGroups/userGroupsPayload.js +7 -0
- package/lib/esm/entity/userGroups/userGroupsReducer.js +25 -0
- package/lib/esm/entity/userGroups/userGroupsSelector.js +8 -0
- package/lib/esm/entity/userGroups/userGroupsState.js +1 -0
- package/lib/esm/epic.js +15 -1
- package/lib/esm/index.js +19 -10
- package/lib/esm/reducer.js +6 -0
- package/lib/esm/view/arAgingView/arAgingReport/arAgingReducer.js +1 -1
- package/lib/esm/view/arAgingView/arAgingReport/arAgingSelector.js +1 -1
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadMatchResultToastEpic.js +33 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +29 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +49 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +40 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +49 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +61 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +33 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +56 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/refetchCompletedTransactionsOnBulkUploadSortEpic.js +12 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +98 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +71 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +7 -5
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +86 -0
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +24 -0
- package/lib/esm/view/expenseAutomationView/helpers/bulkUploadTiming.js +16 -0
- package/lib/esm/view/expenseAutomationView/helpers/rollingCalendarDateRangeInclusive.js +13 -0
- package/lib/esm/view/expenseAutomationView/payload/missingReceiptsPayload.js +198 -1
- package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +456 -2
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +23 -1
- package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +245 -1
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +2 -1
- package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +44 -0
- package/lib/esm/view/expenseAutomationView/types/transactionsViewState.js +2 -1
- package/lib/esm/view/financeStatement/financeStatementReducer.js +11 -8
- package/lib/esm/view/financeStatement/financeStatementSelector.js +24 -9
- package/lib/esm/view/profitAndLossClassesView/horizontalSectionEmptyBalancesSlice.js +17 -0
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +331 -0
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.js +9 -0
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesViewReducer.js +6 -1
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesViewSelector.js +2 -29
- package/lib/esm/view/profitAndLossClassesView/profitAndLossForTimeframeClassesViewEpic.js +7 -5
- package/lib/esm/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +262 -0
- package/lib/esm/view/reportUIOptions/updateReportUIOptionCOABalancesRangeEpic.js +9 -7
- package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
- package/lib/esm/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.js +1 -0
- package/lib/esm/view/taskManager/taskListView/taskListSelector.js +3 -1
- package/lib/esm/view/userGroupListView/userGroupListViewReducer.js +65 -0
- package/lib/esm/view/userGroupListView/userGroupListViewSelector.js +16 -0
- package/lib/esm/view/userGroupListView/userGroupListViewState.js +1 -0
- package/lib/esm/view/userListView/fetchUserListByTypeEpic.js +11 -0
- package/lib/esm/zeniAPI.js +0 -2
- package/lib/index.d.ts +20 -12
- package/lib/index.js +97 -34
- package/lib/reducer.d.ts +6 -0
- package/lib/reducer.js +6 -0
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
- package/lib/view/arAgingView/arAgingReport/arAgingReducer.js +2 -2
- package/lib/view/arAgingView/arAgingReport/arAgingSelector.js +5 -5
- package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadMatchResultToastEpic.d.ts +13 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadMatchResultToastEpic.js +37 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.d.ts +18 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +33 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.d.ts +7 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +53 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +44 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.d.ts +7 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +53 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +65 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +37 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.d.ts +9 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +61 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/refetchCompletedTransactionsOnBulkUploadSortEpic.d.ts +10 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/refetchCompletedTransactionsOnBulkUploadSortEpic.js +16 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.d.ts +18 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +102 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.d.ts +14 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +75 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +7 -5
- package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts +25 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +92 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.d.ts +7 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +28 -0
- package/lib/view/expenseAutomationView/helpers/bulkUploadTiming.d.ts +16 -0
- package/lib/view/expenseAutomationView/helpers/bulkUploadTiming.js +19 -0
- package/lib/view/expenseAutomationView/helpers/rollingCalendarDateRangeInclusive.d.ts +7 -0
- package/lib/view/expenseAutomationView/helpers/rollingCalendarDateRangeInclusive.js +16 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.d.ts +123 -0
- package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.js +211 -0
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +86 -3
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +457 -2
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +11 -3
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +24 -2
- package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +70 -1
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +1 -0
- package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.d.ts +1 -1
- package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +244 -0
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +2 -1
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +146 -0
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +54 -1
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +2 -1
- package/lib/view/expenseAutomationView/types/transactionsViewState.js +2 -1
- package/lib/view/financeStatement/financeStatementReducer.js +11 -8
- package/lib/view/financeStatement/financeStatementSelector.d.ts +2 -0
- package/lib/view/financeStatement/financeStatementSelector.js +24 -9
- package/lib/view/profitAndLossClassesView/horizontalSectionEmptyBalancesSlice.d.ts +9 -0
- package/lib/view/profitAndLossClassesView/horizontalSectionEmptyBalancesSlice.js +20 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.d.ts +15 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +335 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.d.ts +111 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.js +13 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesViewReducer.d.ts +4 -2
- package/lib/view/profitAndLossClassesView/profitAndLossClassesViewReducer.js +7 -2
- package/lib/view/profitAndLossClassesView/profitAndLossClassesViewSelector.js +2 -29
- package/lib/view/profitAndLossClassesView/profitAndLossClassesViewState.d.ts +4 -0
- package/lib/view/profitAndLossClassesView/profitAndLossForTimeframeClassesViewEpic.js +7 -5
- package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.d.ts +6 -0
- package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +265 -0
- package/lib/view/reportUIOptions/updateReportUIOptionCOABalancesRangeEpic.js +8 -6
- package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
- package/lib/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.d.ts +1 -0
- package/lib/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.js +1 -0
- package/lib/view/taskManager/taskListView/taskListSelector.d.ts +2 -0
- package/lib/view/taskManager/taskListView/taskListSelector.js +3 -1
- package/lib/view/userGroupListView/userGroupListViewReducer.d.ts +23 -0
- package/lib/view/userGroupListView/userGroupListViewReducer.js +69 -0
- package/lib/view/userGroupListView/userGroupListViewSelector.d.ts +7 -0
- package/lib/view/userGroupListView/userGroupListViewSelector.js +20 -0
- package/lib/view/userGroupListView/userGroupListViewState.d.ts +8 -0
- package/lib/view/userGroupListView/userGroupListViewState.js +2 -0
- package/lib/view/userListView/fetchUserListByTypeEpic.d.ts +3 -1
- package/lib/view/userListView/fetchUserListByTypeEpic.js +11 -0
- package/lib/view/userListView/userListViewPayload.d.ts +2 -0
- package/lib/zeniAPI.js +0 -2
- package/package.json +3 -3
|
@@ -5,9 +5,9 @@ exports.clearArAging = exports.updateArAgingNodeCollapseState = exports.updateAr
|
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
6
|
const viewAndReportPayloadv2_1 = require("../../../commonPayloadTypes/v2/viewAndReportPayloadv2");
|
|
7
7
|
const agingBalance_1 = require("../../../commonStateTypes/agingBalance/agingBalance");
|
|
8
|
+
const currencyHelper_1 = require("../../../commonStateTypes/currencyHelper");
|
|
8
9
|
const getNestedCustomerHierarchy_1 = require("../../../commonStateTypes/customerView/getNestedCustomerHierarchy");
|
|
9
10
|
const customerPayload_1 = require("../../../entity/customer/customerPayload");
|
|
10
|
-
const customerState_1 = require("../../../entity/customer/customerState");
|
|
11
11
|
const zeniDayJS_1 = require("../../../zeniDayJS");
|
|
12
12
|
const arAgingPayload_1 = require("./arAgingPayload");
|
|
13
13
|
exports.inititalUIState = {
|
|
@@ -30,7 +30,7 @@ exports.initialState = {
|
|
|
30
30
|
agingPeriods: [],
|
|
31
31
|
bookCloseDate: undefined,
|
|
32
32
|
dataAvailable: undefined,
|
|
33
|
-
currency:
|
|
33
|
+
currency: currencyHelper_1.defaultCustomerCurrency,
|
|
34
34
|
};
|
|
35
35
|
exports.initialStateAgingBalances = {
|
|
36
36
|
arAgingBalancesByCustomerId: {},
|
|
@@ -7,8 +7,8 @@ exports.getArAgingReport = void 0;
|
|
|
7
7
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
8
8
|
const orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
9
9
|
const agingBalance_1 = require("../../../commonStateTypes/agingBalance/agingBalance");
|
|
10
|
+
const currencyHelper_1 = require("../../../commonStateTypes/currencyHelper");
|
|
10
11
|
const customerSelector_1 = require("../../../entity/customer/customerSelector");
|
|
11
|
-
const customerState_1 = require("../../../entity/customer/customerState");
|
|
12
12
|
exports.getArAgingReport = (0, toolkit_1.createSelector)((state) => state.arAgingState, (state) => state.customerState, (arAgingState, customerState) => {
|
|
13
13
|
const { reportId, reportTitle, fetchState, uiState, firstMonthOfFY, agingPeriods, } = arAgingState;
|
|
14
14
|
const { searchString, sortOrder, sortKey, selectedDate } = uiState;
|
|
@@ -87,13 +87,13 @@ const getCustomerAgingReport = (customerState, nestedCustomer, arAgingBalancesBy
|
|
|
87
87
|
children: getNestedAgingBalancesByCustomer(customerState, arAgingBalancesByCustomerId, nestedCustomer.children, searchString, sortKey, sortOrder),
|
|
88
88
|
total: {
|
|
89
89
|
amount: customerTotal,
|
|
90
|
-
currencyCode: currencyCode ??
|
|
91
|
-
currencySymbol: currencySymbol ??
|
|
90
|
+
currencyCode: currencyCode ?? currencyHelper_1.defaultCustomerCurrency.currencyCode,
|
|
91
|
+
currencySymbol: currencySymbol ?? currencyHelper_1.defaultCustomerCurrency.currencySymbol,
|
|
92
92
|
},
|
|
93
93
|
totalWithChildren: {
|
|
94
94
|
amount: customerTotalWithChildren,
|
|
95
|
-
currencyCode: currencyCode ??
|
|
96
|
-
currencySymbol: currencySymbol ??
|
|
95
|
+
currencyCode: currencyCode ?? currencyHelper_1.defaultCustomerCurrency.currencyCode,
|
|
96
|
+
currencySymbol: currencySymbol ?? currencyHelper_1.defaultCustomerCurrency.currencySymbol,
|
|
97
97
|
},
|
|
98
98
|
};
|
|
99
99
|
};
|
package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadMatchResultToastEpic.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ActionsObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
4
|
+
import { bulkUploadReceiptsSuccess, clearBulkUpload, fetchBulkUploadBatchDetailsSuccess, restoreBulkUploadMatchingState, storeBatchDetails } from '../../reducers/missingReceiptsViewReducer';
|
|
5
|
+
export type ActionType = ReturnType<typeof bulkUploadReceiptsSuccess> | ReturnType<typeof restoreBulkUploadMatchingState> | ReturnType<typeof fetchBulkUploadBatchDetailsSuccess> | ReturnType<typeof storeBatchDetails> | ReturnType<typeof clearBulkUpload> | ReturnType<typeof openSnackbar>;
|
|
6
|
+
/**
|
|
7
|
+
* Show a success toast when batch details arrive for the current upload batch,
|
|
8
|
+
* e.g. "17 out of 20 Receipts Matched". Scoped per upload session so it fires
|
|
9
|
+
* only once: starts on `bulkUploadReceiptsSuccess` (or `restoreBulkUploadMatchingState`
|
|
10
|
+
* for a restored session), waits for the first batch-details action for that batch,
|
|
11
|
+
* emits the toast, then stops. `clearBulkUpload` cancels the in-flight wait.
|
|
12
|
+
*/
|
|
13
|
+
export declare const bulkUploadMatchResultToastEpic: (actions$: ActionsObservable<ActionType>) => Observable<ActionType>;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadMatchResultToastEpic.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bulkUploadMatchResultToastEpic = 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 missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
8
|
+
/**
|
|
9
|
+
* Show a success toast when batch details arrive for the current upload batch,
|
|
10
|
+
* e.g. "17 out of 20 Receipts Matched". Scoped per upload session so it fires
|
|
11
|
+
* only once: starts on `bulkUploadReceiptsSuccess` (or `restoreBulkUploadMatchingState`
|
|
12
|
+
* for a restored session), waits for the first batch-details action for that batch,
|
|
13
|
+
* emits the toast, then stops. `clearBulkUpload` cancels the in-flight wait.
|
|
14
|
+
*/
|
|
15
|
+
const bulkUploadMatchResultToastEpic = (actions$) => actions$.pipe((0, operators_1.filter)((action) => missingReceiptsViewReducer_1.bulkUploadReceiptsSuccess.match(action) ||
|
|
16
|
+
missingReceiptsViewReducer_1.restoreBulkUploadMatchingState.match(action)), (0, operators_1.switchMap)((uploadAction) => {
|
|
17
|
+
const { batchId } = uploadAction.payload;
|
|
18
|
+
return (0, rxjs_1.merge)(actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsSuccess.match)), actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.storeBatchDetails.match))).pipe((0, operators_1.filter)((a) => a.payload.batchId === batchId), (0, operators_1.take)(1), (0, operators_1.mergeMap)((action) => {
|
|
19
|
+
const { summary } = action.payload;
|
|
20
|
+
return (0, rxjs_1.of)((0, snackbarReducer_1.openSnackbar)({
|
|
21
|
+
messageSection: 'receipts_bulk_match',
|
|
22
|
+
messageText: 'success',
|
|
23
|
+
type: 'success',
|
|
24
|
+
variables: [
|
|
25
|
+
{
|
|
26
|
+
variableName: '_matched_',
|
|
27
|
+
variableValue: String(summary.matched),
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
variableName: '_total_',
|
|
31
|
+
variableValue: String(summary.total),
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
}));
|
|
35
|
+
}), (0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.clearBulkUpload.match))));
|
|
36
|
+
}));
|
|
37
|
+
exports.bulkUploadMatchResultToastEpic = bulkUploadMatchResultToastEpic;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ActionsObservable } from 'redux-observable';
|
|
2
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
3
|
+
import { bulkUploadReceipts, bulkUploadReceiptsFailure, bulkUploadReceiptsSuccess } from '../../reducers/missingReceiptsViewReducer';
|
|
4
|
+
export type ActionType = ReturnType<typeof bulkUploadReceipts> | ReturnType<typeof bulkUploadReceiptsSuccess> | ReturnType<typeof bulkUploadReceiptsFailure>;
|
|
5
|
+
export declare const bulkUploadReceiptsEpic: (actions$: ActionsObservable<ActionType>, _state$: unknown, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
|
|
6
|
+
payload: {
|
|
7
|
+
batchId: import("../../../..").ID;
|
|
8
|
+
};
|
|
9
|
+
type: "expenseAutomationMissingReceiptsView/bulkUploadReceiptsSuccess";
|
|
10
|
+
} | {
|
|
11
|
+
payload: {
|
|
12
|
+
error: import("../../../../responsePayload").ZeniAPIStatus;
|
|
13
|
+
};
|
|
14
|
+
type: "expenseAutomationMissingReceiptsView/bulkUploadReceiptsFailure";
|
|
15
|
+
} | {
|
|
16
|
+
payload: number;
|
|
17
|
+
type: "expenseAutomationMissingReceiptsView/updateBulkUploadProgress";
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bulkUploadReceiptsEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const responsePayload_1 = require("../../../../responsePayload");
|
|
7
|
+
const bulkUploadTiming_1 = require("../../helpers/bulkUploadTiming");
|
|
8
|
+
const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
9
|
+
const bulkUploadReceiptsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.bulkUploadReceipts.match), (0, operators_1.mergeMap)((action) => {
|
|
10
|
+
const { files } = action.payload;
|
|
11
|
+
const formData = new FormData();
|
|
12
|
+
for (const file of files) {
|
|
13
|
+
formData.append('files', file, file.name);
|
|
14
|
+
}
|
|
15
|
+
return zeniAPI
|
|
16
|
+
.postFormData(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/bulk-upload`, formData)
|
|
17
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
18
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
19
|
+
const batchId = String(response.data.batch_id ?? '').trim();
|
|
20
|
+
if (batchId === '') {
|
|
21
|
+
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.bulkUploadReceiptsFailure)({
|
|
22
|
+
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Bulk upload succeeded but batch_id was missing or empty.'),
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
return (0, rxjs_1.concat)((0, rxjs_1.of)((0, missingReceiptsViewReducer_1.updateBulkUploadProgress)(100)), (0, rxjs_1.timer)(bulkUploadTiming_1.BULK_UPLOAD_BAR_COMPLETE_HOLD_MS).pipe((0, operators_1.mergeMap)(() => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.bulkUploadReceiptsSuccess)({ batchId })))));
|
|
26
|
+
}
|
|
27
|
+
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.bulkUploadReceiptsFailure)({ error: response.status }));
|
|
28
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.bulkUploadReceiptsFailure)({
|
|
29
|
+
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Bulk upload receipts API call errored out: ' +
|
|
30
|
+
JSON.stringify(error)),
|
|
31
|
+
}))));
|
|
32
|
+
}));
|
|
33
|
+
exports.bulkUploadReceiptsEpic = bulkUploadReceiptsEpic;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ActionsObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
4
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
5
|
+
import { confirmBulkUploadMatch, confirmBulkUploadMatchFailure, confirmBulkUploadMatchSuccess } from '../../reducers/missingReceiptsViewReducer';
|
|
6
|
+
export type ActionType = ReturnType<typeof confirmBulkUploadMatch> | ReturnType<typeof confirmBulkUploadMatchSuccess> | ReturnType<typeof confirmBulkUploadMatchFailure> | ReturnType<typeof openSnackbar>;
|
|
7
|
+
export declare const confirmBulkUploadMatchEpic: (actions$: ActionsObservable<ActionType>, _state$: unknown, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.confirmBulkUploadMatchEpic = 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 responsePayload_1 = require("../../../../responsePayload");
|
|
8
|
+
const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
9
|
+
const confirmBulkUploadMatchEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.confirmBulkUploadMatch.match), (0, operators_1.exhaustMap)((action) => {
|
|
10
|
+
const { batchId, attachmentId, transactionId, transactionType, fileName } = action.payload;
|
|
11
|
+
return zeniAPI
|
|
12
|
+
.postAndGetJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/manual-match`, {
|
|
13
|
+
attachment_id: attachmentId,
|
|
14
|
+
transaction_id: transactionId,
|
|
15
|
+
transaction_type: transactionType,
|
|
16
|
+
file_name: fileName,
|
|
17
|
+
})
|
|
18
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
19
|
+
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
20
|
+
return (0, rxjs_1.from)([
|
|
21
|
+
(0, missingReceiptsViewReducer_1.confirmBulkUploadMatchSuccess)({
|
|
22
|
+
batchId,
|
|
23
|
+
attachmentId,
|
|
24
|
+
transactionId,
|
|
25
|
+
}),
|
|
26
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
27
|
+
messageSection: 'receipt_match',
|
|
28
|
+
messageText: 'success',
|
|
29
|
+
type: 'success',
|
|
30
|
+
}),
|
|
31
|
+
]);
|
|
32
|
+
}
|
|
33
|
+
return (0, rxjs_1.from)([
|
|
34
|
+
(0, missingReceiptsViewReducer_1.confirmBulkUploadMatchFailure)({ error: response.status }),
|
|
35
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
36
|
+
messageSection: 'receipt_match',
|
|
37
|
+
messageText: 'failed',
|
|
38
|
+
type: 'error',
|
|
39
|
+
}),
|
|
40
|
+
]);
|
|
41
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
|
|
42
|
+
(0, missingReceiptsViewReducer_1.confirmBulkUploadMatchFailure)({
|
|
43
|
+
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Confirm bulk upload match errored out: ' +
|
|
44
|
+
JSON.stringify(error)),
|
|
45
|
+
}),
|
|
46
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
47
|
+
messageSection: 'receipt_match',
|
|
48
|
+
messageText: 'failed',
|
|
49
|
+
type: 'error',
|
|
50
|
+
}),
|
|
51
|
+
])));
|
|
52
|
+
}));
|
|
53
|
+
exports.confirmBulkUploadMatchEpic = confirmBulkUploadMatchEpic;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.d.ts
ADDED
|
@@ -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 { fetchBulkUploadBatchDetails, fetchBulkUploadBatchDetailsFailure, fetchBulkUploadBatchDetailsSuccess, fetchBulkUploadBatches } from '../../reducers/missingReceiptsViewReducer';
|
|
7
|
+
export type ActionType = ReturnType<typeof fetchBulkUploadBatchDetails> | ReturnType<typeof updateTransactions> | ReturnType<typeof fetchBulkUploadBatchDetailsSuccess> | ReturnType<typeof fetchBulkUploadBatchDetailsFailure> | ReturnType<typeof fetchBulkUploadBatches>;
|
|
8
|
+
export declare const fetchBulkUploadBatchDetailsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchBulkUploadBatchDetailsEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const transactionReducer_1 = require("../../../../entity/transaction/transactionReducer");
|
|
7
|
+
const responsePayload_1 = require("../../../../responsePayload");
|
|
8
|
+
const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
|
|
9
|
+
const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
10
|
+
const fetchBulkUploadBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchBulkUploadBatchDetails.match), (0, operators_1.mergeMap)(() => {
|
|
11
|
+
const bulkUpload = state$.value.expenseAutomationMissingReceiptsViewState.bulkUpload;
|
|
12
|
+
const { currentBatchId } = bulkUpload;
|
|
13
|
+
if (currentBatchId == null) {
|
|
14
|
+
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsFailure)({
|
|
15
|
+
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'No current batch ID available'),
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
if (!(0, missingReceiptsPayload_1.shouldFetchBatchDetailsForBatchId)(bulkUpload.batchStatusById, bulkUpload.batchListByPeriod, currentBatchId)) {
|
|
19
|
+
return rxjs_1.EMPTY;
|
|
20
|
+
}
|
|
21
|
+
return zeniAPI
|
|
22
|
+
.getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/${currentBatchId}`)
|
|
23
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
24
|
+
if (!(0, responsePayload_1.isSuccessResponse)(response) ||
|
|
25
|
+
response.data == null ||
|
|
26
|
+
!(0, missingReceiptsPayload_1.isBatchDetailsApiStatusCompleted)(response.data.status)) {
|
|
27
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
28
|
+
return rxjs_1.EMPTY;
|
|
29
|
+
}
|
|
30
|
+
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsFailure)({ error: response.status }));
|
|
31
|
+
}
|
|
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)({ cacheOverride: true }));
|
|
39
|
+
return (0, rxjs_1.from)(actions);
|
|
40
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsFailure)({
|
|
41
|
+
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch batch details errored out: ' + JSON.stringify(error)),
|
|
42
|
+
}))));
|
|
43
|
+
}));
|
|
44
|
+
exports.fetchBulkUploadBatchDetailsEpic = fetchBulkUploadBatchDetailsEpic;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../../../reducer';
|
|
4
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
5
|
+
import { fetchBulkUploadBatches, fetchBulkUploadBatchesFailure, fetchBulkUploadBatchesSuccess } from '../../reducers/missingReceiptsViewReducer';
|
|
6
|
+
export type ActionType = ReturnType<typeof fetchBulkUploadBatches> | ReturnType<typeof fetchBulkUploadBatchesSuccess> | ReturnType<typeof fetchBulkUploadBatchesFailure>;
|
|
7
|
+
export declare const fetchBulkUploadBatchesEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchBulkUploadBatchesEpic = 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 responsePayload_1 = require("../../../../responsePayload");
|
|
9
|
+
const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
|
|
10
|
+
const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
11
|
+
const bulkUploadTiming_1 = require("../../helpers/bulkUploadTiming");
|
|
12
|
+
const rollingCalendarDateRangeInclusive_1 = require("../../helpers/rollingCalendarDateRangeInclusive");
|
|
13
|
+
const fetchBulkUploadBatchesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchBulkUploadBatches.match), (0, operators_1.switchMap)((action) => {
|
|
14
|
+
const { cacheOverride } = action.payload;
|
|
15
|
+
const state = state$.value;
|
|
16
|
+
const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload }, } = state;
|
|
17
|
+
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
|
|
18
|
+
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
19
|
+
const periodId = (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod);
|
|
20
|
+
const existingBatches = bulkUpload.batchListByPeriod[periodId] ?? [];
|
|
21
|
+
if (cacheOverride !== true && existingBatches.length > 0) {
|
|
22
|
+
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchesSuccess)({
|
|
23
|
+
batchList: existingBatches,
|
|
24
|
+
selectedPeriod,
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
const { end, start } = (0, rollingCalendarDateRangeInclusive_1.rollingCalendarDateRangeInclusive)(bulkUploadTiming_1.BULK_UPLOAD_BATCH_LIST_DATE_RANGE_DAYS);
|
|
28
|
+
const queryParam = {
|
|
29
|
+
start_date: start,
|
|
30
|
+
end_date: end,
|
|
31
|
+
sort_order: 'desc',
|
|
32
|
+
};
|
|
33
|
+
return zeniAPI
|
|
34
|
+
.getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
35
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
36
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
37
|
+
/** Full list (all statuses) for UI; batch-details epics filter to `completed` only. */
|
|
38
|
+
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchesSuccess)({
|
|
39
|
+
batchList: response.data.batches.map(missingReceiptsPayload_1.toBatchListItem),
|
|
40
|
+
selectedPeriod,
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchesFailure)({
|
|
44
|
+
error: response.status,
|
|
45
|
+
selectedPeriod,
|
|
46
|
+
}));
|
|
47
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchesFailure)({
|
|
48
|
+
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch bulk upload batches errored out: ' +
|
|
49
|
+
JSON.stringify(error)),
|
|
50
|
+
selectedPeriod,
|
|
51
|
+
}))));
|
|
52
|
+
}));
|
|
53
|
+
exports.fetchBulkUploadBatchesEpic = fetchBulkUploadBatchesEpic;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.d.ts
ADDED
|
@@ -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 { fetchCompletedTransactions, fetchCompletedTransactionsFailure, fetchCompletedTransactionsSuccess } from '../../reducers/missingReceiptsViewReducer';
|
|
7
|
+
export type ActionType = ReturnType<typeof fetchCompletedTransactions> | ReturnType<typeof updateTransactions> | ReturnType<typeof fetchCompletedTransactionsSuccess> | ReturnType<typeof fetchCompletedTransactionsFailure>;
|
|
8
|
+
export declare const fetchCompletedTransactionsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchCompletedTransactionsEpic = 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 missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
11
|
+
const fetchCompletedTransactionsEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchCompletedTransactions.match), (0, operators_1.switchMap)((action) => {
|
|
12
|
+
const state = state$.value;
|
|
13
|
+
const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload }, } = state;
|
|
14
|
+
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
|
|
15
|
+
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
16
|
+
const periodId = (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod);
|
|
17
|
+
const isInitialLoad = action.payload.pageToken == null;
|
|
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) {
|
|
24
|
+
return (0, rxjs_1.from)([]);
|
|
25
|
+
}
|
|
26
|
+
const period = (0, timePeriod_1.convertToPeriod)(selectedPeriod);
|
|
27
|
+
const queryPayload = {
|
|
28
|
+
start_date: period.start,
|
|
29
|
+
end_date: period.end,
|
|
30
|
+
sort_by: bulkUpload.sortKey,
|
|
31
|
+
sort_order: bulkUpload.sortOrder === 'ascending' ? 'asc' : 'desc',
|
|
32
|
+
page_token: action.payload.pageToken ?? null,
|
|
33
|
+
page_size: 25,
|
|
34
|
+
};
|
|
35
|
+
if (bulkUpload.completedSubTab !== 'all') {
|
|
36
|
+
queryPayload.match_type = bulkUpload.completedSubTab;
|
|
37
|
+
}
|
|
38
|
+
const encodedQuery = encodeURIComponent(JSON.stringify(queryPayload));
|
|
39
|
+
return zeniAPI
|
|
40
|
+
.getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipt-agent/transactions/completed?query=${encodedQuery}`)
|
|
41
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
42
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
43
|
+
const transactionIds = response.data.transactions.map((t) => t.transaction_id);
|
|
44
|
+
const updateActions = [];
|
|
45
|
+
updateActions.push((0, transactionReducer_1.updateTransactions)(response.data.transactions, (value) => value.transaction_id));
|
|
46
|
+
updateActions.push((0, missingReceiptsViewReducer_1.fetchCompletedTransactionsSuccess)({
|
|
47
|
+
isInitialLoad,
|
|
48
|
+
transactionIds,
|
|
49
|
+
nextPageToken: response.data.next_page_token,
|
|
50
|
+
totalCount: response.data.total_count,
|
|
51
|
+
selectedPeriod,
|
|
52
|
+
}));
|
|
53
|
+
return (0, rxjs_1.from)(updateActions);
|
|
54
|
+
}
|
|
55
|
+
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchCompletedTransactionsFailure)({
|
|
56
|
+
error: response.status,
|
|
57
|
+
selectedPeriod,
|
|
58
|
+
}));
|
|
59
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchCompletedTransactionsFailure)({
|
|
60
|
+
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch completed transactions errored: ' +
|
|
61
|
+
JSON.stringify(error)),
|
|
62
|
+
selectedPeriod,
|
|
63
|
+
}))));
|
|
64
|
+
}));
|
|
65
|
+
exports.fetchCompletedTransactionsEpic = fetchCompletedTransactionsEpic;
|
|
@@ -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, fetchBulkUploadBatchDetails, fetchBulkUploadBatchesSuccess, fetchMoreBatchDetails, fetchMoreBatchDetailsComplete, fetchMoreBatchDetailsFailure, setInitialBatchDetailsLoading, storeBatchDetails } from '../../reducers/missingReceiptsViewReducer';
|
|
7
|
+
export type ActionType = ReturnType<typeof fetchBulkUploadBatchDetails> | 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,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchMoreBatchDetailsEpic = 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 responsePayload_1 = require("../../../../responsePayload");
|
|
9
|
+
const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
|
|
10
|
+
const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
11
|
+
const fetchMultipleBatchDetailsEpic_1 = require("./fetchMultipleBatchDetailsEpic");
|
|
12
|
+
const MORE_BATCH_PAGE_SIZE = 5;
|
|
13
|
+
const fetchMoreBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchMoreBatchDetails.match),
|
|
14
|
+
/** One page at a time — avoids duplicate loads if IO + scroll fallback both fire. */
|
|
15
|
+
(0, operators_1.exhaustMap)(() => {
|
|
16
|
+
const state = state$.value;
|
|
17
|
+
const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload }, } = state;
|
|
18
|
+
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
|
|
19
|
+
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
20
|
+
if (selectedPeriod == null) {
|
|
21
|
+
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchMoreBatchDetailsComplete)());
|
|
22
|
+
}
|
|
23
|
+
const periodId = (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod);
|
|
24
|
+
const batchList = bulkUpload.batchListByPeriod[periodId] ?? [];
|
|
25
|
+
const failedIds = new Set(bulkUpload.failedBatchDetailIds);
|
|
26
|
+
const unfetchedBatches = (0, missingReceiptsPayload_1.filterBatchListItemsForBatchDetailsFetch)(batchList).filter((batch) => bulkUpload.batchDetailsById[batch.batchId] == null &&
|
|
27
|
+
!failedIds.has(batch.batchId));
|
|
28
|
+
const unfetchedBatchIds = unfetchedBatches.map((batch) => batch.batchId);
|
|
29
|
+
if (unfetchedBatchIds.length === 0) {
|
|
30
|
+
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchMoreBatchDetailsComplete)());
|
|
31
|
+
}
|
|
32
|
+
const nextPage = unfetchedBatchIds.slice(0, MORE_BATCH_PAGE_SIZE);
|
|
33
|
+
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)({
|
|
34
|
+
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch more batch details errored out: ' + JSON.stringify(error)),
|
|
35
|
+
}))));
|
|
36
|
+
}));
|
|
37
|
+
exports.fetchMoreBatchDetailsEpic = fetchMoreBatchDetailsEpic;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
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, fetchBulkUploadBatchDetails, fetchBulkUploadBatchesSuccess, fetchMoreBatchDetailsComplete, setInitialBatchDetailsLoading, storeBatchDetails } from '../../reducers/missingReceiptsViewReducer';
|
|
7
|
+
export type ActionType = ReturnType<typeof fetchBulkUploadBatchDetails> | 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>;
|
|
9
|
+
export declare const fetchMultipleBatchDetailsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchMultipleBatchDetailsEpic = void 0;
|
|
4
|
+
exports.fetchBatchDetailsByIds = fetchBatchDetailsByIds;
|
|
5
|
+
const rxjs_1 = require("rxjs");
|
|
6
|
+
const operators_1 = require("rxjs/operators");
|
|
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
|
+
const INITIAL_BATCH_PAGE_SIZE = 5;
|
|
12
|
+
function fetchBatchDetailsByIds(batchIds, zeniAPI) {
|
|
13
|
+
if (batchIds.length === 0) {
|
|
14
|
+
return rxjs_1.EMPTY;
|
|
15
|
+
}
|
|
16
|
+
return (0, rxjs_1.from)(batchIds).pipe((0, operators_1.mergeMap)((batchId) => zeniAPI
|
|
17
|
+
.getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/${batchId}`)
|
|
18
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
19
|
+
if (!(0, responsePayload_1.isSuccessResponse)(response) ||
|
|
20
|
+
response.data == null ||
|
|
21
|
+
!(0, missingReceiptsPayload_1.isBatchDetailsApiStatusCompleted)(response.data.status)) {
|
|
22
|
+
return rxjs_1.EMPTY;
|
|
23
|
+
}
|
|
24
|
+
const actions = [];
|
|
25
|
+
const transactionPayloads = (0, missingReceiptsPayload_1.extractTransactionPayloadsFromBatchFiles)(response.data.files);
|
|
26
|
+
if (transactionPayloads.length > 0) {
|
|
27
|
+
actions.push((0, transactionReducer_1.updateTransactions)(transactionPayloads, (value) => value.transaction_id));
|
|
28
|
+
}
|
|
29
|
+
actions.push((0, missingReceiptsViewReducer_1.storeBatchDetails)((0, missingReceiptsPayload_1.toBatchDetails)(response.data, zeniAPI.apiEndPoints.fileMicroServiceBaseUrl)));
|
|
30
|
+
return (0, rxjs_1.from)(actions);
|
|
31
|
+
}), (0, operators_1.catchError)((error) => {
|
|
32
|
+
console.error(`Failed to fetch batch details for ${batchId}:`, (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch batch details errored out: ' + JSON.stringify(error)));
|
|
33
|
+
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.batchDetailFetchFailed)({ batchId }));
|
|
34
|
+
})), 5));
|
|
35
|
+
}
|
|
36
|
+
const fetchMultipleBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchBulkUploadBatchesSuccess.match), (0, operators_1.mergeMap)((action) => {
|
|
37
|
+
const batchList = action.payload.batchList;
|
|
38
|
+
const { batchDetailsById } = state$.value.expenseAutomationMissingReceiptsViewState.bulkUpload;
|
|
39
|
+
/** Only completed list rows may trigger batch-details API; preserve platform order. */
|
|
40
|
+
const completedBatchesMissingDetails = (0, missingReceiptsPayload_1.filterBatchListItemsForBatchDetailsFetch)(batchList).filter((batch) => batchDetailsById[batch.batchId] == null);
|
|
41
|
+
const completedBatchIds = completedBatchesMissingDetails.map((batch) => batch.batchId);
|
|
42
|
+
const batchIdsToFetch = completedBatchIds.slice(0, INITIAL_BATCH_PAGE_SIZE);
|
|
43
|
+
if (batchIdsToFetch.length === 0) {
|
|
44
|
+
/**
|
|
45
|
+
* List refresh can complete while no row is `completed` yet (multi-fetch skips), or
|
|
46
|
+
* `currentBatchId` may not appear in the filtered list but still needs `GET /batches/:id`.
|
|
47
|
+
* Fall back to the single-batch-details epic so `phase` and details can resolve.
|
|
48
|
+
*/
|
|
49
|
+
const bulkUpload = state$.value.expenseAutomationMissingReceiptsViewState.bulkUpload;
|
|
50
|
+
const currentId = bulkUpload.currentBatchId;
|
|
51
|
+
if (currentId != null &&
|
|
52
|
+
bulkUpload.phase === 'matching' &&
|
|
53
|
+
bulkUpload.batchDetailsById[currentId] == null &&
|
|
54
|
+
(0, missingReceiptsPayload_1.shouldFetchBatchDetailsForBatchId)(bulkUpload.batchStatusById, bulkUpload.batchListByPeriod, currentId)) {
|
|
55
|
+
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetails)());
|
|
56
|
+
}
|
|
57
|
+
return rxjs_1.EMPTY;
|
|
58
|
+
}
|
|
59
|
+
return (0, rxjs_1.concat)((0, rxjs_1.of)((0, missingReceiptsViewReducer_1.setInitialBatchDetailsLoading)()), fetchBatchDetailsByIds(batchIdsToFetch, zeniAPI), (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchMoreBatchDetailsComplete)()));
|
|
60
|
+
}));
|
|
61
|
+
exports.fetchMultipleBatchDetailsEpic = fetchMultipleBatchDetailsEpic;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ActionsObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { fetchCompletedTransactions, setBulkUploadCompletedSubTab, setBulkUploadSortConfig } from '../../reducers/missingReceiptsViewReducer';
|
|
4
|
+
export type ActionType = ReturnType<typeof setBulkUploadSortConfig> | ReturnType<typeof setBulkUploadCompletedSubTab> | ReturnType<typeof fetchCompletedTransactions>;
|
|
5
|
+
/**
|
|
6
|
+
* Completed transactions are cached per sort key/order/sub-tab. After a sort or sub-tab
|
|
7
|
+
* change, the fetch epic would otherwise skip the network when that cache entry already
|
|
8
|
+
* exists — dispatch a cache-bypassing initial fetch whenever either changes from the UI.
|
|
9
|
+
*/
|
|
10
|
+
export declare const refetchCompletedTransactionsOnBulkUploadSortEpic: (actions$: ActionsObservable<ActionType>) => Observable<ActionType>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.refetchCompletedTransactionsOnBulkUploadSortEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
7
|
+
/**
|
|
8
|
+
* Completed transactions are cached per sort key/order/sub-tab. After a sort or sub-tab
|
|
9
|
+
* change, the fetch epic would otherwise skip the network when that cache entry already
|
|
10
|
+
* exists — dispatch a cache-bypassing initial fetch whenever either changes from the UI.
|
|
11
|
+
*/
|
|
12
|
+
const refetchCompletedTransactionsOnBulkUploadSortEpic = (actions$) => {
|
|
13
|
+
return actions$.pipe((0, operators_1.filter)((action) => missingReceiptsViewReducer_1.setBulkUploadSortConfig.match(action) ||
|
|
14
|
+
missingReceiptsViewReducer_1.setBulkUploadCompletedSubTab.match(action)), (0, operators_1.mergeMap)(() => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchCompletedTransactions)(undefined, true))));
|
|
15
|
+
};
|
|
16
|
+
exports.refetchCompletedTransactionsOnBulkUploadSortEpic = refetchCompletedTransactionsOnBulkUploadSortEpic;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../../../reducer';
|
|
4
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
5
|
+
import { fetchBulkUploadBatchesSuccess, restoreBulkUploadAutomatchingOnMount, restoreBulkUploadMatchingState } from '../../reducers/missingReceiptsViewReducer';
|
|
6
|
+
export type ActionType = ReturnType<typeof restoreBulkUploadAutomatchingOnMount> | ReturnType<typeof fetchBulkUploadBatchesSuccess> | ReturnType<typeof restoreBulkUploadMatchingState>;
|
|
7
|
+
/**
|
|
8
|
+
* On missing-receipts entry / period switch, hydrate the automatching banner for the logged-in
|
|
9
|
+
* user without relying on UI-driven list fetches (the Missing tab does not fetch the batch list
|
|
10
|
+
* while `phase === 'idle'`). Flow:
|
|
11
|
+
* 1. Call `GET /1.0/batches` (rolling 30-day window).
|
|
12
|
+
* 2. Emit `fetchBulkUploadBatchesSuccess` so `batchListByPeriod` is populated for the selected
|
|
13
|
+
* period (prevents a duplicate list fetch when the user switches to the Unmatched tab).
|
|
14
|
+
* 3. For each `processing|pending` row, call `GET /1.0/batches/:id` in order; for the first row
|
|
15
|
+
* whose details `user_id` matches the logged-in user and whose status is still
|
|
16
|
+
* pending/processing, dispatch `restoreBulkUploadMatchingState` and stop.
|
|
17
|
+
*/
|
|
18
|
+
export declare const restoreBulkUploadAutomatchingOnMountEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|