@zeniai/client-epic-state 4.15.96 → 4.15.97

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.
@@ -114,7 +114,7 @@ const expenseAutomationFluxAnalysisView = (0, toolkit_1.createSlice)({
114
114
  handleFetchCompletion(draft, selectedPeriod, fetchReimbursement, groupToBeFetched);
115
115
  draft.fetchState = 'Completed';
116
116
  // Update flux analysis entities
117
- const allFluxAnalysisEntities = updateFluxAnalysisEntities(draft.fluxAnalysisEntities, expensesPayload, currency, keepExistingListItems);
117
+ const allFluxAnalysisEntities = updateFluxAnalysisEntities(draft.fluxAnalysisEntities, expensesPayload, currency);
118
118
  // Update operating expense ids based on the "keepExistingListItems" flag
119
119
  updateOperatingExpenseIds(draft, selectedPeriod, groupToBeFetched, fluxOpExEntityIds, fetchReimbursement, keepExistingListItems);
120
120
  // Update total balances and variance if available
@@ -306,15 +306,19 @@ const handleFetchCompletion = (draft, selectedPeriod, fetchReimbursement, groupT
306
306
  }
307
307
  };
308
308
  // Helper function to update flux analysis entities
309
- const updateFluxAnalysisEntities = (existingEntities, expensesPayload, currency, keepExistingListItems = false) => {
309
+ const updateFluxAnalysisEntities = (existingEntities, expensesPayload, currency) => {
310
310
  const incomingExpenses = toFluxAnalysisOperatingExpenses(expensesPayload, currency);
311
- const allExpensesMap = new Map();
312
- // Preserve existing
313
- if (keepExistingListItems === true) {
314
- existingEntities.operatingExpenses.forEach((e) => allExpensesMap.set(e.fluxAnalysisEntityId, e));
315
- }
316
- incomingExpenses.forEach((e) => allExpensesMap.set(e.fluxAnalysisEntityId, e));
317
- return { operatingExpenses: Array.from(allExpensesMap.values()) };
311
+ // Combine existing and incoming expenses, prioritizing incoming
312
+ const allExpenses = [
313
+ ...existingEntities.operatingExpenses,
314
+ ...incomingExpenses,
315
+ ];
316
+ // Use a Map to deduplicate by fluxAnalysisEntityId, keeping the latest (incoming) entry
317
+ const expensesMap = new Map();
318
+ allExpenses.forEach((expense) => {
319
+ expensesMap.set(expense.fluxAnalysisEntityId, expense);
320
+ });
321
+ return { operatingExpenses: Array.from(expensesMap.values()) };
318
322
  };
319
323
  // Helper function to update operating expense ids
320
324
  const updateOperatingExpenseIds = (draft, selectedPeriod, groupToBeFetched, fluxOpExEntityIds, fetchReimbursement, keepExistingListItems) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.15.96",
3
+ "version": "4.15.97",
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",