@zeniai/client-epic-state 5.2.32-betaRD0 → 5.2.33

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.
@@ -1,3 +1,4 @@
1
+ import { reduceAnyFetchState } from '../../../commonStateTypes/reduceFetchState';
1
2
  import { toMonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
2
3
  import { getAccountBase } from '../../../entity/account/accountSelector';
3
4
  import { getClassById } from '../../../entity/class/classSelector';
@@ -6,7 +7,7 @@ import { getUserByUserId } from '../../../entity/user/userSelector';
6
7
  import { getVendorByVendorId } from '../../../entity/vendor/vendorSelector';
7
8
  import { getAllSteps } from './getAllStepsHelper';
8
9
  export function getExpenseAutomationFluxAnalysisView(state) {
9
- const { expenseAutomationFluxAnalysisViewState, monthEndCloseChecksState } = state;
10
+ const { expenseAutomationFluxAnalysisViewState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
10
11
  const { fetchState, error, lastRefreshSuccessTime, refreshStatus, uiState, reviewOperatingExpenseIdsByPeriod, selectedSectionIdsByPeriod, groupsBySelectedPeriod, fluxAnalysisEntities, bulkReviewStatus, currency, totalBalancesAndVariance, } = expenseAutomationFluxAnalysisViewState;
11
12
  const fetchStateAndError = {
12
13
  fetchState,
@@ -91,26 +92,17 @@ export function getExpenseAutomationFluxAnalysisView(state) {
91
92
  },
92
93
  };
93
94
  const completionStatus = fluxCompletionStatus != null ? fluxCompletionStatus : 'incomplete';
94
- const groupsForSelectedPeriod = monthYearPeriodId != null
95
- ? groupsBySelectedPeriod[monthYearPeriodId]
96
- : undefined;
97
- /**
98
- * `fetchState` is a flat slice field that survives a period switch, so it still reads
99
- * 'Completed' before the newly selected period has been requested. The per-period group is
100
- * created by the fetch's own request reducer, so its absence means "not requested yet for this
101
- * period" -- report 'Not-Started' so the table keeps its skeleton instead of rendering the
102
- * previous period's rows during the transition.
103
- *
104
- * This used to fall out of merging in the month-close/checks fetch state, which also coupled
105
- * the tab's first load to an unrelated request that resolves 6-12s later.
106
- */
107
- const fetchStatus = fetchState === 'Completed' && groupsForSelectedPeriod == null
108
- ? { fetchState: 'Not-Started', error: undefined }
109
- : fetchStateAndError;
95
+ const monthEndFetchState = monthYearPeriodId != null
96
+ ? (monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[currentTenant.tenantId]?.[monthYearPeriodId] ?? { fetchState: 'Not-Started', error: undefined })
97
+ : { fetchState: 'Not-Started', error: undefined };
98
+ const reducedFetchStatus = reduceAnyFetchState([
99
+ fetchStateAndError,
100
+ monthEndFetchState,
101
+ ]);
110
102
  return {
111
103
  sections,
112
104
  totalBalancesAndVariance,
113
- fetchStatus,
105
+ fetchStatus: reducedFetchStatus,
114
106
  bulkReviewStatus,
115
107
  reviewOperatingExpensesIds,
116
108
  selectedSectionIds,
@@ -1,5 +1,6 @@
1
1
  import omit from 'lodash/omit';
2
2
  import orderBy from 'lodash/orderBy';
3
+ import { reduceAnyFetchState } from '../../../commonStateTypes/reduceFetchState';
3
4
  import { LAST_SCHEDULE_DAY_OF_MONTH, toMonthYearPeriodId, } from '../../../commonStateTypes/timePeriod';
4
5
  import { getAccountIdsForTypes } from '../../../entity/account/accountSelector';
5
6
  import { generateJEOneTimeAccrualKey } from '../../../entity/jeSchedules/jeScheduleHelper';
@@ -209,7 +210,7 @@ export function getExpenseAutomationJESchedulesView(state) {
209
210
  const failedJeScheduledTransaction = [];
210
211
  const accruedSchedules = [];
211
212
  const oneTimeAccruals = [];
212
- const { accountState, accountListState, classState, classListState, expenseAutomationJESchedulesViewState, expenseAutomationViewState, monthEndCloseChecksState, } = state;
213
+ const { accountState, accountListState, classState, classListState, expenseAutomationJESchedulesViewState, expenseAutomationViewState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
213
214
  const { jeScheduleTransactionKeysByPeriodAndTab, jeScheduleAccruedKeysByPeriodAndTab, jeScheduleOneTimeAccrualKeysByPeriodAndTab, failedJeScheduleTransactionKeysByPeriodAndTab, jeScheduleLocalDataById, postStatusById, ignoreStatusById, revertStatusById, oneTimeAccrualActionStatusById, uiState, error, fetchState, refreshStatus, newSchedule, } = expenseAutomationJESchedulesViewState;
214
215
  const accountSettingsView = getJEAccountSettingsView(state);
215
216
  const newScheduleView = newSchedule.selectedDetailScheduleType === 'fixed_assets' ||
@@ -400,6 +401,13 @@ export function getExpenseAutomationJESchedulesView(state) {
400
401
  : [];
401
402
  const jeCompletionStatus = allSteps.find((step) => step.step === 'je_schedules')?.completionStatus;
402
403
  const completionStatus = jeCompletionStatus != null ? jeCompletionStatus : 'incomplete';
404
+ const monthEndFetchState = monthYearPeriodId != null
405
+ ? (monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[currentTenant.tenantId]?.[monthYearPeriodId] ?? { fetchState: 'Not-Started', error: undefined })
406
+ : { fetchState: 'Not-Started', error: undefined };
407
+ const reducedFetchStatus = reduceAnyFetchState([
408
+ { fetchState, error },
409
+ monthEndFetchState,
410
+ ]);
403
411
  const countByType = (schedules) => {
404
412
  const counts = ALL_SCHEDULES_TYPES.reduce((acc, type) => ({ ...acc, [type]: 0 }), {});
405
413
  schedules.forEach((schedule) => {
@@ -437,10 +445,10 @@ export function getExpenseAutomationJESchedulesView(state) {
437
445
  ignoreStatusById: ignoreStatusById,
438
446
  revertStatusById: revertStatusById,
439
447
  oneTimeAccrualActionStatusById: oneTimeAccrualActionStatusById,
440
- fetchState,
448
+ fetchState: reducedFetchStatus.fetchState,
441
449
  jeScheduleLocalDataById: jeScheduleLocalDataById,
442
450
  uiState: uiState,
443
- error,
451
+ error: reducedFetchStatus.error,
444
452
  refreshStatus,
445
453
  completionStatus,
446
454
  };
@@ -1,4 +1,5 @@
1
1
  import orderBy from 'lodash/orderBy';
2
+ import { reduceAnyFetchState } from '../../../commonStateTypes/reduceFetchState';
2
3
  import { toMonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
3
4
  import { getCurrentTenant } from '../../../entity/tenant/tenantSelector';
4
5
  import { getSupportedTransactionById, getSupportedTransactionsByIds, } from '../../../entity/transaction/transactionSelector';
@@ -7,7 +8,7 @@ import { getCompletedTransactionsCacheKey } from '../reducers/missingReceiptsVie
7
8
  import { isUnmatchedTabFileStatus, } from '../types/missingReceiptsViewState';
8
9
  import { getAllSteps } from './getAllStepsHelper';
9
10
  export function getExpenseAutomationMissingReceiptsView(state) {
10
- const { expenseAutomationMissingReceiptsViewState, expenseAutomationViewState, transactionState, monthEndCloseChecksState, } = state;
11
+ const { expenseAutomationMissingReceiptsViewState, expenseAutomationViewState, transactionState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
11
12
  const currentTenant = getCurrentTenant(state);
12
13
  const { selectedPeriodByTenantId } = expenseAutomationViewState;
13
14
  const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
@@ -175,21 +176,16 @@ export function getExpenseAutomationMissingReceiptsView(state) {
175
176
  vendorLogo: result.vendorLogo ?? transaction?.logo?.href,
176
177
  };
177
178
  });
178
- /**
179
- * `fetchState` is a flat slice field that survives a period switch, so it still reads
180
- * 'Completed' before the newly selected period's ids land. Report 'Not-Started' until they do,
181
- * so the table keeps its skeleton rather than flashing the "all done" empty state over the
182
- * previous period's rows.
183
- *
184
- * This used to fall out of merging in the month-close/checks fetch state, which also coupled
185
- * the tab's first load to an unrelated request that resolves 6-12s later.
186
- */
187
- const fetchStatus = fetchState === 'Completed' && transactionIdsForSelectedPeriod == null
188
- ? { fetchState: 'Not-Started', error: undefined }
189
- : { fetchState, error };
179
+ const monthEndFetchState = monthYearPeriodId != null
180
+ ? (monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[currentTenant.tenantId]?.[monthYearPeriodId] ?? { fetchState: 'Not-Started', error: undefined })
181
+ : { fetchState: 'Not-Started', error: undefined };
182
+ const reducedFetchStatus = reduceAnyFetchState([
183
+ { fetchState, error },
184
+ monthEndFetchState,
185
+ ]);
190
186
  return {
191
- fetchState: fetchStatus.fetchState,
192
- error: fetchStatus.error,
187
+ fetchState: reducedFetchStatus.fetchState,
188
+ error: reducedFetchStatus.error,
193
189
  uploadReceiptStatusById,
194
190
  uiState,
195
191
  refreshStatus,
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getExpenseAutomationFluxAnalysisView = getExpenseAutomationFluxAnalysisView;
4
+ const reduceFetchState_1 = require("../../../commonStateTypes/reduceFetchState");
4
5
  const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
5
6
  const accountSelector_1 = require("../../../entity/account/accountSelector");
6
7
  const classSelector_1 = require("../../../entity/class/classSelector");
@@ -9,7 +10,7 @@ const userSelector_1 = require("../../../entity/user/userSelector");
9
10
  const vendorSelector_1 = require("../../../entity/vendor/vendorSelector");
10
11
  const getAllStepsHelper_1 = require("./getAllStepsHelper");
11
12
  function getExpenseAutomationFluxAnalysisView(state) {
12
- const { expenseAutomationFluxAnalysisViewState, monthEndCloseChecksState } = state;
13
+ const { expenseAutomationFluxAnalysisViewState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
13
14
  const { fetchState, error, lastRefreshSuccessTime, refreshStatus, uiState, reviewOperatingExpenseIdsByPeriod, selectedSectionIdsByPeriod, groupsBySelectedPeriod, fluxAnalysisEntities, bulkReviewStatus, currency, totalBalancesAndVariance, } = expenseAutomationFluxAnalysisViewState;
14
15
  const fetchStateAndError = {
15
16
  fetchState,
@@ -94,26 +95,17 @@ function getExpenseAutomationFluxAnalysisView(state) {
94
95
  },
95
96
  };
96
97
  const completionStatus = fluxCompletionStatus != null ? fluxCompletionStatus : 'incomplete';
97
- const groupsForSelectedPeriod = monthYearPeriodId != null
98
- ? groupsBySelectedPeriod[monthYearPeriodId]
99
- : undefined;
100
- /**
101
- * `fetchState` is a flat slice field that survives a period switch, so it still reads
102
- * 'Completed' before the newly selected period has been requested. The per-period group is
103
- * created by the fetch's own request reducer, so its absence means "not requested yet for this
104
- * period" -- report 'Not-Started' so the table keeps its skeleton instead of rendering the
105
- * previous period's rows during the transition.
106
- *
107
- * This used to fall out of merging in the month-close/checks fetch state, which also coupled
108
- * the tab's first load to an unrelated request that resolves 6-12s later.
109
- */
110
- const fetchStatus = fetchState === 'Completed' && groupsForSelectedPeriod == null
111
- ? { fetchState: 'Not-Started', error: undefined }
112
- : fetchStateAndError;
98
+ const monthEndFetchState = monthYearPeriodId != null
99
+ ? (monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[currentTenant.tenantId]?.[monthYearPeriodId] ?? { fetchState: 'Not-Started', error: undefined })
100
+ : { fetchState: 'Not-Started', error: undefined };
101
+ const reducedFetchStatus = (0, reduceFetchState_1.reduceAnyFetchState)([
102
+ fetchStateAndError,
103
+ monthEndFetchState,
104
+ ]);
113
105
  return {
114
106
  sections,
115
107
  totalBalancesAndVariance,
116
- fetchStatus,
108
+ fetchStatus: reducedFetchStatus,
117
109
  bulkReviewStatus,
118
110
  reviewOperatingExpensesIds,
119
111
  selectedSectionIds,
@@ -14,6 +14,7 @@ exports.getExpenseAutomationJESchedulesView = getExpenseAutomationJESchedulesVie
14
14
  exports.getExpenseAutomationJEOneTimeAccrualDetailView = getExpenseAutomationJEOneTimeAccrualDetailView;
15
15
  const omit_1 = __importDefault(require("lodash/omit"));
16
16
  const orderBy_1 = __importDefault(require("lodash/orderBy"));
17
+ const reduceFetchState_1 = require("../../../commonStateTypes/reduceFetchState");
17
18
  const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
18
19
  const accountSelector_1 = require("../../../entity/account/accountSelector");
19
20
  const jeScheduleHelper_1 = require("../../../entity/jeSchedules/jeScheduleHelper");
@@ -224,7 +225,7 @@ function getExpenseAutomationJESchedulesView(state) {
224
225
  const failedJeScheduledTransaction = [];
225
226
  const accruedSchedules = [];
226
227
  const oneTimeAccruals = [];
227
- const { accountState, accountListState, classState, classListState, expenseAutomationJESchedulesViewState, expenseAutomationViewState, monthEndCloseChecksState, } = state;
228
+ const { accountState, accountListState, classState, classListState, expenseAutomationJESchedulesViewState, expenseAutomationViewState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
228
229
  const { jeScheduleTransactionKeysByPeriodAndTab, jeScheduleAccruedKeysByPeriodAndTab, jeScheduleOneTimeAccrualKeysByPeriodAndTab, failedJeScheduleTransactionKeysByPeriodAndTab, jeScheduleLocalDataById, postStatusById, ignoreStatusById, revertStatusById, oneTimeAccrualActionStatusById, uiState, error, fetchState, refreshStatus, newSchedule, } = expenseAutomationJESchedulesViewState;
229
230
  const accountSettingsView = (0, jeAccountSettingsViewSelector_1.getJEAccountSettingsView)(state);
230
231
  const newScheduleView = newSchedule.selectedDetailScheduleType === 'fixed_assets' ||
@@ -415,6 +416,13 @@ function getExpenseAutomationJESchedulesView(state) {
415
416
  : [];
416
417
  const jeCompletionStatus = allSteps.find((step) => step.step === 'je_schedules')?.completionStatus;
417
418
  const completionStatus = jeCompletionStatus != null ? jeCompletionStatus : 'incomplete';
419
+ const monthEndFetchState = monthYearPeriodId != null
420
+ ? (monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[currentTenant.tenantId]?.[monthYearPeriodId] ?? { fetchState: 'Not-Started', error: undefined })
421
+ : { fetchState: 'Not-Started', error: undefined };
422
+ const reducedFetchStatus = (0, reduceFetchState_1.reduceAnyFetchState)([
423
+ { fetchState, error },
424
+ monthEndFetchState,
425
+ ]);
418
426
  const countByType = (schedules) => {
419
427
  const counts = jeSchedulesTypes_1.ALL_SCHEDULES_TYPES.reduce((acc, type) => ({ ...acc, [type]: 0 }), {});
420
428
  schedules.forEach((schedule) => {
@@ -452,10 +460,10 @@ function getExpenseAutomationJESchedulesView(state) {
452
460
  ignoreStatusById: ignoreStatusById,
453
461
  revertStatusById: revertStatusById,
454
462
  oneTimeAccrualActionStatusById: oneTimeAccrualActionStatusById,
455
- fetchState,
463
+ fetchState: reducedFetchStatus.fetchState,
456
464
  jeScheduleLocalDataById: jeScheduleLocalDataById,
457
465
  uiState: uiState,
458
- error,
466
+ error: reducedFetchStatus.error,
459
467
  refreshStatus,
460
468
  completionStatus,
461
469
  };
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getExpenseAutomationMissingReceiptsView = getExpenseAutomationMissingReceiptsView;
7
7
  const orderBy_1 = __importDefault(require("lodash/orderBy"));
8
+ const reduceFetchState_1 = require("../../../commonStateTypes/reduceFetchState");
8
9
  const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
9
10
  const tenantSelector_1 = require("../../../entity/tenant/tenantSelector");
10
11
  const transactionSelector_1 = require("../../../entity/transaction/transactionSelector");
@@ -13,7 +14,7 @@ const missingReceiptsViewReducer_1 = require("../reducers/missingReceiptsViewRed
13
14
  const missingReceiptsViewState_1 = require("../types/missingReceiptsViewState");
14
15
  const getAllStepsHelper_1 = require("./getAllStepsHelper");
15
16
  function getExpenseAutomationMissingReceiptsView(state) {
16
- const { expenseAutomationMissingReceiptsViewState, expenseAutomationViewState, transactionState, monthEndCloseChecksState, } = state;
17
+ const { expenseAutomationMissingReceiptsViewState, expenseAutomationViewState, transactionState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
17
18
  const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
18
19
  const { selectedPeriodByTenantId } = expenseAutomationViewState;
19
20
  const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
@@ -181,21 +182,16 @@ function getExpenseAutomationMissingReceiptsView(state) {
181
182
  vendorLogo: result.vendorLogo ?? transaction?.logo?.href,
182
183
  };
183
184
  });
184
- /**
185
- * `fetchState` is a flat slice field that survives a period switch, so it still reads
186
- * 'Completed' before the newly selected period's ids land. Report 'Not-Started' until they do,
187
- * so the table keeps its skeleton rather than flashing the "all done" empty state over the
188
- * previous period's rows.
189
- *
190
- * This used to fall out of merging in the month-close/checks fetch state, which also coupled
191
- * the tab's first load to an unrelated request that resolves 6-12s later.
192
- */
193
- const fetchStatus = fetchState === 'Completed' && transactionIdsForSelectedPeriod == null
194
- ? { fetchState: 'Not-Started', error: undefined }
195
- : { fetchState, error };
185
+ const monthEndFetchState = monthYearPeriodId != null
186
+ ? (monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[currentTenant.tenantId]?.[monthYearPeriodId] ?? { fetchState: 'Not-Started', error: undefined })
187
+ : { fetchState: 'Not-Started', error: undefined };
188
+ const reducedFetchStatus = (0, reduceFetchState_1.reduceAnyFetchState)([
189
+ { fetchState, error },
190
+ monthEndFetchState,
191
+ ]);
196
192
  return {
197
- fetchState: fetchStatus.fetchState,
198
- error: fetchStatus.error,
193
+ fetchState: reducedFetchStatus.fetchState,
194
+ error: reducedFetchStatus.error,
199
195
  uploadReceiptStatusById,
200
196
  uiState,
201
197
  refreshStatus,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.2.32-betaRD0",
3
+ "version": "5.2.33",
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
  "module": "lib/esm/index.js",