@zeniai/client-epic-state 4.11.4 → 4.11.6

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.
@@ -257,7 +257,10 @@ const isTransactionMiscategorized = (transaction) => {
257
257
  line.type === 'transaction_with_product_or_service_line' ||
258
258
  line.type === 'journal_entry_transaction_line') {
259
259
  const lineItem = line;
260
- if (lineItem.isCategoryMiscategorized || lineItem.isClassMiscategorized) {
260
+ if (lineItem.isCategoryMiscategorized ||
261
+ lineItem.isClassMiscategorized ||
262
+ (lineItem.vendor == null && lineItem.customer == null) // This ensures that neither vendor or customer is present at line level, safe to say miscat line due to vendor/customer
263
+ ) {
261
264
  isTransactionMisCategorized = true;
262
265
  }
263
266
  }
@@ -30,10 +30,9 @@ const updateTransactionDetailEpic = (actions$, state$, zeniAPI) => actions$.pipe
30
30
  return zeniAPI
31
31
  .putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/${action.payload.transactionId.id}/categorize`, preparePayload(transactionState, vendorState, transactionDetailState, action.payload.transactionId, action.payload.transactionSaveUpdates))
32
32
  .pipe((0, operators_1.mergeMap)((response) => {
33
- var _a, _b, _c, _d, _e;
34
- if ((0, responsePayload_1.isSuccessResponse)(response)) {
35
- const transactionIdResp = (0, transactionIDPayload_1.toTransactionID)(response.data.transaction // eslint-disable-line @typescript-eslint/no-non-null-assertion
36
- );
33
+ var _a, _b;
34
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
35
+ const transactionIdResp = (0, transactionIDPayload_1.toTransactionID)(response.data.transaction);
37
36
  const transactionDetailKeyForResponse = (0, transactionDetailState_1.getTransactionDetailKey)(transactionIdResp);
38
37
  const tranDetail = (0, get_1.default)(transactionDetailState.transactionDetailById, transactionDetailKeyForResponse, undefined);
39
38
  const tranVendorUpdates = tranDetail === null || tranDetail === void 0 ? void 0 : tranDetail.transactionDetailLocalData.vendorUpdates;
@@ -54,22 +53,21 @@ const updateTransactionDetailEpic = (actions$, state$, zeniAPI) => actions$.pipe
54
53
  }
55
54
  }
56
55
  const actions = [];
57
- if (((_a = response.data) === null || _a === void 0 ? void 0 : _a.vendors) != null) {
56
+ if (response.data.vendors != null) {
58
57
  actions.push((0, vendorReducer_1.updateVendors)(response.data.vendors, 'merge'));
59
58
  }
60
- actions.push((0, transactionReducer_1.updateTransaction)(transactionDetailKeyForResponse,
61
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
62
- response.data.transaction));
59
+ actions.push((0, transactionReducer_1.updateTransaction)(transactionDetailKeyForResponse, response.data.transaction));
63
60
  actions.push((0, transactionDetailReducer_1.initializeTransactionDetailLocalData)({
64
61
  transactionId: transactionIdResp,
65
- vendorId: (_d = (_c = (_b = response.data) === null || _b === void 0 ? void 0 : _b.vendors) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.vendor_id,
62
+ vendorId: (_b = (_a = response.data.vendors) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.vendor_id,
66
63
  }));
67
64
  actions.push((0, transactionDetailReducer_1.updateTransactionDetailSaveStatus)(transactionIdResp, 'Completed'));
68
65
  let callMarkTransactionAsNotMiscategorized = true;
69
66
  // NOTE: If tran is vendorType transaction and there is no vendor chosen on this tranaction while saving,
70
67
  // then we need to skip mark-miscategorized-as-correct api call
71
- if ((0, transactionType_1.toVendorTransactionTypeStrict)((_e = response.data) === null || _e === void 0 ? void 0 : _e.transaction.transaction_type) != null) {
72
- if ((vendorUpdates === null || vendorUpdates === void 0 ? void 0 : vendorUpdates.id) == null) {
68
+ if ((0, transactionType_1.toVendorTransactionTypeStrict)(response.data.transaction.transaction_type) != null) {
69
+ const isAnyClassMissing = checkIfClassMissingForAnyLineItem(response.data.transaction);
70
+ if ((vendorUpdates === null || vendorUpdates === void 0 ? void 0 : vendorUpdates.id) == null || isAnyClassMissing == true) {
73
71
  callMarkTransactionAsNotMiscategorized = false;
74
72
  }
75
73
  }
@@ -196,6 +194,18 @@ const toTransactionUpdatePayload = (updates, detail, vendorUpdates) => {
196
194
  return (0, transactionPayload_1.toTransactionPayload)(transaction);
197
195
  }
198
196
  };
197
+ const checkIfClassMissingForAnyLineItem = (transactionPayload) => {
198
+ let isAnyClassMissing = false;
199
+ if ((transactionPayload === null || transactionPayload === void 0 ? void 0 : transactionPayload.lines) != null) {
200
+ transactionPayload.lines.forEach((line) => {
201
+ var _a;
202
+ if (((_a = line.line_detail) === null || _a === void 0 ? void 0 : _a.class.accounting_class_id) == null) {
203
+ isAnyClassMissing = true;
204
+ }
205
+ });
206
+ }
207
+ return isAnyClassMissing;
208
+ };
199
209
  const toEntityUpdatePayload = (entityUpdates) => {
200
210
  const entityUpdatesPayload = [];
201
211
  let entityKey;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.11.4",
3
+ "version": "4.11.6",
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",