@zeniai/client-epic-state 4.13.73 → 4.13.75
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/commonVendorView/transactionVendorView/epics/saveTransactionVendorEpic.js +1 -0
- package/lib/view/commonVendorView/transactionVendorView/transactionVendorViewReducer.d.ts +2 -1
- package/lib/view/commonVendorView/transactionVendorView/transactionVendorViewReducer.js +2 -1
- package/lib/view/expenseAutomationView/helpers/saveTransactionHelper.js +1 -1
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +26 -8
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +8 -2
- package/lib/view/transactionDetail/epics/saveTransactionDetailEpic.js +2 -1
- package/lib/view/transactionDetail/epics/saveTransactionHelper.d.ts +2 -2
- package/lib/view/transactionDetail/epics/saveTransactionHelper.js +6 -3
- package/lib/view/transactionDetail/transactionDetailReducer.d.ts +1 -0
- package/package.json +1 -1
|
@@ -61,6 +61,7 @@ const saveTransactionVendorEpic = (actions$, state$, zeniAPI) => actions$.pipe((
|
|
|
61
61
|
action.payload.transactionId != null) {
|
|
62
62
|
actions.push((0, transactionDetailReducer_1.saveTransactionDetail)({
|
|
63
63
|
transactionId: action.payload.transactionId,
|
|
64
|
+
isExpenseAutomationEnabled: action.payload.isExpenseAutomationEnabled,
|
|
64
65
|
}));
|
|
65
66
|
}
|
|
66
67
|
return (0, rxjs_1.from)(actions);
|
|
@@ -6,10 +6,11 @@ export declare const initialVendorDetailLocalData: TransactionVendorLocalData;
|
|
|
6
6
|
export declare const initialState: TransactionVendorViewState;
|
|
7
7
|
export declare const updateVendorSaveStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
8
8
|
vendorId?: string | undefined;
|
|
9
|
-
}, string>, saveTransactionVendor: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionId?: TransactionID | undefined, vendorId?: string | undefined, saveTransaction?: boolean | undefined], {
|
|
9
|
+
}, string>, saveTransactionVendor: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionId?: TransactionID | undefined, vendorId?: string | undefined, saveTransaction?: boolean | undefined, isExpenseAutomationEnabled?: any], {
|
|
10
10
|
vendorId: string | undefined;
|
|
11
11
|
transactionId: TransactionID | undefined;
|
|
12
12
|
saveTransaction: boolean | undefined;
|
|
13
|
+
isExpenseAutomationEnabled: any;
|
|
13
14
|
}, string, never, never>, saveTransactionVendorSuccessOrFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[fetchState: FetchState, vendorId?: string | undefined, error?: ZeniAPIStatus<Record<string, unknown>> | undefined], {
|
|
14
15
|
fetchState: FetchState;
|
|
15
16
|
vendorId: string | undefined;
|
|
@@ -45,12 +45,13 @@ const transactionVendorView = (0, toolkit_1.createSlice)({
|
|
|
45
45
|
draft.newVendorState.saveStatus.error = undefined;
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
|
-
prepare(transactionId, vendorId, saveTransaction) {
|
|
48
|
+
prepare(transactionId, vendorId, saveTransaction, isExpenseAutomationEnabled = false) {
|
|
49
49
|
return {
|
|
50
50
|
payload: {
|
|
51
51
|
vendorId,
|
|
52
52
|
transactionId,
|
|
53
53
|
saveTransaction,
|
|
54
|
+
isExpenseAutomationEnabled,
|
|
54
55
|
},
|
|
55
56
|
};
|
|
56
57
|
},
|
|
@@ -16,7 +16,7 @@ const toTransactionUpdatesFromTransactionCategorizationLocalData = (transactionC
|
|
|
16
16
|
};
|
|
17
17
|
const updatesByLineId = {};
|
|
18
18
|
const entityUpdates = {};
|
|
19
|
-
const isTransactionMisCategorized = (0, saveTransactionHelper_1.isTransactionMiscategorized)(transaction);
|
|
19
|
+
const isTransactionMisCategorized = (0, saveTransactionHelper_1.isTransactionMiscategorized)(transaction, true);
|
|
20
20
|
const isTransactionUnCategorized = (0, saveTransactionHelper_1.isTransactionUncategorized)(transaction, uncategorizedIncomeExpense);
|
|
21
21
|
updates.memo = transactionCategorizationLocalData.memo;
|
|
22
22
|
if ((0, vendorTransaction_1.isVendorTransaction)(transaction) === true) {
|
package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ export declare const INCOME_QBOID = "30";
|
|
|
10
10
|
export declare const EXPENSE_QBOID = "31";
|
|
11
11
|
export declare const toTransactionDetailLocalData: (transaction: SupportedTransaction) => TransactionReviewLocalData;
|
|
12
12
|
export declare const toSetAllLineItemsToCategoryClass: (draft: TransactionsTabViewState, transaction: SupportedTransaction, transactionId: ID, transactionLineId: ID, transactionDetailLocalData: TransactionReviewLocalData, vendorId?: string | undefined, selectedAccount?: AccountBase | undefined, selectedClassBase?: ClassBase | undefined) => TransactionReviewLocalData;
|
|
13
|
-
export declare const setEntityRecommendationForLineIdInLocalData: (transaction: SupportedTransaction, transactionDetailLocalData: TransactionReviewLocalData, entity: Entity, recommendationLineIds: ID[], recommendationByLineId?: RecommendationByLineId | undefined) => TransactionReviewLocalData;
|
|
13
|
+
export declare const setEntityRecommendationForLineIdInLocalData: (draft: TransactionsTabViewState, transaction: SupportedTransaction, transactionDetailLocalData: TransactionReviewLocalData, entity: Entity, recommendationLineIds: ID[], recommendationByLineId?: RecommendationByLineId | undefined) => TransactionReviewLocalData;
|
|
14
14
|
export declare const checkIfAllLineItemsAreCategoryClassFilled: (transaction: SupportedTransaction, transactionDetailLocalData: TransactionReviewLocalData) => boolean;
|
|
@@ -102,8 +102,12 @@ const toSetAllLineItemsToCategoryClass = (draft, transaction, transactionId, tra
|
|
|
102
102
|
// if the line is the one that is being updated, then set the account and class
|
|
103
103
|
if (transactionId === record.transactionId &&
|
|
104
104
|
transactionLineId === lineId) {
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
if (selectedAccount != null) {
|
|
106
|
+
record.account = selectedAccount;
|
|
107
|
+
}
|
|
108
|
+
if (selectedClassBase != null) {
|
|
109
|
+
record.class = selectedClassBase;
|
|
110
|
+
}
|
|
107
111
|
if (record.class != null && record.account != null) {
|
|
108
112
|
if (selectedCheckBoxTransactionIds.length < exports.MAX_SELECTION_LIMIT &&
|
|
109
113
|
selectedCheckBoxTransactionIds.includes(transaction.id) === false) {
|
|
@@ -122,9 +126,10 @@ const toSetAllLineItemsToCategoryClass = (draft, transaction, transactionId, tra
|
|
|
122
126
|
transactionDetailLocalData.vendor.id === vendorId) ||
|
|
123
127
|
(record.vendor != null && record.vendor.id === vendorId)) {
|
|
124
128
|
// if the vendor is same, then set the account and class with the selected ones and add the transaction to the selected list
|
|
125
|
-
if (
|
|
126
|
-
((
|
|
127
|
-
|
|
129
|
+
if (selectedAccount != null &&
|
|
130
|
+
(((_a = record.account) === null || _a === void 0 ? void 0 : _a.qboId) == null ||
|
|
131
|
+
((_b = record.account) === null || _b === void 0 ? void 0 : _b.qboId) === exports.EXPENSE_QBOID ||
|
|
132
|
+
((_c = record.account) === null || _c === void 0 ? void 0 : _c.qboId) === exports.INCOME_QBOID)) {
|
|
128
133
|
record.account = selectedAccount;
|
|
129
134
|
if (record.class != null &&
|
|
130
135
|
selectedCheckBoxTransactionIds.length < exports.MAX_SELECTION_LIMIT &&
|
|
@@ -133,7 +138,7 @@ const toSetAllLineItemsToCategoryClass = (draft, transaction, transactionId, tra
|
|
|
133
138
|
selectedCheckBoxTransactionIds.push(transaction.id);
|
|
134
139
|
}
|
|
135
140
|
}
|
|
136
|
-
if (((_d = record.class) === null || _d === void 0 ? void 0 : _d.qboId) == null) {
|
|
141
|
+
if (selectedClassBase != null && ((_d = record.class) === null || _d === void 0 ? void 0 : _d.qboId) == null) {
|
|
137
142
|
record.class = selectedClassBase;
|
|
138
143
|
if (record.account != null &&
|
|
139
144
|
selectedCheckBoxTransactionIds.length < exports.MAX_SELECTION_LIMIT &&
|
|
@@ -171,10 +176,11 @@ const toSetAllLineItemsToCategoryClass = (draft, transaction, transactionId, tra
|
|
|
171
176
|
return newLocalData;
|
|
172
177
|
};
|
|
173
178
|
exports.toSetAllLineItemsToCategoryClass = toSetAllLineItemsToCategoryClass;
|
|
174
|
-
const setEntityRecommendationForLineIdInLocalData = (transaction, transactionDetailLocalData, entity, recommendationLineIds, recommendationByLineId) => {
|
|
179
|
+
const setEntityRecommendationForLineIdInLocalData = (draft, transaction, transactionDetailLocalData, entity, recommendationLineIds, recommendationByLineId) => {
|
|
175
180
|
const newLineItems = {};
|
|
176
181
|
let matchingEntityLineId = undefined;
|
|
177
182
|
const checkIfNotJEAndDeposit = !(0, vendorTransaction_1.isVendorTransaction)(transaction);
|
|
183
|
+
let selectedCheckBoxTransactionIds = draft.selectedCheckBoxTransactionIds;
|
|
178
184
|
if (transaction.lines != null) {
|
|
179
185
|
// always preserving the order of the line items. hence iterating over this
|
|
180
186
|
transaction.lines.forEach((line) => {
|
|
@@ -207,7 +213,15 @@ const setEntityRecommendationForLineIdInLocalData = (transaction, transactionDet
|
|
|
207
213
|
if ((0, transactionDetailLocalDataHelper_1.isEntityMatching)(entity, oldRecord)) {
|
|
208
214
|
matchingEntityLineId = lineId;
|
|
209
215
|
}
|
|
210
|
-
|
|
216
|
+
const record = Object.assign({}, oldRecord);
|
|
217
|
+
if (checkIfNotJEAndDeposit === false) {
|
|
218
|
+
const recommendations = (0, transactionDetailLocalDataHelper_1.mergeTransactionAndEntityRecommendations)(oldRecord.recommendations, recommendationByLineId === null || recommendationByLineId === void 0 ? void 0 : recommendationByLineId[lineId]);
|
|
219
|
+
const accountLine = line;
|
|
220
|
+
record.account = accountLine.account;
|
|
221
|
+
record.class = accountLine.class;
|
|
222
|
+
record.recommendations = recommendations;
|
|
223
|
+
}
|
|
224
|
+
newLineItems[lineId] = record;
|
|
211
225
|
}
|
|
212
226
|
});
|
|
213
227
|
}
|
|
@@ -219,6 +233,10 @@ const setEntityRecommendationForLineIdInLocalData = (transaction, transactionDet
|
|
|
219
233
|
newLineItems[matchingEntityLineId] = Object.assign(Object.assign({}, newLineItem), { class: matchingRecord.class, account: matchingRecord.account, lineEntity: matchingRecord.lineEntity });
|
|
220
234
|
}
|
|
221
235
|
const newLocalData = Object.assign(Object.assign({}, transactionsViewState_1.initialSupportedTransactionCategorization.transactionReviewLocalData), { memo: transactionDetailLocalData.memo, lineItemById: newLineItems, transactionDate: transactionDetailLocalData.transactionDate, transactionType: transactionDetailLocalData.transactionType, transactionTypeName: transactionDetailLocalData.transactionTypeName, vendorUpdates: transactionDetailLocalData.vendorUpdates, vendorDetails: transactionDetailLocalData.vendorDetails, vendor: transactionDetailLocalData.vendor });
|
|
236
|
+
if (!(0, exports.checkIfAllLineItemsAreCategoryClassFilled)(transaction, newLocalData)) {
|
|
237
|
+
selectedCheckBoxTransactionIds = selectedCheckBoxTransactionIds.filter((id) => id !== transaction.id);
|
|
238
|
+
}
|
|
239
|
+
draft.selectedCheckBoxTransactionIds = selectedCheckBoxTransactionIds;
|
|
222
240
|
return newLocalData;
|
|
223
241
|
};
|
|
224
242
|
exports.setEntityRecommendationForLineIdInLocalData = setEntityRecommendationForLineIdInLocalData;
|
|
@@ -219,7 +219,13 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
219
219
|
const { vendorId, selectedAccount, selectedClassBase, transactions, transactionId, lineId, selectedTab, } = action.payload;
|
|
220
220
|
const transactionLocalData = (0, get_1.default)(draft[selectedTab].transactionReviewLocalDataById, transactionId, undefined);
|
|
221
221
|
if (transactionLocalData != null) {
|
|
222
|
-
const newTransactionLocalData = Object.assign(Object.assign({}, transactionLocalData.transactionReviewLocalData), { lineItemById: Object.assign(Object.assign({}, transactionLocalData.transactionReviewLocalData.lineItemById), { [lineId]: Object.assign(Object.assign({}, transactionLocalData.transactionReviewLocalData.lineItemById[lineId]), { account: selectedAccount
|
|
222
|
+
const newTransactionLocalData = Object.assign(Object.assign({}, transactionLocalData.transactionReviewLocalData), { lineItemById: Object.assign(Object.assign({}, transactionLocalData.transactionReviewLocalData.lineItemById), { [lineId]: Object.assign(Object.assign({}, transactionLocalData.transactionReviewLocalData.lineItemById[lineId]), { account: selectedAccount != null
|
|
223
|
+
? selectedAccount
|
|
224
|
+
: transactionLocalData.transactionReviewLocalData
|
|
225
|
+
.lineItemById[lineId].account, class: selectedClassBase != null
|
|
226
|
+
? selectedClassBase
|
|
227
|
+
: transactionLocalData.transactionReviewLocalData
|
|
228
|
+
.lineItemById[lineId].class }) }) });
|
|
223
229
|
draft[selectedTab].transactionReviewLocalDataById[transactionId] = {
|
|
224
230
|
transactionReviewLocalData: newTransactionLocalData,
|
|
225
231
|
transactionId,
|
|
@@ -284,7 +290,7 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
284
290
|
if (transactionLocalData != null) {
|
|
285
291
|
draft[selectedTab].transactionReviewLocalDataById[transaction.id] = {
|
|
286
292
|
transactionId: transaction.id,
|
|
287
|
-
transactionReviewLocalData: (0, transactionCategorizationLocalDataHelper_1.setEntityRecommendationForLineIdInLocalData)(transaction, transactionLocalData.transactionReviewLocalData, entity, lineIds, action.payload.recommendationByLineId),
|
|
293
|
+
transactionReviewLocalData: (0, transactionCategorizationLocalDataHelper_1.setEntityRecommendationForLineIdInLocalData)(draft[selectedTab], transaction, transactionLocalData.transactionReviewLocalData, entity, lineIds, action.payload.recommendationByLineId),
|
|
288
294
|
};
|
|
289
295
|
}
|
|
290
296
|
},
|
|
@@ -14,6 +14,7 @@ const accountListSelector_1 = require("../../accountList/accountListSelector");
|
|
|
14
14
|
const transactionSelector_1 = require("../../../entity/transaction/transactionSelector");
|
|
15
15
|
const saveTransactionDetailEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(transactionDetailReducer_1.saveTransactionDetail.match), (0, operators_1.mergeMap)((action) => {
|
|
16
16
|
const transactionId = action.payload.transactionId;
|
|
17
|
+
const isExpenseAutomationEnabled = action.payload.isExpenseAutomationEnabled;
|
|
17
18
|
const fetchActions = [];
|
|
18
19
|
const transactionDetailState = state$.value.transactionDetailState;
|
|
19
20
|
const transactionState = state$.value.transactionState;
|
|
@@ -23,7 +24,7 @@ const saveTransactionDetailEpic = (actions$, state$) => actions$.pipe((0, operat
|
|
|
23
24
|
if (detail != null && transaction != null) {
|
|
24
25
|
const uncategorizedIncomeExpense = (0, accountListSelector_1.getUncategorizedAccounts)(state$.value.accountState, state$.value.accountListState, 'accountList');
|
|
25
26
|
const localData = detail.transactionDetailLocalData;
|
|
26
|
-
const transactionSaveUpdates = (0, saveTransactionHelper_1.toTransactionUpdatesFromTransactionDetailLocalData)(localData, transaction, uncategorizedIncomeExpense);
|
|
27
|
+
const transactionSaveUpdates = (0, saveTransactionHelper_1.toTransactionUpdatesFromTransactionDetailLocalData)(localData, transaction, uncategorizedIncomeExpense, isExpenseAutomationEnabled);
|
|
27
28
|
fetchActions.push((0, transactionDetailReducer_1.updateTransactionDetail)(transactionId, transactionSaveUpdates));
|
|
28
29
|
return (0, rxjs_1.from)(fetchActions);
|
|
29
30
|
}
|
|
@@ -21,9 +21,9 @@ import { TransactionDetailLocalData } from '../transactionDetailTypes';
|
|
|
21
21
|
* 4. Only difference between this and Miscategorized will be that we will
|
|
22
22
|
* additionally fire “Mark as not miscat” for every point above.
|
|
23
23
|
*/
|
|
24
|
-
export declare const toTransactionUpdatesFromTransactionDetailLocalData: (transactionDetailLocalData: TransactionDetailLocalData, transaction: SupportedTransaction, uncategorizedIncomeExpense: UncategorizedAccounts) => TransactionSaveUpdates;
|
|
24
|
+
export declare const toTransactionUpdatesFromTransactionDetailLocalData: (transactionDetailLocalData: TransactionDetailLocalData, transaction: SupportedTransaction, uncategorizedIncomeExpense: UncategorizedAccounts, isExpenseAutomationEnabled: boolean) => TransactionSaveUpdates;
|
|
25
25
|
export declare const toRecommendedAccountBase: (amountValue: number, accountBase?: AccountBase | undefined, recommendationBase?: RecommendationBase | undefined) => RecommendedAccountBase | undefined;
|
|
26
26
|
export declare const toRecommendedClassBase: (amountValue: number, classBase?: ClassBase | undefined, recommendationBase?: RecommendationBase | undefined) => RecommendedClassBase | undefined;
|
|
27
|
-
export declare const isTransactionMiscategorized: (transaction: SupportedTransaction) => boolean;
|
|
27
|
+
export declare const isTransactionMiscategorized: (transaction: SupportedTransaction, isExpenseAutomationEnabled: boolean) => boolean;
|
|
28
28
|
export declare const isTransactionUncategorized: (transaction: SupportedTransaction, uncategorizedIncomeExpense: UncategorizedAccounts) => boolean;
|
|
29
29
|
export declare const isAccountUncategorized: (uncategorizedIncomeExpense: UncategorizedAccounts, lineQboId?: string | undefined) => boolean;
|
|
@@ -24,14 +24,14 @@ const recommendationState_1 = require("../../recommendation/recommendationState"
|
|
|
24
24
|
* 4. Only difference between this and Miscategorized will be that we will
|
|
25
25
|
* additionally fire “Mark as not miscat” for every point above.
|
|
26
26
|
*/
|
|
27
|
-
const toTransactionUpdatesFromTransactionDetailLocalData = (transactionDetailLocalData, transaction, uncategorizedIncomeExpense) => {
|
|
27
|
+
const toTransactionUpdatesFromTransactionDetailLocalData = (transactionDetailLocalData, transaction, uncategorizedIncomeExpense, isExpenseAutomationEnabled) => {
|
|
28
28
|
var _a, _b, _c;
|
|
29
29
|
const updates = {
|
|
30
30
|
updatesByLineId: {},
|
|
31
31
|
};
|
|
32
32
|
const updatesByLineId = {};
|
|
33
33
|
const entityUpdates = {};
|
|
34
|
-
const isTransactionMisCategorized = (0, exports.isTransactionMiscategorized)(transaction);
|
|
34
|
+
const isTransactionMisCategorized = (0, exports.isTransactionMiscategorized)(transaction, isExpenseAutomationEnabled);
|
|
35
35
|
const isTransactionUnCategorized = (0, exports.isTransactionUncategorized)(transaction, uncategorizedIncomeExpense);
|
|
36
36
|
updates.memo = transactionDetailLocalData.memo;
|
|
37
37
|
const updatedEntityId = transactionDetailLocalData.updatePreviousTransactionsWithUpdatedVendor ===
|
|
@@ -252,8 +252,11 @@ const getEntityDetails = (entity, lineItemLocalData, vendorUpdates) => {
|
|
|
252
252
|
}
|
|
253
253
|
return undefined;
|
|
254
254
|
};
|
|
255
|
-
const isTransactionMiscategorized = (transaction) => {
|
|
255
|
+
const isTransactionMiscategorized = (transaction, isExpenseAutomationEnabled) => {
|
|
256
256
|
const lines = transaction.lines;
|
|
257
|
+
if (isExpenseAutomationEnabled === true && (0, vendorTransaction_1.isVendorTransaction)(transaction)) {
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
257
260
|
let isTransactionMisCategorized = false;
|
|
258
261
|
lines === null || lines === void 0 ? void 0 : lines.forEach((line) => {
|
|
259
262
|
if (line.type === 'transaction_with_account_and_class_line' ||
|
|
@@ -44,6 +44,7 @@ export declare const fetchTransactionDetail: import("@reduxjs/toolkit").ActionCr
|
|
|
44
44
|
transactionId: TransactionID;
|
|
45
45
|
}, string>, saveTransactionDetail: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
46
46
|
transactionId: TransactionID;
|
|
47
|
+
isExpenseAutomationEnabled: boolean;
|
|
47
48
|
}, string>, initializeTransactionDetailLocalData: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
48
49
|
transactionId: TransactionID;
|
|
49
50
|
vendorId?: string | undefined;
|
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.75",
|
|
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",
|