@zeniai/client-epic-state 4.15.35 → 4.15.36
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/commonPayloadTypes/recommendationPayload.d.ts +1 -0
- package/lib/entity/transaction/payloadTypes/transactionPayload.js +2 -3
- package/lib/index.d.ts +6 -6
- package/lib/index.js +30 -26
- package/lib/view/expenseAutomationView/epics/transactionCategorization/updateTransactionCategorizationEpic.js +18 -7
- package/lib/view/expenseAutomationView/helpers/saveTransactionHelper.js +59 -34
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +38 -8
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +11 -1
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +61 -3
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +2 -0
- package/lib/view/transactionDetail/epics/saveTransactionHelper.js +35 -14
- package/lib/view/transactionDetail/epics/updateTransactionDetailEpic.js +7 -2
- package/lib/view/transactionDetail/transactionDetailLocalDataHelper.js +57 -18
- package/lib/view/transactionDetail/transactionDetailReducer.d.ts +11 -2
- package/lib/view/transactionDetail/transactionDetailReducer.js +51 -21
- package/lib/view/transactionDetail/transactionDetailTypes.d.ts +2 -0
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ const saveTransactionHelper_1 = require("../../transactionDetail/epics/saveTrans
|
|
|
11
11
|
* @param transactionCategorizationLocalData
|
|
12
12
|
*/
|
|
13
13
|
const toTransactionUpdatesFromTransactionCategorizationLocalData = (transactionCategorizationLocalData, transaction, uncategorizedIncomeExpense) => {
|
|
14
|
-
var _a
|
|
14
|
+
var _a;
|
|
15
15
|
const updates = {
|
|
16
16
|
updatesByLineId: {},
|
|
17
17
|
};
|
|
@@ -20,21 +20,27 @@ const toTransactionUpdatesFromTransactionCategorizationLocalData = (transactionC
|
|
|
20
20
|
const isTransactionMisCategorized = (0, saveTransactionHelper_1.isTransactionMiscategorized)(transaction, true);
|
|
21
21
|
const isTransactionUnCategorized = (0, saveTransactionHelper_1.isTransactionUncategorized)(transaction, uncategorizedIncomeExpense);
|
|
22
22
|
updates.memo = transactionCategorizationLocalData.memo;
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const currentSelectedEntity = transactionCategorizationLocalData.selectedEntity;
|
|
24
|
+
if ((0, vendorTransaction_1.isVendorTransaction)(transaction) === true &&
|
|
25
|
+
currentSelectedEntity != null &&
|
|
26
|
+
currentSelectedEntity.type === 'vendor') {
|
|
27
|
+
updates.vendorId = currentSelectedEntity.id;
|
|
25
28
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
if ((0, vendorTransaction_1.isVendorTransactionWithCustomer)(transaction) === true &&
|
|
30
|
+
currentSelectedEntity != null &&
|
|
31
|
+
currentSelectedEntity.type === 'customer') {
|
|
32
|
+
updates.customerId = currentSelectedEntity.id;
|
|
29
33
|
}
|
|
30
|
-
const entity = getEntityFromTransaction(transaction);
|
|
34
|
+
const entity = getEntityFromTransaction(transaction, currentSelectedEntity);
|
|
31
35
|
let lastUpdatedCategory;
|
|
32
36
|
let lastUpdatedClass;
|
|
33
37
|
// single recommendation to just pick the last recommendation in the list of lines
|
|
34
|
-
(
|
|
38
|
+
(_a = transaction.lines) === null || _a === void 0 ? void 0 : _a.forEach((line) => {
|
|
35
39
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
36
40
|
const updatedEntityId = (_b = (_a = transactionCategorizationLocalData.vendorUpdates) === null || _a === void 0 ? void 0 : _a.qboId) !== null && _b !== void 0 ? _b : (_c = transactionCategorizationLocalData.customerUpdates) === null || _c === void 0 ? void 0 : _c.qboId;
|
|
37
|
-
const
|
|
41
|
+
const currentSelectedEntityLine = transactionCategorizationLocalData.lineItemById[line.id]
|
|
42
|
+
.selectedEntityLine;
|
|
43
|
+
const entityDetails = getEntityDetails(entity, transactionCategorizationLocalData.lineItemById[line.id], transactionCategorizationLocalData.vendorUpdates, transactionCategorizationLocalData.customerUpdates, currentSelectedEntityLine);
|
|
38
44
|
if (line.type === 'transaction_with_account_and_class_line' ||
|
|
39
45
|
line.type === 'transaction_with_product_or_service_line' ||
|
|
40
46
|
line.type === 'journal_entry_transaction_line') {
|
|
@@ -47,7 +53,13 @@ const toTransactionUpdatesFromTransactionCategorizationLocalData = (transactionC
|
|
|
47
53
|
};
|
|
48
54
|
if (line.type === 'journal_entry_transaction_line' ||
|
|
49
55
|
line.platformLineDetailType === 'deposit_line_detail') {
|
|
50
|
-
updatesByLineId[line.id] = Object.assign(Object.assign({}, updatesByLineId[line.id]), { vendor:
|
|
56
|
+
updatesByLineId[line.id] = Object.assign(Object.assign({}, updatesByLineId[line.id]), { vendor: currentSelectedEntityLine != null &&
|
|
57
|
+
currentSelectedEntityLine.type === 'vendor'
|
|
58
|
+
? lineItem.vendor
|
|
59
|
+
: undefined, customer: currentSelectedEntityLine != null &&
|
|
60
|
+
currentSelectedEntityLine.type === 'customer'
|
|
61
|
+
? lineItem.customer
|
|
62
|
+
: undefined });
|
|
51
63
|
}
|
|
52
64
|
let hasCategoryChanged = false;
|
|
53
65
|
let hasClassChanged = false;
|
|
@@ -136,7 +148,7 @@ const doUpdateEntityUpdates = (entityUpdates, entityId, entityType, recommendati
|
|
|
136
148
|
entityUpdates[entityKey] = Object.assign(Object.assign({}, entityUpdate), { recommendations: recommendation });
|
|
137
149
|
}
|
|
138
150
|
};
|
|
139
|
-
const getEntityDetails = (entity, lineItemLocalData, vendorUpdates, customerUpdates) => {
|
|
151
|
+
const getEntityDetails = (entity, lineItemLocalData, vendorUpdates, customerUpdates, currentSelectedEntityLine) => {
|
|
140
152
|
var _a, _b, _c, _d;
|
|
141
153
|
if (entity != null) {
|
|
142
154
|
return {
|
|
@@ -150,25 +162,35 @@ const getEntityDetails = (entity, lineItemLocalData, vendorUpdates, customerUpda
|
|
|
150
162
|
entityType: lineItemLocalData.vendor != null ? 'vendor' : 'customer',
|
|
151
163
|
};
|
|
152
164
|
}
|
|
153
|
-
if (
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
165
|
+
if (currentSelectedEntityLine != null &&
|
|
166
|
+
currentSelectedEntityLine.type === 'vendor') {
|
|
167
|
+
if (vendorUpdates != null && vendorUpdates.id != null) {
|
|
168
|
+
return {
|
|
169
|
+
entityId: vendorUpdates.id,
|
|
170
|
+
entityType: 'vendor',
|
|
171
|
+
};
|
|
172
|
+
}
|
|
158
173
|
}
|
|
159
|
-
if (
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
174
|
+
if (currentSelectedEntityLine != null &&
|
|
175
|
+
currentSelectedEntityLine.type === 'customer') {
|
|
176
|
+
if (customerUpdates != null && customerUpdates.id != null) {
|
|
177
|
+
return {
|
|
178
|
+
entityId: customerUpdates.id,
|
|
179
|
+
entityType: 'customer',
|
|
180
|
+
};
|
|
181
|
+
}
|
|
164
182
|
}
|
|
165
|
-
if (((_c = lineItemLocalData.customer) === null || _c === void 0 ? void 0 : _c.id) != null
|
|
183
|
+
if (((_c = lineItemLocalData.customer) === null || _c === void 0 ? void 0 : _c.id) != null &&
|
|
184
|
+
currentSelectedEntityLine != null &&
|
|
185
|
+
currentSelectedEntityLine.type === 'customer') {
|
|
166
186
|
return {
|
|
167
187
|
entityId: lineItemLocalData.customer.id,
|
|
168
188
|
entityType: 'customer',
|
|
169
189
|
};
|
|
170
190
|
}
|
|
171
|
-
if (((_d = lineItemLocalData.vendor) === null || _d === void 0 ? void 0 : _d.id) != null
|
|
191
|
+
if (((_d = lineItemLocalData.vendor) === null || _d === void 0 ? void 0 : _d.id) != null &&
|
|
192
|
+
currentSelectedEntityLine != null &&
|
|
193
|
+
currentSelectedEntityLine.type === 'vendor') {
|
|
172
194
|
return {
|
|
173
195
|
entityId: lineItemLocalData.vendor.id,
|
|
174
196
|
entityType: 'vendor',
|
|
@@ -176,12 +198,13 @@ const getEntityDetails = (entity, lineItemLocalData, vendorUpdates, customerUpda
|
|
|
176
198
|
}
|
|
177
199
|
return undefined;
|
|
178
200
|
};
|
|
179
|
-
const getEntityFromTransaction = (transaction) => {
|
|
180
|
-
if ((0, vendorTransaction_1.isVendorTransaction)(transaction)
|
|
181
|
-
(0, vendorTransaction_1.isVendorTransactionWithCustomer)(transaction)) {
|
|
201
|
+
const getEntityFromTransaction = (transaction, currentSelectedEntity) => {
|
|
202
|
+
if ((0, vendorTransaction_1.isVendorTransaction)(transaction)) {
|
|
182
203
|
const vendor = transaction.vendor;
|
|
183
204
|
const customer = transaction.customer;
|
|
184
|
-
if (customer != null
|
|
205
|
+
if (customer != null &&
|
|
206
|
+
currentSelectedEntity != null &&
|
|
207
|
+
currentSelectedEntity.type === 'customer') {
|
|
185
208
|
return {
|
|
186
209
|
id: customer.id,
|
|
187
210
|
name: customer.name,
|
|
@@ -190,7 +213,9 @@ const getEntityFromTransaction = (transaction) => {
|
|
|
190
213
|
zeniId: customer.id,
|
|
191
214
|
};
|
|
192
215
|
}
|
|
193
|
-
if (vendor != null
|
|
216
|
+
if (vendor != null &&
|
|
217
|
+
currentSelectedEntity != null &&
|
|
218
|
+
currentSelectedEntity.type === 'vendor') {
|
|
194
219
|
return {
|
|
195
220
|
id: vendor.id,
|
|
196
221
|
name: vendor.name,
|
|
@@ -201,14 +226,14 @@ const getEntityFromTransaction = (transaction) => {
|
|
|
201
226
|
}
|
|
202
227
|
}
|
|
203
228
|
if ((0, customerTransaction_1.isCustomerTransaction)(transaction)) {
|
|
204
|
-
const
|
|
205
|
-
if (
|
|
229
|
+
const customerEntity = transaction.customer;
|
|
230
|
+
if (customerEntity != null) {
|
|
206
231
|
return {
|
|
207
|
-
id:
|
|
208
|
-
name:
|
|
232
|
+
id: customerEntity.id,
|
|
233
|
+
name: customerEntity.name,
|
|
209
234
|
type: (0, entity_1.toEntityType)('customer'),
|
|
210
|
-
qboId:
|
|
211
|
-
zeniId:
|
|
235
|
+
qboId: customerEntity.id,
|
|
236
|
+
zeniId: customerEntity.id,
|
|
212
237
|
};
|
|
213
238
|
}
|
|
214
239
|
}
|
|
@@ -30,18 +30,30 @@ const toTransactionDetailLocalData = (transaction) => {
|
|
|
30
30
|
logo: transaction.logo,
|
|
31
31
|
}
|
|
32
32
|
: undefined;
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
if ((0, vendorTransaction_1.isVendorTransaction)(transaction) &&
|
|
34
|
+
transaction.vendorId != null &&
|
|
35
|
+
transaction.vendorName != null) {
|
|
36
|
+
transactionLocal.selectedEntity = {
|
|
37
|
+
id: transaction.vendorId,
|
|
38
|
+
name: transaction.vendorName,
|
|
39
|
+
type: 'vendor',
|
|
40
|
+
qboId: transaction.vendorId,
|
|
41
|
+
zeniId: transaction.vendorId,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if ((0, vendorTransaction_1.isVendorTransaction)(transaction) &&
|
|
45
|
+
transaction.customerId != null &&
|
|
35
46
|
transaction.customerName != null) {
|
|
36
|
-
transactionLocal.
|
|
47
|
+
transactionLocal.selectedEntity = {
|
|
37
48
|
id: transaction.customerId,
|
|
38
49
|
name: transaction.customerName,
|
|
50
|
+
type: 'customer',
|
|
39
51
|
qboId: transaction.customerId,
|
|
52
|
+
zeniId: transaction.customerId,
|
|
40
53
|
};
|
|
41
54
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
55
|
+
transactionLocal.vendorUpdates = undefined;
|
|
56
|
+
transactionLocal.customerUpdates = undefined;
|
|
45
57
|
transactionLocal.lineItemById =
|
|
46
58
|
transaction.lines != null && transaction.lines.length > 0
|
|
47
59
|
? buildLineItemById(transaction, transaction.recommendations)
|
|
@@ -85,6 +97,24 @@ const buildLineItemById = (transaction, recommendations) => {
|
|
|
85
97
|
logo: accountLine.customer.logo,
|
|
86
98
|
}
|
|
87
99
|
: undefined;
|
|
100
|
+
record.selectedEntityLine =
|
|
101
|
+
record.vendor != null
|
|
102
|
+
? {
|
|
103
|
+
id: record.vendor.id,
|
|
104
|
+
name: record.vendor.name,
|
|
105
|
+
type: 'vendor',
|
|
106
|
+
qboId: record.vendor.id,
|
|
107
|
+
zeniId: record.vendor.id,
|
|
108
|
+
}
|
|
109
|
+
: record.customer != null
|
|
110
|
+
? {
|
|
111
|
+
id: record.customer.id,
|
|
112
|
+
name: record.customer.name,
|
|
113
|
+
type: 'customer',
|
|
114
|
+
qboId: record.customer.id,
|
|
115
|
+
zeniId: record.customer.id,
|
|
116
|
+
}
|
|
117
|
+
: undefined;
|
|
88
118
|
record.billable = accountLine.billable;
|
|
89
119
|
record.categorizationStatus = accountLine.categorizationStatus;
|
|
90
120
|
record.reviewPendingReasons = accountLine.reviewPendingReasons;
|
|
@@ -208,7 +238,7 @@ const toSetAllLineItemsToCategoryClass = (draft, transaction, transactionId, tra
|
|
|
208
238
|
}
|
|
209
239
|
});
|
|
210
240
|
}
|
|
211
|
-
const newLocalData = Object.assign(Object.assign({}, transactionsViewState_1.initialSupportedTransactionCategorization.transactionReviewLocalData), { sortedLineItems: transactionDetailLocalData.sortedLineItems, memo: transactionDetailLocalData.memo, lineItemById: newLineItems, transactionDate: transactionDetailLocalData.transactionDate, transactionType: transactionDetailLocalData.transactionType, transactionTypeName: transactionDetailLocalData.transactionTypeName, vendor: transactionDetailLocalData.vendor, customer: transactionDetailLocalData.customer, vendorUpdates: transactionDetailLocalData.vendorUpdates, customerUpdates: transactionDetailLocalData.customerUpdates, vendorDetails: transactionDetailLocalData.vendorDetails, customerDetails: transactionDetailLocalData.customerDetails });
|
|
241
|
+
const newLocalData = Object.assign(Object.assign({}, transactionsViewState_1.initialSupportedTransactionCategorization.transactionReviewLocalData), { sortedLineItems: transactionDetailLocalData.sortedLineItems, memo: transactionDetailLocalData.memo, lineItemById: newLineItems, transactionDate: transactionDetailLocalData.transactionDate, transactionType: transactionDetailLocalData.transactionType, transactionTypeName: transactionDetailLocalData.transactionTypeName, vendor: transactionDetailLocalData.vendor, customer: transactionDetailLocalData.customer, vendorUpdates: transactionDetailLocalData.vendorUpdates, customerUpdates: transactionDetailLocalData.customerUpdates, vendorDetails: transactionDetailLocalData.vendorDetails, customerDetails: transactionDetailLocalData.customerDetails, selectedEntity: transactionDetailLocalData.selectedEntity });
|
|
212
242
|
if (!(0, exports.checkIfAllLineItemsAreCategoryClassFilled)(transaction, newLocalData, uncategorizedAccounts)) {
|
|
213
243
|
selectedCheckBoxTransactionIds = selectedCheckBoxTransactionIds.filter((id) => id !== transaction.id);
|
|
214
244
|
}
|
|
@@ -272,7 +302,7 @@ const setEntityRecommendationForLineIdInLocalData = (draft, transaction, transac
|
|
|
272
302
|
const newLineItem = newLineItems[matchingEntityLineId];
|
|
273
303
|
newLineItems[matchingEntityLineId] = Object.assign(Object.assign({}, newLineItem), { class: matchingRecord.class, account: matchingRecord.account, lineEntity: matchingRecord.lineEntity });
|
|
274
304
|
}
|
|
275
|
-
const newLocalData = Object.assign(Object.assign({}, transactionsViewState_1.initialSupportedTransactionCategorization.transactionReviewLocalData), { sortedLineItems: transactionDetailLocalData.sortedLineItems, memo: transactionDetailLocalData.memo, lineItemById: newLineItems, transactionDate: transactionDetailLocalData.transactionDate, transactionType: transactionDetailLocalData.transactionType, transactionTypeName: transactionDetailLocalData.transactionTypeName, vendorUpdates: transactionDetailLocalData.vendorUpdates, customerUpdates: transactionDetailLocalData.customerUpdates, vendorDetails: transactionDetailLocalData.vendorDetails, customerDetails: transactionDetailLocalData.customerDetails, vendor: transactionDetailLocalData.vendor, customer: transactionDetailLocalData.customer });
|
|
305
|
+
const newLocalData = Object.assign(Object.assign({}, transactionsViewState_1.initialSupportedTransactionCategorization.transactionReviewLocalData), { sortedLineItems: transactionDetailLocalData.sortedLineItems, memo: transactionDetailLocalData.memo, lineItemById: newLineItems, transactionDate: transactionDetailLocalData.transactionDate, transactionType: transactionDetailLocalData.transactionType, transactionTypeName: transactionDetailLocalData.transactionTypeName, vendorUpdates: transactionDetailLocalData.vendorUpdates, customerUpdates: transactionDetailLocalData.customerUpdates, vendorDetails: transactionDetailLocalData.vendorDetails, customerDetails: transactionDetailLocalData.customerDetails, vendor: transactionDetailLocalData.vendor, customer: transactionDetailLocalData.customer, selectedEntity: transactionDetailLocalData.selectedEntity });
|
|
276
306
|
if (!(0, exports.checkIfAllLineItemsAreCategoryClassFilled)(transaction, newLocalData, uncategorizedAccounts)) {
|
|
277
307
|
selectedCheckBoxTransactionIds = selectedCheckBoxTransactionIds.filter((id) => id !== transaction.id);
|
|
278
308
|
}
|
|
@@ -4,6 +4,7 @@ import { MonthYearPeriod, TimePeriod } from '../../../commonStateTypes/timePerio
|
|
|
4
4
|
import { PageToken } from '../../../commonStateTypes/viewAndReport/viewAndReport';
|
|
5
5
|
import { AccountBase } from '../../../entity/account/accountState';
|
|
6
6
|
import { ClassBase } from '../../../entity/class/classState';
|
|
7
|
+
import { CustomerBase } from '../../../entity/customer/customerState';
|
|
7
8
|
import { Entity } from '../../../entity/genericEntity/entity';
|
|
8
9
|
import { RecommendationByLineId, TransactionID } from '../../../entity/transaction/stateTypes/transaction';
|
|
9
10
|
import { SupportedTransaction } from '../../../entity/transaction/transactionState';
|
|
@@ -76,7 +77,16 @@ export declare const fetchTransactionCategorization: import("@reduxjs/toolkit").
|
|
|
76
77
|
selectedTransaction: SupportedTransaction;
|
|
77
78
|
uncategorizedAccounts: UncategorizedAccounts;
|
|
78
79
|
updatedVendor?: VendorBase;
|
|
79
|
-
|
|
80
|
+
selectedEntity?: Entity;
|
|
81
|
+
}, "expenseAutomationTransactionsView/updateSelectedVendorForTransaction">, updateSelectedCustomerForTransaction: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
82
|
+
selectedTab: TransactionsTab;
|
|
83
|
+
transactionId: ID;
|
|
84
|
+
lineId: ID;
|
|
85
|
+
selectedTransaction: SupportedTransaction;
|
|
86
|
+
uncategorizedAccounts: UncategorizedAccounts;
|
|
87
|
+
updatedCustomer?: CustomerBase;
|
|
88
|
+
selectedEntity?: Entity;
|
|
89
|
+
}, "expenseAutomationTransactionsView/updateSelectedCustomerForTransaction">, setAllItemsToCategoryClassInLocalDataForCategorization: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", transactionId: string, lineId: string, transactions: SupportedTransaction[], uncategorizedAccounts: UncategorizedAccounts, vendorId?: string | undefined, customerId?: string | undefined, selectedAccount?: AccountBase | undefined, selectedClassBase?: ClassBase | undefined, lineEntity?: Entity | undefined, recommendations?: Recommendation[] | undefined], {
|
|
80
90
|
selectedTab: "review" | "autoCategorized";
|
|
81
91
|
transactionId: string;
|
|
82
92
|
lineId: string;
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
var _a;
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.updateSelectedTransactionId = exports.setEntityRecommendationForLineIdsForCategorization = exports.clearExpenseAutomationTransactionsView = exports.clearExpenseAutomationTransactionsViewPerTabView = exports.updateSelectedCheckboxTransactionIds = exports.fetchTransactionCategorizationView = exports.fetchTransactionCategorizationSuccess = exports.updateTotalCountForTransactionCategorization = exports.setAllItemsToCategoryClassInLocalDataForCategorization = exports.updateSelectedVendorForTransaction = exports.updateStatusForTransactionNotMiscategorizedUpdate = exports.markTransactionAsNotMiscategorized = exports.updateTransactionCategorizationSaveStatus = exports.updateCurrentSelectedTransactionCategorizationTab = exports.updateTransactionCategorization = exports.saveTransactionCategorization = exports.fetchTransactionCategorizationFailure = exports.saveTransactionCategorizationLocalData = exports.initializeTransactionCategorizationViewLocalData = exports.updateTransactionCategorizationUIState = exports.fetchTransactionCategorization = exports.initialState = exports.initialTransactionTabViewState = void 0;
|
|
7
|
+
exports.updateSelectedTransactionId = exports.setEntityRecommendationForLineIdsForCategorization = exports.clearExpenseAutomationTransactionsView = exports.clearExpenseAutomationTransactionsViewPerTabView = exports.updateSelectedCheckboxTransactionIds = exports.fetchTransactionCategorizationView = exports.fetchTransactionCategorizationSuccess = exports.updateTotalCountForTransactionCategorization = exports.setAllItemsToCategoryClassInLocalDataForCategorization = exports.updateSelectedCustomerForTransaction = exports.updateSelectedVendorForTransaction = exports.updateStatusForTransactionNotMiscategorizedUpdate = exports.markTransactionAsNotMiscategorized = exports.updateTransactionCategorizationSaveStatus = exports.updateCurrentSelectedTransactionCategorizationTab = exports.updateTransactionCategorization = exports.saveTransactionCategorization = exports.fetchTransactionCategorizationFailure = exports.saveTransactionCategorizationLocalData = exports.initializeTransactionCategorizationViewLocalData = exports.updateTransactionCategorizationUIState = exports.fetchTransactionCategorization = exports.initialState = exports.initialTransactionTabViewState = void 0;
|
|
8
8
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
9
9
|
const get_1 = __importDefault(require("lodash/get"));
|
|
10
10
|
const uniq_1 = __importDefault(require("lodash/uniq"));
|
|
@@ -367,6 +367,58 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
367
367
|
draft.transactionCategorizationView[selectedTab].error =
|
|
368
368
|
action.payload.status;
|
|
369
369
|
},
|
|
370
|
+
updateSelectedCustomerForTransaction(draft, action) {
|
|
371
|
+
const { transactionId, lineId, updatedCustomer, selectedTransaction, selectedTab, uncategorizedAccounts, } = action.payload;
|
|
372
|
+
const transactionLocalData = (0, get_1.default)(draft.transactionCategorizationView[selectedTab]
|
|
373
|
+
.transactionReviewLocalDataById, transactionId, undefined);
|
|
374
|
+
if (transactionLocalData != null) {
|
|
375
|
+
let newTransactionLocalData = Object.assign({}, transactionLocalData.transactionReviewLocalData);
|
|
376
|
+
if (!(0, vendorTransaction_1.isVendorTransaction)(selectedTransaction) &&
|
|
377
|
+
updatedCustomer != null) {
|
|
378
|
+
newTransactionLocalData = Object.assign(Object.assign({}, newTransactionLocalData), { lineItemById: Object.assign(Object.assign({}, transactionLocalData.transactionReviewLocalData.lineItemById), { [lineId]: Object.assign(Object.assign({}, transactionLocalData.transactionReviewLocalData.lineItemById[lineId]), { customer: updatedCustomer, selectedEntityLine: action.payload.selectedEntity != null
|
|
379
|
+
? action.payload.selectedEntity
|
|
380
|
+
: undefined }) }) });
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
if (action.payload.selectedEntity != null) {
|
|
384
|
+
newTransactionLocalData.selectedEntity =
|
|
385
|
+
action.payload.selectedEntity;
|
|
386
|
+
}
|
|
387
|
+
newTransactionLocalData.customerUpdates =
|
|
388
|
+
updatedCustomer != null && updatedCustomer.id != null
|
|
389
|
+
? {
|
|
390
|
+
id: updatedCustomer.id,
|
|
391
|
+
name: updatedCustomer.name,
|
|
392
|
+
qboId: updatedCustomer.id,
|
|
393
|
+
}
|
|
394
|
+
: undefined;
|
|
395
|
+
newTransactionLocalData.customer =
|
|
396
|
+
updatedCustomer != null && updatedCustomer.id != null
|
|
397
|
+
? {
|
|
398
|
+
id: updatedCustomer.id,
|
|
399
|
+
name: updatedCustomer.name,
|
|
400
|
+
logo: updatedCustomer.logo,
|
|
401
|
+
}
|
|
402
|
+
: undefined;
|
|
403
|
+
}
|
|
404
|
+
draft.transactionCategorizationView[selectedTab].transactionReviewLocalDataById[transactionId] = {
|
|
405
|
+
transactionReviewLocalData: newTransactionLocalData,
|
|
406
|
+
transactionId,
|
|
407
|
+
};
|
|
408
|
+
const selectedCheckBoxTransactionIds = draft.transactionCategorizationView[selectedTab]
|
|
409
|
+
.selectedCheckBoxTransactionIds;
|
|
410
|
+
if (newTransactionLocalData.customer != null &&
|
|
411
|
+
newTransactionLocalData.customer.id != null &&
|
|
412
|
+
(0, transactionCategorizationLocalDataHelper_1.checkIfAllLineItemsAreCategoryClassFilled)(selectedTransaction, newTransactionLocalData, uncategorizedAccounts) === true && // check if all line items are filled
|
|
413
|
+
selectedCheckBoxTransactionIds.length < transactionCategorizationLocalDataHelper_1.MAX_SELECTION_LIMIT &&
|
|
414
|
+
selectedCheckBoxTransactionIds.includes(transactionId) === false) {
|
|
415
|
+
draft.transactionCategorizationView[selectedTab].selectedCheckBoxTransactionIds = [
|
|
416
|
+
...selectedCheckBoxTransactionIds,
|
|
417
|
+
transactionId,
|
|
418
|
+
];
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
},
|
|
370
422
|
updateSelectedVendorForTransaction(draft, action) {
|
|
371
423
|
const { transactionId, lineId, updatedVendor, selectedTransaction, selectedTab, uncategorizedAccounts, } = action.payload;
|
|
372
424
|
const transactionLocalData = (0, get_1.default)(draft.transactionCategorizationView[selectedTab]
|
|
@@ -375,9 +427,15 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
375
427
|
let newTransactionLocalData = Object.assign({}, transactionLocalData.transactionReviewLocalData);
|
|
376
428
|
if (!(0, vendorTransaction_1.isVendorTransaction)(selectedTransaction) &&
|
|
377
429
|
updatedVendor != null) {
|
|
378
|
-
newTransactionLocalData = Object.assign(Object.assign({}, newTransactionLocalData), { lineItemById: Object.assign(Object.assign({}, transactionLocalData.transactionReviewLocalData.lineItemById), { [lineId]: Object.assign(Object.assign({}, transactionLocalData.transactionReviewLocalData.lineItemById[lineId]), { vendor: updatedVendor
|
|
430
|
+
newTransactionLocalData = Object.assign(Object.assign({}, newTransactionLocalData), { lineItemById: Object.assign(Object.assign({}, transactionLocalData.transactionReviewLocalData.lineItemById), { [lineId]: Object.assign(Object.assign({}, transactionLocalData.transactionReviewLocalData.lineItemById[lineId]), { vendor: updatedVendor, selectedEntityLine: action.payload.selectedEntity != null
|
|
431
|
+
? action.payload.selectedEntity
|
|
432
|
+
: undefined }) }) });
|
|
379
433
|
}
|
|
380
434
|
else {
|
|
435
|
+
if (action.payload.selectedEntity != null) {
|
|
436
|
+
newTransactionLocalData.selectedEntity =
|
|
437
|
+
action.payload.selectedEntity;
|
|
438
|
+
}
|
|
381
439
|
newTransactionLocalData.vendorUpdates =
|
|
382
440
|
updatedVendor != null && updatedVendor.id != null
|
|
383
441
|
? {
|
|
@@ -503,5 +561,5 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
503
561
|
},
|
|
504
562
|
},
|
|
505
563
|
});
|
|
506
|
-
_a = expenseAutomationTransactionsView.actions, exports.fetchTransactionCategorization = _a.fetchTransactionCategorization, exports.updateTransactionCategorizationUIState = _a.updateTransactionCategorizationUIState, exports.initializeTransactionCategorizationViewLocalData = _a.initializeTransactionCategorizationViewLocalData, exports.saveTransactionCategorizationLocalData = _a.saveTransactionCategorizationLocalData, exports.fetchTransactionCategorizationFailure = _a.fetchTransactionCategorizationFailure, exports.saveTransactionCategorization = _a.saveTransactionCategorization, exports.updateTransactionCategorization = _a.updateTransactionCategorization, exports.updateCurrentSelectedTransactionCategorizationTab = _a.updateCurrentSelectedTransactionCategorizationTab, exports.updateTransactionCategorizationSaveStatus = _a.updateTransactionCategorizationSaveStatus, exports.markTransactionAsNotMiscategorized = _a.markTransactionAsNotMiscategorized, exports.updateStatusForTransactionNotMiscategorizedUpdate = _a.updateStatusForTransactionNotMiscategorizedUpdate, exports.updateSelectedVendorForTransaction = _a.updateSelectedVendorForTransaction, exports.setAllItemsToCategoryClassInLocalDataForCategorization = _a.setAllItemsToCategoryClassInLocalDataForCategorization, exports.updateTotalCountForTransactionCategorization = _a.updateTotalCountForTransactionCategorization, exports.fetchTransactionCategorizationSuccess = _a.fetchTransactionCategorizationSuccess, exports.fetchTransactionCategorizationView = _a.fetchTransactionCategorizationView, exports.updateSelectedCheckboxTransactionIds = _a.updateSelectedCheckboxTransactionIds, exports.clearExpenseAutomationTransactionsViewPerTabView = _a.clearExpenseAutomationTransactionsViewPerTabView, exports.clearExpenseAutomationTransactionsView = _a.clearExpenseAutomationTransactionsView, exports.setEntityRecommendationForLineIdsForCategorization = _a.setEntityRecommendationForLineIdsForCategorization, exports.updateSelectedTransactionId = _a.updateSelectedTransactionId;
|
|
564
|
+
_a = expenseAutomationTransactionsView.actions, exports.fetchTransactionCategorization = _a.fetchTransactionCategorization, exports.updateTransactionCategorizationUIState = _a.updateTransactionCategorizationUIState, exports.initializeTransactionCategorizationViewLocalData = _a.initializeTransactionCategorizationViewLocalData, exports.saveTransactionCategorizationLocalData = _a.saveTransactionCategorizationLocalData, exports.fetchTransactionCategorizationFailure = _a.fetchTransactionCategorizationFailure, exports.saveTransactionCategorization = _a.saveTransactionCategorization, exports.updateTransactionCategorization = _a.updateTransactionCategorization, exports.updateCurrentSelectedTransactionCategorizationTab = _a.updateCurrentSelectedTransactionCategorizationTab, exports.updateTransactionCategorizationSaveStatus = _a.updateTransactionCategorizationSaveStatus, exports.markTransactionAsNotMiscategorized = _a.markTransactionAsNotMiscategorized, exports.updateStatusForTransactionNotMiscategorizedUpdate = _a.updateStatusForTransactionNotMiscategorizedUpdate, exports.updateSelectedVendorForTransaction = _a.updateSelectedVendorForTransaction, exports.updateSelectedCustomerForTransaction = _a.updateSelectedCustomerForTransaction, exports.setAllItemsToCategoryClassInLocalDataForCategorization = _a.setAllItemsToCategoryClassInLocalDataForCategorization, exports.updateTotalCountForTransactionCategorization = _a.updateTotalCountForTransactionCategorization, exports.fetchTransactionCategorizationSuccess = _a.fetchTransactionCategorizationSuccess, exports.fetchTransactionCategorizationView = _a.fetchTransactionCategorizationView, exports.updateSelectedCheckboxTransactionIds = _a.updateSelectedCheckboxTransactionIds, exports.clearExpenseAutomationTransactionsViewPerTabView = _a.clearExpenseAutomationTransactionsViewPerTabView, exports.clearExpenseAutomationTransactionsView = _a.clearExpenseAutomationTransactionsView, exports.setEntityRecommendationForLineIdsForCategorization = _a.setEntityRecommendationForLineIdsForCategorization, exports.updateSelectedTransactionId = _a.updateSelectedTransactionId;
|
|
507
565
|
exports.default = expenseAutomationTransactionsView.reducer;
|
|
@@ -55,6 +55,7 @@ export interface TransactionCategorizationLineItemData extends TransactionLineBa
|
|
|
55
55
|
lineEntity?: Entity;
|
|
56
56
|
isCategoryMiscategorized: boolean;
|
|
57
57
|
isClassMiscategorized: boolean;
|
|
58
|
+
selectedEntityLine?: Entity;
|
|
58
59
|
}
|
|
59
60
|
export interface TransactionReviewLocalData {
|
|
60
61
|
lineItemById: Record<ID, TransactionCategorizationLineItemData>;
|
|
@@ -77,6 +78,7 @@ export interface TransactionReviewLocalData {
|
|
|
77
78
|
transactionTypeName?: string;
|
|
78
79
|
vendorUpdates?: TransactionVendorUpdates;
|
|
79
80
|
customerUpdates?: TransactionVendorUpdates;
|
|
81
|
+
selectedEntity?: Entity;
|
|
80
82
|
}
|
|
81
83
|
export interface SupportedTransactionCategorization {
|
|
82
84
|
transactionReviewLocalData: TransactionReviewLocalData;
|
|
@@ -25,7 +25,7 @@ const recommendationState_1 = require("../../recommendation/recommendationState"
|
|
|
25
25
|
* additionally fire “Mark as not miscat” for every point above.
|
|
26
26
|
*/
|
|
27
27
|
const toTransactionUpdatesFromTransactionDetailLocalData = (transactionDetailLocalData, transaction, isExpenseAutomationEnabled) => {
|
|
28
|
-
var _a, _b
|
|
28
|
+
var _a, _b;
|
|
29
29
|
const updates = {
|
|
30
30
|
updatesByLineId: {},
|
|
31
31
|
};
|
|
@@ -33,20 +33,27 @@ const toTransactionUpdatesFromTransactionDetailLocalData = (transactionDetailLoc
|
|
|
33
33
|
const entityUpdates = {};
|
|
34
34
|
const isTransactionMisCategorized = (0, exports.isTransactionMiscategorized)(transaction, isExpenseAutomationEnabled);
|
|
35
35
|
updates.memo = transactionDetailLocalData.memo;
|
|
36
|
+
const selectedEntity = transactionDetailLocalData.selectedEntity;
|
|
36
37
|
const updatedEntityId = transactionDetailLocalData.updatePreviousTransactionsWithUpdatedVendor ===
|
|
37
38
|
true
|
|
38
39
|
? (_a = transactionDetailLocalData.vendorUpdates) === null || _a === void 0 ? void 0 : _a.qboId
|
|
39
40
|
: undefined;
|
|
40
|
-
if ((0, vendorTransaction_1.isVendorTransaction)(transaction)
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
if ((0, vendorTransaction_1.isVendorTransaction)(transaction) &&
|
|
42
|
+
selectedEntity != null &&
|
|
43
|
+
selectedEntity.type === 'vendor') {
|
|
44
|
+
updates.vendorId = selectedEntity.id;
|
|
45
|
+
}
|
|
46
|
+
if ((0, vendorTransaction_1.isVendorTransaction)(transaction) &&
|
|
47
|
+
selectedEntity != null &&
|
|
48
|
+
selectedEntity.type === 'customer') {
|
|
49
|
+
updates.customerId = selectedEntity.id;
|
|
43
50
|
}
|
|
44
51
|
let isBulkUpdate = false;
|
|
45
|
-
const entity = getEntityFromTransaction(transaction);
|
|
52
|
+
const entity = getEntityFromTransaction(transaction, selectedEntity);
|
|
46
53
|
let lastUpdatedCategory;
|
|
47
54
|
let lastUpdatedClass;
|
|
48
55
|
// single recommendation to just pick the last recommendation in the list of lines
|
|
49
|
-
(
|
|
56
|
+
(_b = transaction.lines) === null || _b === void 0 ? void 0 : _b.forEach((line) => {
|
|
50
57
|
var _a, _b, _c, _d, _e, _f;
|
|
51
58
|
const entityDetails = getEntityDetails(entity, transactionDetailLocalData.lineItemById[line.id], transactionDetailLocalData.vendorUpdates, transactionDetailLocalData.customerUpdates);
|
|
52
59
|
if (line.type === 'transaction_with_account_and_class_line' ||
|
|
@@ -202,17 +209,31 @@ const getVendorOrCustomerDetails = (lineItem) => {
|
|
|
202
209
|
}
|
|
203
210
|
return {};
|
|
204
211
|
};
|
|
205
|
-
const getEntityFromTransaction = (transaction) => {
|
|
212
|
+
const getEntityFromTransaction = (transaction, currentSelectedEntity) => {
|
|
206
213
|
let entity = undefined;
|
|
207
214
|
if ((0, vendorTransaction_1.isVendorTransaction)(transaction)) {
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
215
|
+
const vendor = transaction.vendor;
|
|
216
|
+
const customer = transaction.customer;
|
|
217
|
+
if (customer != null &&
|
|
218
|
+
currentSelectedEntity != null &&
|
|
219
|
+
currentSelectedEntity.type === 'customer') {
|
|
220
|
+
return {
|
|
221
|
+
id: customer.id,
|
|
222
|
+
name: customer.name,
|
|
223
|
+
type: (0, entity_1.toEntityType)('customer'),
|
|
224
|
+
qboId: customer.id,
|
|
225
|
+
zeniId: customer.id,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
if (vendor != null &&
|
|
229
|
+
currentSelectedEntity != null &&
|
|
230
|
+
currentSelectedEntity.type === 'vendor') {
|
|
231
|
+
return {
|
|
232
|
+
id: vendor.id,
|
|
233
|
+
name: vendor.name,
|
|
213
234
|
type: (0, entity_1.toEntityType)('vendor'),
|
|
214
|
-
qboId:
|
|
215
|
-
zeniId:
|
|
235
|
+
qboId: vendor.id,
|
|
236
|
+
zeniId: vendor.id,
|
|
216
237
|
};
|
|
217
238
|
}
|
|
218
239
|
}
|
|
@@ -127,8 +127,11 @@ function preparePayload(transactionState, vendorState, transactionDetailState, t
|
|
|
127
127
|
const tranDetail = (0, get_1.default)(transactionDetailState.transactionDetailById, transactionDetailKey, undefined);
|
|
128
128
|
const tranVendorUpdates = tranDetail === null || tranDetail === void 0 ? void 0 : tranDetail.transactionDetailLocalData.vendorUpdates;
|
|
129
129
|
const tranCustomerUpdates = tranDetail === null || tranDetail === void 0 ? void 0 : tranDetail.transactionDetailLocalData.customerUpdates;
|
|
130
|
+
const currentSelectedEntity = tranDetail === null || tranDetail === void 0 ? void 0 : tranDetail.transactionDetailLocalData.selectedEntity;
|
|
130
131
|
let vendorUpdates = undefined;
|
|
131
|
-
if ((tranVendorUpdates === null || tranVendorUpdates === void 0 ? void 0 : tranVendorUpdates.qboId) != null
|
|
132
|
+
if ((tranVendorUpdates === null || tranVendorUpdates === void 0 ? void 0 : tranVendorUpdates.qboId) != null &&
|
|
133
|
+
currentSelectedEntity != null &&
|
|
134
|
+
currentSelectedEntity.type === 'vendor') {
|
|
132
135
|
const vendor = (0, vendorSelector_1.getVendorByVendorId)(vendorState, tranVendorUpdates.qboId);
|
|
133
136
|
if (vendor != null) {
|
|
134
137
|
vendorUpdates = {
|
|
@@ -144,7 +147,9 @@ function preparePayload(transactionState, vendorState, transactionDetailState, t
|
|
|
144
147
|
}
|
|
145
148
|
}
|
|
146
149
|
let customerUpdates = undefined;
|
|
147
|
-
if ((tranCustomerUpdates === null || tranCustomerUpdates === void 0 ? void 0 : tranCustomerUpdates.qboId) != null
|
|
150
|
+
if ((tranCustomerUpdates === null || tranCustomerUpdates === void 0 ? void 0 : tranCustomerUpdates.qboId) != null &&
|
|
151
|
+
currentSelectedEntity != null &&
|
|
152
|
+
currentSelectedEntity.type === 'customer') {
|
|
148
153
|
customerUpdates = {
|
|
149
154
|
id: tranCustomerUpdates.qboId,
|
|
150
155
|
name: tranCustomerUpdates.name,
|