@zeniai/client-epic-state 4.18.67 → 4.18.68

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.
@@ -39,6 +39,7 @@ const toRecommendedVendorBasePayload = (vendorRecommendation) => {
39
39
  var _a, _b, _c, _d, _e;
40
40
  return {
41
41
  vendor_name: vendorRecommendation.name,
42
+ vendor_name_confidence: vendorRecommendation.vendorNameConfidence,
42
43
  third_party_merchant_id: vendorRecommendation.thirdPartyMerchantId,
43
44
  vendor_id: (_a = vendorRecommendation.id) !== null && _a !== void 0 ? _a : null,
44
45
  qbo_id: (_b = vendorRecommendation.qboId) !== null && _b !== void 0 ? _b : null,
@@ -40,7 +40,7 @@ const updateTransactionCategorizationEpic = (actions$, state$, zeniAPI) => actio
40
40
  }));
41
41
  exports.updateTransactionCategorizationEpic = updateTransactionCategorizationEpic;
42
42
  function prepareTransactionPayload(selectedTab, transactionState, vendorState, transactionsViewState, transactionId, saveUpdates, cotTrackingByTransactionId) {
43
- var _a, _b, _c;
43
+ var _a, _b, _c, _d;
44
44
  const detail = (0, transactionSelector_1.getSupportedTransactionById)(transactionState, transactionId);
45
45
  const tranDetail = (0, get_1.default)(transactionsViewState.transactionCategorizationView[selectedTab]
46
46
  .transactionReviewLocalDataById, transactionId, undefined);
@@ -52,18 +52,13 @@ function prepareTransactionPayload(selectedTab, transactionState, vendorState, t
52
52
  tranSelectedEntity != null &&
53
53
  tranSelectedEntity.type === 'vendor') {
54
54
  const vendor = (0, vendorSelector_1.getVendorByVendorId)(vendorState, tranVendorUpdates.qboId);
55
- if (vendor != null) {
56
- vendorUpdates = {
57
- id: vendor.qboId,
58
- name: vendor.name,
59
- };
60
- }
61
- else {
62
- vendorUpdates = {
63
- id: tranVendorUpdates.qboId,
64
- name: tranVendorUpdates.name,
65
- };
66
- }
55
+ const vendorSource = vendor !== null && vendor !== void 0 ? vendor : tranVendorUpdates;
56
+ vendorUpdates = {
57
+ id: vendorSource.qboId === vendorSource.name
58
+ ? ''
59
+ : ((_d = vendorSource.qboId) !== null && _d !== void 0 ? _d : ''),
60
+ name: vendorSource.name,
61
+ };
67
62
  }
68
63
  let customerUpdates = undefined;
69
64
  if (tranSelectedEntity != null && tranSelectedEntity.type === 'customer') {
@@ -195,6 +190,11 @@ const toEntityUpdatePayload = (entityUpdates) => {
195
190
  is_bulk_update: entityUpdate.isBulkUpdate,
196
191
  updated_entity_id: entityUpdate.updatedEntityId,
197
192
  };
193
+ // Add vendor_name if it's a vendor entity and name is provided
194
+ if (entityUpdate.entityType === 'vendor' &&
195
+ entityUpdate.vendorName != null) {
196
+ entityUpdatePayload.vendor_name = entityUpdate.vendorName;
197
+ }
198
198
  entityUpdatesPayload.push(entityUpdatePayload);
199
199
  }
200
200
  return entityUpdatesPayload;
@@ -82,7 +82,7 @@ const toTransactionUpdatesFromTransactionCategorizationLocalData = (transactionC
82
82
  };
83
83
  if (recommended.class != null || recommended.account != null) {
84
84
  const entityId = entityDetails.entityId;
85
- doUpdateEntityUpdates(entityUpdates, entityId, entityDetails.entityType, recommended, false, undefined);
85
+ doUpdateEntityUpdates(entityUpdates, entityId, entityDetails.entityType, recommended, false, undefined, entityDetails.entityName);
86
86
  }
87
87
  }
