@zeniai/client-epic-state 5.2.11-beta0ND → 5.2.11-betaAM2
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/entity/invoicing/invoicingCommonPayload.d.ts +29 -27
- package/lib/entity/invoicing/invoicingCommonPayload.js +75 -37
- package/lib/entity/invoicing/product/productPayload.d.ts +0 -10
- package/lib/entity/invoicing/product/productPayload.js +2 -14
- package/lib/entity/jeSchedules/jeScheduleHelper.d.ts +1 -0
- package/lib/entity/jeSchedules/jeScheduleHelper.js +7 -0
- package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +97 -1
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +209 -0
- package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +4 -2
- package/lib/entity/jeSchedules/jeSchedulesReducer.js +30 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +11 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.js +38 -3
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +140 -1
- package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +24 -1
- package/lib/entity/jeSchedules/jeSchedulesTypes.js +88 -1
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +3 -0
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +2 -0
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
- package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +2 -0
- package/lib/epic.d.ts +15 -3
- package/lib/epic.js +31 -12
- package/lib/esm/entity/invoicing/invoicingCommonPayload.js +73 -33
- package/lib/esm/entity/invoicing/product/productPayload.js +2 -14
- package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +6 -0
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +209 -1
- package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +30 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +36 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +78 -0
- package/lib/esm/entity/snackbar/snackbarTypes.js +3 -0
- package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
- package/lib/esm/epic.js +27 -8
- package/lib/esm/index.js +23 -14
- package/lib/esm/reducer.js +3 -0
- package/lib/esm/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingEpic.js +46 -0
- package/lib/esm/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingPageEpic.js +7 -0
- package/lib/esm/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.js +50 -0
- package/lib/esm/view/expenseAutomationView/epics/actualMatching/searchMatchAccrualsEpic.js +44 -0
- package/lib/esm/view/expenseAutomationView/epics/actualMatching/searchMatchTransactionsEpic.js +44 -0
- package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +30 -10
- package/lib/esm/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.js +9 -1
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +9 -1
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +41 -5
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +45 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +104 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +25 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +136 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +79 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +180 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +111 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +33 -0
- package/lib/esm/view/expenseAutomationView/expenseAutomationViewSelector.js +22 -7
- package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +140 -0
- package/lib/esm/view/expenseAutomationView/payload/actualMatchingPayload.js +35 -0
- package/lib/esm/view/expenseAutomationView/payload/jeSchedulesPayload.js +55 -0
- package/lib/esm/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +260 -0
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +319 -29
- package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +1 -0
- package/lib/esm/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +162 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeAccountSettingsViewSelector.js +1 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +106 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +297 -22
- package/lib/esm/view/expenseAutomationView/types/actualMatchingViewState.js +22 -0
- package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -5
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +9 -25
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +1 -6
- package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +0 -40
- package/lib/esm/view/invoicing/settingsView/settingsViewEpics.js +92 -0
- package/lib/esm/view/invoicing/settingsView/settingsViewReducer.js +1 -25
- package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +0 -41
- package/lib/esm/view/recommendation/recommendationReducer.js +1 -16
- package/lib/esm/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
- package/lib/esm/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +7 -2
- package/lib/esm/view/scheduleView/scheduleListView/scheduleListReducer.js +5 -3
- package/lib/index.d.ts +29 -22
- package/lib/index.js +116 -56
- package/lib/reducer.d.ts +1 -0
- package/lib/reducer.js +3 -0
- package/lib/rootStateTypes.d.ts +2 -0
- package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingEpic.d.ts +9 -0
- package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingEpic.js +50 -0
- package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingPageEpic.d.ts +5 -0
- package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingPageEpic.js +11 -0
- package/lib/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.js +54 -0
- package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchAccrualsEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchAccrualsEpic.js +48 -0
- package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchTransactionsEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchTransactionsEpic.js +48 -0
- package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.d.ts +2 -1
- package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +30 -10
- package/lib/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.d.ts +2 -1
- package/lib/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.js +9 -1
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +9 -1
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +3 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +39 -3
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.d.ts +21 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +49 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.d.ts +9 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +108 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +29 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts +9 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +140 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +83 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.d.ts +13 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +187 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.d.ts +65 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +115 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +7 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +37 -0
- package/lib/view/expenseAutomationView/expenseAutomationViewSelector.js +22 -7
- package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.d.ts +36 -0
- package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +145 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/actualMatchingPayload.d.ts +66 -0
- package/lib/view/expenseAutomationView/payload/actualMatchingPayload.js +40 -0
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +86 -3
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.js +58 -1
- package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.d.ts +53 -0
- package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +264 -0
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +93 -12
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +321 -29
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -1
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +2 -2
- package/lib/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.d.ts +58 -0
- package/lib/view/expenseAutomationView/selectorTypes/expenseAutomationViewSelectorTypes.d.ts +2 -0
- package/lib/view/expenseAutomationView/selectorTypes/jeAccountSettingsViewSelectorTypes.d.ts +1 -0
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +42 -0
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +2 -0
- package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +36 -7
- package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.d.ts +9 -0
- package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +172 -0
- package/lib/view/expenseAutomationView/selectors/jeAccountSettingsViewSelector.js +1 -0
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +21 -0
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +112 -0
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +34 -0
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +305 -21
- package/lib/view/expenseAutomationView/types/actualMatchingViewState.d.ts +76 -0
- package/lib/view/expenseAutomationView/types/actualMatchingViewState.js +27 -0
- package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +83 -8
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +11 -7
- package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +2 -2
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.d.ts +1 -12
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +9 -25
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +1 -6
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.d.ts +1 -10
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +1 -43
- package/lib/view/invoicing/settingsView/settingsViewEpics.d.ts +12 -0
- package/lib/view/invoicing/settingsView/settingsViewEpics.js +99 -0
- package/lib/view/invoicing/settingsView/settingsViewReducer.d.ts +1 -4
- package/lib/view/invoicing/settingsView/settingsViewReducer.js +2 -26
- package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +0 -35
- package/lib/view/invoicing/settingsView/settingsViewSelector.js +1 -43
- package/lib/view/invoicing/settingsView/settingsViewState.d.ts +0 -8
- package/lib/view/recommendation/recommendationPayload.d.ts +0 -34
- package/lib/view/recommendation/recommendationReducer.d.ts +1 -2
- package/lib/view/recommendation/recommendationReducer.js +2 -17
- package/lib/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
- package/lib/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +7 -2
- package/lib/view/scheduleView/scheduleListView/scheduleListReducer.d.ts +4 -2
- package/lib/view/scheduleView/scheduleListView/scheduleListReducer.js +5 -3
- package/package.json +1 -1
- package/lib/esm/view/invoicing/settingsView/epics/connectInvoicingStripeEpic.js +0 -27
- package/lib/esm/view/invoicing/settingsView/epics/disconnectInvoicingStripeEpic.js +0 -19
- package/lib/esm/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.js +0 -19
- package/lib/esm/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.js +0 -39
- package/lib/esm/view/invoicing/settingsView/epics/submitInvoicingQboSettingsEpic.js +0 -25
- package/lib/esm/view/invoicing/settingsView/invoicingQboSettingsFormConfig.js +0 -48
- package/lib/esm/view/recommendation/submitRecommendationFeedbackEpic.js +0 -52
- package/lib/view/invoicing/settingsView/epics/connectInvoicingStripeEpic.d.ts +0 -6
- package/lib/view/invoicing/settingsView/epics/connectInvoicingStripeEpic.js +0 -31
- package/lib/view/invoicing/settingsView/epics/disconnectInvoicingStripeEpic.d.ts +0 -6
- package/lib/view/invoicing/settingsView/epics/disconnectInvoicingStripeEpic.js +0 -23
- package/lib/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.d.ts +0 -6
- package/lib/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.js +0 -23
- package/lib/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.d.ts +0 -6
- package/lib/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.js +0 -43
- package/lib/view/invoicing/settingsView/epics/settingsViewActionType.d.ts +0 -5
- package/lib/view/invoicing/settingsView/epics/submitInvoicingQboSettingsEpic.d.ts +0 -11
- package/lib/view/invoicing/settingsView/epics/submitInvoicingQboSettingsEpic.js +0 -29
- package/lib/view/invoicing/settingsView/invoicingQboSettingsFormConfig.d.ts +0 -34
- package/lib/view/invoicing/settingsView/invoicingQboSettingsFormConfig.js +0 -53
- package/lib/view/recommendation/submitRecommendationFeedbackEpic.d.ts +0 -7
- package/lib/view/recommendation/submitRecommendationFeedbackEpic.js +0 -56
- /package/lib/esm/view/{invoicing/settingsView/epics/settingsViewActionType.js → expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.js} +0 -0
- /package/lib/view/{invoicing/settingsView/epics/settingsViewActionType.js → expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.js} +0 -0
package/lib/esm/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { from, of } from 'rxjs';
|
|
2
|
+
import { catchError, filter, mergeMap, takeUntil } from 'rxjs/operators';
|
|
3
|
+
import { convertToPeriod, toAbsoluteDay, } from '../../../../commonStateTypes/timePeriod';
|
|
4
|
+
import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
|
|
5
|
+
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
6
|
+
import { clearAll } from '../../../../rootActions';
|
|
7
|
+
import { toMatchAndReverseResult, } from '../../payload/actualMatchingPayload';
|
|
8
|
+
import { clearMatchNewModal, fetchActualMatching, matchAndReverseAccruals, matchAndReverseAccrualsFailure, matchAndReverseAccrualsSuccess, } from '../../reducers/actualMatchingViewReducer';
|
|
9
|
+
function refreshActualMatchingList(state) {
|
|
10
|
+
const selectedMonthYear = state.expenseAutomationViewState.selectedPeriodByTenantId[getCurrentTenant(state).tenantId];
|
|
11
|
+
if (selectedMonthYear == null) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
const period = convertToPeriod(selectedMonthYear);
|
|
15
|
+
const start = toAbsoluteDay(period.start);
|
|
16
|
+
const end = toAbsoluteDay(period.end);
|
|
17
|
+
if (start == null || end == null) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
return [fetchActualMatching({ start, end }, true)];
|
|
21
|
+
}
|
|
22
|
+
export const matchAndReverseAccrualsEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(matchAndReverseAccruals.match), mergeMap((action) => {
|
|
23
|
+
const { transactionId, transactionIntegrationId, transactionType, lineId, accrualIds, } = action.payload;
|
|
24
|
+
const body = {
|
|
25
|
+
transaction_id: transactionId,
|
|
26
|
+
transaction_integration_id: transactionIntegrationId,
|
|
27
|
+
transaction_type: transactionType,
|
|
28
|
+
line_id: lineId,
|
|
29
|
+
accrual_ids: accrualIds,
|
|
30
|
+
};
|
|
31
|
+
return zeniAPI
|
|
32
|
+
.postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/match-and-reverse`, body)
|
|
33
|
+
.pipe(mergeMap((response) => {
|
|
34
|
+
if (isSuccessResponse(response) && response.data != null) {
|
|
35
|
+
const results = (response.data.results ?? []).map(toMatchAndReverseResult);
|
|
36
|
+
const successActions = [
|
|
37
|
+
matchAndReverseAccrualsSuccess({ results }),
|
|
38
|
+
];
|
|
39
|
+
const anyReversed = results.some((result) => result.status === 'reversed');
|
|
40
|
+
if (anyReversed) {
|
|
41
|
+
successActions.push(...refreshActualMatchingList(state$.value), clearMatchNewModal());
|
|
42
|
+
}
|
|
43
|
+
return from(successActions);
|
|
44
|
+
}
|
|
45
|
+
return of(matchAndReverseAccrualsFailure({ status: response.status }));
|
|
46
|
+
}), catchError((error) => of(matchAndReverseAccrualsFailure({
|
|
47
|
+
status: createZeniAPIStatus('Unexpected Error', 'Match and reverse accruals REST API call errored out' +
|
|
48
|
+
JSON.stringify(error)),
|
|
49
|
+
}))), takeUntil(actions$.pipe(filter(clearAll.match))));
|
|
50
|
+
}));
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { from, merge, of } from 'rxjs';
|
|
2
|
+
import { catchError, debounceTime, filter, mergeMap, switchMap, } from 'rxjs/operators';
|
|
3
|
+
import { updateJEOneTimeAccruals } from '../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
4
|
+
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
5
|
+
import { searchMatchAccruals, searchMatchAccrualsFailure, searchMatchAccrualsSuccess, } from '../../reducers/actualMatchingViewReducer';
|
|
6
|
+
import { MATCH_ACCRUAL_SEARCH_LIMIT, MATCH_SEARCH_DEBOUNCE_MS, } from '../../types/actualMatchingViewState';
|
|
7
|
+
export const searchMatchAccrualsEpic = (actions$, _state$, zeniAPI) => {
|
|
8
|
+
const searchActions$ = actions$.pipe(filter(searchMatchAccruals.match));
|
|
9
|
+
const pagination$ = searchActions$.pipe(filter((action) => action.payload.pageToken != null));
|
|
10
|
+
const newSearchDebounced$ = searchActions$.pipe(filter((action) => action.payload.pageToken == null), debounceTime(MATCH_SEARCH_DEBOUNCE_MS));
|
|
11
|
+
return merge(pagination$, newSearchDebounced$).pipe(switchMap((action) => {
|
|
12
|
+
const { query, pageToken } = action.payload;
|
|
13
|
+
const offset = pageToken != null && pageToken.length > 0 ? Number(pageToken) : 0;
|
|
14
|
+
const searchText = encodeURIComponent(query);
|
|
15
|
+
const limit = MATCH_ACCRUAL_SEARCH_LIMIT;
|
|
16
|
+
return zeniAPI
|
|
17
|
+
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals?status=posted&reversal_policy=on_bill_match&search_text=${searchText}&limit=${limit}&offset=${offset}`)
|
|
18
|
+
.pipe(mergeMap((response) => {
|
|
19
|
+
if (isSuccessResponse(response) && response.data != null) {
|
|
20
|
+
const accruals = response.data.accruals ?? [];
|
|
21
|
+
const append = pageToken != null;
|
|
22
|
+
const nextOffset = offset + accruals.length;
|
|
23
|
+
const total = response.data.total ?? nextOffset;
|
|
24
|
+
const nextPageToken = nextOffset < total ? String(nextOffset) : null;
|
|
25
|
+
const actionsOut = [];
|
|
26
|
+
if (accruals.length > 0) {
|
|
27
|
+
actionsOut.push(updateJEOneTimeAccruals(accruals));
|
|
28
|
+
}
|
|
29
|
+
actionsOut.push(searchMatchAccrualsSuccess({
|
|
30
|
+
append,
|
|
31
|
+
nextPageToken,
|
|
32
|
+
results: accruals,
|
|
33
|
+
}));
|
|
34
|
+
return from(actionsOut);
|
|
35
|
+
}
|
|
36
|
+
return of(searchMatchAccrualsFailure({
|
|
37
|
+
error: response.status,
|
|
38
|
+
}));
|
|
39
|
+
}), catchError((error) => of(searchMatchAccrualsFailure({
|
|
40
|
+
error: createZeniAPIStatus('Unexpected Error', 'Search match accruals REST API call errored out' +
|
|
41
|
+
JSON.stringify(error)),
|
|
42
|
+
}))));
|
|
43
|
+
}));
|
|
44
|
+
};
|
package/lib/esm/view/expenseAutomationView/epics/actualMatching/searchMatchTransactionsEpic.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { from, merge, of } from 'rxjs';
|
|
2
|
+
import { catchError, debounceTime, filter, mergeMap, switchMap, } from 'rxjs/operators';
|
|
3
|
+
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
4
|
+
import { toActualMatchingTransactionSearchResult, } from '../../payload/actualMatchingPayload';
|
|
5
|
+
import { openMatchNewModal, searchMatchAccruals, searchMatchTransactions, searchMatchTransactionsFailure, searchMatchTransactionsSuccess, } from '../../reducers/actualMatchingViewReducer';
|
|
6
|
+
import { MATCH_SEARCH_DEBOUNCE_MS, MATCH_TRANSACTION_SEARCH_PAGE_SIZE, } from '../../types/actualMatchingViewState';
|
|
7
|
+
export const searchMatchTransactionsEpic = (actions$, _state$, zeniAPI) => {
|
|
8
|
+
const openModal$ = actions$.pipe(filter(openMatchNewModal.match), mergeMap(() => from([
|
|
9
|
+
searchMatchTransactions({ query: '' }),
|
|
10
|
+
searchMatchAccruals({ query: '' }),
|
|
11
|
+
])));
|
|
12
|
+
const searchActions$ = actions$.pipe(filter(searchMatchTransactions.match));
|
|
13
|
+
const pagination$ = searchActions$.pipe(filter((action) => action.payload.pageToken != null));
|
|
14
|
+
const newSearchDebounced$ = searchActions$.pipe(filter((action) => action.payload.pageToken == null), debounceTime(MATCH_SEARCH_DEBOUNCE_MS));
|
|
15
|
+
const search$ = merge(pagination$, newSearchDebounced$).pipe(switchMap((action) => {
|
|
16
|
+
const { query, pageToken } = action.payload;
|
|
17
|
+
const queryParam = {
|
|
18
|
+
search_text: query,
|
|
19
|
+
page_size: MATCH_TRANSACTION_SEARCH_PAGE_SIZE,
|
|
20
|
+
...(pageToken != null ? { page_token: pageToken } : {}),
|
|
21
|
+
};
|
|
22
|
+
return zeniAPI
|
|
23
|
+
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/match-transaction-search?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
24
|
+
.pipe(mergeMap((response) => {
|
|
25
|
+
if (isSuccessResponse(response) && response.data != null) {
|
|
26
|
+
const { transactions, next_page_token } = response.data;
|
|
27
|
+
const append = pageToken != null;
|
|
28
|
+
const results = (transactions ?? []).map(toActualMatchingTransactionSearchResult);
|
|
29
|
+
return of(searchMatchTransactionsSuccess({
|
|
30
|
+
append,
|
|
31
|
+
nextPageToken: next_page_token ?? null,
|
|
32
|
+
results,
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
return of(searchMatchTransactionsFailure({
|
|
36
|
+
error: response.status,
|
|
37
|
+
}));
|
|
38
|
+
}), catchError((error) => of(searchMatchTransactionsFailure({
|
|
39
|
+
error: createZeniAPIStatus('Unexpected Error', 'Search match transactions REST API call errored out' +
|
|
40
|
+
JSON.stringify(error)),
|
|
41
|
+
}))));
|
|
42
|
+
}));
|
|
43
|
+
return merge(openModal$, search$);
|
|
44
|
+
};
|
package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js
CHANGED
|
@@ -3,11 +3,13 @@ import { filter, switchMap } from 'rxjs/operators';
|
|
|
3
3
|
import { convertToPeriod, toAbsoluteDay, toMonthYearPeriodId, } from '../../../../commonStateTypes/timePeriod';
|
|
4
4
|
import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
|
|
5
5
|
import { fetchAllExpenseAutomationTabs } from '../../expenseAutomationViewReducer';
|
|
6
|
+
import { fetchActualMatchingPage } from '../../reducers/actualMatchingViewReducer';
|
|
6
7
|
import { fetchFluxAnalysisView } from '../../reducers/fluxAnalysisViewReducer';
|
|
7
8
|
import { fetchJeSchedulesPage } from '../../reducers/jeSchedulesViewReducer';
|
|
8
9
|
import { fetchMissingReceipts } from '../../reducers/missingReceiptsViewReducer';
|
|
9
10
|
import { fetchReconciliation } from '../../reducers/reconciliationViewReducer';
|
|
10
11
|
import { fetchTransactionCategorizationView } from '../../reducers/transactionsViewReducer';
|
|
12
|
+
import { getJESchedulePeriodTabKey } from '../../types/jeSchedulesViewState';
|
|
11
13
|
export const fetchAllExpenseAutomationTabsEpic = (actions$, state$) => actions$.pipe(filter(fetchAllExpenseAutomationTabs.match), switchMap((action) => {
|
|
12
14
|
const { cacheOverride, refreshViewInBackground } = action.payload;
|
|
13
15
|
const state = state$.value;
|
|
@@ -30,11 +32,14 @@ export const fetchAllExpenseAutomationTabsEpic = (actions$, state$) => actions$.
|
|
|
30
32
|
}
|
|
31
33
|
if (cacheOverride === true) {
|
|
32
34
|
const actions = [];
|
|
35
|
+
const selectedPageTab = state.expenseAutomationJESchedulesViewState.uiState.selectedPageTab;
|
|
33
36
|
actions.push(fetchTransactionCategorizationView(selectedTransactionCategorizationTab, { start: timePeriodStart, end: timePeriodEnd }, cacheOverride, false, undefined, undefined, refreshViewInBackground, false), fetchMissingReceipts({ start: timePeriodStart, end: timePeriodEnd }, {
|
|
34
37
|
amount: 75.0,
|
|
35
38
|
currencyCode: 'USD',
|
|
36
39
|
currencySymbol: '$',
|
|
37
|
-
}, cacheOverride, refreshViewInBackground), fetchFluxAnalysisView(selectedPeriod, cacheOverride, refreshViewInBackground, null),
|
|
40
|
+
}, cacheOverride, refreshViewInBackground), fetchFluxAnalysisView(selectedPeriod, cacheOverride, refreshViewInBackground, null), selectedPageTab === 'actual_matching'
|
|
41
|
+
? fetchActualMatchingPage({ start: timePeriodStart, end: timePeriodEnd }, cacheOverride)
|
|
42
|
+
: fetchJeSchedulesPage({ start: timePeriodStart, end: timePeriodEnd }, cacheOverride));
|
|
38
43
|
if (reconciliationEnabled) {
|
|
39
44
|
actions.push(fetchReconciliation(selectedPeriod, undefined, cacheOverride, refreshViewInBackground));
|
|
40
45
|
}
|
|
@@ -59,15 +64,30 @@ export const fetchAllExpenseAutomationTabsEpic = (actions$, state$) => actions$.
|
|
|
59
64
|
state.expenseAutomationFluxAnalysisViewState.groupsBySelectedPeriod[monthYearPeriodId] == null)) {
|
|
60
65
|
fetchActions.push(fetchFluxAnalysisView(selectedPeriod, cacheOverride, refreshViewInBackground, null));
|
|
61
66
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
// The two JE tabs cache separately, so only the tab actually being shown decides whether a
|
|
68
|
+
// fetch is still needed. Actual Matching is a third tab on the same page with its own
|
|
69
|
+
// endpoint and cache slot.
|
|
70
|
+
const selectedPageTab = state.expenseAutomationJESchedulesViewState.uiState.selectedPageTab;
|
|
71
|
+
if (selectedPageTab === 'actual_matching') {
|
|
72
|
+
const actualMatchingPeriodKeys = state.expenseAutomationActualMatchingViewState.accrualKeysByPeriod[monthYearPeriodId];
|
|
73
|
+
if (state.expenseAutomationActualMatchingViewState.fetchState !==
|
|
74
|
+
'In-Progress' &&
|
|
75
|
+
(!state.expenseAutomationActualMatchingViewState.hasValidState() ||
|
|
76
|
+
actualMatchingPeriodKeys == null)) {
|
|
77
|
+
fetchActions.push(fetchActualMatchingPage({ start: timePeriodStart, end: timePeriodEnd }, cacheOverride));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
const jeSchedulesPeriodTabKey = getJESchedulePeriodTabKey(selectedPageTab, monthYearPeriodId);
|
|
82
|
+
if (state.expenseAutomationJESchedulesViewState.fetchState !==
|
|
83
|
+
'In-Progress' &&
|
|
84
|
+
(!state.expenseAutomationJESchedulesViewState.hasValidState() ||
|
|
85
|
+
state.expenseAutomationJESchedulesViewState
|
|
86
|
+
.jeScheduleTransactionKeysByPeriodAndTab[jeSchedulesPeriodTabKey] == null ||
|
|
87
|
+
state.expenseAutomationJESchedulesViewState
|
|
88
|
+
.failedJeScheduleTransactionKeysByPeriodAndTab[jeSchedulesPeriodTabKey] == null)) {
|
|
89
|
+
fetchActions.push(fetchJeSchedulesPage({ start: timePeriodStart, end: timePeriodEnd }, cacheOverride));
|
|
90
|
+
}
|
|
71
91
|
}
|
|
72
92
|
if (state.expenseAutomationReconciliationViewState.fetchState !==
|
|
73
93
|
'In-Progress' &&
|
package/lib/esm/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.js
CHANGED
|
@@ -4,6 +4,7 @@ import { convertToPeriod, toAbsoluteDay, } from '../../../../commonStateTypes/ti
|
|
|
4
4
|
import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
|
|
5
5
|
import { fetchCompanyMonthEndReportTemplates, fetchCompanyMonthEndReportView, } from '../../../companyMonthEndReportView/companyMonthEndReportViewReducer';
|
|
6
6
|
import { refreshExpenseAutomationCurrentTab } from '../../expenseAutomationViewReducer';
|
|
7
|
+
import { fetchActualMatchingPage } from '../../reducers/actualMatchingViewReducer';
|
|
7
8
|
import { fetchFluxAnalysisView } from '../../reducers/fluxAnalysisViewReducer';
|
|
8
9
|
import { fetchJeSchedulesPage } from '../../reducers/jeSchedulesViewReducer';
|
|
9
10
|
import { fetchMissingReceipts } from '../../reducers/missingReceiptsViewReducer';
|
|
@@ -38,10 +39,17 @@ export const refreshExpenseAutomationCurrentTabEpic = (actions$, state$) => acti
|
|
|
38
39
|
return from([
|
|
39
40
|
fetchFluxAnalysisView(selectedPeriod, true, true, null),
|
|
40
41
|
]);
|
|
41
|
-
case 'je_schedules':
|
|
42
|
+
case 'je_schedules': {
|
|
43
|
+
const selectedPageTab = state.expenseAutomationJESchedulesViewState.uiState.selectedPageTab;
|
|
44
|
+
if (selectedPageTab === 'actual_matching') {
|
|
45
|
+
return from([
|
|
46
|
+
fetchActualMatchingPage({ start: timePeriodStart, end: timePeriodEnd }, true),
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
42
49
|
return from([
|
|
43
50
|
fetchJeSchedulesPage({ start: timePeriodStart, end: timePeriodEnd }, true),
|
|
44
51
|
]);
|
|
52
|
+
}
|
|
45
53
|
case 'month_end_insights':
|
|
46
54
|
return from([
|
|
47
55
|
fetchCompanyMonthEndReportView(true, companyId, currentTenant.tenantId, period.end, true),
|
|
@@ -14,6 +14,14 @@ export const fetchJeSchedulesPageEpic = (actions$, state$) => actions$.pipe(filt
|
|
|
14
14
|
jeSchedulePageActions.push(fetchAccountList(accountType.accountListKey, true, false, false, false, accountType.allowedAccountList));
|
|
15
15
|
}
|
|
16
16
|
jeSchedulePageActions.push(fetchJeSchedules(period, refreshViewInBackground));
|
|
17
|
-
|
|
17
|
+
// Only on the first page load. Account settings cannot change from a tab switch or a
|
|
18
|
+
// refresh, and re-initializing puts accountSettingsView back to 'In-Progress' -- which the
|
|
19
|
+
// page reads as "still loading" and answers with a full skeleton over rows it already has.
|
|
20
|
+
// The action also resets localData, so re-dispatching it blindly would empty the settings
|
|
21
|
+
// form until the refetch lands. Saving account settings still re-initializes explicitly.
|
|
22
|
+
if (!state$.value.expenseAutomationJESchedulesViewState.accountSettings
|
|
23
|
+
.hasLoadedAccountSettings) {
|
|
24
|
+
jeSchedulePageActions.push(initializeAccountSettingsView());
|
|
25
|
+
}
|
|
18
26
|
return concat(from(jeSchedulePageActions));
|
|
19
27
|
}));
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { from, of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { catchError, filter, mergeMap, takeUntil } from 'rxjs/operators';
|
|
3
|
+
import { DEFAULT_DATE_FORMAT } from '../../../../commonStateTypes/timePeriod';
|
|
4
|
+
import { toAbsoluteDay, toString } from '../../../../commonStateTypes/timePeriod';
|
|
5
|
+
import { updateAccruedJESchedules, updateAccruedJESchedulesDetails, updateJEOneTimeAccruals, updateJESchedules, updateJESchedulesDetails, } from '../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
5
6
|
import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
|
|
6
7
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
8
|
+
import { clearAll } from '../../../../rootActions';
|
|
9
|
+
import { date } from '../../../../zeniDayJS';
|
|
7
10
|
import { fetchJeSchedules, fetchJeSchedulesFailure, fetchJeSchedulesSuccess, initializeJeScheduleLocalData, } from '../../reducers/jeSchedulesViewReducer';
|
|
8
11
|
export const fetchJeSchedulesEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchJeSchedules.match), mergeMap((action) => {
|
|
9
12
|
const state = state$.value;
|
|
@@ -11,27 +14,54 @@ export const fetchJeSchedulesEpic = (actions$, state$, zeniAPI) => actions$.pipe
|
|
|
11
14
|
const { period, refreshViewInBackground } = action.payload;
|
|
12
15
|
const currentTenant = getCurrentTenant(state);
|
|
13
16
|
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
17
|
+
const { selectedPageTab } = state.expenseAutomationJESchedulesViewState.uiState;
|
|
18
|
+
const isClosePeriodTab = selectedPageTab === 'schedules';
|
|
19
|
+
const existingEndDate = toAbsoluteDay(date(toString(period.start))
|
|
20
|
+
.subtract(1, 'month')
|
|
21
|
+
.endOf('month')
|
|
22
|
+
.format(DEFAULT_DATE_FORMAT));
|
|
14
23
|
const queryParam = {
|
|
15
24
|
start_date: toString(period.start),
|
|
16
|
-
end_date:
|
|
25
|
+
end_date: isClosePeriodTab || existingEndDate == null
|
|
26
|
+
? toString(period.end)
|
|
27
|
+
: toString(existingEndDate),
|
|
28
|
+
include_accrued: true,
|
|
29
|
+
...(isClosePeriodTab
|
|
30
|
+
? { close_period_start_date: toString(period.start) }
|
|
31
|
+
: {}),
|
|
17
32
|
};
|
|
18
33
|
return zeniAPI
|
|
19
34
|
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expenses_automation/je_schedules?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
20
35
|
.pipe(mergeMap((response) => {
|
|
21
36
|
if (isSuccessResponse(response) && response.data != null) {
|
|
22
37
|
const updateActions = [];
|
|
38
|
+
const accruedJeSchedules = response.data.accrued_je_schedules?.je_schedules ?? [];
|
|
39
|
+
const oneTimeAccruals = response.data.one_time_accruals ?? [];
|
|
23
40
|
updateActions.push(updateJESchedules([
|
|
24
41
|
...response.data.je_schedules,
|
|
25
42
|
...response.data.failed_je_postings.je_schedules,
|
|
26
43
|
]), updateJESchedulesDetails([...response.data.failed_je_postings.je_schedules], response.data.failed_je_postings.scheduled_journal_entries), initializeJeScheduleLocalData([
|
|
27
44
|
...response.data.failed_je_postings.je_schedules,
|
|
28
45
|
]));
|
|
46
|
+
if (accruedJeSchedules.length > 0) {
|
|
47
|
+
updateActions.push(updateAccruedJESchedules(accruedJeSchedules), updateAccruedJESchedulesDetails(accruedJeSchedules, response.data.accrued_je_schedules
|
|
48
|
+
?.scheduled_journal_entries));
|
|
49
|
+
}
|
|
50
|
+
if (oneTimeAccruals.length > 0) {
|
|
51
|
+
// Single action, unlike the accrued pair above: this one writes the entity
|
|
52
|
+
// directly because an accrual denormalizes its vendor, accounts and classes, so
|
|
53
|
+
// there is no fan-out fetch to trigger.
|
|
54
|
+
updateActions.push(updateJEOneTimeAccruals(oneTimeAccruals));
|
|
55
|
+
}
|
|
29
56
|
updateActions.push(fetchJeSchedulesSuccess({
|
|
30
57
|
jeSchedules: [...response.data.je_schedules],
|
|
31
58
|
failedJeSchedules: [
|
|
32
59
|
...response.data.failed_je_postings.je_schedules,
|
|
33
60
|
],
|
|
61
|
+
accruedJeSchedules: accruedJeSchedules,
|
|
62
|
+
oneTimeAccruals: oneTimeAccruals,
|
|
34
63
|
selectedPeriod: selectedPeriod,
|
|
64
|
+
selectedPageTab: selectedPageTab,
|
|
35
65
|
refreshViewInBackground: refreshViewInBackground,
|
|
36
66
|
}));
|
|
37
67
|
return from(updateActions);
|
|
@@ -40,11 +70,17 @@ export const fetchJeSchedulesEpic = (actions$, state$, zeniAPI) => actions$.pipe
|
|
|
40
70
|
return of(fetchJeSchedulesFailure({
|
|
41
71
|
status: response.status,
|
|
42
72
|
selectedPeriod,
|
|
73
|
+
selectedPageTab,
|
|
43
74
|
}));
|
|
44
75
|
}
|
|
45
76
|
}), catchError((error) => of(fetchJeSchedulesFailure({
|
|
46
77
|
status: createZeniAPIStatus('Unexpected Error', 'fetch JE schedules REST API call errored out' +
|
|
47
78
|
JSON.stringify(error)),
|
|
48
79
|
selectedPeriod,
|
|
49
|
-
|
|
80
|
+
selectedPageTab,
|
|
81
|
+
}))),
|
|
82
|
+
// A tenant switch clears the store while this request is still in flight. Without this
|
|
83
|
+
// the old tenant's rows are written back into the freshly cleared store and stay on
|
|
84
|
+
// screen under the new tenant until a manual refresh.
|
|
85
|
+
takeUntil(actions$.pipe(filter(clearAll.match))));
|
|
50
86
|
}));
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { from } from 'rxjs';
|
|
2
|
+
import { catchError, filter, mergeMap, takeUntil } from 'rxjs/operators';
|
|
3
|
+
import { updateJEOneTimeAccruals } from '../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
4
|
+
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
5
|
+
import { clearAll } from '../../../../rootActions';
|
|
6
|
+
import { fetchOneTimeAccrual, fetchOneTimeAccrualFailure, fetchOneTimeAccrualSuccess, } from '../../reducers/jeSchedulesViewReducer';
|
|
7
|
+
/**
|
|
8
|
+
* Read one accrual by id so its detail page can render from a URL alone.
|
|
9
|
+
*
|
|
10
|
+
* Every other row on this page arrives with the JE Schedules list, and the accrual detail page used
|
|
11
|
+
* to render only from what that list had already put in the store -- so opening its URL directly, on
|
|
12
|
+
* a refresh or a shared link, had nothing to render and showed not-found. This is the read that
|
|
13
|
+
* makes the URL self-sufficient.
|
|
14
|
+
*
|
|
15
|
+
* The response is the same `{accrual}` envelope promote / ignore / revert return, and it goes through
|
|
16
|
+
* the same `updateJEOneTimeAccruals`, so a page loaded cold holds exactly the entity a page reached
|
|
17
|
+
* through the list holds.
|
|
18
|
+
*/
|
|
19
|
+
export const fetchOneTimeAccrualEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchOneTimeAccrual.match), mergeMap((action) => {
|
|
20
|
+
const { accrualId } = action.payload;
|
|
21
|
+
return zeniAPI
|
|
22
|
+
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${accrualId}`)
|
|
23
|
+
.pipe(mergeMap((response) => {
|
|
24
|
+
if (isSuccessResponse(response) && response.data != null) {
|
|
25
|
+
return from([
|
|
26
|
+
updateJEOneTimeAccruals([response.data.accrual]),
|
|
27
|
+
fetchOneTimeAccrualSuccess({ accrualId }),
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
// A deleted or ignored accrual answers 404 here, the same as an id that never existed.
|
|
31
|
+
// Both end as an error state the page turns into not-found, rather than a spinner that
|
|
32
|
+
// never resolves.
|
|
33
|
+
return from([
|
|
34
|
+
fetchOneTimeAccrualFailure({ accrualId, status: response.status }),
|
|
35
|
+
]);
|
|
36
|
+
}), catchError((error) => from([
|
|
37
|
+
fetchOneTimeAccrualFailure({
|
|
38
|
+
accrualId,
|
|
39
|
+
status: createZeniAPIStatus('Unexpected Error', `Fetch one-time accrual REST API call errored out ${JSON.stringify(error)}`),
|
|
40
|
+
}),
|
|
41
|
+
])),
|
|
42
|
+
// A tenant switch clears the store while this request is in flight. Without this the old
|
|
43
|
+
// tenant's accrual is written back into the freshly cleared store.
|
|
44
|
+
takeUntil(actions$.pipe(filter(clearAll.match))));
|
|
45
|
+
}));
|
package/lib/esm/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js
CHANGED
|
@@ -11,13 +11,25 @@ import { ignoreRecommendedJeSchedule, ignoreRecommendedJeScheduleFailure, ignore
|
|
|
11
11
|
export const ignoreRecommendedJeScheduleEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(ignoreRecommendedJeSchedule.match), mergeMap((action) => {
|
|
12
12
|
const state = state$.value;
|
|
13
13
|
const { expenseAutomationViewState: { selectedPeriodByTenantId }, } = state;
|
|
14
|
-
const { scheduleType, jeScheduleTransactionKey } = action.payload;
|
|
14
|
+
const { scheduleType, jeScheduleTransactionKey, reason, note } = action.payload;
|
|
15
15
|
const currentTenant = getCurrentTenant(state);
|
|
16
16
|
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
17
17
|
const actions = [];
|
|
18
18
|
const jeScheduleTransactionState = getJEScheduledTransactionByJEScheduleTransactionKey(jeScheduleTransactionKey, state);
|
|
19
|
+
const ignorePayload = prepareIgnoreSchedulePayload(scheduleType, jeScheduleTransactionState, state);
|
|
20
|
+
// The gateway reads reason/note from je_schedules[0].feedback and nowhere else, and rejects
|
|
21
|
+
// anything but those two keys inside it — `action` is stamped server-side.
|
|
19
22
|
const payload = {
|
|
20
|
-
...
|
|
23
|
+
...ignorePayload,
|
|
24
|
+
je_schedules: ignorePayload.je_schedules.map((schedule, index) => index === 0
|
|
25
|
+
? {
|
|
26
|
+
...schedule,
|
|
27
|
+
feedback: {
|
|
28
|
+
reason,
|
|
29
|
+
...(note != null && note !== '' ? { note } : {}),
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
: schedule),
|
|
21
33
|
};
|
|
22
34
|
const queryParam = {
|
|
23
35
|
je_schedule_type: scheduleType,
|
package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { from } from 'rxjs';
|
|
2
|
+
import { catchError, filter, mergeMap, takeUntil } from 'rxjs/operators';
|
|
3
|
+
import { convertToPeriod, toAbsoluteDay, } from '../../../../../commonStateTypes/timePeriod';
|
|
4
|
+
import { updateJEOneTimeAccruals } from '../../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
5
|
+
import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
|
|
6
|
+
import { getCurrentTenant } from '../../../../../entity/tenant/tenantSelector';
|
|
7
|
+
import { clearAll } from '../../../../../rootActions';
|
|
8
|
+
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
9
|
+
import { prepareCreateOneTimeAccrualPayload, } from '../../../payload/jeSchedulesPayload';
|
|
10
|
+
import { createOneTimeAccrual, createOneTimeAccrualFailure, createOneTimeAccrualSuccess, fetchJeSchedules, } from '../../../reducers/jeSchedulesViewReducer';
|
|
11
|
+
export const createOneTimeAccrualEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(createOneTimeAccrual.match), mergeMap((action) => {
|
|
12
|
+
const state = state$.value;
|
|
13
|
+
const { localData } = action.payload;
|
|
14
|
+
/*
|
|
15
|
+
* Idempotency for the create. agent-je dedupes on this: the same key again returns the
|
|
16
|
+
* existing accrual rather than posting a second JE to QBO.
|
|
17
|
+
*
|
|
18
|
+
* Body `request_id` rather than the `Idempotency-Key` header the API doc prefers, on Mohit's
|
|
19
|
+
* call (2026-08-24). The header cannot reach the service from a browser -- common's
|
|
20
|
+
* Access-Control-Allow-Headers does not list it, so cross-origin preflight rejects the
|
|
21
|
+
* request. Same meaning either way; the header simply wins when both are sent.
|
|
22
|
+
*
|
|
23
|
+
* Minted here, per create action, and deliberately not held in local data or the form: a new
|
|
24
|
+
* Save must produce a new key, and only a retry of *this* request may reuse one. Nothing
|
|
25
|
+
* retries today -- if a retry operator is ever added below, it has to sit inside this
|
|
26
|
+
* mergeMap so the key is not re-minted, or the guarantee is silently lost.
|
|
27
|
+
*/
|
|
28
|
+
const requestId = crypto.randomUUID();
|
|
29
|
+
const payload = {
|
|
30
|
+
...prepareCreateOneTimeAccrualPayload(state, localData),
|
|
31
|
+
request_id: requestId,
|
|
32
|
+
};
|
|
33
|
+
// convertToPeriod destructures, so an unset period would throw here and take the epic
|
|
34
|
+
// subscription down for the whole session — a missed refresh is the cheaper failure.
|
|
35
|
+
const selectedMonthYear = state.expenseAutomationViewState.selectedPeriodByTenantId[getCurrentTenant(state).tenantId];
|
|
36
|
+
const selectedPeriod = selectedMonthYear != null
|
|
37
|
+
? convertToPeriod(selectedMonthYear)
|
|
38
|
+
: undefined;
|
|
39
|
+
const periodStart = selectedPeriod != null
|
|
40
|
+
? toAbsoluteDay(selectedPeriod.start)
|
|
41
|
+
: undefined;
|
|
42
|
+
const periodEnd = selectedPeriod != null ? toAbsoluteDay(selectedPeriod.end) : undefined;
|
|
43
|
+
return zeniAPI
|
|
44
|
+
.postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals`, payload)
|
|
45
|
+
.pipe(mergeMap((response) => {
|
|
46
|
+
if (isSuccessResponse(response) && response.data != null) {
|
|
47
|
+
const successActions = [
|
|
48
|
+
updateJEOneTimeAccruals([response.data.accrual]),
|
|
49
|
+
createOneTimeAccrualSuccess(),
|
|
50
|
+
openSnackbar({
|
|
51
|
+
messageSection: 'create_schedule',
|
|
52
|
+
messageText: 'success',
|
|
53
|
+
type: 'success',
|
|
54
|
+
variables: [
|
|
55
|
+
{
|
|
56
|
+
variableName: '_vendor_name_',
|
|
57
|
+
variableValue: localData.vendorName,
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
}),
|
|
61
|
+
];
|
|
62
|
+
// The tab buckets (jeScheduleOneTimeAccrualKeysByPeriodAndTab) are rebuilt wholesale
|
|
63
|
+
// per fetch, and the backend decides whether a freshly posted accrual belongs to
|
|
64
|
+
// Review or Existing — so refetch rather than guess which bucket to insert into.
|
|
65
|
+
if (periodStart != null && periodEnd != null) {
|
|
66
|
+
successActions.push(fetchJeSchedules({ start: periodStart, end: periodEnd }, true));
|
|
67
|
+
}
|
|
68
|
+
return from(successActions);
|
|
69
|
+
}
|
|
70
|
+
return from([
|
|
71
|
+
createOneTimeAccrualFailure({ status: response.status }),
|
|
72
|
+
openSnackbar({
|
|
73
|
+
messageSection: 'create_schedule',
|
|
74
|
+
messageText: 'failed',
|
|
75
|
+
type: 'error',
|
|
76
|
+
variables: [
|
|
77
|
+
{
|
|
78
|
+
variableName: '_api-error_',
|
|
79
|
+
variableValue: response.status.message,
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
}),
|
|
83
|
+
]);
|
|
84
|
+
}), catchError((error) => from([
|
|
85
|
+
openSnackbar({
|
|
86
|
+
messageSection: 'create_schedule',
|
|
87
|
+
messageText: 'failed',
|
|
88
|
+
type: 'error',
|
|
89
|
+
variables: [
|
|
90
|
+
{
|
|
91
|
+
variableName: '_api-error_',
|
|
92
|
+
variableValue: JSON.stringify(error),
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
}),
|
|
96
|
+
createOneTimeAccrualFailure({
|
|
97
|
+
status: createZeniAPIStatus('Unexpected Error', `Create One Time Accrual REST API call errored out ${JSON.stringify(error)}`),
|
|
98
|
+
}),
|
|
99
|
+
])),
|
|
100
|
+
// A tenant switch clears the store while this request is still in flight.
|
|
101
|
+
// Without this the old tenant's response is written back into the freshly
|
|
102
|
+
// cleared store and stays on screen under the new tenant.
|
|
103
|
+
takeUntil(actions$.pipe(filter(clearAll.match))));
|
|
104
|
+
}));
|
package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { from } from 'rxjs';
|
|
2
|
+
import { filter, mergeMap } from 'rxjs/operators';
|
|
3
|
+
import { fetchAccountList } from '../../../../accountList/accountListReducer';
|
|
4
|
+
import { fetchClassList } from '../../../../classList/classListReducer';
|
|
5
|
+
import { getAccountsTypesForScheduleEpics } from '../../../../scheduleView/scheduleListView/scheduleListHelper';
|
|
6
|
+
import { clearSearchTransactionsForNewSchedule, initializeNewSchedule, resetNewScheduleLocalData, } from '../../../reducers/jeSchedulesViewReducer';
|
|
7
|
+
export const initializeNewScheduleEpic = (actions$, state$) => actions$.pipe(filter(initializeNewSchedule.match), mergeMap((action) => {
|
|
8
|
+
const newScheduleActions = [];
|
|
9
|
+
const accountType = getAccountsTypesForScheduleEpics();
|
|
10
|
+
const { accountListState, classListState } = state$.value;
|
|
11
|
+
if (accountListState.byReportId[accountType.accountListKey]?.fetchState ===
|
|
12
|
+
'Not-Started') {
|
|
13
|
+
newScheduleActions.push(fetchAccountList(accountType.accountListKey, true, false, false, false, accountType.allowedAccountList));
|
|
14
|
+
}
|
|
15
|
+
if (classListState.fetchState === 'Not-Started') {
|
|
16
|
+
newScheduleActions.push(fetchClassList());
|
|
17
|
+
}
|
|
18
|
+
// The account and class fetches above are idempotent (both guard on 'Not-Started'), so they
|
|
19
|
+
// can run on every open. Clearing what the user entered cannot, so it is opt-in.
|
|
20
|
+
if (action.payload.shouldResetEnteredData) {
|
|
21
|
+
newScheduleActions.push(resetNewScheduleLocalData({ scheduleType: action.payload.scheduleType }));
|
|
22
|
+
newScheduleActions.push(clearSearchTransactionsForNewSchedule());
|
|
23
|
+
}
|
|
24
|
+
return from(newScheduleActions);
|
|
25
|
+
}));
|