@zeniai/client-epic-state 4.13.38 → 4.13.40
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/view/expenseAutomationView/epics/transactionCategorization/markTransactionAsNotMiscatgorizedEpic.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/transactionCategorization/markTransactionAsNotMiscatgorizedEpic.js +14 -1
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +14 -3
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +9 -5
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
2
|
import { RootState } from '../../../../reducer';
|
|
3
3
|
import { ZeniAPI } from '../../../../zeniAPI';
|
|
4
|
-
import { updateStatusForTransactionNotMiscategorizedUpdate, markTransactionAsNotMiscategorized } from '../../reducers/transactionsViewReducer';
|
|
4
|
+
import { updateStatusForTransactionNotMiscategorizedUpdate, markTransactionAsNotMiscategorized, updateTotalCountForTransactionCategorization } from '../../reducers/transactionsViewReducer';
|
|
5
5
|
import { removeTransactionCategorization } from '../../../../entity/transaction/transactionReducer';
|
|
6
6
|
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
7
|
-
export declare type ActionType = ReturnType<typeof removeTransactionCategorization> | ReturnType<typeof openSnackbar> | ReturnType<typeof markTransactionAsNotMiscategorized> | ReturnType<typeof updateStatusForTransactionNotMiscategorizedUpdate>;
|
|
7
|
+
export declare type ActionType = ReturnType<typeof removeTransactionCategorization> | ReturnType<typeof openSnackbar> | ReturnType<typeof markTransactionAsNotMiscategorized> | ReturnType<typeof updateStatusForTransactionNotMiscategorizedUpdate> | ReturnType<typeof updateTotalCountForTransactionCategorization>;
|
|
8
8
|
export declare const markTransactionAsNotMiscategorizedEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<ActionType>;
|
|
@@ -9,22 +9,35 @@ const transactionsViewReducer_1 = require("../../reducers/transactionsViewReduce
|
|
|
9
9
|
const transactionReducer_1 = require("../../../../entity/transaction/transactionReducer");
|
|
10
10
|
const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
|
|
11
11
|
const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
|
|
12
|
+
const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
|
|
12
13
|
const TRANSACTION_COUNT_VARIABLE_NAME = '_transactions_count_';
|
|
13
14
|
const markTransactionAsNotMiscategorizedEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(transactionsViewReducer_1.markTransactionAsNotMiscategorized.match), (0, operators_2.mergeMap)((action) => {
|
|
15
|
+
const { expenseAutomationViewState, expenseAutomationTransactionsViewState, } = state$.value;
|
|
14
16
|
const transactionsInReview = action.payload.transactionsInReview;
|
|
15
17
|
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state$.value);
|
|
16
|
-
const selectedPeriod =
|
|
18
|
+
const selectedPeriod = expenseAutomationViewState.selectedPeriodByTenantId[currentTenant.tenantId];
|
|
19
|
+
const { selectedTab } = action.payload;
|
|
20
|
+
const { uiState } = expenseAutomationTransactionsViewState[selectedTab];
|
|
17
21
|
if (transactionsInReview.length > 0) {
|
|
18
22
|
return zeniAPI
|
|
19
23
|
.putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/mark-as-reviewed`, { transactions_reviewed: transactionsInReview })
|
|
20
24
|
.pipe((0, operators_2.mergeMap)((response) => {
|
|
21
25
|
if ((0, responsePayload_1.isSuccessStatus)(response)) {
|
|
22
26
|
const transactionIds = transactionsInReview.map((transaction) => transaction.transaction_id);
|
|
27
|
+
const totalCountByPeriod = uiState.totalCount[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)];
|
|
28
|
+
const updatedTotalCount = transactionIds.length === 0
|
|
29
|
+
? totalCountByPeriod
|
|
30
|
+
: totalCountByPeriod - transactionIds.length;
|
|
23
31
|
const actions = [];
|
|
24
32
|
actions.push((0, transactionsViewReducer_1.updateStatusForTransactionNotMiscategorizedUpdate)(action.payload.selectedTab, transactionIds, selectedPeriod, 'Completed'));
|
|
25
33
|
actions.push((0, transactionReducer_1.removeTransactionCategorization)({
|
|
26
34
|
transactionIds: transactionIds,
|
|
27
35
|
}));
|
|
36
|
+
actions.push((0, transactionsViewReducer_1.updateTotalCountForTransactionCategorization)({
|
|
37
|
+
selectedPeriod,
|
|
38
|
+
selectedTab,
|
|
39
|
+
totalCount: updatedTotalCount,
|
|
40
|
+
}));
|
|
28
41
|
actions.push((0, snackbarReducer_1.openSnackbar)({
|
|
29
42
|
messageSection: 'transactions_reviewed',
|
|
30
43
|
messageText: 'success',
|
package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts
CHANGED
|
@@ -8,4 +8,4 @@ export declare const INCOME_QBOID = "30";
|
|
|
8
8
|
export declare const EXPENSE_QBOID = "31";
|
|
9
9
|
export declare const toTransactionDetailLocalData: (transaction: SupportedTransaction) => TransactionReviewLocalData;
|
|
10
10
|
export declare const toSetAllLineItemsToCategoryClass: (draft: TransactionsTabViewState, transaction: SupportedTransaction, transactionId: ID, transactionLineId: ID, transactionDetailLocalData: TransactionReviewLocalData, vendorId?: string | undefined, selectedAccount?: AccountBase | undefined, selectedClassBase?: ClassBase | undefined) => TransactionReviewLocalData;
|
|
11
|
-
export declare const checkIfAllLineItemsAreCategoryClassFilled: (transactionDetailLocalData: TransactionReviewLocalData) => boolean;
|
|
11
|
+
export declare const checkIfAllLineItemsAreCategoryClassFilled: (transaction: SupportedTransaction, transactionDetailLocalData: TransactionReviewLocalData) => boolean;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.checkIfAllLineItemsAreCategoryClassFilled = exports.toSetAllLineItemsToCategoryClass = exports.toTransactionDetailLocalData = exports.EXPENSE_QBOID = exports.INCOME_QBOID = exports.MAX_SELECTION_LIMIT = void 0;
|
|
4
4
|
const transactionDetailLocalDataHelper_1 = require("../../transactionDetail/transactionDetailLocalDataHelper");
|
|
5
5
|
const transactionsViewState_1 = require("../types/transactionsViewState");
|
|
6
|
+
const vendorTransaction_1 = require("../../../entity/transaction/stateTypes/vendorTransaction");
|
|
6
7
|
exports.MAX_SELECTION_LIMIT = 5;
|
|
7
8
|
exports.INCOME_QBOID = '30';
|
|
8
9
|
exports.EXPENSE_QBOID = '31';
|
|
@@ -165,7 +166,7 @@ const toSetAllLineItemsToCategoryClass = (draft, transaction, transactionId, tra
|
|
|
165
166
|
const newLocalData = Object.assign(Object.assign({}, transactionsViewState_1.initialSupportedTransactionCategorization.transactionReviewLocalData), { memo: transactionDetailLocalData.memo, lineItemById: newLineItems, transactionDate: transactionDetailLocalData.transactionDate, transactionType: transactionDetailLocalData.transactionType, transactionTypeName: transactionDetailLocalData.transactionTypeName, vendor: transactionDetailLocalData.vendor, vendorUpdates: transactionDetailLocalData.vendorUpdates, vendorDetails: transactionDetailLocalData.vendorDetails });
|
|
166
167
|
if (transactionDetailLocalData.vendor != null &&
|
|
167
168
|
transactionDetailLocalData.vendor.id === vendorId) {
|
|
168
|
-
if (!(0, exports.checkIfAllLineItemsAreCategoryClassFilled)(newLocalData)) {
|
|
169
|
+
if (!(0, exports.checkIfAllLineItemsAreCategoryClassFilled)(transaction, newLocalData)) {
|
|
169
170
|
selectedCheckBoxTransactionIds = selectedCheckBoxTransactionIds.filter((id) => id !== transaction.id);
|
|
170
171
|
}
|
|
171
172
|
draft.selectedCheckBoxTransactionIds = selectedCheckBoxTransactionIds;
|
|
@@ -173,8 +174,18 @@ const toSetAllLineItemsToCategoryClass = (draft, transaction, transactionId, tra
|
|
|
173
174
|
return newLocalData;
|
|
174
175
|
};
|
|
175
176
|
exports.toSetAllLineItemsToCategoryClass = toSetAllLineItemsToCategoryClass;
|
|
176
|
-
const checkIfAllLineItemsAreCategoryClassFilled = (transactionDetailLocalData) => {
|
|
177
|
+
const checkIfAllLineItemsAreCategoryClassFilled = (transaction, transactionDetailLocalData) => {
|
|
177
178
|
const lineItems = Object.values(transactionDetailLocalData.lineItemById);
|
|
178
|
-
|
|
179
|
+
const isVendorTransactionAvailable = (0, vendorTransaction_1.isVendorTransaction)(transaction);
|
|
180
|
+
return lineItems.every((lineItem) => {
|
|
181
|
+
var _a, _b, _c;
|
|
182
|
+
return lineItem.account != null &&
|
|
183
|
+
lineItem.class != null &&
|
|
184
|
+
!(((_a = lineItem.account) === null || _a === void 0 ? void 0 : _a.qboId) != null &&
|
|
185
|
+
[exports.EXPENSE_QBOID, exports.INCOME_QBOID].includes(lineItem.account.qboId)) &&
|
|
186
|
+
(isVendorTransactionAvailable
|
|
187
|
+
? ((_b = transactionDetailLocalData.vendor) === null || _b === void 0 ? void 0 : _b.id) != null
|
|
188
|
+
: ((_c = lineItem.vendor) === null || _c === void 0 ? void 0 : _c.id) != null);
|
|
189
|
+
});
|
|
179
190
|
};
|
|
180
191
|
exports.checkIfAllLineItemsAreCategoryClassFilled = checkIfAllLineItemsAreCategoryClassFilled;
|
|
@@ -94,7 +94,9 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
94
94
|
scrollLeft: undefined,
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
if (action.payload.keepExistingListItems === false) {
|
|
98
|
+
draft[selectedTab].selectedCheckBoxTransactionIds = [];
|
|
99
|
+
}
|
|
98
100
|
draft[selectedTab].uiState.pageToken = (_a = action.payload.pageToken) !== null && _a !== void 0 ? _a : null;
|
|
99
101
|
draft[selectedTab].uiState.searchString =
|
|
100
102
|
(_b = action.payload.searchString) !== null && _b !== void 0 ? _b : '';
|
|
@@ -137,6 +139,7 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
137
139
|
const { keepExistingListItems, transactionIds, transactionLocalData, selectedPeriod, selectedTab, pageToken, totalCount, } = action.payload;
|
|
138
140
|
if (keepExistingListItems === false) {
|
|
139
141
|
draft[selectedTab].transactionIdsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)] = transactionIds;
|
|
142
|
+
draft[selectedTab].selectedCheckBoxTransactionIds = [];
|
|
140
143
|
}
|
|
141
144
|
else {
|
|
142
145
|
const previousData = draft[selectedTab].transactionIdsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)];
|
|
@@ -148,7 +151,6 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
148
151
|
}
|
|
149
152
|
}
|
|
150
153
|
draft[selectedTab].transactionReviewLocalDataById = Object.assign(Object.assign({}, draft[selectedTab].transactionReviewLocalDataById), transactionLocalData);
|
|
151
|
-
draft[selectedTab].selectedCheckBoxTransactionIds = [];
|
|
152
154
|
if (action.payload.refreshViewInBackground === true) {
|
|
153
155
|
draft[selectedTab].refreshStatus = {
|
|
154
156
|
fetchState: 'Completed',
|
|
@@ -311,8 +313,7 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
311
313
|
const selectedCheckBoxTransactionIds = draft[selectedTab].selectedCheckBoxTransactionIds;
|
|
312
314
|
if (newTransactionLocalData.vendor != null &&
|
|
313
315
|
newTransactionLocalData.vendor.id != null &&
|
|
314
|
-
(0, transactionCategorizationLocalDataHelper_1.checkIfAllLineItemsAreCategoryClassFilled)(newTransactionLocalData) ===
|
|
315
|
-
true && // check if all line items are filled
|
|
316
|
+
(0, transactionCategorizationLocalDataHelper_1.checkIfAllLineItemsAreCategoryClassFilled)(selectedTransaction, newTransactionLocalData) === true && // check if all line items are filled
|
|
316
317
|
selectedCheckBoxTransactionIds.length < transactionCategorizationLocalDataHelper_1.MAX_SELECTION_LIMIT &&
|
|
317
318
|
selectedCheckBoxTransactionIds.includes(transactionId) === false) {
|
|
318
319
|
draft[selectedTab].selectedCheckBoxTransactionIds = [
|
|
@@ -361,7 +362,10 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
361
362
|
reducer(draft, action) {
|
|
362
363
|
const { selectedTab, selectedPeriod, transactionIds } = action.payload;
|
|
363
364
|
if (action.payload.fetchState === 'Completed') {
|
|
364
|
-
draft[selectedTab].selectedCheckBoxTransactionIds
|
|
365
|
+
const selectedCheckBoxTransactionIds = draft[selectedTab].selectedCheckBoxTransactionIds.filter((id) => !transactionIds.includes(id));
|
|
366
|
+
draft[selectedTab].selectedCheckBoxTransactionIds = [
|
|
367
|
+
...selectedCheckBoxTransactionIds,
|
|
368
|
+
];
|
|
365
369
|
const transactionIdsBySelectedPeriod = draft[selectedTab].transactionIdsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)];
|
|
366
370
|
if (transactionIdsBySelectedPeriod != null) {
|
|
367
371
|
draft[selectedTab].transactionIdsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)] = transactionIdsBySelectedPeriod.filter((id) => !transactionIds.includes(id));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.40",
|
|
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
|
"types": "lib/index.d.ts",
|