@zeniai/client-epic-state 5.1.50-betaRR0 → 5.1.50
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.
|
@@ -4,93 +4,11 @@ import { toMonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
|
|
|
4
4
|
import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
5
5
|
import { getCurrentTenant } from '../../../entity/tenant/tenantSelector';
|
|
6
6
|
import { removeTransactionCategorization, updateTransactionIsMiscategorized, } from '../../../entity/transaction/transactionReducer';
|
|
7
|
-
import {
|
|
8
|
-
import { createZeniAPIStatus, isSuccessResponse, isSuccessStatus, } from '../../../responsePayload';
|
|
7
|
+
import { createZeniAPIStatus, isSuccessStatus, } from '../../../responsePayload';
|
|
9
8
|
import { updateStatusForTransactionNotMiscategorizedUpdateForCategorization, updateTotalCountForTransactionCategorization, } from '../../expenseAutomationView/reducers/transactionsViewReducer';
|
|
10
9
|
import { markTransactionAsNotMiscategorized, updateStatusConsolidatedSaveTransactionDetail, updateStatusForTransactionNotMiscategorizedUpdate, } from '../transactionDetailReducer';
|
|
11
10
|
import { getTransactionDetailKey } from '../transactionDetailState';
|
|
12
11
|
export const markTransactionAsNotMiscategorizedEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(markTransactionAsNotMiscategorized.match), mergeMap((action) => {
|
|
13
|
-
if (action.payload.isExpenseAutomationEnabled === true) {
|
|
14
|
-
const transactionKey = getTransactionDetailKey(action.payload.transactionId);
|
|
15
|
-
const transaction = getSupportedTransactionById(state$.value.transactionState, transactionKey);
|
|
16
|
-
const lineIds = (transaction?.lines ?? []).map((line) => line.id);
|
|
17
|
-
return zeniAPI
|
|
18
|
-
.putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/mark-as-reviewed`, {
|
|
19
|
-
transactions_reviewed: [
|
|
20
|
-
{
|
|
21
|
-
transaction_id: action.payload.transactionId.id,
|
|
22
|
-
line_ids: lineIds,
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
})
|
|
26
|
-
.pipe(mergeMap((response) => {
|
|
27
|
-
if (isSuccessResponse(response)) {
|
|
28
|
-
const actions = [];
|
|
29
|
-
actions.push(updateStatusForTransactionNotMiscategorizedUpdate(action.payload.transactionId, 'Completed', undefined));
|
|
30
|
-
const txnId = action.payload.transactionId.id;
|
|
31
|
-
const reviewedFailed = response.data?.transactions_reviewed_failed ?? [];
|
|
32
|
-
const isTransactionFailed = reviewedFailed.some((t) => t.transaction_id === txnId);
|
|
33
|
-
if (!isTransactionFailed) {
|
|
34
|
-
actions.push(updateTransactionIsMiscategorized(transactionKey, false));
|
|
35
|
-
const { expenseAutomationViewState, expenseAutomationTransactionsViewState, } = state$.value;
|
|
36
|
-
const { transactionCategorizationView, selectedTransactionCategorizationTab, } = expenseAutomationTransactionsViewState;
|
|
37
|
-
const currentTenant = getCurrentTenant(state$.value);
|
|
38
|
-
const { selectedPeriodByTenantId } = expenseAutomationViewState;
|
|
39
|
-
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
40
|
-
const autoTabLineItems = transactionCategorizationView.autoCategorized
|
|
41
|
-
.transactionReviewLocalDataById[txnId]
|
|
42
|
-
?.transactionReviewLocalData.tabSpecificLineItems
|
|
43
|
-
.autoCategorized ?? [];
|
|
44
|
-
const hasAutoLines = autoTabLineItems.length > 0;
|
|
45
|
-
const { uiState } = transactionCategorizationView[selectedTransactionCategorizationTab];
|
|
46
|
-
const removeIdsFromPeriod = selectedTransactionCategorizationTab === 'review'
|
|
47
|
-
? [txnId]
|
|
48
|
-
: hasAutoLines
|
|
49
|
-
? []
|
|
50
|
-
: [txnId];
|
|
51
|
-
actions.push(updateStatusForTransactionNotMiscategorizedUpdateForCategorization(selectedTransactionCategorizationTab, [txnId], removeIdsFromPeriod, selectedPeriod, 'Completed'));
|
|
52
|
-
if (!hasAutoLines) {
|
|
53
|
-
actions.push(removeTransactionCategorization({
|
|
54
|
-
transactionIds: [txnId],
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
if (removeIdsFromPeriod.length > 0) {
|
|
58
|
-
const totalCountByPeriod = uiState.totalCount[toMonthYearPeriodId(selectedPeriod)];
|
|
59
|
-
const updatedTotalCount = totalCountByPeriod === 0
|
|
60
|
-
? totalCountByPeriod
|
|
61
|
-
: totalCountByPeriod - 1;
|
|
62
|
-
actions.push(updateTotalCountForTransactionCategorization({
|
|
63
|
-
selectedPeriod,
|
|
64
|
-
selectedTab: selectedTransactionCategorizationTab,
|
|
65
|
-
totalCount: updatedTotalCount,
|
|
66
|
-
}));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
actions.push(updateStatusConsolidatedSaveTransactionDetail({
|
|
70
|
-
transactionId: action.payload.transactionId,
|
|
71
|
-
fetchState: 'Completed',
|
|
72
|
-
}));
|
|
73
|
-
if (action.payload.transactionSaveUpdates.anyBulkUpdates === true) {
|
|
74
|
-
actions.push(openSnackbar({
|
|
75
|
-
messageSection: 'transactionDetails_updatingPastTransactions',
|
|
76
|
-
messageText: 'success',
|
|
77
|
-
type: 'success',
|
|
78
|
-
}));
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
actions.push(openSnackbar({
|
|
82
|
-
messageSection: 'transactionDetails_transactionUpdated',
|
|
83
|
-
messageText: 'success',
|
|
84
|
-
type: 'success',
|
|
85
|
-
}));
|
|
86
|
-
}
|
|
87
|
-
return from(actions);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
return of(updateStatusForTransactionNotMiscategorizedUpdate(action.payload.transactionId, 'Error', response.status));
|
|
91
|
-
}
|
|
92
|
-
}), catchError((error) => of(updateStatusForTransactionNotMiscategorizedUpdate(action.payload.transactionId, 'Error', createZeniAPIStatus('Unexpected Error', `Transaction mark as reviewed REST API call errored out ${error}`)))));
|
|
93
|
-
}
|
|
94
12
|
return zeniAPI
|
|
95
13
|
.putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/${action.payload.transactionId.id}/mark-miscategorized-as-correct`, preparePayload(action.payload.transactionId))
|
|
96
14
|
.pipe(mergeMap((response) => {
|
|
@@ -98,7 +16,44 @@ export const markTransactionAsNotMiscategorizedEpic = (actions$, state$, zeniAPI
|
|
|
98
16
|
const actions = [];
|
|
99
17
|
actions.push(updateStatusForTransactionNotMiscategorizedUpdate(action.payload.transactionId, 'Completed', undefined));
|
|
100
18
|
const transactionKey = getTransactionDetailKey(action.payload.transactionId);
|
|
19
|
+
// Mark this transaction as not miscategorized anymore
|
|
101
20
|
actions.push(updateTransactionIsMiscategorized(transactionKey, false));
|
|
21
|
+
if (action.payload.isExpenseAutomationEnabled === true) {
|
|
22
|
+
const { expenseAutomationViewState, expenseAutomationTransactionsViewState, } = state$.value;
|
|
23
|
+
const { transactionCategorizationView, selectedTransactionCategorizationTab, } = expenseAutomationTransactionsViewState;
|
|
24
|
+
const currentTenant = getCurrentTenant(state$.value);
|
|
25
|
+
const { selectedPeriodByTenantId } = expenseAutomationViewState;
|
|
26
|
+
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
27
|
+
const txnId = action.payload.transactionId.id;
|
|
28
|
+
const autoTabLineItems = transactionCategorizationView.autoCategorized
|
|
29
|
+
.transactionReviewLocalDataById[txnId]
|
|
30
|
+
?.transactionReviewLocalData.tabSpecificLineItems
|
|
31
|
+
.autoCategorized ?? [];
|
|
32
|
+
const hasAutoLines = autoTabLineItems.length > 0;
|
|
33
|
+
const { uiState } = transactionCategorizationView[selectedTransactionCategorizationTab];
|
|
34
|
+
const removeIdsFromPeriod = selectedTransactionCategorizationTab === 'review'
|
|
35
|
+
? [txnId]
|
|
36
|
+
: hasAutoLines
|
|
37
|
+
? []
|
|
38
|
+
: [txnId];
|
|
39
|
+
actions.push(updateStatusForTransactionNotMiscategorizedUpdateForCategorization(selectedTransactionCategorizationTab, [txnId], removeIdsFromPeriod, selectedPeriod, 'Completed'));
|
|
40
|
+
if (!hasAutoLines) {
|
|
41
|
+
actions.push(removeTransactionCategorization({
|
|
42
|
+
transactionIds: [txnId],
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
if (removeIdsFromPeriod.length > 0) {
|
|
46
|
+
const totalCountByPeriod = uiState.totalCount[toMonthYearPeriodId(selectedPeriod)];
|
|
47
|
+
const updatedTotalCount = totalCountByPeriod === 0
|
|
48
|
+
? totalCountByPeriod
|
|
49
|
+
: totalCountByPeriod - 1;
|
|
50
|
+
actions.push(updateTotalCountForTransactionCategorization({
|
|
51
|
+
selectedPeriod,
|
|
52
|
+
selectedTab: selectedTransactionCategorizationTab,
|
|
53
|
+
totalCount: updatedTotalCount,
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
102
57
|
actions.push(updateStatusConsolidatedSaveTransactionDetail({
|
|
103
58
|
transactionId: action.payload.transactionId,
|
|
104
59
|
fetchState: 'Completed',
|
|
@@ -111,6 +66,7 @@ export const markTransactionAsNotMiscategorizedEpic = (actions$, state$, zeniAPI
|
|
|
111
66
|
}));
|
|
112
67
|
}
|
|
113
68
|
else {
|
|
69
|
+
//Finally everything done for this transaction
|
|
114
70
|
actions.push(openSnackbar({
|
|
115
71
|
messageSection: 'transactionDetails_transactionUpdated',
|
|
116
72
|
messageText: 'success',
|
|
@@ -7,93 +7,11 @@ const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
|
|
|
7
7
|
const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
|
|
8
8
|
const tenantSelector_1 = require("../../../entity/tenant/tenantSelector");
|
|
9
9
|
const transactionReducer_1 = require("../../../entity/transaction/transactionReducer");
|
|
10
|
-
const transactionSelector_1 = require("../../../entity/transaction/transactionSelector");
|
|
11
10
|
const responsePayload_1 = require("../../../responsePayload");
|
|
12
11
|
const transactionsViewReducer_1 = require("../../expenseAutomationView/reducers/transactionsViewReducer");
|
|
13
12
|
const transactionDetailReducer_1 = require("../transactionDetailReducer");
|
|
14
13
|
const transactionDetailState_1 = require("../transactionDetailState");
|
|
15
14
|
const markTransactionAsNotMiscategorizedEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(transactionDetailReducer_1.markTransactionAsNotMiscategorized.match), (0, operators_1.mergeMap)((action) => {
|
|
16
|
-
if (action.payload.isExpenseAutomationEnabled === true) {
|
|
17
|
-
const transactionKey = (0, transactionDetailState_1.getTransactionDetailKey)(action.payload.transactionId);
|
|
18
|
-
const transaction = (0, transactionSelector_1.getSupportedTransactionById)(state$.value.transactionState, transactionKey);
|
|
19
|
-
const lineIds = (transaction?.lines ?? []).map((line) => line.id);
|
|
20
|
-
return zeniAPI
|
|
21
|
-
.putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/mark-as-reviewed`, {
|
|
22
|
-
transactions_reviewed: [
|
|
23
|
-
{
|
|
24
|
-
transaction_id: action.payload.transactionId.id,
|
|
25
|
-
line_ids: lineIds,
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
})
|
|
29
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
30
|
-
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
31
|
-
const actions = [];
|
|
32
|
-
actions.push((0, transactionDetailReducer_1.updateStatusForTransactionNotMiscategorizedUpdate)(action.payload.transactionId, 'Completed', undefined));
|
|
33
|
-
const txnId = action.payload.transactionId.id;
|
|
34
|
-
const reviewedFailed = response.data?.transactions_reviewed_failed ?? [];
|
|
35
|
-
const isTransactionFailed = reviewedFailed.some((t) => t.transaction_id === txnId);
|
|
36
|
-
if (!isTransactionFailed) {
|
|
37
|
-
actions.push((0, transactionReducer_1.updateTransactionIsMiscategorized)(transactionKey, false));
|
|
38
|
-
const { expenseAutomationViewState, expenseAutomationTransactionsViewState, } = state$.value;
|
|
39
|
-
const { transactionCategorizationView, selectedTransactionCategorizationTab, } = expenseAutomationTransactionsViewState;
|
|
40
|
-
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state$.value);
|
|
41
|
-
const { selectedPeriodByTenantId } = expenseAutomationViewState;
|
|
42
|
-
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
43
|
-
const autoTabLineItems = transactionCategorizationView.autoCategorized
|
|
44
|
-
.transactionReviewLocalDataById[txnId]
|
|
45
|
-
?.transactionReviewLocalData.tabSpecificLineItems
|
|
46
|
-
.autoCategorized ?? [];
|
|
47
|
-
const hasAutoLines = autoTabLineItems.length > 0;
|
|
48
|
-
const { uiState } = transactionCategorizationView[selectedTransactionCategorizationTab];
|
|
49
|
-
const removeIdsFromPeriod = selectedTransactionCategorizationTab === 'review'
|
|
50
|
-
? [txnId]
|
|
51
|
-
: hasAutoLines
|
|
52
|
-
? []
|
|
53
|
-
: [txnId];
|
|
54
|
-
actions.push((0, transactionsViewReducer_1.updateStatusForTransactionNotMiscategorizedUpdateForCategorization)(selectedTransactionCategorizationTab, [txnId], removeIdsFromPeriod, selectedPeriod, 'Completed'));
|
|
55
|
-
if (!hasAutoLines) {
|
|
56
|
-
actions.push((0, transactionReducer_1.removeTransactionCategorization)({
|
|
57
|
-
transactionIds: [txnId],
|
|
58
|
-
}));
|
|
59
|
-
}
|
|
60
|
-
if (removeIdsFromPeriod.length > 0) {
|
|
61
|
-
const totalCountByPeriod = uiState.totalCount[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)];
|
|
62
|
-
const updatedTotalCount = totalCountByPeriod === 0
|
|
63
|
-
? totalCountByPeriod
|
|
64
|
-
: totalCountByPeriod - 1;
|
|
65
|
-
actions.push((0, transactionsViewReducer_1.updateTotalCountForTransactionCategorization)({
|
|
66
|
-
selectedPeriod,
|
|
67
|
-
selectedTab: selectedTransactionCategorizationTab,
|
|
68
|
-
totalCount: updatedTotalCount,
|
|
69
|
-
}));
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
actions.push((0, transactionDetailReducer_1.updateStatusConsolidatedSaveTransactionDetail)({
|
|
73
|
-
transactionId: action.payload.transactionId,
|
|
74
|
-
fetchState: 'Completed',
|
|
75
|
-
}));
|
|
76
|
-
if (action.payload.transactionSaveUpdates.anyBulkUpdates === true) {
|
|
77
|
-
actions.push((0, snackbarReducer_1.openSnackbar)({
|
|
78
|
-
messageSection: 'transactionDetails_updatingPastTransactions',
|
|
79
|
-
messageText: 'success',
|
|
80
|
-
type: 'success',
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
actions.push((0, snackbarReducer_1.openSnackbar)({
|
|
85
|
-
messageSection: 'transactionDetails_transactionUpdated',
|
|
86
|
-
messageText: 'success',
|
|
87
|
-
type: 'success',
|
|
88
|
-
}));
|
|
89
|
-
}
|
|
90
|
-
return (0, rxjs_1.from)(actions);
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
return (0, rxjs_1.of)((0, transactionDetailReducer_1.updateStatusForTransactionNotMiscategorizedUpdate)(action.payload.transactionId, 'Error', response.status));
|
|
94
|
-
}
|
|
95
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, transactionDetailReducer_1.updateStatusForTransactionNotMiscategorizedUpdate)(action.payload.transactionId, 'Error', (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', `Transaction mark as reviewed REST API call errored out ${error}`)))));
|
|
96
|
-
}
|
|
97
15
|
return zeniAPI
|
|
98
16
|
.putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/${action.payload.transactionId.id}/mark-miscategorized-as-correct`, preparePayload(action.payload.transactionId))
|
|
99
17
|
.pipe((0, operators_1.mergeMap)((response) => {
|
|
@@ -101,7 +19,44 @@ const markTransactionAsNotMiscategorizedEpic = (actions$, state$, zeniAPI) => ac
|
|
|
101
19
|
const actions = [];
|
|
102
20
|
actions.push((0, transactionDetailReducer_1.updateStatusForTransactionNotMiscategorizedUpdate)(action.payload.transactionId, 'Completed', undefined));
|
|
103
21
|
const transactionKey = (0, transactionDetailState_1.getTransactionDetailKey)(action.payload.transactionId);
|
|
22
|
+
// Mark this transaction as not miscategorized anymore
|
|
104
23
|
actions.push((0, transactionReducer_1.updateTransactionIsMiscategorized)(transactionKey, false));
|
|
24
|
+
if (action.payload.isExpenseAutomationEnabled === true) {
|
|
25
|
+
const { expenseAutomationViewState, expenseAutomationTransactionsViewState, } = state$.value;
|
|
26
|
+
const { transactionCategorizationView, selectedTransactionCategorizationTab, } = expenseAutomationTransactionsViewState;
|
|
27
|
+
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state$.value);
|
|
28
|
+
const { selectedPeriodByTenantId } = expenseAutomationViewState;
|
|
29
|
+
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
30
|
+
const txnId = action.payload.transactionId.id;
|
|
31
|
+
const autoTabLineItems = transactionCategorizationView.autoCategorized
|
|
32
|
+
.transactionReviewLocalDataById[txnId]
|
|
33
|
+
?.transactionReviewLocalData.tabSpecificLineItems
|
|
34
|
+
.autoCategorized ?? [];
|
|
35
|
+
const hasAutoLines = autoTabLineItems.length > 0;
|
|
36
|
+
const { uiState } = transactionCategorizationView[selectedTransactionCategorizationTab];
|
|
37
|
+
const removeIdsFromPeriod = selectedTransactionCategorizationTab === 'review'
|
|
38
|
+
? [txnId]
|
|
39
|
+
: hasAutoLines
|
|
40
|
+
? []
|
|
41
|
+
: [txnId];
|
|
42
|
+
actions.push((0, transactionsViewReducer_1.updateStatusForTransactionNotMiscategorizedUpdateForCategorization)(selectedTransactionCategorizationTab, [txnId], removeIdsFromPeriod, selectedPeriod, 'Completed'));
|
|
43
|
+
if (!hasAutoLines) {
|
|
44
|
+
actions.push((0, transactionReducer_1.removeTransactionCategorization)({
|
|
45
|
+
transactionIds: [txnId],
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
if (removeIdsFromPeriod.length > 0) {
|
|
49
|
+
const totalCountByPeriod = uiState.totalCount[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)];
|
|
50
|
+
const updatedTotalCount = totalCountByPeriod === 0
|
|
51
|
+
? totalCountByPeriod
|
|
52
|
+
: totalCountByPeriod - 1;
|
|
53
|
+
actions.push((0, transactionsViewReducer_1.updateTotalCountForTransactionCategorization)({
|
|
54
|
+
selectedPeriod,
|
|
55
|
+
selectedTab: selectedTransactionCategorizationTab,
|
|
56
|
+
totalCount: updatedTotalCount,
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
105
60
|
actions.push((0, transactionDetailReducer_1.updateStatusConsolidatedSaveTransactionDetail)({
|
|
106
61
|
transactionId: action.payload.transactionId,
|
|
107
62
|
fetchState: 'Completed',
|
|
@@ -114,6 +69,7 @@ const markTransactionAsNotMiscategorizedEpic = (actions$, state$, zeniAPI) => ac
|
|
|
114
69
|
}));
|
|
115
70
|
}
|
|
116
71
|
else {
|
|
72
|
+
//Finally everything done for this transaction
|
|
117
73
|
actions.push((0, snackbarReducer_1.openSnackbar)({
|
|
118
74
|
messageSection: 'transactionDetails_transactionUpdated',
|
|
119
75
|
messageText: 'success',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.1.50
|
|
3
|
+
"version": "5.1.50",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|