@zeniai/client-epic-state 4.13.86 → 4.13.88

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.
@@ -16,7 +16,7 @@ const initializeTransactionCategorizationViewLocalDataEpic = (actions$, state$)
16
16
  const transactionLocalData = Object.assign({}, transactionReviewLocalDataById);
17
17
  const transactions = (0, transactionSelector_1.getSupportedTransactionsByIds)(transactionState, transactionIds);
18
18
  transactions.forEach((transaction) => {
19
- var _a, _b, _c, _d;
19
+ var _a, _b;
20
20
  const newTransactionsLocalData = (0, transactionCategorizationLocalDataHelper_1.toTransactionDetailLocalData)(transaction);
21
21
  if (transactionLocalData[transaction.id] == null) {
22
22
  transactionLocalData[transaction.id] = Object.assign(Object.assign({}, transactionsViewState_1.initialSupportedTransactionCategorization), { transactionId: transaction.id, transactionReviewLocalData: Object.assign(Object.assign({}, newTransactionsLocalData), { sortedLineItems: (_b = (_a = transaction.lines) === null || _a === void 0 ? void 0 : _a.map((line) => line.id)) !== null && _b !== void 0 ? _b : [] }) });
@@ -25,8 +25,8 @@ const initializeTransactionCategorizationViewLocalDataEpic = (actions$, state$)
25
25
  transactionLocalData[transaction.id] = {
26
26
  transactionId: transaction.id,
27
27
  transactionReviewLocalData: Object.assign(Object.assign({}, transactionLocalData[transaction.id]
28
- .transactionReviewLocalData), Object.assign(Object.assign({}, newTransactionsLocalData), { lineItemById: Object.assign(Object.assign({}, transactionLocalData[transaction.id]
29
- .transactionReviewLocalData.lineItemById), newTransactionsLocalData.lineItemById), sortedLineItems: transactionLocalData[transaction.id].transactionReviewLocalData.sortedLineItems.concat((_d = (_c = transaction.lines) === null || _c === void 0 ? void 0 : _c.map((line) => line.id)) !== null && _d !== void 0 ? _d : []) })),
28
+ .transactionReviewLocalData), Object.assign(Object.assign({}, newTransactionsLocalData), { lineItemById: Object.assign({}, mergeTransactionLineItems(transactionLocalData[transaction.id]
29
+ .transactionReviewLocalData.lineItemById, newTransactionsLocalData.lineItemById)), sortedLineItems: transactionLocalData[transaction.id].transactionReviewLocalData.sortedLineItems.concat(newTransactionsLocalData.sortedLineItems) })),
30
30
  };
31
31
  }
32
32
  });
@@ -43,3 +43,12 @@ const initializeTransactionCategorizationViewLocalDataEpic = (actions$, state$)
43
43
  return (0, rxjs_1.from)(fetchActions);
44
44
  }));
45
45
  exports.initializeTransactionCategorizationViewLocalDataEpic = initializeTransactionCategorizationViewLocalDataEpic;
46
+ // Better option to merge line items using this helper than merging inline to avoid overwriting the line items in future
47
+ // This function is used to merge the line items of a transaction so that the line items are not overwritten
48
+ function mergeTransactionLineItems(existingLineItems, newLineItems) {
49
+ const mergedLineItems = Object.assign({}, existingLineItems);
50
+ for (const id of Object.keys(newLineItems)) {
51
+ mergedLineItems[id] = Object.assign(Object.assign({}, existingLineItems[id]), newLineItems[id]);
52
+ }
53
+ return mergedLineItems;
54
+ }
@@ -26,6 +26,10 @@ const toTransactionDetailLocalData = (transaction) => {
26
26
  transaction.lines != null && transaction.lines.length > 0
27
27
  ? buildLineItemById(transaction, transaction.recommendations)
28
28
  : {};
29
+ transactionLocal.sortedLineItems =
30
+ transaction.lines != null && transaction.lines.length > 0
31
+ ? transaction.lines.map((line) => line.id)
32
+ : [];
29
33
  return transactionLocal;
30
34
  };
