@zeniai/client-epic-state 4.20.7 → 4.20.9-beta0ND
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/coreEpics.js +2 -1
- 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/tenant/SessionManager.d.ts +38 -0
- package/lib/entity/tenant/SessionManager.js +171 -0
- package/lib/entity/tenant/epic/sessionHeartbeatEpic.d.ts +16 -0
- package/lib/entity/tenant/epic/sessionHeartbeatEpic.js +16 -0
- package/lib/entity/tenant/sessionTypes.d.ts +26 -0
- package/lib/entity/tenant/sessionTypes.js +12 -0
- package/lib/entity/tenant/tenantReducer.d.ts +5 -1
- package/lib/entity/tenant/tenantReducer.js +23 -2
- package/lib/entity/tenant/tenantState.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/coreEpics.js +2 -1
- 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/tenant/SessionManager.js +167 -0
- package/lib/esm/entity/tenant/epic/sessionHeartbeatEpic.js +12 -0
- package/lib/esm/entity/tenant/sessionTypes.js +9 -0
- package/lib/esm/entity/tenant/tenantReducer.js +21 -1
- 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 +24 -12
- 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 +246 -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 +25 -14
- package/lib/index.js +100 -31
- 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 +71 -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 +245 -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
package/lib/esm/reducer.js
CHANGED
|
@@ -58,6 +58,7 @@ import toastNotification, { initialState as initialToastNotificationState, } fro
|
|
|
58
58
|
import transaction, { initialState as initialTransactionState, } from './entity/transaction/transactionReducer';
|
|
59
59
|
import transactionActivityLog, { initialState as initialTransactionActivityLogState, } from './entity/transactionActivityLog/transactionActivityLogReducer';
|
|
60
60
|
import user, { initialState as initialUserState, } from './entity/user/userReducer';
|
|
61
|
+
import userGroups, { initialState as initialUserGroupsState, } from './entity/userGroups/userGroupsReducer';
|
|
61
62
|
import userRole, { initialState as initialUserRoleState, } from './entity/userRole/userRoleReducer';
|
|
62
63
|
import vendor, { initialState as initialVendorState, } from './entity/vendor/vendorReducer';
|
|
63
64
|
import vendorExpense, { initialState as initialVendorExpenseState, } from './entity/vendorExpense/vendorExpenseReducer';
|
|
@@ -198,6 +199,7 @@ import trend, { initialTrendState } from './view/trend/trendReducer';
|
|
|
198
199
|
import trendWithTransactions, { initialTrendWithTransactionsState, } from './view/trendWithTransactions/trendWithTransactionsReducer';
|
|
199
200
|
import twoFactorAuthentication, { initialState as initialTwoFactorAuthenticationState, } from './view/twoFactorAuthentication/twoFactorAuthenticationReducer';
|
|
200
201
|
import userFinancialAccountState, { initialState as initialUserFinancialAccountState, } from './view/userFinancialAccount/userFinancialAccountReducer';
|
|
202
|
+
import userGroupListView, { initialState as initialUserGroupListViewState, } from './view/userGroupListView/userGroupListViewReducer';
|
|
201
203
|
import userListView, { initialState as initialUserListViewState, } from './view/userListView/userListViewReducer';
|
|
202
204
|
import userRoleConfig, { initialState as initialUserRoleConfigState, } from './view/userRoleConfigView/userRoleConfigReducer';
|
|
203
205
|
import vendor1099TypeList, { initialState as initialVendor1099TypeListState, } from './view/vendor1099TypeList/vendor1099TypeListReducer';
|
|
@@ -270,6 +272,7 @@ const initialEntitiesState = {
|
|
|
270
272
|
toastNotificationState: initialToastNotificationState,
|
|
271
273
|
transactionActivityLogState: initialTransactionActivityLogState,
|
|
272
274
|
transactionState: initialTransactionState,
|
|
275
|
+
userGroupsState: initialUserGroupsState,
|
|
273
276
|
userRoleState: initialUserRoleState,
|
|
274
277
|
userState: initialUserState,
|
|
275
278
|
vendorExpenseState: initialVendorExpenseState,
|
|
@@ -408,6 +411,7 @@ const initialViewsState = {
|
|
|
408
411
|
trendWithTransactionsState: initialTrendWithTransactionsState,
|
|
409
412
|
twoFactorAuthenticationState: initialTwoFactorAuthenticationState,
|
|
410
413
|
userFinancialAccountState: initialUserFinancialAccountState,
|
|
414
|
+
userGroupListViewState: initialUserGroupListViewState,
|
|
411
415
|
userListViewState: initialUserListViewState,
|
|
412
416
|
userRoleConfigState: initialUserRoleConfigState,
|
|
413
417
|
vendorFirstReviewViewState: initialVendorFirstReviewViewState,
|
|
@@ -492,6 +496,7 @@ const entityReducers = {
|
|
|
492
496
|
toastNotificationState: toastNotification,
|
|
493
497
|
transactionActivityLogState: transactionActivityLog,
|
|
494
498
|
transactionState: transaction,
|
|
499
|
+
userGroupsState: userGroups,
|
|
495
500
|
userRoleState: userRole,
|
|
496
501
|
userState: user,
|
|
497
502
|
vendorExpenseState: vendorExpense,
|
|
@@ -630,6 +635,7 @@ const viewReducers = {
|
|
|
630
635
|
trendWithTransactionsState: trendWithTransactions,
|
|
631
636
|
twoFactorAuthenticationState: twoFactorAuthentication,
|
|
632
637
|
userFinancialAccountState: userFinancialAccountState,
|
|
638
|
+
userGroupListViewState: userGroupListView,
|
|
633
639
|
userListViewState: userListView,
|
|
634
640
|
userRoleConfigState: userRoleConfig,
|
|
635
641
|
vendorFirstReviewViewState: vendorFirstReviewView,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createSlice } from '@reduxjs/toolkit';
|
|
2
2
|
import { mapReportPayloadV2ToReportV2 } from '../../../commonPayloadTypes/v2/viewAndReportPayloadv2';
|
|
3
3
|
import { getAgingBalancesKey, toAgingPeriod, } from '../../../commonStateTypes/agingBalance/agingBalance';
|
|
4
|
+
import { defaultCustomerCurrency } from '../../../commonStateTypes/currencyHelper';
|
|
4
5
|
import { getNestedCustomerHierarchy } from '../../../commonStateTypes/customerView/getNestedCustomerHierarchy';
|
|
5
6
|
import { toCustomer } from '../../../entity/customer/customerPayload';
|
|
6
|
-
import { defaultCustomerCurrency } from '../../../entity/customer/customerState';
|
|
7
7
|
import { dateNow } from '../../../zeniDayJS';
|
|
8
8
|
import { toArAgingDataByCustomerId, toArAgingTotals, } from './arAgingPayload';
|
|
9
9
|
export const inititalUIState = {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createSelector } from '@reduxjs/toolkit';
|
|
2
2
|
import orderBy from 'lodash/orderBy';
|
|
3
3
|
import { getAgingBalancesKey, } from '../../../commonStateTypes/agingBalance/agingBalance';
|
|
4
|
+
import { defaultCustomerCurrency } from '../../../commonStateTypes/currencyHelper';
|
|
4
5
|
import { getCustomer } from '../../../entity/customer/customerSelector';
|
|
5
|
-
import { defaultCustomerCurrency, } from '../../../entity/customer/customerState';
|
|
6
6
|
export const getArAgingReport = createSelector((state) => state.arAgingState, (state) => state.customerState, (arAgingState, customerState) => {
|
|
7
7
|
const { reportId, reportTitle, fetchState, uiState, firstMonthOfFY, agingPeriods, } = arAgingState;
|
|
8
8
|
const { searchString, sortOrder, sortKey, selectedDate } = uiState;
|
package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadMatchResultToastEpic.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { merge, of } from 'rxjs';
|
|
2
|
+
import { filter, mergeMap, switchMap, take, takeUntil } from 'rxjs/operators';
|
|
3
|
+
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
4
|
+
import { bulkUploadReceiptsSuccess, clearBulkUpload, fetchBulkUploadBatchDetailsSuccess, restoreBulkUploadMatchingState, storeBatchDetails, } from '../../reducers/missingReceiptsViewReducer';
|
|
5
|
+
/**
|
|
6
|
+
* Show a success toast when batch details arrive for the current upload batch,
|
|
7
|
+
* e.g. "17 out of 20 Receipts Matched". Scoped per upload session so it fires
|
|
8
|
+
* only once: starts on `bulkUploadReceiptsSuccess` (or `restoreBulkUploadMatchingState`
|
|
9
|
+
* for a restored session), waits for the first batch-details action for that batch,
|
|
10
|
+
* emits the toast, then stops. `clearBulkUpload` cancels the in-flight wait.
|
|
11
|
+
*/
|
|
12
|
+
export const bulkUploadMatchResultToastEpic = (actions$) => actions$.pipe(filter((action) => bulkUploadReceiptsSuccess.match(action) ||
|
|
13
|
+
restoreBulkUploadMatchingState.match(action)), switchMap((uploadAction) => {
|
|
14
|
+
const { batchId } = uploadAction.payload;
|
|
15
|
+
return merge(actions$.pipe(filter(fetchBulkUploadBatchDetailsSuccess.match)), actions$.pipe(filter(storeBatchDetails.match))).pipe(filter((a) => a.payload.batchId === batchId), take(1), mergeMap((action) => {
|
|
16
|
+
const { summary } = action.payload;
|
|
17
|
+
return of(openSnackbar({
|
|
18
|
+
messageSection: 'receipts_bulk_match',
|
|
19
|
+
messageText: 'success',
|
|
20
|
+
type: 'success',
|
|
21
|
+
variables: [
|
|
22
|
+
{
|
|
23
|
+
variableName: '_matched_',
|
|
24
|
+
variableValue: String(summary.matched),
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
variableName: '_total_',
|
|
28
|
+
variableValue: String(summary.total),
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
}));
|
|
32
|
+
}), takeUntil(actions$.pipe(filter(clearBulkUpload.match))));
|
|
33
|
+
}));
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { concat, of, timer } from 'rxjs';
|
|
2
|
+
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
+
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
4
|
+
import { BULK_UPLOAD_BAR_COMPLETE_HOLD_MS } from '../../helpers/bulkUploadTiming';
|
|
5
|
+
import { bulkUploadReceipts, bulkUploadReceiptsFailure, bulkUploadReceiptsSuccess, updateBulkUploadProgress, } from '../../reducers/missingReceiptsViewReducer';
|
|
6
|
+
export const bulkUploadReceiptsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(bulkUploadReceipts.match), mergeMap((action) => {
|
|
7
|
+
const { files } = action.payload;
|
|
8
|
+
const formData = new FormData();
|
|
9
|
+
for (const file of files) {
|
|
10
|
+
formData.append('files', file, file.name);
|
|
11
|
+
}
|
|
12
|
+
return zeniAPI
|
|
13
|
+
.postFormData(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/bulk-upload`, formData)
|
|
14
|
+
.pipe(mergeMap((response) => {
|
|
15
|
+
if (isSuccessResponse(response) && response.data != null) {
|
|
16
|
+
const batchId = String(response.data.batch_id ?? '').trim();
|
|
17
|
+
if (batchId === '') {
|
|
18
|
+
return of(bulkUploadReceiptsFailure({
|
|
19
|
+
error: createZeniAPIStatus('Unexpected Error', 'Bulk upload succeeded but batch_id was missing or empty.'),
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
return concat(of(updateBulkUploadProgress(100)), timer(BULK_UPLOAD_BAR_COMPLETE_HOLD_MS).pipe(mergeMap(() => of(bulkUploadReceiptsSuccess({ batchId })))));
|
|
23
|
+
}
|
|
24
|
+
return of(bulkUploadReceiptsFailure({ error: response.status }));
|
|
25
|
+
}), catchError((error) => of(bulkUploadReceiptsFailure({
|
|
26
|
+
error: createZeniAPIStatus('Unexpected Error', 'Bulk upload receipts API call errored out: ' +
|
|
27
|
+
JSON.stringify(error)),
|
|
28
|
+
}))));
|
|
29
|
+
}));
|
package/lib/esm/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { from } from 'rxjs';
|
|
2
|
+
import { catchError, exhaustMap, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
+
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
4
|
+
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
5
|
+
import { confirmBulkUploadMatch, confirmBulkUploadMatchFailure, confirmBulkUploadMatchSuccess, } from '../../reducers/missingReceiptsViewReducer';
|
|
6
|
+
export const confirmBulkUploadMatchEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(confirmBulkUploadMatch.match), exhaustMap((action) => {
|
|
7
|
+
const { batchId, attachmentId, transactionId, transactionType, fileName } = action.payload;
|
|
8
|
+
return zeniAPI
|
|
9
|
+
.postAndGetJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/manual-match`, {
|
|
10
|
+
attachment_id: attachmentId,
|
|
11
|
+
transaction_id: transactionId,
|
|
12
|
+
transaction_type: transactionType,
|
|
13
|
+
file_name: fileName,
|
|
14
|
+
})
|
|
15
|
+
.pipe(mergeMap((response) => {
|
|
16
|
+
if (isSuccessResponse(response)) {
|
|
17
|
+
return from([
|
|
18
|
+
confirmBulkUploadMatchSuccess({
|
|
19
|
+
batchId,
|
|
20
|
+
attachmentId,
|
|
21
|
+
transactionId,
|
|
22
|
+
}),
|
|
23
|
+
openSnackbar({
|
|
24
|
+
messageSection: 'receipt_match',
|
|
25
|
+
messageText: 'success',
|
|
26
|
+
type: 'success',
|
|
27
|
+
}),
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
return from([
|
|
31
|
+
confirmBulkUploadMatchFailure({ error: response.status }),
|
|
32
|
+
openSnackbar({
|
|
33
|
+
messageSection: 'receipt_match',
|
|
34
|
+
messageText: 'failed',
|
|
35
|
+
type: 'error',
|
|
36
|
+
}),
|
|
37
|
+
]);
|
|
38
|
+
}), catchError((error) => from([
|
|
39
|
+
confirmBulkUploadMatchFailure({
|
|
40
|
+
error: createZeniAPIStatus('Unexpected Error', 'Confirm bulk upload match errored out: ' +
|
|
41
|
+
JSON.stringify(error)),
|
|
42
|
+
}),
|
|
43
|
+
openSnackbar({
|
|
44
|
+
messageSection: 'receipt_match',
|
|
45
|
+
messageText: 'failed',
|
|
46
|
+
type: 'error',
|
|
47
|
+
}),
|
|
48
|
+
])));
|
|
49
|
+
}));
|
package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { EMPTY, from, of } from 'rxjs';
|
|
2
|
+
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
+
import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
|
|
4
|
+
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
5
|
+
import { extractTransactionPayloadsFromBatchFiles, isBatchDetailsApiStatusCompleted, shouldFetchBatchDetailsForBatchId, toBatchDetails, } from '../../payload/missingReceiptsPayload';
|
|
6
|
+
import { fetchBulkUploadBatchDetails, fetchBulkUploadBatchDetailsFailure, fetchBulkUploadBatchDetailsSuccess, fetchBulkUploadBatches, } from '../../reducers/missingReceiptsViewReducer';
|
|
7
|
+
export const fetchBulkUploadBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchBulkUploadBatchDetails.match), mergeMap(() => {
|
|
8
|
+
const bulkUpload = state$.value.expenseAutomationMissingReceiptsViewState.bulkUpload;
|
|
9
|
+
const { currentBatchId } = bulkUpload;
|
|
10
|
+
if (currentBatchId == null) {
|
|
11
|
+
return of(fetchBulkUploadBatchDetailsFailure({
|
|
12
|
+
error: createZeniAPIStatus('Unexpected Error', 'No current batch ID available'),
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
if (!shouldFetchBatchDetailsForBatchId(bulkUpload.batchStatusById, bulkUpload.batchListByPeriod, currentBatchId)) {
|
|
16
|
+
return EMPTY;
|
|
17
|
+
}
|
|
18
|
+
return zeniAPI
|
|
19
|
+
.getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/${currentBatchId}`)
|
|
20
|
+
.pipe(mergeMap((response) => {
|
|
21
|
+
if (!isSuccessResponse(response) ||
|
|
22
|
+
response.data == null ||
|
|
23
|
+
!isBatchDetailsApiStatusCompleted(response.data.status)) {
|
|
24
|
+
if (isSuccessResponse(response) && response.data != null) {
|
|
25
|
+
return EMPTY;
|
|
26
|
+
}
|
|
27
|
+
return of(fetchBulkUploadBatchDetailsFailure({ error: response.status }));
|
|
28
|
+
}
|
|
29
|
+
const actions = [];
|
|
30
|
+
const transactionPayloads = extractTransactionPayloadsFromBatchFiles(response.data.files);
|
|
31
|
+
if (transactionPayloads.length > 0) {
|
|
32
|
+
actions.push(updateTransactions(transactionPayloads, (value) => value.transaction_id));
|
|
33
|
+
}
|
|
34
|
+
actions.push(fetchBulkUploadBatchDetailsSuccess(toBatchDetails(response.data, zeniAPI.apiEndPoints.fileMicroServiceBaseUrl)));
|
|
35
|
+
actions.push(fetchBulkUploadBatches({ cacheOverride: true }));
|
|
36
|
+
return from(actions);
|
|
37
|
+
}), catchError((error) => of(fetchBulkUploadBatchDetailsFailure({
|
|
38
|
+
error: createZeniAPIStatus('Unexpected Error', 'Fetch batch details errored out: ' + JSON.stringify(error)),
|
|
39
|
+
}))));
|
|
40
|
+
}));
|
package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { of } from 'rxjs';
|
|
2
|
+
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
|
+
import { toMonthYearPeriodId } from '../../../../commonStateTypes/timePeriod';
|
|
4
|
+
import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
|
|
5
|
+
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
6
|
+
import { toBatchListItem, } from '../../payload/missingReceiptsPayload';
|
|
7
|
+
import { fetchBulkUploadBatches, fetchBulkUploadBatchesFailure, fetchBulkUploadBatchesSuccess, } from '../../reducers/missingReceiptsViewReducer';
|
|
8
|
+
import { BULK_UPLOAD_BATCH_LIST_DATE_RANGE_DAYS } from '../../helpers/bulkUploadTiming';
|
|
9
|
+
import { rollingCalendarDateRangeInclusive } from '../../helpers/rollingCalendarDateRangeInclusive';
|
|
10
|
+
export const fetchBulkUploadBatchesEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchBulkUploadBatches.match), switchMap((action) => {
|
|
11
|
+
const { cacheOverride } = action.payload;
|
|
12
|
+
const state = state$.value;
|
|
13
|
+
const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload }, } = state;
|
|
14
|
+
const currentTenant = getCurrentTenant(state);
|
|
15
|
+
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
16
|
+
const periodId = toMonthYearPeriodId(selectedPeriod);
|
|
17
|
+
const existingBatches = bulkUpload.batchListByPeriod[periodId] ?? [];
|
|
18
|
+
if (cacheOverride !== true && existingBatches.length > 0) {
|
|
19
|
+
return of(fetchBulkUploadBatchesSuccess({
|
|
20
|
+
batchList: existingBatches,
|
|
21
|
+
selectedPeriod,
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
const { end, start } = rollingCalendarDateRangeInclusive(BULK_UPLOAD_BATCH_LIST_DATE_RANGE_DAYS);
|
|
25
|
+
const queryParam = {
|
|
26
|
+
start_date: start,
|
|
27
|
+
end_date: end,
|
|
28
|
+
sort_order: 'desc',
|
|
29
|
+
};
|
|
30
|
+
return zeniAPI
|
|
31
|
+
.getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
32
|
+
.pipe(mergeMap((response) => {
|
|
33
|
+
if (isSuccessResponse(response) && response.data != null) {
|
|
34
|
+
/** Full list (all statuses) for UI; batch-details epics filter to `completed` only. */
|
|
35
|
+
return of(fetchBulkUploadBatchesSuccess({
|
|
36
|
+
batchList: response.data.batches.map(toBatchListItem),
|
|
37
|
+
selectedPeriod,
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
return of(fetchBulkUploadBatchesFailure({
|
|
41
|
+
error: response.status,
|
|
42
|
+
selectedPeriod,
|
|
43
|
+
}));
|
|
44
|
+
}), catchError((error) => of(fetchBulkUploadBatchesFailure({
|
|
45
|
+
error: createZeniAPIStatus('Unexpected Error', 'Fetch bulk upload batches errored out: ' +
|
|
46
|
+
JSON.stringify(error)),
|
|
47
|
+
selectedPeriod,
|
|
48
|
+
}))));
|
|
49
|
+
}));
|
package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { from, of } from 'rxjs';
|
|
2
|
+
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
|
+
import { convertToPeriod, toMonthYearPeriodId, } from '../../../../commonStateTypes/timePeriod';
|
|
4
|
+
import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
|
|
5
|
+
import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
|
|
6
|
+
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
7
|
+
import { fetchCompletedTransactions, fetchCompletedTransactionsFailure, fetchCompletedTransactionsSuccess, getCompletedTransactionsCacheKey, } from '../../reducers/missingReceiptsViewReducer';
|
|
8
|
+
export const fetchCompletedTransactionsEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchCompletedTransactions.match), switchMap((action) => {
|
|
9
|
+
const state = state$.value;
|
|
10
|
+
const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload }, } = state;
|
|
11
|
+
const currentTenant = getCurrentTenant(state);
|
|
12
|
+
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
13
|
+
const periodId = toMonthYearPeriodId(selectedPeriod);
|
|
14
|
+
const isInitialLoad = action.payload.pageToken == null;
|
|
15
|
+
const cacheKey = getCompletedTransactionsCacheKey(periodId, bulkUpload.sortKey, bulkUpload.sortOrder, bulkUpload.completedSubTab);
|
|
16
|
+
const existingData = bulkUpload.completedTransactionsByPeriod[cacheKey];
|
|
17
|
+
if (isInitialLoad &&
|
|
18
|
+
action.payload.cacheOverride !== true &&
|
|
19
|
+
existingData != null &&
|
|
20
|
+
existingData.transactionIds.length > 0) {
|
|
21
|
+
return from([]);
|
|
22
|
+
}
|
|
23
|
+
const period = convertToPeriod(selectedPeriod);
|
|
24
|
+
const queryPayload = {
|
|
25
|
+
start_date: period.start,
|
|
26
|
+
end_date: period.end,
|
|
27
|
+
sort_by: bulkUpload.sortKey,
|
|
28
|
+
sort_order: bulkUpload.sortOrder === 'ascending' ? 'asc' : 'desc',
|
|
29
|
+
page_token: action.payload.pageToken ?? null,
|
|
30
|
+
page_size: 25,
|
|
31
|
+
};
|
|
32
|
+
if (bulkUpload.completedSubTab !== 'all') {
|
|
33
|
+
queryPayload.match_type = bulkUpload.completedSubTab;
|
|
34
|
+
}
|
|
35
|
+
const encodedQuery = encodeURIComponent(JSON.stringify(queryPayload));
|
|
36
|
+
return zeniAPI
|
|
37
|
+
.getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipt-agent/transactions/completed?query=${encodedQuery}`)
|
|
38
|
+
.pipe(mergeMap((response) => {
|
|
39
|
+
if (isSuccessResponse(response) && response.data != null) {
|
|
40
|
+
const transactionIds = response.data.transactions.map((t) => t.transaction_id);
|
|
41
|
+
const updateActions = [];
|
|
42
|
+
updateActions.push(updateTransactions(response.data.transactions, (value) => value.transaction_id));
|
|
43
|
+
updateActions.push(fetchCompletedTransactionsSuccess({
|
|
44
|
+
isInitialLoad,
|
|
45
|
+
transactionIds,
|
|
46
|
+
nextPageToken: response.data.next_page_token,
|
|
47
|
+
totalCount: response.data.total_count,
|
|
48
|
+
selectedPeriod,
|
|
49
|
+
}));
|
|
50
|
+
return from(updateActions);
|
|
51
|
+
}
|
|
52
|
+
return of(fetchCompletedTransactionsFailure({
|
|
53
|
+
error: response.status,
|
|
54
|
+
selectedPeriod,
|
|
55
|
+
}));
|
|
56
|
+
}), catchError((error) => of(fetchCompletedTransactionsFailure({
|
|
57
|
+
error: createZeniAPIStatus('Unexpected Error', 'Fetch completed transactions errored: ' +
|
|
58
|
+
JSON.stringify(error)),
|
|
59
|
+
selectedPeriod,
|
|
60
|
+
}))));
|
|
61
|
+
}));
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { concat, of } from 'rxjs';
|
|
2
|
+
import { catchError, exhaustMap, filter } from 'rxjs/operators';
|
|
3
|
+
import { toMonthYearPeriodId } from '../../../../commonStateTypes/timePeriod';
|
|
4
|
+
import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
|
|
5
|
+
import { createZeniAPIStatus } from '../../../../responsePayload';
|
|
6
|
+
import { filterBatchListItemsForBatchDetailsFetch } from '../../payload/missingReceiptsPayload';
|
|
7
|
+
import { fetchMoreBatchDetails, fetchMoreBatchDetailsComplete, fetchMoreBatchDetailsFailure, } from '../../reducers/missingReceiptsViewReducer';
|
|
8
|
+
import { fetchBatchDetailsByIds } from './fetchMultipleBatchDetailsEpic';
|
|
9
|
+
const MORE_BATCH_PAGE_SIZE = 5;
|
|
10
|
+
export const fetchMoreBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchMoreBatchDetails.match),
|
|
11
|
+
/** One page at a time — avoids duplicate loads if IO + scroll fallback both fire. */
|
|
12
|
+
exhaustMap(() => {
|
|
13
|
+
const state = state$.value;
|
|
14
|
+
const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload }, } = state;
|
|
15
|
+
const currentTenant = getCurrentTenant(state);
|
|
16
|
+
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
17
|
+
if (selectedPeriod == null) {
|
|
18
|
+
return of(fetchMoreBatchDetailsComplete());
|
|
19
|
+
}
|
|
20
|
+
const periodId = toMonthYearPeriodId(selectedPeriod);
|
|
21
|
+
const batchList = bulkUpload.batchListByPeriod[periodId] ?? [];
|
|
22
|
+
const failedIds = new Set(bulkUpload.failedBatchDetailIds);
|
|
23
|
+
const unfetchedBatches = filterBatchListItemsForBatchDetailsFetch(batchList).filter((batch) => bulkUpload.batchDetailsById[batch.batchId] == null &&
|
|
24
|
+
!failedIds.has(batch.batchId));
|
|
25
|
+
const unfetchedBatchIds = unfetchedBatches.map((batch) => batch.batchId);
|
|
26
|
+
if (unfetchedBatchIds.length === 0) {
|
|
27
|
+
return of(fetchMoreBatchDetailsComplete());
|
|
28
|
+
}
|
|
29
|
+
const nextPage = unfetchedBatchIds.slice(0, MORE_BATCH_PAGE_SIZE);
|
|
30
|
+
return concat(fetchBatchDetailsByIds(nextPage, zeniAPI), of(fetchMoreBatchDetailsComplete())).pipe(catchError((error) => of(fetchMoreBatchDetailsFailure({
|
|
31
|
+
error: createZeniAPIStatus('Unexpected Error', 'Fetch more batch details errored out: ' + JSON.stringify(error)),
|
|
32
|
+
}))));
|
|
33
|
+
}));
|
package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { EMPTY, concat, from, of } from 'rxjs';
|
|
2
|
+
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
+
import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
|
|
4
|
+
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
5
|
+
import { extractTransactionPayloadsFromBatchFiles, filterBatchListItemsForBatchDetailsFetch, isBatchDetailsApiStatusCompleted, shouldFetchBatchDetailsForBatchId, toBatchDetails, } from '../../payload/missingReceiptsPayload';
|
|
6
|
+
import { batchDetailFetchFailed, fetchBulkUploadBatchDetails, fetchBulkUploadBatchesSuccess, fetchMoreBatchDetailsComplete, setInitialBatchDetailsLoading, storeBatchDetails, } from '../../reducers/missingReceiptsViewReducer';
|
|
7
|
+
const INITIAL_BATCH_PAGE_SIZE = 5;
|
|
8
|
+
export function fetchBatchDetailsByIds(batchIds, zeniAPI) {
|
|
9
|
+
if (batchIds.length === 0) {
|
|
10
|
+
return EMPTY;
|
|
11
|
+
}
|
|
12
|
+
return from(batchIds).pipe(mergeMap((batchId) => zeniAPI
|
|
13
|
+
.getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/${batchId}`)
|
|
14
|
+
.pipe(mergeMap((response) => {
|
|
15
|
+
if (!isSuccessResponse(response) ||
|
|
16
|
+
response.data == null ||
|
|
17
|
+
!isBatchDetailsApiStatusCompleted(response.data.status)) {
|
|
18
|
+
return EMPTY;
|
|
19
|
+
}
|
|
20
|
+
const actions = [];
|
|
21
|
+
const transactionPayloads = extractTransactionPayloadsFromBatchFiles(response.data.files);
|
|
22
|
+
if (transactionPayloads.length > 0) {
|
|
23
|
+
actions.push(updateTransactions(transactionPayloads, (value) => value.transaction_id));
|
|
24
|
+
}
|
|
25
|
+
actions.push(storeBatchDetails(toBatchDetails(response.data, zeniAPI.apiEndPoints.fileMicroServiceBaseUrl)));
|
|
26
|
+
return from(actions);
|
|
27
|
+
}), catchError((error) => {
|
|
28
|
+
console.error(`Failed to fetch batch details for ${batchId}:`, createZeniAPIStatus('Unexpected Error', 'Fetch batch details errored out: ' + JSON.stringify(error)));
|
|
29
|
+
return of(batchDetailFetchFailed({ batchId }));
|
|
30
|
+
})), 5));
|
|
31
|
+
}
|
|
32
|
+
export const fetchMultipleBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchBulkUploadBatchesSuccess.match), mergeMap((action) => {
|
|
33
|
+
const batchList = action.payload.batchList;
|
|
34
|
+
const { batchDetailsById } = state$.value.expenseAutomationMissingReceiptsViewState.bulkUpload;
|
|
35
|
+
/** Only completed list rows may trigger batch-details API; preserve platform order. */
|
|
36
|
+
const completedBatchesMissingDetails = filterBatchListItemsForBatchDetailsFetch(batchList).filter((batch) => batchDetailsById[batch.batchId] == null);
|
|
37
|
+
const completedBatchIds = completedBatchesMissingDetails.map((batch) => batch.batchId);
|
|
38
|
+
const batchIdsToFetch = completedBatchIds.slice(0, INITIAL_BATCH_PAGE_SIZE);
|
|
39
|
+
if (batchIdsToFetch.length === 0) {
|
|
40
|
+
/**
|
|
41
|
+
* List refresh can complete while no row is `completed` yet (multi-fetch skips), or
|
|
42
|
+
* `currentBatchId` may not appear in the filtered list but still needs `GET /batches/:id`.
|
|
43
|
+
* Fall back to the single-batch-details epic so `phase` and details can resolve.
|
|
44
|
+
*/
|
|
45
|
+
const bulkUpload = state$.value.expenseAutomationMissingReceiptsViewState.bulkUpload;
|
|
46
|
+
const currentId = bulkUpload.currentBatchId;
|
|
47
|
+
if (currentId != null &&
|
|
48
|
+
bulkUpload.phase === 'matching' &&
|
|
49
|
+
bulkUpload.batchDetailsById[currentId] == null &&
|
|
50
|
+
shouldFetchBatchDetailsForBatchId(bulkUpload.batchStatusById, bulkUpload.batchListByPeriod, currentId)) {
|
|
51
|
+
return of(fetchBulkUploadBatchDetails());
|
|
52
|
+
}
|
|
53
|
+
return EMPTY;
|
|
54
|
+
}
|
|
55
|
+
return concat(of(setInitialBatchDetailsLoading()), fetchBatchDetailsByIds(batchIdsToFetch, zeniAPI), of(fetchMoreBatchDetailsComplete()));
|
|
56
|
+
}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { of } from 'rxjs';
|
|
2
|
+
import { filter, mergeMap } from 'rxjs/operators';
|
|
3
|
+
import { fetchCompletedTransactions, setBulkUploadCompletedSubTab, setBulkUploadSortConfig, } from '../../reducers/missingReceiptsViewReducer';
|
|
4
|
+
/**
|
|
5
|
+
* Completed transactions are cached per sort key/order/sub-tab. After a sort or sub-tab
|
|
6
|
+
* change, the fetch epic would otherwise skip the network when that cache entry already
|
|
7
|
+
* exists — dispatch a cache-bypassing initial fetch whenever either changes from the UI.
|
|
8
|
+
*/
|
|
9
|
+
export const refetchCompletedTransactionsOnBulkUploadSortEpic = (actions$) => {
|
|
10
|
+
return actions$.pipe(filter((action) => setBulkUploadSortConfig.match(action) ||
|
|
11
|
+
setBulkUploadCompletedSubTab.match(action)), mergeMap(() => of(fetchCompletedTransactions(undefined, true))));
|
|
12
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { EMPTY, concat, from, of } from 'rxjs';
|
|
2
|
+
import { catchError, concatMap, filter, mergeMap, take } from 'rxjs/operators';
|
|
3
|
+
import { isSuccessResponse } from '../../../../responsePayload';
|
|
4
|
+
import { isBatchDetailsStatusPendingOrProcessing, toBatchListItem, } from '../../payload/missingReceiptsPayload';
|
|
5
|
+
import { fetchBulkUploadBatchesSuccess, restoreBulkUploadAutomatchingOnMount, restoreBulkUploadMatchingState, } from '../../reducers/missingReceiptsViewReducer';
|
|
6
|
+
import { BULK_UPLOAD_BATCH_LIST_DATE_RANGE_DAYS } from '../../helpers/bulkUploadTiming';
|
|
7
|
+
import { rollingCalendarDateRangeInclusive } from '../../helpers/rollingCalendarDateRangeInclusive';
|
|
8
|
+
import { toMonthYearPeriodId } from '../../../../commonStateTypes/timePeriod';
|
|
9
|
+
import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
|
|
10
|
+
/**
|
|
11
|
+
* On missing-receipts entry / period switch, hydrate the automatching banner for the logged-in
|
|
12
|
+
* user without relying on UI-driven list fetches (the Missing tab does not fetch the batch list
|
|
13
|
+
* while `phase === 'idle'`). Flow:
|
|
14
|
+
* 1. Call `GET /1.0/batches` (rolling 30-day window).
|
|
15
|
+
* 2. Emit `fetchBulkUploadBatchesSuccess` so `batchListByPeriod` is populated for the selected
|
|
16
|
+
* period (prevents a duplicate list fetch when the user switches to the Unmatched tab).
|
|
17
|
+
* 3. For each `processing|pending` row, call `GET /1.0/batches/:id` in order; for the first row
|
|
18
|
+
* whose details `user_id` matches the logged-in user and whose status is still
|
|
19
|
+
* pending/processing, dispatch `restoreBulkUploadMatchingState` and stop.
|
|
20
|
+
*/
|
|
21
|
+
export const restoreBulkUploadAutomatchingOnMountEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(restoreBulkUploadAutomatchingOnMount.match), mergeMap(() => {
|
|
22
|
+
const state = state$.value;
|
|
23
|
+
const { expenseAutomationMissingReceiptsViewState: { bulkUpload }, expenseAutomationViewState: { selectedPeriodByTenantId }, } = state;
|
|
24
|
+
if (bulkUpload.phase !== 'idle') {
|
|
25
|
+
return EMPTY;
|
|
26
|
+
}
|
|
27
|
+
if (bulkUpload.batchListFetchState.fetchState === 'In-Progress') {
|
|
28
|
+
return EMPTY;
|
|
29
|
+
}
|
|
30
|
+
const loggedInUserId = state.tenantState.loggedInUser?.userId;
|
|
31
|
+
if (loggedInUserId == null) {
|
|
32
|
+
return EMPTY;
|
|
33
|
+
}
|
|
34
|
+
const currentTenant = getCurrentTenant(state);
|
|
35
|
+
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
36
|
+
if (selectedPeriod == null) {
|
|
37
|
+
return EMPTY;
|
|
38
|
+
}
|
|
39
|
+
const { end, start } = rollingCalendarDateRangeInclusive(BULK_UPLOAD_BATCH_LIST_DATE_RANGE_DAYS);
|
|
40
|
+
const queryParam = {
|
|
41
|
+
start_date: start,
|
|
42
|
+
end_date: end,
|
|
43
|
+
sort_order: 'desc',
|
|
44
|
+
};
|
|
45
|
+
const listUrl = `${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches?query=${encodeURIComponent(JSON.stringify(queryParam))}`;
|
|
46
|
+
const detailsBaseUrl = `${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/`;
|
|
47
|
+
const periodId = toMonthYearPeriodId(selectedPeriod);
|
|
48
|
+
const alreadyCached = (bulkUpload.batchListByPeriod[periodId] ?? []).length > 0 &&
|
|
49
|
+
bulkUpload.batchListFetchState.fetchState === 'Completed';
|
|
50
|
+
const listSource = alreadyCached
|
|
51
|
+
? of(null)
|
|
52
|
+
: zeniAPI.getJSON(listUrl).pipe(catchError(() => of(null)));
|
|
53
|
+
return listSource.pipe(mergeMap((listResponse) => {
|
|
54
|
+
const batchList = alreadyCached
|
|
55
|
+
? bulkUpload.batchListByPeriod[periodId] ?? []
|
|
56
|
+
: listResponse != null &&
|
|
57
|
+
isSuccessResponse(listResponse) &&
|
|
58
|
+
listResponse.data != null
|
|
59
|
+
? listResponse.data.batches.map(toBatchListItem)
|
|
60
|
+
: null;
|
|
61
|
+
if (batchList == null) {
|
|
62
|
+
return EMPTY;
|
|
63
|
+
}
|
|
64
|
+
const successAction = alreadyCached
|
|
65
|
+
? null
|
|
66
|
+
: fetchBulkUploadBatchesSuccess({
|
|
67
|
+
batchList,
|
|
68
|
+
selectedPeriod,
|
|
69
|
+
});
|
|
70
|
+
const processingBatches = batchList.filter((b) => {
|
|
71
|
+
const status = b.status.toLowerCase();
|
|
72
|
+
return status === 'processing' || status === 'pending';
|
|
73
|
+
});
|
|
74
|
+
const restoreStream = from(processingBatches).pipe(concatMap((batch) => zeniAPI
|
|
75
|
+
.getJSON(`${detailsBaseUrl}${batch.batchId}`)
|
|
76
|
+
.pipe(mergeMap((response) => {
|
|
77
|
+
if (!isSuccessResponse(response) || response.data == null) {
|
|
78
|
+
return EMPTY;
|
|
79
|
+
}
|
|
80
|
+
const data = response.data;
|
|
81
|
+
const detailsUserId = data.user_id;
|
|
82
|
+
if (detailsUserId == null ||
|
|
83
|
+
detailsUserId !== loggedInUserId) {
|
|
84
|
+
return EMPTY;
|
|
85
|
+
}
|
|
86
|
+
if (!isBatchDetailsStatusPendingOrProcessing(data.status)) {
|
|
87
|
+
return EMPTY;
|
|
88
|
+
}
|
|
89
|
+
return of(restoreBulkUploadMatchingState({
|
|
90
|
+
batchId: batch.batchId,
|
|
91
|
+
totalFiles: batch.totalFiles,
|
|
92
|
+
}));
|
|
93
|
+
}), catchError(() => EMPTY))), take(1));
|
|
94
|
+
return successAction != null
|
|
95
|
+
? concat(of(successAction), restoreStream)
|
|
96
|
+
: restoreStream;
|
|
97
|
+
}));
|
|
98
|
+
}));
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { EMPTY, from, merge, of } from 'rxjs';
|
|
2
|
+
import { catchError, debounceTime, filter, mergeMap, switchMap, } from 'rxjs/operators';
|
|
3
|
+
import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
|
|
4
|
+
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
5
|
+
import { supportedTransactionPayloadToManualSearchResult } from '../../payload/missingReceiptsPayload';
|
|
6
|
+
import { searchTransactionsForManualMatch, searchTransactionsForManualMatchFailure, searchTransactionsForManualMatchSuccess, } from '../../reducers/missingReceiptsViewReducer';
|
|
7
|
+
import { toTransactionsSortKey } from '../../types/transactionsViewState';
|
|
8
|
+
import { rollingCalendarDateRangeInclusive } from '../../helpers/rollingCalendarDateRangeInclusive';
|
|
9
|
+
/**
|
|
10
|
+
* `auto_categorized` for manual transaction search (Unmatched).
|
|
11
|
+
* Backend contract TBD — align with `fetchTransactionCategorizationEpic` (`selectedTab === 'autoCategorized'`)
|
|
12
|
+
* when the expense-automation API documents the intended filter for this flow.
|
|
13
|
+
*/
|
|
14
|
+
export const MANUAL_TRANSACTION_SEARCH_AUTO_CATEGORIZED = false;
|
|
15
|
+
/** Inclusive rolling window for manual match search (ignores accounting period picker). */
|
|
16
|
+
const MANUAL_SEARCH_TRANSACTION_DATE_RANGE_DAYS = 90;
|
|
17
|
+
export const searchTransactionsForManualMatchEpic = (actions$, state$, zeniAPI) => {
|
|
18
|
+
const searchActions$ = actions$.pipe(filter(searchTransactionsForManualMatch.match));
|
|
19
|
+
const pagination$ = searchActions$.pipe(filter((action) => action.payload.pageToken != null));
|
|
20
|
+
/**
|
|
21
|
+
* No API for empty or 1-char queries; immediate merge so switchMap cancels any in-flight HTTP.
|
|
22
|
+
*/
|
|
23
|
+
const newSearchTooShortOrClear$ = searchActions$.pipe(filter((action) => action.payload.pageToken == null &&
|
|
24
|
+
action.payload.query.trim().length < 2));
|
|
25
|
+
const newSearchDebounced$ = searchActions$.pipe(filter((action) => action.payload.pageToken == null &&
|
|
26
|
+
action.payload.query.trim().length >= 2), debounceTime(300));
|
|
27
|
+
return merge(pagination$, newSearchTooShortOrClear$, newSearchDebounced$).pipe(switchMap((action) => {
|
|
28
|
+
const { query, pageToken } = action.payload;
|
|
29
|
+
if (pageToken == null && query.trim().length < 2) {
|
|
30
|
+
return EMPTY;
|
|
31
|
+
}
|
|
32
|
+
const state = state$.value;
|
|
33
|
+
const { expenseAutomationMissingReceiptsViewState: { bulkUpload: { manualSearch, sortKey, sortOrder }, }, } = state;
|
|
34
|
+
const { end, start } = rollingCalendarDateRangeInclusive(MANUAL_SEARCH_TRANSACTION_DATE_RANGE_DAYS);
|
|
35
|
+
const queryParam = {
|
|
36
|
+
start_date: start,
|
|
37
|
+
end_date: end,
|
|
38
|
+
auto_categorized: MANUAL_TRANSACTION_SEARCH_AUTO_CATEGORIZED,
|
|
39
|
+
sort_by: toTransactionsSortKey(sortKey),
|
|
40
|
+
sort_order: sortOrder === 'ascending' ? 'asc' : 'desc',
|
|
41
|
+
page_token: pageToken ?? null,
|
|
42
|
+
page_size: manualSearch.pageSize,
|
|
43
|
+
search_text: query,
|
|
44
|
+
};
|
|
45
|
+
return zeniAPI
|
|
46
|
+
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/transactions?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
47
|
+
.pipe(mergeMap((response) => {
|
|
48
|
+
if (isSuccessResponse(response) && response.data != null) {
|
|
49
|
+
const { transactions, next_page_token, total_count } = response.data;
|
|
50
|
+
const append = pageToken != null;
|
|
51
|
+
const results = transactions.map(supportedTransactionPayloadToManualSearchResult);
|
|
52
|
+
const actionsOut = [
|
|
53
|
+
updateTransactions(transactions, (value) => value.transaction_id, 'merge'),
|
|
54
|
+
searchTransactionsForManualMatchSuccess({
|
|
55
|
+
append,
|
|
56
|
+
nextPageToken: next_page_token ?? null,
|
|
57
|
+
results,
|
|
58
|
+
totalCount: total_count,
|
|
59
|
+
}),
|
|
60
|
+
];
|
|
61
|
+
return from(actionsOut);
|
|
62
|
+
}
|
|
63
|
+
return of(searchTransactionsForManualMatchFailure({
|
|
64
|
+
error: response.status,
|
|
65
|
+
}));
|
|
66
|
+
}), catchError((error) => of(searchTransactionsForManualMatchFailure({
|
|
67
|
+
error: createZeniAPIStatus('Unexpected Error', 'Search transactions for manual match errored: ' +
|
|
68
|
+
JSON.stringify(error)),
|
|
69
|
+
}))));
|
|
70
|
+
}));
|
|
71
|
+
};
|
package/lib/esm/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js
CHANGED
|
@@ -12,11 +12,13 @@ export const uploadMissingReceiptSuccessEpic = (actions$, state$) => actions$.pi
|
|
|
12
12
|
updateActions.push(updateTransaction(transactionPayload.transaction_id, transactionPayload, updateType));
|
|
13
13
|
if (currentTenant != null) {
|
|
14
14
|
const monthEndChecksPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
if (monthEndChecksPeriod != null) {
|
|
16
|
+
updateActions.push(fetchMonthEndCloseChecks({
|
|
17
|
+
tenantId: currentTenant.tenantId,
|
|
18
|
+
period: monthEndChecksPeriod,
|
|
19
|
+
refreshViewInBackground: true,
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return from(updateActions);
|
|
22
24
|
}));
|