@zeniai/client-epic-state 4.15.39 → 4.15.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/entity/customer/customerPayload.js +7 -7
- package/lib/entity/transaction/payloadTypes/vendorTransactionPayload.d.ts +1 -1
- package/lib/entity/transaction/payloadTypes/vendorTransactionPayload.js +3 -2
- package/lib/view/commonVendorView/transactionVendorView/epics/saveTransactionVendorEpic.js +7 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/updateTransactionCategorizationEpic.js +4 -8
- package/lib/view/expenseAutomationView/helpers/saveTransactionHelper.js +55 -75
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -0
- package/lib/view/transactionDetail/epics/saveTransactionHelper.js +24 -61
- package/lib/view/transactionDetail/epics/updateTransactionDetailEpic.js +4 -4
- package/lib/view/transactionDetail/transactionDetailLocalDataHelper.js +1 -4
- package/package.json +1 -1
|
@@ -14,19 +14,19 @@ const toCustomerBase = (payload, parseOutParentName) => ({
|
|
|
14
14
|
exports.toCustomerBase = toCustomerBase;
|
|
15
15
|
const toCustomerBasePayload = (customer, customerUpdates) => {
|
|
16
16
|
var _a, _b;
|
|
17
|
-
if (
|
|
17
|
+
if (customerUpdates != null && customerUpdates.id != null) {
|
|
18
18
|
return {
|
|
19
|
-
customer_id:
|
|
20
|
-
customer_name:
|
|
21
|
-
qbo_id:
|
|
19
|
+
customer_id: (_a = customerUpdates === null || customerUpdates === void 0 ? void 0 : customerUpdates.id) !== null && _a !== void 0 ? _a : '',
|
|
20
|
+
customer_name: (_b = customerUpdates === null || customerUpdates === void 0 ? void 0 : customerUpdates.name) !== null && _b !== void 0 ? _b : '',
|
|
21
|
+
qbo_id: customerUpdates === null || customerUpdates === void 0 ? void 0 : customerUpdates.qboId,
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
25
|
// Customer field is read-only in v1. Will require customerUpdates when made editable
|
|
26
26
|
return {
|
|
27
|
-
customer_id:
|
|
28
|
-
customer_name:
|
|
29
|
-
qbo_id:
|
|
27
|
+
customer_id: customer != null ? customer.id : '',
|
|
28
|
+
customer_name: customer != null ? customer.name : '',
|
|
29
|
+
qbo_id: customer != null ? customer.qboId : '',
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
};
|
|
@@ -20,4 +20,4 @@ export declare const toVendorTransaction: (payload: VendorTransactionPayload) =>
|
|
|
20
20
|
export declare const toVendorTransactionPayload: (transaction: VendorTransaction, vendorUpdates?: VendorBase) => Partial<VendorTransactionPayload>;
|
|
21
21
|
export declare const isVendorTransactionWithCustomerPayload: (payload: TransactionPayload) => boolean;
|
|
22
22
|
export declare const toVendorTransactionWithCustomer: (payload: VendorTransactionWithCustomerPayload) => VendorTransactionWithCustomer;
|
|
23
|
-
export declare const toVendorTransactionWithCustomerPayload: (transaction: VendorTransactionWithCustomer,
|
|
23
|
+
export declare const toVendorTransactionWithCustomerPayload: (transaction: VendorTransactionWithCustomer, customerUpdates?: CustomerBase) => Partial<VendorTransactionWithCustomerPayload>;
|
|
@@ -40,7 +40,8 @@ const toVendorTransactionWithCustomer = (payload) => {
|
|
|
40
40
|
: undefined });
|
|
41
41
|
};
|
|
42
42
|
exports.toVendorTransactionWithCustomer = toVendorTransactionWithCustomer;
|
|
43
|
-
const toVendorTransactionWithCustomerPayload = (transaction,
|
|
44
|
-
|
|
43
|
+
const toVendorTransactionWithCustomerPayload = (transaction, customerUpdates) => {
|
|
44
|
+
const payload = (0, transactionPayload_1.toTransactionPayload)(transaction);
|
|
45
|
+
return Object.assign(Object.assign(Object.assign({}, payload), (0, customerPayload_1.toCustomerBasePayload)(transaction.customer, customerUpdates)), { vendor_id: '', vendor_name: '' });
|
|
45
46
|
};
|
|
46
47
|
exports.toVendorTransactionWithCustomerPayload = toVendorTransactionWithCustomerPayload;
|
|
@@ -63,6 +63,13 @@ const saveTransactionVendorEpic = (actions$, state$, zeniAPI) => actions$.pipe((
|
|
|
63
63
|
name: response.data.vendors[0].vendor_name,
|
|
64
64
|
id: response.data.vendors[0].vendor_id,
|
|
65
65
|
},
|
|
66
|
+
selectedEntity: {
|
|
67
|
+
name: response.data.vendors[0].vendor_name,
|
|
68
|
+
id: response.data.vendors[0].vendor_id,
|
|
69
|
+
type: 'vendor',
|
|
70
|
+
zeniId: response.data.vendors[0].vendor_id,
|
|
71
|
+
qboId: response.data.vendors[0].qbo_id,
|
|
72
|
+
},
|
|
66
73
|
}));
|
|
67
74
|
}
|
|
68
75
|
}
|
|
@@ -81,7 +81,7 @@ function prepareTransactionPayload(selectedTab, transactionState, vendorState, t
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
if (detail != null) {
|
|
84
|
-
const transUpdates = toTransactionUpdatePayload(saveUpdates.updates, detail, vendorUpdates, customerUpdates);
|
|
84
|
+
const transUpdates = toTransactionUpdatePayload(saveUpdates.updates, detail, vendorUpdates, customerUpdates, tranSelectedEntity);
|
|
85
85
|
const entityUpdates = toEntityUpdatePayload(saveUpdates.entityRelatedUpdates);
|
|
86
86
|
return {
|
|
87
87
|
entity_related_updates: entityUpdates,
|
|
@@ -110,14 +110,10 @@ function preparePayload(selectedTab, transactionState, vendorState, transactions
|
|
|
110
110
|
return payload;
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
const toTransactionUpdatePayload = (updates, detail, vendorUpdates, customerUpdates) => {
|
|
113
|
+
const toTransactionUpdatePayload = (updates, detail, vendorUpdates, customerUpdates, tranSelectedEntity) => {
|
|
114
114
|
var _a, _b;
|
|
115
115
|
const transaction = Object.assign({}, detail);
|
|
116
116
|
transaction.memo = (_a = updates.memo) !== null && _a !== void 0 ? _a : '';
|
|
117
|
-
transaction.vendorId = vendorUpdates === null || vendorUpdates === void 0 ? void 0 : vendorUpdates.id;
|
|
118
|
-
transaction.vendorName = vendorUpdates === null || vendorUpdates === void 0 ? void 0 : vendorUpdates.name;
|
|
119
|
-
transaction.customerId = customerUpdates === null || customerUpdates === void 0 ? void 0 : customerUpdates.id;
|
|
120
|
-
transaction.customerName = customerUpdates === null || customerUpdates === void 0 ? void 0 : customerUpdates.name;
|
|
121
117
|
const recommendationUpdates = {};
|
|
122
118
|
for (const key in updates.updatesByLineId) {
|
|
123
119
|
const lineUpdates = updates.updatesByLineId[key];
|
|
@@ -159,8 +155,8 @@ const toTransactionUpdatePayload = (updates, detail, vendorUpdates, customerUpda
|
|
|
159
155
|
return (0, customerTransactionPayload_1.toCustomerTransactionPayload)(transaction);
|
|
160
156
|
}
|
|
161
157
|
else if ((0, vendorTransaction_1.isVendorTransaction)(transaction)) {
|
|
162
|
-
if (
|
|
163
|
-
return (0, vendorTransactionPayload_1.toVendorTransactionWithCustomerPayload)(transaction,
|
|
158
|
+
if (tranSelectedEntity != null && tranSelectedEntity.type === 'customer') {
|
|
159
|
+
return (0, vendorTransactionPayload_1.toVendorTransactionWithCustomerPayload)(transaction, customerUpdates);
|
|
164
160
|
}
|
|
165
161
|
else {
|
|
166
162
|
return (0, vendorTransactionPayload_1.toVendorTransactionPayload)(transaction, vendorUpdates);
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toTransactionUpdatesFromTransactionCategorizationLocalData = void 0;
|
|
4
|
-
const entity_1 = require("../../../entity/genericEntity/entity");
|
|
5
|
-
const customerTransaction_1 = require("../../../entity/transaction/stateTypes/customerTransaction");
|
|
6
4
|
const vendorTransaction_1 = require("../../../entity/transaction/stateTypes/vendorTransaction");
|
|
7
5
|
const recommendationState_1 = require("../../recommendation/recommendationState");
|
|
8
6
|
const saveTransactionHelper_1 = require("../../transactionDetail/epics/saveTransactionHelper");
|
|
@@ -11,7 +9,7 @@ const saveTransactionHelper_1 = require("../../transactionDetail/epics/saveTrans
|
|
|
11
9
|
* @param transactionCategorizationLocalData
|
|
12
10
|
*/
|
|
13
11
|
const toTransactionUpdatesFromTransactionCategorizationLocalData = (transactionCategorizationLocalData, transaction, uncategorizedIncomeExpense) => {
|
|
14
|
-
var _a;
|
|
12
|
+
var _a, _b, _c, _d, _e;
|
|
15
13
|
const updates = {
|
|
16
14
|
updatesByLineId: {},
|
|
17
15
|
};
|
|
@@ -31,16 +29,28 @@ const toTransactionUpdatesFromTransactionCategorizationLocalData = (transactionC
|
|
|
31
29
|
currentSelectedEntity.type === 'customer') {
|
|
32
30
|
updates.customerId = currentSelectedEntity.id;
|
|
33
31
|
}
|
|
34
|
-
const entity = getEntityFromTransaction(transaction, currentSelectedEntity);
|
|
35
32
|
let lastUpdatedCategory;
|
|
36
33
|
let lastUpdatedClass;
|
|
37
|
-
|
|
38
|
-
(
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
let updatedEntityId;
|
|
35
|
+
if (currentSelectedEntity != null &&
|
|
36
|
+
currentSelectedEntity.type === 'vendor') {
|
|
37
|
+
if (((_a = transactionCategorizationLocalData.vendorUpdates) === null || _a === void 0 ? void 0 : _a.qboId) !==
|
|
38
|
+
transaction.vendorId) {
|
|
39
|
+
updatedEntityId = (_b = transactionCategorizationLocalData.vendorUpdates) === null || _b === void 0 ? void 0 : _b.qboId;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
if (((_c = transactionCategorizationLocalData.customerUpdates) === null || _c === void 0 ? void 0 : _c.qboId) !==
|
|
44
|
+
transaction.customerId) {
|
|
45
|
+
updatedEntityId =
|
|
46
|
+
(_d = transactionCategorizationLocalData.customerUpdates) === null || _d === void 0 ? void 0 : _d.qboId;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
(_e = transaction.lines) === null || _e === void 0 ? void 0 : _e.forEach((line) => {
|
|
50
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
41
51
|
const currentSelectedEntityLine = transactionCategorizationLocalData.lineItemById[line.id]
|
|
42
52
|
.selectedEntityLine;
|
|
43
|
-
const entityDetails = getEntityDetails(
|
|
53
|
+
const entityDetails = getEntityDetails(currentSelectedEntity, transactionCategorizationLocalData.lineItemById[line.id], transactionCategorizationLocalData.vendorUpdates, transactionCategorizationLocalData.customerUpdates, currentSelectedEntityLine);
|
|
44
54
|
if (line.type === 'transaction_with_account_and_class_line' ||
|
|
45
55
|
line.type === 'transaction_with_product_or_service_line' ||
|
|
46
56
|
line.type === 'journal_entry_transaction_line') {
|
|
@@ -65,22 +75,32 @@ const toTransactionUpdatesFromTransactionCategorizationLocalData = (transactionC
|
|
|
65
75
|
let hasClassChanged = false;
|
|
66
76
|
const accountLine = line;
|
|
67
77
|
hasCategoryChanged =
|
|
68
|
-
((
|
|
69
|
-
Boolean((
|
|
78
|
+
((_a = lineItem.account) === null || _a === void 0 ? void 0 : _a.qboId) !== accountLine.account.qboId &&
|
|
79
|
+
Boolean((_b = lineItem.account) === null || _b === void 0 ? void 0 : _b.qboId);
|
|
70
80
|
hasClassChanged =
|
|
71
|
-
Boolean((
|
|
72
|
-
((
|
|
81
|
+
Boolean((_c = lineItem.class) === null || _c === void 0 ? void 0 : _c.qboId) &&
|
|
82
|
+
((_d = lineItem.class) === null || _d === void 0 ? void 0 : _d.qboId) !== accountLine.class.qboId;
|
|
73
83
|
const recommendedAccountBase = (0, saveTransactionHelper_1.toRecommendedAccountBase)(lineItem.amount.amount, lineItem.account);
|
|
74
84
|
const recommendedClassBase = (0, saveTransactionHelper_1.toRecommendedClassBase)(lineItem.amount.amount, lineItem.class);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
let updatedLineEntityId;
|
|
86
|
+
if ((currentSelectedEntityLine === null || currentSelectedEntityLine === void 0 ? void 0 : currentSelectedEntityLine.type) === 'vendor') {
|
|
87
|
+
if (((_e = accountLine.vendor) === null || _e === void 0 ? void 0 : _e.id) != null) {
|
|
88
|
+
updatedLineEntityId =
|
|
89
|
+
((_f = accountLine.vendor) === null || _f === void 0 ? void 0 : _f.id) !== ((_g = lineItem.vendor) === null || _g === void 0 ? void 0 : _g.id)
|
|
90
|
+
? currentSelectedEntityLine === null || currentSelectedEntityLine === void 0 ? void 0 : currentSelectedEntityLine.qboId
|
|
91
|
+
: undefined;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else if (((_h = accountLine.customer) === null || _h === void 0 ? void 0 : _h.id) != null &&
|
|
95
|
+
(currentSelectedEntityLine === null || currentSelectedEntityLine === void 0 ? void 0 : currentSelectedEntityLine.type) === 'customer') {
|
|
96
|
+
updatedLineEntityId =
|
|
97
|
+
((_j = accountLine.customer) === null || _j === void 0 ? void 0 : _j.id) !== ((_k = lineItem.customer) === null || _k === void 0 ? void 0 : _k.id)
|
|
98
|
+
? currentSelectedEntityLine === null || currentSelectedEntityLine === void 0 ? void 0 : currentSelectedEntityLine.qboId
|
|
99
|
+
: undefined;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
updatedLineEntityId = undefined;
|
|
103
|
+
}
|
|
84
104
|
if (entityDetails != null &&
|
|
85
105
|
(hasCategoryChanged === true || hasClassChanged === true)) {
|
|
86
106
|
lastUpdatedCategory =
|
|
@@ -96,10 +116,11 @@ const toTransactionUpdatesFromTransactionCategorizationLocalData = (transactionC
|
|
|
96
116
|
if (recommended.class != null ||
|
|
97
117
|
recommended.account != null ||
|
|
98
118
|
updatedEntityId != null) {
|
|
99
|
-
const vendorIdToUpdate = (
|
|
100
|
-
if (line.type === 'journal_entry_transaction_line' ||
|
|
101
|
-
line.platformLineDetailType === 'deposit_line_detail')
|
|
102
|
-
|
|
119
|
+
const vendorIdToUpdate = (_l = transactionCategorizationLocalData.selectedEntity) === null || _l === void 0 ? void 0 : _l.id;
|
|
120
|
+
if ((line.type === 'journal_entry_transaction_line' ||
|
|
121
|
+
line.platformLineDetailType === 'deposit_line_detail') &&
|
|
122
|
+
updatedLineEntityId != null) {
|
|
123
|
+
const entityId = entityDetails.entityId;
|
|
103
124
|
if (entityId != null) {
|
|
104
125
|
doUpdateEntityUpdates(entityUpdates, entityId, entityDetails.entityType, recommended, false, updatedLineEntityId);
|
|
105
126
|
}
|
|
@@ -148,17 +169,17 @@ const doUpdateEntityUpdates = (entityUpdates, entityId, entityType, recommendati
|
|
|
148
169
|
entityUpdates[entityKey] = Object.assign(Object.assign({}, entityUpdate), { recommendations: recommendation });
|
|
149
170
|
}
|
|
150
171
|
};
|
|
151
|
-
const getEntityDetails = (
|
|
152
|
-
var _a, _b, _c
|
|
153
|
-
if (
|
|
172
|
+
const getEntityDetails = (currentSelectedEntity, lineItemLocalData, vendorUpdates, customerUpdates, currentSelectedEntityLine) => {
|
|
173
|
+
var _a, _b, _c;
|
|
174
|
+
if (currentSelectedEntity != null) {
|
|
154
175
|
return {
|
|
155
|
-
entityId:
|
|
156
|
-
entityType:
|
|
176
|
+
entityId: currentSelectedEntity.id,
|
|
177
|
+
entityType: currentSelectedEntity.type,
|
|
157
178
|
};
|
|
158
179
|
}
|
|
159
180
|
if (lineItemLocalData.lineEntity != null) {
|
|
160
181
|
return {
|
|
161
|
-
entityId: (
|
|
182
|
+
entityId: (_a = lineItemLocalData.lineEntity.qboId) !== null && _a !== void 0 ? _a : lineItemLocalData.lineEntity.id,
|
|
162
183
|
entityType: lineItemLocalData.vendor != null ? 'vendor' : 'customer',
|
|
163
184
|
};
|
|
164
185
|
}
|
|
@@ -180,7 +201,7 @@ const getEntityDetails = (entity, lineItemLocalData, vendorUpdates, customerUpda
|
|
|
180
201
|
};
|
|
181
202
|
}
|
|
182
203
|
}
|
|
183
|
-
if (((
|
|
204
|
+
if (((_b = lineItemLocalData.customer) === null || _b === void 0 ? void 0 : _b.id) != null &&
|
|
184
205
|
currentSelectedEntityLine != null &&
|
|
185
206
|
currentSelectedEntityLine.type === 'customer') {
|
|
186
207
|
return {
|
|
@@ -188,7 +209,7 @@ const getEntityDetails = (entity, lineItemLocalData, vendorUpdates, customerUpda
|
|
|
188
209
|
entityType: 'customer',
|
|
189
210
|
};
|
|
190
211
|
}
|
|
191
|
-
if (((
|
|
212
|
+
if (((_c = lineItemLocalData.vendor) === null || _c === void 0 ? void 0 : _c.id) != null &&
|
|
192
213
|
currentSelectedEntityLine != null &&
|
|
193
214
|
currentSelectedEntityLine.type === 'vendor') {
|
|
194
215
|
return {
|
|
@@ -198,44 +219,3 @@ const getEntityDetails = (entity, lineItemLocalData, vendorUpdates, customerUpda
|
|
|
198
219
|
}
|
|
199
220
|
return undefined;
|
|
200
221
|
};
|
|
201
|
-
const getEntityFromTransaction = (transaction, currentSelectedEntity) => {
|
|
202
|
-
if ((0, vendorTransaction_1.isVendorTransaction)(transaction)) {
|
|
203
|
-
const vendor = transaction.vendor;
|
|
204
|
-
const customer = transaction.customer;
|
|
205
|
-
if (customer != null &&
|
|
206
|
-
currentSelectedEntity != null &&
|
|
207
|
-
currentSelectedEntity.type === 'customer') {
|
|
208
|
-
return {
|
|
209
|
-
id: customer.id,
|
|
210
|
-
name: customer.name,
|
|
211
|
-
type: (0, entity_1.toEntityType)('customer'),
|
|
212
|
-
qboId: customer.id,
|
|
213
|
-
zeniId: customer.id,
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
if (vendor != null &&
|
|
217
|
-
currentSelectedEntity != null &&
|
|
218
|
-
currentSelectedEntity.type === 'vendor') {
|
|
219
|
-
return {
|
|
220
|
-
id: vendor.id,
|
|
221
|
-
name: vendor.name,
|
|
222
|
-
type: (0, entity_1.toEntityType)('vendor'),
|
|
223
|
-
qboId: vendor.id,
|
|
224
|
-
zeniId: vendor.id,
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
if ((0, customerTransaction_1.isCustomerTransaction)(transaction)) {
|
|
229
|
-
const customerEntity = transaction.customer;
|
|
230
|
-
if (customerEntity != null) {
|
|
231
|
-
return {
|
|
232
|
-
id: customerEntity.id,
|
|
233
|
-
name: customerEntity.name,
|
|
234
|
-
type: (0, entity_1.toEntityType)('customer'),
|
|
235
|
-
qboId: customerEntity.id,
|
|
236
|
-
zeniId: customerEntity.id,
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
return undefined;
|
|
241
|
-
};
|
|
@@ -39,6 +39,7 @@ const toTransactionDetailLocalData = (transaction) => {
|
|
|
39
39
|
type: 'vendor',
|
|
40
40
|
qboId: transaction.vendorId,
|
|
41
41
|
zeniId: transaction.vendorId,
|
|
42
|
+
logo: transaction.logo,
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
45
|
if ((0, vendorTransaction_1.isVendorTransaction)(transaction) &&
|
|
@@ -50,6 +51,7 @@ const toTransactionDetailLocalData = (transaction) => {
|
|
|
50
51
|
type: 'customer',
|
|
51
52
|
qboId: transaction.customerId,
|
|
52
53
|
zeniId: transaction.customerId,
|
|
54
|
+
logo: transaction.logo,
|
|
53
55
|
};
|
|
54
56
|
}
|
|
55
57
|
transactionLocal.vendorUpdates = undefined;
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isAccountUncategorized = exports.isTransactionUncategorized = exports.isTransactionMiscategorized = exports.toRecommendedClassBase = exports.toRecommendedAccountBase = exports.toTransactionUpdatesFromTransactionDetailLocalData = void 0;
|
|
4
4
|
const recommendationBase_1 = require("../../../commonStateTypes/recommendationBase");
|
|
5
|
-
const entity_1 = require("../../../entity/genericEntity/entity");
|
|
6
|
-
const customerTransaction_1 = require("../../../entity/transaction/stateTypes/customerTransaction");
|
|
7
5
|
const transactionType_1 = require("../../../entity/transaction/stateTypes/transactionType");
|
|
8
6
|
const vendorTransaction_1 = require("../../../entity/transaction/stateTypes/vendorTransaction");
|
|
9
7
|
const recommendationState_1 = require("../../recommendation/recommendationState");
|
|
@@ -49,13 +47,12 @@ const toTransactionUpdatesFromTransactionDetailLocalData = (transactionDetailLoc
|
|
|
49
47
|
updates.customerId = selectedEntity.id;
|
|
50
48
|
}
|
|
51
49
|
let isBulkUpdate = false;
|
|
52
|
-
const entity = getEntityFromTransaction(transaction, selectedEntity);
|
|
53
50
|
let lastUpdatedCategory;
|
|
54
51
|
let lastUpdatedClass;
|
|
55
52
|
// single recommendation to just pick the last recommendation in the list of lines
|
|
56
53
|
(_b = transaction.lines) === null || _b === void 0 ? void 0 : _b.forEach((line) => {
|
|
57
54
|
var _a, _b, _c, _d, _e, _f;
|
|
58
|
-
const entityDetails = getEntityDetails(
|
|
55
|
+
const entityDetails = getEntityDetails(selectedEntity, transactionDetailLocalData.lineItemById[line.id], transactionDetailLocalData.vendorUpdates, transactionDetailLocalData.customerUpdates);
|
|
59
56
|
if (line.type === 'transaction_with_account_and_class_line' ||
|
|
60
57
|
line.type === 'transaction_with_product_or_service_line' ||
|
|
61
58
|
line.type === 'journal_entry_transaction_line') {
|
|
@@ -68,7 +65,14 @@ const toTransactionUpdatesFromTransactionDetailLocalData = (transactionDetailLoc
|
|
|
68
65
|
};
|
|
69
66
|
if (line.type === 'journal_entry_transaction_line' ||
|
|
70
67
|
line.platformLineDetailType === 'deposit_line_detail') {
|
|
71
|
-
|
|
68
|
+
const currentSelectedEntityLine = lineItem.lineEntity;
|
|
69
|
+
updatesByLineId[line.id] = Object.assign(Object.assign({}, updatesByLineId[line.id]), { customer: currentSelectedEntityLine != null &&
|
|
70
|
+
currentSelectedEntityLine.type === 'customer'
|
|
71
|
+
? lineItem.customer
|
|
72
|
+
: undefined, vendor: currentSelectedEntityLine != null &&
|
|
73
|
+
currentSelectedEntityLine.type === 'vendor'
|
|
74
|
+
? lineItem.vendor
|
|
75
|
+
: undefined });
|
|
72
76
|
}
|
|
73
77
|
let hasCategoryChanged = false;
|
|
74
78
|
let hasClassChanged = false;
|
|
@@ -195,62 +199,21 @@ const toRecommendedClassBase = (amountValue, classBase, recommendationBase) => {
|
|
|
195
199
|
}
|
|
196
200
|
};
|
|
197
201
|
exports.toRecommendedClassBase = toRecommendedClassBase;
|
|
198
|
-
const getVendorOrCustomerDetails = (
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
let entity = undefined;
|
|
214
|
-
if ((0, vendorTransaction_1.isVendorTransaction)(transaction)) {
|
|
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,
|
|
234
|
-
type: (0, entity_1.toEntityType)('vendor'),
|
|
235
|
-
qboId: vendor.id,
|
|
236
|
-
zeniId: vendor.id,
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
if ((0, customerTransaction_1.isCustomerTransaction)(transaction)) {
|
|
241
|
-
const customerEntity = transaction.customer;
|
|
242
|
-
if (customerEntity != null) {
|
|
243
|
-
entity = {
|
|
244
|
-
id: customerEntity.id,
|
|
245
|
-
name: customerEntity.name,
|
|
246
|
-
type: (0, entity_1.toEntityType)('customer'),
|
|
247
|
-
qboId: customerEntity.id,
|
|
248
|
-
zeniId: customerEntity.id,
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
return entity;
|
|
253
|
-
};
|
|
202
|
+
// const getVendorOrCustomerDetails = (
|
|
203
|
+
// lineItem: TransactionDetailLineItemData
|
|
204
|
+
// ) => {
|
|
205
|
+
// if (lineItem.lineEntity != null) {
|
|
206
|
+
// const lineEntity = lineItem.lineEntity;
|
|
207
|
+
// const type = lineItem.vendor != null ? 'vendor' : 'customer';
|
|
208
|
+
// return {
|
|
209
|
+
// [type]: {
|
|
210
|
+
// name: lineEntity?.name,
|
|
211
|
+
// id: lineEntity?.qboId ?? lineEntity?.id, // For vendor we don't have qbo_id in VendorBase so using id instead
|
|
212
|
+
// },
|
|
213
|
+
// };
|
|
214
|
+
// }
|
|
215
|
+
// return {};
|
|
216
|
+
// };
|
|
254
217
|
const getEntityDetails = (entity, lineItemLocalData, vendorUpdates, customerUpdates) => {
|
|
255
218
|
var _a, _b, _c, _d;
|
|
256
219
|
if (entity != null) {
|
|
@@ -156,7 +156,7 @@ function preparePayload(transactionState, vendorState, transactionDetailState, t
|
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
158
|
if (detail != null) {
|
|
159
|
-
const transUpdates = toTransactionUpdatePayload(saveUpdates.updates, detail, vendorUpdates, customerUpdates);
|
|
159
|
+
const transUpdates = toTransactionUpdatePayload(saveUpdates.updates, detail, vendorUpdates, customerUpdates, currentSelectedEntity);
|
|
160
160
|
const entityUpdates = toEntityUpdatePayload(saveUpdates.entityRelatedUpdates);
|
|
161
161
|
return {
|
|
162
162
|
entity_related_updates: entityUpdates,
|
|
@@ -166,7 +166,7 @@ function preparePayload(transactionState, vendorState, transactionDetailState, t
|
|
|
166
166
|
}
|
|
167
167
|
return undefined;
|
|
168
168
|
}
|
|
169
|
-
const toTransactionUpdatePayload = (updates, detail, vendorUpdates, customerUpdates) => {
|
|
169
|
+
const toTransactionUpdatePayload = (updates, detail, vendorUpdates, customerUpdates, tranSelectedEntity) => {
|
|
170
170
|
var _a, _b;
|
|
171
171
|
const transaction = Object.assign({}, detail);
|
|
172
172
|
transaction.memo = (_a = updates.memo) !== null && _a !== void 0 ? _a : '';
|
|
@@ -210,8 +210,8 @@ const toTransactionUpdatePayload = (updates, detail, vendorUpdates, customerUpda
|
|
|
210
210
|
return (0, customerTransactionPayload_1.toCustomerTransactionPayload)(transaction);
|
|
211
211
|
}
|
|
212
212
|
else if ((0, vendorTransaction_1.isVendorTransaction)(transaction)) {
|
|
213
|
-
if (
|
|
214
|
-
return (0, vendorTransactionPayload_1.toVendorTransactionWithCustomerPayload)(transaction,
|
|
213
|
+
if (tranSelectedEntity != null && tranSelectedEntity.type === 'customer') {
|
|
214
|
+
return (0, vendorTransactionPayload_1.toVendorTransactionWithCustomerPayload)(transaction, customerUpdates);
|
|
215
215
|
}
|
|
216
216
|
else {
|
|
217
217
|
return (0, vendorTransactionPayload_1.toVendorTransactionPayload)(transaction, vendorUpdates);
|
|
@@ -453,7 +453,6 @@ const toSetAllLineItemsToCategoryClass = (transaction, transactionDetailLocalDat
|
|
|
453
453
|
record.postingType = lineRecord.postingType;
|
|
454
454
|
record.postingTypeName = lineRecord.postingTypeName;
|
|
455
455
|
record.lineEntity = (0, exports.toLineEntity)(lineRecord);
|
|
456
|
-
record.selectedEntityLine = (0, exports.toLineEntity)(lineRecord);
|
|
457
456
|
}
|
|
458
457
|
newLineItems[lineId] = record;
|
|
459
458
|
}
|
|
@@ -520,10 +519,8 @@ const setEntityRecommendationForLineIdInLocalData = (transaction, transactionDet
|
|
|
520
519
|
if (checkIfNotJEAndDeposit === true) {
|
|
521
520
|
record.customer = accountLine.customer;
|
|
522
521
|
record.vendor = accountLine.vendor;
|
|
523
|
-
record.selectedEntityLine = entity;
|
|
524
522
|
}
|
|
525
523
|
else {
|
|
526
|
-
record.selectedEntityLine = entity;
|
|
527
524
|
record.lineEntity = entity;
|
|
528
525
|
record.vendor = undefined;
|
|
529
526
|
record.customer = undefined;
|
|
@@ -653,7 +650,7 @@ const removeEntityRecommendationForLineIdInLocalData = (transaction, transaction
|
|
|
653
650
|
}
|
|
654
651
|
});
|
|
655
652
|
}
|
|
656
|
-
const newLocalData = Object.assign(Object.assign({}, transactionDetailState_1.initialSupportedTransactionDetail.transactionDetailLocalData), { memo: transactionDetailLocalData.memo, lineItemById: newLineItems, vendorDetails: transactionDetailLocalData.vendorDetails, vendorUpdates: transactionDetailLocalData.vendorUpdates, customerUpdates: transactionDetailLocalData.customerUpdates, customerDetails: transactionDetailLocalData.customerDetails, updatePreviousTransactionsWithUpdatedVendor: transactionDetailLocalData.updatePreviousTransactionsWithUpdatedVendor, isVendorUpdateAllChecked: transactionDetailLocalData.isVendorUpdateAllChecked, latestSelectedEntityOnLineItem: transactionDetailLocalData.latestSelectedEntityOnLineItem, latestUpdatedLineWithEntity: transactionDetailLocalData.latestUpdatedLineWithEntity });
|
|
653
|
+
const newLocalData = Object.assign(Object.assign({}, transactionDetailState_1.initialSupportedTransactionDetail.transactionDetailLocalData), { memo: transactionDetailLocalData.memo, lineItemById: newLineItems, vendorDetails: transactionDetailLocalData.vendorDetails, vendorUpdates: transactionDetailLocalData.vendorUpdates, customerUpdates: transactionDetailLocalData.customerUpdates, customerDetails: transactionDetailLocalData.customerDetails, updatePreviousTransactionsWithUpdatedVendor: transactionDetailLocalData.updatePreviousTransactionsWithUpdatedVendor, isVendorUpdateAllChecked: transactionDetailLocalData.isVendorUpdateAllChecked, latestSelectedEntityOnLineItem: transactionDetailLocalData.latestSelectedEntityOnLineItem, latestUpdatedLineWithEntity: transactionDetailLocalData.latestUpdatedLineWithEntity, selectedEntity: transactionDetailLocalData.selectedEntity });
|
|
657
654
|
return newLocalData;
|
|
658
655
|
};
|
|
659
656
|
exports.removeEntityRecommendationForLineIdInLocalData = removeEntityRecommendationForLineIdInLocalData;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.15.
|
|
3
|
+
"version": "4.15.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",
|