31
35
  exports.toTransactionDetailLocalData = toTransactionDetailLocalData;
@@ -168,7 +172,7 @@ const toSetAllLineItemsToCategoryClass = (draft, transaction, transactionId, tra
168
172
  }
169
173
  });
170
174
  }
171
- const newLocalData = Object.assign(Object.assign({}, transactionsViewState_1.initialSupportedTransactionCategorization.transactionReviewLocalData), { memo: transactionDetailLocalData.memo, lineItemById: newLineItems, transactionDate: transactionDetailLocalData.transactionDate, transactionType: transactionDetailLocalData.transactionType, transactionTypeName: transactionDetailLocalData.transactionTypeName, vendor: transactionDetailLocalData.vendor, vendorUpdates: transactionDetailLocalData.vendorUpdates, vendorDetails: transactionDetailLocalData.vendorDetails });
175
+ 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, vendorUpdates: transactionDetailLocalData.vendorUpdates, vendorDetails: transactionDetailLocalData.vendorDetails });
172
176
  if (!(0, exports.checkIfAllLineItemsAreCategoryClassFilled)(transaction, newLocalData)) {
173
177
  selectedCheckBoxTransactionIds = selectedCheckBoxTransactionIds.filter((id) => id !== transaction.id);
174
178
  }
@@ -232,7 +236,7 @@ const setEntityRecommendationForLineIdInLocalData = (draft, transaction, transac
232
236
  const newLineItem = newLineItems[matchingEntityLineId];
233
237
  newLineItems[matchingEntityLineId] = Object.assign(Object.assign({}, newLineItem), { class: matchingRecord.class, account: matchingRecord.account, lineEntity: matchingRecord.lineEntity });
234
238
  }
235
- const newLocalData = Object.assign(Object.assign({}, transactionsViewState_1.initialSupportedTransactionCategorization.transactionReviewLocalData), { memo: transactionDetailLocalData.memo, lineItemById: newLineItems, transactionDate: transactionDetailLocalData.transactionDate, transactionType: transactionDetailLocalData.transactionType, transactionTypeName: transactionDetailLocalData.transactionTypeName, vendorUpdates: transactionDetailLocalData.vendorUpdates, vendorDetails: transactionDetailLocalData.vendorDetails, vendor: transactionDetailLocalData.vendor });
239
+ 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, vendorDetails: transactionDetailLocalData.vendorDetails, vendor: transactionDetailLocalData.vendor });
236
240
  if (!(0, exports.checkIfAllLineItemsAreCategoryClassFilled)(transaction, newLocalData)) {
237
241
  selectedCheckBoxTransactionIds = selectedCheckBoxTransactionIds.filter((id) => id !== transaction.id);
238
242
  }