88
88
  }
@@ -103,35 +103,36 @@ const toTransactionUpdatesFromTransactionCategorizationLocalData = (transactionC
103
103
  };
104
104
  };
105
105
  exports.toTransactionUpdatesFromTransactionCategorizationLocalData = toTransactionUpdatesFromTransactionCategorizationLocalData;
106
- const doUpdateEntityUpdates = (entityUpdates, entityId, entityType, recommendation, isBulkUpdate = false, updatedEntityId) => {
106
+ const doUpdateEntityUpdates = (entityUpdates, entityId, entityType, recommendation, isBulkUpdate = false, updatedEntityId, entityName) => {
107
107
  // see if this entity is already being updated
108
108
  const entityKey = (0, recommendationState_1.getEntityRecommendationKey)(entityType, entityId);
109
109
  const entityUpdate = entityUpdates[entityKey];
110
+ const commonUpdate = Object.assign({ recommendations: recommendation, entityId: entityId === entityName ? null : entityId }, (entityType === 'vendor' && entityName != null
111
+ ? { vendorName: entityName }
112
+ : {}));
110
113
  if (entityUpdate == null) {
111
- entityUpdates[entityKey] = {
112
- entityId,
113
- entityType,
114
- recommendations: recommendation,
114
+ entityUpdates[entityKey] = Object.assign({ entityType,
115
115
  isBulkUpdate,
116
- updatedEntityId,
117
- };
116
+ updatedEntityId }, commonUpdate);
118
117
  }
119
118
  else {
120
- entityUpdates[entityKey] = Object.assign(Object.assign({}, entityUpdate), { recommendations: recommendation });
119
+ entityUpdates[entityKey] = Object.assign(Object.assign({}, entityUpdate), commonUpdate);
121
120
  }
122
121
  };
123
122
  const getEntityDetails = (entity, lineItemLocalData, vendorUpdates, customerUpdates, currentSelectedEntityLine) => {
124
- var _a, _b, _c, _d, _e, _f;
123
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
125
124
  if (entity != null) {
126
125
  return {
127
126
  entityId: (_a = entity.qboId) !== null && _a !== void 0 ? _a : entity.id,
128
127
  entityType: entity.type,
128
+ entityName: entity.name,
129
129
  };
130
130
  }
131
- if (vendorUpdates != null && vendorUpdates.id != null) {
131
+ if (vendorUpdates != null) {
132
132
  return {
133
- entityId: vendorUpdates.id,
133
+ entityId: (_c = (_b = vendorUpdates.qboId) !== null && _b !== void 0 ? _b : vendorUpdates.id) !== null && _c !== void 0 ? _c : vendorUpdates.name,
134
134
  entityType: 'vendor',
135
+ entityName: vendorUpdates.name,
135
136
  };
136
137
  }
137
138
  if (customerUpdates != null && customerUpdates.id != null) {
@@ -142,24 +143,25 @@ const getEntityDetails = (entity, lineItemLocalData, vendorUpdates, customerUpda
142
143
  }
143
144
  if (lineItemLocalData.lineEntity != null) {
144
145
  return {
145
- entityId: (_b = lineItemLocalData.lineEntity.qboId) !== null && _b !== void 0 ? _b : lineItemLocalData.lineEntity.id,
146
+ entityId: (_d = lineItemLocalData.lineEntity.qboId) !== null && _d !== void 0 ? _d : lineItemLocalData.lineEntity.id,
146
147
  entityType: lineItemLocalData.vendor != null ? 'vendor' : 'customer',
148
+ entityName: lineItemLocalData.lineEntity.name,
147
149
  };
148
150
  }
149
- if (((_c = lineItemLocalData.customer) === null || _c === void 0 ? void 0 : _c.id) != null &&
151
+ if (((_e = lineItemLocalData.customer) === null || _e === void 0 ? void 0 : _e.id) != null &&
150
152
  currentSelectedEntityLine != null &&
151
153
  currentSelectedEntityLine.type === 'customer') {
152
154
  return {
153
- entityId: (_d = currentSelectedEntityLine.qboId) !== null && _d !== void 0 ? _d : lineItemLocalData.customer.id,
155
+ entityId: (_f = currentSelectedEntityLine.qboId) !== null && _f !== void 0 ? _f : lineItemLocalData.customer.id,
154
156
  entityType: 'customer',
155
157
  };
156
158
  }
157
- if (((_e = lineItemLocalData.vendor) === null || _e === void 0 ? void 0 : _e.id) != null &&
158
- currentSelectedEntityLine != null &&
159
+ if (currentSelectedEntityLine != null &&
159
160
  currentSelectedEntityLine.type === 'vendor') {
160
161
  return {
161
- entityId: (_f = currentSelectedEntityLine.qboId) !== null && _f !== void 0 ? _f : lineItemLocalData.vendor.id,
162
+ entityId: (_g = currentSelectedEntityLine.qboId) !== null && _g !== void 0 ? _g : (_h = lineItemLocalData.vendor) === null || _h === void 0 ? void 0 : _h.id,
162
163
  entityType: 'vendor',
164
+ entityName: (_j = currentSelectedEntityLine.name) !== null && _j !== void 0 ? _j : (_k = lineItemLocalData.vendor) === null || _k === void 0 ? void 0 : _k.name,
163
165
  };
164
166
  }
165
167
  return undefined;
@@ -20,11 +20,12 @@ export interface TransactionCategorizationPayload {
20
20
  }
21
21
  export type TransactionCategorizationResponse = ZeniAPIResponse<TransactionCategorizationPayload>;
22
22
  export interface EntityRelatedUpdatesPayload {
23
- entity_id: string;
23
+ entity_id: string | null;
24
24
  entity_type: string;
25
25
  is_bulk_update: boolean;
26
26
  recommendations: EntityRecommendationPayload;
27
27
  updated_entity_id: string | undefined;
28
+ vendor_name?: string;
28
29
  }
29
30
  export interface UpdateTransactionCategorizationPayload {
30
31
  transaction: Partial<TransactionPayload>;
@@ -117,11 +117,12 @@ export interface TransactionUpdates {
117
117
  vendorId?: ID;
118
118
  }
119
119
  export interface EntityRelatedRecommendationUpdates {
120
- entityId: ID;
120
+ entityId: ID | null;
121
121
  entityType: EntityType;
122
122
  isBulkUpdate: boolean;
123
123
  recommendations: Recommendation;
124
124
  updatedEntityId: ID | undefined;
125
+ vendorName?: string;
125
126
  }
126
127
  export interface TransactionSaveUpdates {
127
128
  anyBulkUpdates: boolean;
@@ -134,7 +134,7 @@ const toTransactionUpdatesFromTransactionDetailLocalData = (transactionDetailLoc
134
134
  entityId = customerIdToUpdate;
135
135
  }
136
136
  }
137
- doUpdateEntityUpdates(entityUpdates, entityId, entityDetails.entityType, recommended, lineItem.isUpdateAllChecked, updatedEntityId);
137
+ doUpdateEntityUpdates(entityUpdates, entityId, entityDetails.entityType, recommended, lineItem.isUpdateAllChecked, updatedEntityId, entityDetails.entityName);
138
138
  }
139
139
  }
140
140
  }
@@ -153,21 +153,20 @@ const toTransactionUpdatesFromTransactionDetailLocalData = (transactionDetailLoc
153
153
  };
154
154
  };
155
155
  exports.toTransactionUpdatesFromTransactionDetailLocalData = toTransactionUpdatesFromTransactionDetailLocalData;
156
- const doUpdateEntityUpdates = (entityUpdates, entityId, entityType, recommendation, isBulkUpdate = false, updatedEntityId) => {
156
+ const doUpdateEntityUpdates = (entityUpdates, entityId, entityType, recommendation, isBulkUpdate = false, updatedEntityId, entityName) => {
157
157
  // see if this entity is already being updated
158
- const entityKey = (0, recommendationState_1.getEntityRecommendationKey)(entityType, entityId);
158
+ const entityKey = (0, recommendationState_1.getEntityRecommendationKey)(entityType, entityId !== null && entityId !== void 0 ? entityId : entityName);
159
159
  const entityUpdate = entityUpdates[entityKey];
160
+ const commonUpdate = Object.assign({ recommendations: recommendation, entityId: entityId === entityName ? null : entityId }, (entityType === 'vendor' && entityName != null
161
+ ? { vendorName: entityName }
162
+ : {}));
160
163
  if (entityUpdate == null) {
161
- entityUpdates[entityKey] = {
162
- entityId,
163
- entityType,
164
- recommendations: recommendation,
164
+ entityUpdates[entityKey] = Object.assign({ entityType,
165
165
  isBulkUpdate,
166
- updatedEntityId,
167
- };
166
+ updatedEntityId }, commonUpdate);
168
167
  }
169
168
  else {
170
- entityUpdates[entityKey] = Object.assign(Object.assign({}, entityUpdate), { recommendations: recommendation });
169
+ entityUpdates[entityKey] = Object.assign(Object.assign({}, entityUpdate), commonUpdate);
171
170
  }
172
171
  };
173
172
  const toRecommendedAccountBase = (amountValue, accountBase, recommendationBase) => {
@@ -199,17 +198,19 @@ const toRecommendedClassBase = (amountValue, classBase, recommendationBase) => {
199
198
  };
200
199
  exports.toRecommendedClassBase = toRecommendedClassBase;
201
200
  const getEntityDetails = (entity, lineItemLocalData, vendorUpdates, customerUpdates) => {
202
- var _a, _b;
201
+ var _a, _b, _c, _d;
203
202
  if (entity != null) {
204
203
  return {
205
204
  entityId: (_a = entity.qboId) !== null && _a !== void 0 ? _a : entity.id,
206
205
  entityType: entity.type,
206
+ entityName: entity.name,
207
207
  };
208
208
  }
209
209
  if (lineItemLocalData.lineEntity != null) {
210
210
  return {
211
211
  entityId: (_b = lineItemLocalData.lineEntity.qboId) !== null && _b !== void 0 ? _b : lineItemLocalData.lineEntity.id,
212
212
  entityType: lineItemLocalData.lineEntity.type,
213
+ entityName: lineItemLocalData.lineEntity.name,
213
214
  };
214
215
  }
215
216
  if (customerUpdates != null &&
@@ -220,10 +221,11 @@ const getEntityDetails = (entity, lineItemLocalData, vendorUpdates, customerUpda
220
221
  entityType: 'customer',
221
222
  };
222
223
  }
223
- if (vendorUpdates != null && vendorUpdates.id != null) {
224
+ if (vendorUpdates != null) {
224
225
  return {
225
- entityId: vendorUpdates.id,
226
+ entityId: (_d = (_c = vendorUpdates.qboId) !== null && _c !== void 0 ? _c : vendorUpdates.id) !== null && _d !== void 0 ? _d : vendorUpdates.name,
226
227
  entityType: 'vendor',
228
+ entityName: vendorUpdates.name,
227
229
  };
228
230
  }
229
231
  return undefined;
@@ -123,6 +123,7 @@ const updateTransactionDetailEpic = (actions$, state$, zeniAPI) => actions$.pipe
123
123
  }));
124
124
  exports.updateTransactionDetailEpic = updateTransactionDetailEpic;
125
125
  function preparePayload(transactionState, vendorState, transactionDetailState, transactionId, saveUpdates, cotTransactionTracking) {
126
+ var _a;
126
127
  const transactionDetailKey = (0, transactionDetailState_1.getTransactionDetailKey)(transactionId);
127
128
  const detail = (0, transactionSelector_1.getSupportedTransactionById)(transactionState, transactionDetailKey);
128
129
  const tranDetail = (0, get_1.default)(transactionDetailState.transactionDetailById, transactionDetailKey, undefined);
@@ -134,16 +135,13 @@ function preparePayload(transactionState, vendorState, transactionDetailState, t
134
135
  currentSelectedEntity != null &&
135
136
  currentSelectedEntity.type === 'vendor') {
136
137
  const vendor = (0, vendorSelector_1.getVendorByVendorId)(vendorState, tranVendorUpdates.qboId);
137
- if (vendor != null) {
138
+ const vendorSource = vendor !== null && vendor !== void 0 ? vendor : ((tranVendorUpdates === null || tranVendorUpdates === void 0 ? void 0 : tranVendorUpdates.name) != null ? tranVendorUpdates : undefined);
139
+ if (vendorSource) {
138
140
  vendorUpdates = {
139
- id: vendor === null || vendor === void 0 ? void 0 : vendor.qboId,
140
- name: vendor === null || vendor === void 0 ? void 0 : vendor.name,
141
- };
142
- }
143
- else if (tranVendorUpdates.name != null) {
144
- vendorUpdates = {
145
- id: tranVendorUpdates.qboId,
146
- name: tranVendorUpdates.name,
141
+ id: vendorSource.qboId === vendorSource.name
142
+ ? ''
143
+ : ((_a = vendorSource.qboId) !== null && _a !== void 0 ? _a : ''),
144
+ name: vendorSource.name,
147
145
  };
148
146
  }
149
147
  }
@@ -276,6 +274,11 @@ const toEntityUpdatePayload = (entityUpdates) => {
276
274
  is_bulk_update: entityUpdate.isBulkUpdate,
277
275
  updated_entity_id: entityUpdate.updatedEntityId,
278
276
  };
277
+ // Add vendor_name if it's a vendor entity and name is provided
278
+ if (entityUpdate.entityType === 'vendor' &&
279
+ entityUpdate.vendorName != null) {
280
+ entityUpdatePayload.vendor_name = entityUpdate.vendorName;
281
+ }
279
282
  entityUpdatesPayload.push(entityUpdatePayload);
280
283
  }
281
284
  return entityUpdatesPayload;
@@ -14,11 +14,13 @@ interface TransactionDetailPayload {
14
14
  }
15
15
  export type TransactionDetailResponse = ZeniAPIResponse<TransactionDetailPayload>;
16
16
  export interface EntityRelatedUpdatesPayload {
17
- entity_id: string;
17
+ entity_id: string | null;
18
18
  entity_type: string;
19
19
  is_bulk_update: boolean;
20
20
  recommendations: EntityRecommendationPayload;
21
21
  updated_entity_id: string | undefined;
22
+ customer_name?: string;
23
+ vendor_name?: string;
22
24
  }
23
25
  export interface UpdateTransactionDetailPayload {
24
26
  transaction: Partial<TransactionPayload>;
@@ -531,11 +531,12 @@ const transactionDetail = (0, toolkit_1.createSlice)({
531
531
  _a = transactionDetail.actions, exports.downloadAccountingProviderAttachment = _a.downloadAccountingProviderAttachment, exports.downloadAccountingProviderAttachmentSuccess = _a.downloadAccountingProviderAttachmentSuccess, exports.downloadAccountingProviderAttachmentFailure = _a.downloadAccountingProviderAttachmentFailure, exports.fetchTransactionDetail = _a.fetchTransactionDetail, exports.updateTransactionDetailFetchState = _a.updateTransactionDetailFetchState, exports.removeTransactionDetail = _a.removeTransactionDetail, exports.clearTransactionDetail = _a.clearTransactionDetail, exports.uploadMissingAttachmentSuccess = _a.uploadMissingAttachmentSuccess, exports.updateTransactionDetail = _a.updateTransactionDetail, exports.updateTransactionDetailSaveStatus = _a.updateTransactionDetailSaveStatus, exports.clearTransactionDetailSaveStatus = _a.clearTransactionDetailSaveStatus, exports.markTransactionAsNotMiscategorized = _a.markTransactionAsNotMiscategorized, exports.deleteTransactionAttachment = _a.deleteTransactionAttachment, exports.deleteTransactionAttachmentFailure = _a.deleteTransactionAttachmentFailure, exports.deleteTransactionAttachmentSuccess = _a.deleteTransactionAttachmentSuccess, exports.updateStatusForTransactionNotMiscategorizedUpdate = _a.updateStatusForTransactionNotMiscategorizedUpdate, exports.updateStatusConsolidatedSaveTransactionDetail = _a.updateStatusConsolidatedSaveTransactionDetail, exports.updateTransactionStateIfUpdateActionNotAllowed = _a.updateTransactionStateIfUpdateActionNotAllowed, exports.saveTransactionDetail = _a.saveTransactionDetail, exports.initializeTransactionDetailLocalData = _a.initializeTransactionDetailLocalData, exports.saveTransactionDetailLocalData = _a.saveTransactionDetailLocalData, exports.clearTransactionDetailLocalData = _a.clearTransactionDetailLocalData, exports.resetLineItemsCategoryClassInLocalData = _a.resetLineItemsCategoryClassInLocalData, exports.setAllLineItemsToCategoryClassInLocalData = _a.setAllLineItemsToCategoryClassInLocalData, exports.setAllLineItemsLocalDataIsUpdateAllChecked = _a.setAllLineItemsLocalDataIsUpdateAllChecked, exports.setEntityRecommendationForLineIdsForTransactionDetail = _a.setEntityRecommendationForLineIdsForTransactionDetail, exports.removeEntityRecommendationForLineIdForTransactionDetail = _a.removeEntityRecommendationForLineIdForTransactionDetail, exports.updateSelectedVendor = _a.updateSelectedVendor, exports.updateSelectedCustomer = _a.updateSelectedCustomer, exports.resetVendor = _a.resetVendor, exports.resetSelectedCustomer = _a.resetSelectedCustomer, exports.updateLocalDataWithTransactionsUpdateWithVendorCheckbox = _a.updateLocalDataWithTransactionsUpdateWithVendorCheckbox, exports.updateVendorToAllLineItems = _a.updateVendorToAllLineItems, exports.resetAllLineItemsToVendor = _a.resetAllLineItemsToVendor, exports.updateLatestSelectedEntity = _a.updateLatestSelectedEntity, exports.updateVendorBulkRecommendationsFetchStatus = _a.updateVendorBulkRecommendationsFetchStatus, exports.setIsVendorUpdateAllChecked = _a.setIsVendorUpdateAllChecked;
532
532
  exports.default = transactionDetail.reducer;
533
533
  function getUpdatedEntityLocalData(detail, updates, entity, resetRecommendations, type) {
534
+ var _a, _b, _c, _d;
534
535
  const key = type === 'customer' ? 'customerUpdates' : 'vendorUpdates';
535
536
  const transactionDetailLocalData = Object.assign(Object.assign({}, detail), { [key]: {
536
537
  name: updates.name,
537
- id: updates.id,
538
- qboId: updates.qboId,
538
+ id: (_b = (_a = updates.id) !== null && _a !== void 0 ? _a : updates.name) !== null && _b !== void 0 ? _b : '',
539
+ qboId: (_d = (_c = updates.qboId) !== null && _c !== void 0 ? _c : updates.name) !== null && _d !== void 0 ? _d : '',
539
540
  }, selectedEntity: entity });
540
541
  if (resetRecommendations === true) {
541
542
  for (const key in transactionDetailLocalData.lineItemById) {
@@ -62,11 +62,12 @@ export interface TransactionUpdates {
62
62
  vendorId?: ID;
63
63
  }
64
64
  export interface EntityRelatedRecommendationUpdates {
65
- entityId: ID;
65
+ entityId: ID | null;
66
66
  entityType: EntityType;
67
67
  isBulkUpdate: boolean;
68
68
  recommendations: Recommendation;
69
69
  updatedEntityId: ID | undefined;
70
+ vendorName?: string;
70
71
  }
71
72
  export interface TransactionSaveUpdates {
72
73
  anyBulkUpdates: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.18.67",
3
+ "version": "4.18.68",
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",