@@ -15,7 +15,7 @@ import { BillableStatus, CategorizationStatusType, PlatformLineDetailType, Produ
15
15
  import { Entity, EntityType } from '../../../entity/genericEntity/entity';
16
16
  import { TransactionType, TransactionCategory } from '../../../entity/transaction/stateTypes/transactionType';
17
17
  import { MonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
18
- export declare const toTransactionsSortKey: (v: string) => "date" | "amount" | "vendor" | "transactionType" | "category" | "class";
18
+ export declare const toTransactionsSortKey: (v: string) => "date" | "amount" | "vendor" | "transaction_type" | "category" | "class";
19
19
  export declare type TransactionsSortKey = ReturnType<typeof toTransactionsSortKey>;
20
20
  export declare const toTransactionsTabKey: (v: string) => "review" | "autoCategorized";
21
21
  export declare type TransactionsTab = ReturnType<typeof toTransactionsTabKey>;
@@ -6,7 +6,7 @@ const transactionDetailState_1 = require("../../transactionDetail/transactionDet
6
6
  const TRANSACTIONS_SORT_KEYS = [
7
7
  'vendor',
8
8
  'amount',
9
- 'transactionType',
9
+ 'transaction_type',
10
10
  'date',
11
11
  'category',
12
12
  'class',
@@ -17,9 +17,9 @@ const recommendation = (0, toolkit_1.createSlice)({
17
17
  action) {
18
18
  const { entity } = action.payload;
19
19
  const key = (0, recommendationState_1.getEntityRecommendationKey)(entity.type, entity.id);
20
- const existingRecommmendation = draft.recommendationByEntity[key];
21
- if (existingRecommmendation == null) {
22
- draft.recommendationByEntity[key] = Object.assign(Object.assign({}, recommendationState_1.intialEntityRecommendationState), { fetchState: 'In-Progress' });
20
+ const existingRecommendation = draft.recommendationByEntity[key];
21
+ if (existingRecommendation == null) {
22
+ draft.recommendationByEntity[key] = Object.assign(Object.assign({}, recommendationState_1.initialEntityRecommendationState), { fetchState: 'In-Progress' });
23
23
  }
24
24
  },
25
25
  prepare(entity, amount, transactionDetails, isBulkFetch, isTransactionCategorizationFlow = false) {
@@ -38,10 +38,10 @@ const recommendation = (0, toolkit_1.createSlice)({
38
38
  reducer(draft, action) {
39
39
  const { entityName, entityType } = action.payload;
40
40
  const key = (0, recommendationState_1.getEntityRecommendationKey)(entityType, entityName);
41
- const existingRecommmendation = draft.recommendationByEntity[key];
42
- if (existingRecommmendation == null ||
43
- existingRecommmendation.fetchState !== 'Completed') {
44
- draft.recommendationByEntity[key] = Object.assign(Object.assign({}, recommendationState_1.intialEntityRecommendationState), { fetchState: 'In-Progress' });
41
+ const existingRecommendation = draft.recommendationByEntity[key];
42
+ if (existingRecommendation == null ||
43
+ existingRecommendation.fetchState !== 'Completed') {
44
+ draft.recommendationByEntity[key] = Object.assign(Object.assign({}, recommendationState_1.initialEntityRecommendationState), { fetchState: 'In-Progress' });
45
45
  }
46
46
  },
47
47
  prepare(entityName, entityType) {
@@ -57,10 +57,10 @@ const recommendation = (0, toolkit_1.createSlice)({
57
57
  reducer(draft, action) {
58
58
  const { entityId, entityType } = action.payload;
59
59
  const key = (0, recommendationState_1.getEntityRecommendationKey)(entityType, entityId);
60
- const existingRecommmendation = draft.recommendationByEntity[key];
61
- if (existingRecommmendation == null ||
62
- existingRecommmendation.fetchState !== 'Completed') {
63
- draft.recommendationByEntity[key] = Object.assign(Object.assign({}, recommendationState_1.intialEntityRecommendationState), { fetchState: 'In-Progress' });
60
+ const existingRecommendation = draft.recommendationByEntity[key];
61
+ if (existingRecommendation == null ||
62
+ existingRecommendation.fetchState !== 'Completed') {
63
+ draft.recommendationByEntity[key] = Object.assign(Object.assign({}, recommendationState_1.initialEntityRecommendationState), { fetchState: 'In-Progress' });
64
64
  }
65
65
  },
66
66
  prepare(entityId, entityType) {
@@ -79,7 +79,7 @@ const recommendation = (0, toolkit_1.createSlice)({
79
79
  updateRecommendationForEntityFailure(draft, action) {
80
80
  const { entityId, entityType, status } = action.payload;
81
81
  const key = (0, recommendationState_1.getEntityRecommendationKey)(entityType, entityId);
82
- draft.recommendationByEntity[key] = Object.assign(Object.assign({}, recommendationState_1.intialEntityRecommendationState), { fetchState: 'Error', error: status });
82
+ draft.recommendationByEntity[key] = Object.assign(Object.assign({}, recommendationState_1.initialEntityRecommendationState), { fetchState: 'Error', error: status });
83
83
  },
84
84
  indicateReadyToInitializeRecommendation: {
85
85
  reducer(
@@ -107,5 +107,5 @@ _a = recommendation.actions, exports.fetchEntityRecommendationsByTransactionId =
107
107
  exports.default = recommendation.reducer;
108
108
  const doUpdateRecommendationForEntity = (draft, entityId, entityType, payload) => {
109
109
  const key = (0, recommendationState_1.getEntityRecommendationKey)(entityType, entityId);
110
- draft[key] = Object.assign(Object.assign({}, recommendationState_1.intialEntityRecommendationState), { fetchState: 'Completed', recommendations: payload });
110
+ draft[key] = Object.assign(Object.assign({}, recommendationState_1.initialEntityRecommendationState), { fetchState: 'Completed', recommendations: payload });
111
111
  };
@@ -6,7 +6,7 @@ export declare type EntityRecommendationKey = ReturnType<typeof getEntityRecomme
6
6
  export interface EntityRecommendationsStatus extends FetchedState {
7
7
  recommendations?: Recommendation[];
8
8
  }
9
- export declare const intialEntityRecommendationState: EntityRecommendationsStatus;
9
+ export declare const initialEntityRecommendationState: EntityRecommendationsStatus;
10
10
  export interface EntityRecommendationState {
11
11
  recommendationByEntity: Record<EntityRecommendationKey, EntityRecommendationsStatus>;
12
12
  }
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.intialEntityRecommendationState = exports.getEntityRecommendationKey = void 0;
3
+ exports.initialEntityRecommendationState = exports.getEntityRecommendationKey = void 0;
4
4
  const getEntityRecommendationKey = (entityType, entityIdOrName) => `${entityType}_${entityIdOrName}`;
5
5
  exports.getEntityRecommendationKey = getEntityRecommendationKey;
6
- exports.intialEntityRecommendationState = {
6
+ exports.initialEntityRecommendationState = {
7
7
  fetchState: 'Not-Started',
8
8
  error: undefined,
9
9
  hasValidState() {
@@ -1,3 +1,3 @@
1
- declare const toLinkBillExpenseKeysType: (v: string) => "attachment" | "name" | "amount" | "transactionType" | "memo" | "creationDate";
1
+ declare const toLinkBillExpenseKeysType: (v: string) => "attachment" | "name" | "amount" | "memo" | "transactionType" | "creationDate";
2
2
  export declare type LinkBillExpenseKey = ReturnType<typeof toLinkBillExpenseKeysType>;
3
3
  export {};
@@ -7,7 +7,7 @@ export declare const getScheduleListKey: (selectedCategory: ID, selectedTimefram
7
7
  export declare type ScheduleListKey = ReturnType<typeof getScheduleListKey>;
8
8
  export declare const toScheduleSubTabType: (v: string) => "all" | "new" | "completed" | "ongoing";
9
9
  export declare type ScheduleSubTabType = ReturnType<typeof toScheduleSubTabType>;
10
- declare const toScheduleSortKeyType: (v: string) => "status" | "user" | "months" | "amount" | "vendor" | "transactionType" | "class" | "memo" | "transactionDate" | "balanceAsOfToday" | "createTime" | "assetId" | "accruedExpenseCategory" | "scheduleCategory" | "expenseCategory" | "accumulatedDepreciationCategory" | "startMonth" | "endMonth";
10
+ declare const toScheduleSortKeyType: (v: string) => "status" | "user" | "months" | "amount" | "vendor" | "class" | "memo" | "transactionDate" | "transactionType" | "balanceAsOfToday" | "createTime" | "assetId" | "accruedExpenseCategory" | "scheduleCategory" | "expenseCategory" | "accumulatedDepreciationCategory" | "startMonth" | "endMonth";
11
11
  export declare type ScheduleListSortKey = ReturnType<typeof toScheduleSortKeyType>;
12
12
  export interface DownloadJEScheduleTabOptions {
13
13
  timezone: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.13.86",
3
+ "version": "4.13.88",
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",