@zeniai/client-epic-state 5.2.55 → 5.2.56-betaRD1

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.
Files changed (33) hide show
  1. package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +4 -1
  2. package/lib/entity/jeSchedules/jeSchedulesReducer.js +79 -5
  3. package/lib/epic.d.ts +2 -1
  4. package/lib/epic.js +6 -4
  5. package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +78 -4
  6. package/lib/esm/epic.js +6 -4
  7. package/lib/esm/index.js +3 -3
  8. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.js +39 -0
  9. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +14 -1
  10. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +10 -13
  11. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/initializeJeScheduleLocalDataEpic.js +38 -17
  12. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.js +17 -1
  13. package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +74 -1
  14. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +49 -14
  15. package/lib/index.d.ts +3 -3
  16. package/lib/index.js +50 -49
  17. package/lib/tsconfig.mocks.tsbuildinfo +1 -0
  18. package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
  19. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.d.ts +20 -0
  20. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.js +43 -0
  21. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.d.ts +2 -2
  22. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +13 -0
  23. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +8 -11
  24. package/lib/view/expenseAutomationView/epics/jeSchedule/initializeJeScheduleLocalDataEpic.js +38 -17
  25. package/lib/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.d.ts +2 -2
  26. package/lib/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.js +17 -1
  27. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +18 -0
  28. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +10 -3
  29. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +76 -3
  30. package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +3 -0
  31. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +49 -14
  32. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +16 -0
  33. package/package.json +1 -1
@@ -225,7 +225,7 @@ function getExpenseAutomationJESchedulesView(state) {
225
225
  const accruedSchedules = [];
226
226
  const oneTimeAccruals = [];
227
227
  const { accountState, accountListState, classState, classListState, expenseAutomationJESchedulesViewState, expenseAutomationViewState, monthEndCloseChecksState, } = state;
228
- const { jeScheduleTransactionKeysByPeriodAndTab, jeScheduleAccruedKeysByPeriodAndTab, jeScheduleOneTimeAccrualKeysByPeriodAndTab, failedJeScheduleTransactionKeysByPeriodAndTab, jeScheduleLocalDataById, postStatusById, ignoreStatusById, revertStatusById, oneTimeAccrualActionStatusById, uiState, error, fetchState, refreshStatus, newSchedule, } = expenseAutomationJESchedulesViewState;
228
+ const { jeScheduleTransactionKeysByPeriodAndTab, jeScheduleAccruedKeysByPeriodAndTab, jeScheduleOneTimeAccrualKeysByPeriodAndTab, failedJePostings, jeScheduleLocalDataById, postStatusById, ignoreStatusById, revertStatusById, oneTimeAccrualActionStatusById, uiState, error, fetchState, refreshStatus, newSchedule, } = expenseAutomationJESchedulesViewState;
229
229
  const accountSettingsView = (0, jeAccountSettingsViewSelector_1.getJEAccountSettingsView)(state);
230
230
  const newScheduleView = newSchedule.selectedDetailScheduleType === 'fixed_assets' ||
231
231
  newSchedule.selectedDetailScheduleType === 'prepaid_expenses'
@@ -264,15 +264,11 @@ function getExpenseAutomationJESchedulesView(state) {
264
264
  const jeScheduleTransactionKeysForSelectedTab = selectedPeriodTabKey != null
265
265
  ? jeScheduleTransactionKeysByPeriodAndTab[selectedPeriodTabKey]
266
266
  : undefined;
267
- const failedJeScheduleTransactionKeysForSelectedTab = selectedPeriodTabKey != null
268
- ? failedJeScheduleTransactionKeysByPeriodAndTab[selectedPeriodTabKey]
269
- : undefined;
270
267
  // Distinguishes "this tab has never been fetched for this period" from "fetched and genuinely
271
268
  // empty". Without it the page cannot tell a first visit from a real empty state, and renders an
272
269
  // empty table where it should render a skeleton.
273
270
  const hasLoadedForSelectedTab = jeScheduleTransactionKeysForSelectedTab != null;
274
271
  const jeScheduleTransactionKeys = jeScheduleTransactionKeysForSelectedTab ?? [];
275
- const failedJeScheduleTransactionKeys = failedJeScheduleTransactionKeysForSelectedTab ?? [];
276
272
  const jeScheduleAccruedKeys = (selectedPeriodTabKey != null
277
273
  ? jeScheduleAccruedKeysByPeriodAndTab[selectedPeriodTabKey]
278
274
  : undefined) ?? [];
@@ -295,24 +291,57 @@ function getExpenseAutomationJESchedulesView(state) {
295
291
  accruedSchedules.push(accruedScheduleDetails);
296
292
  }
297
293
  });
298
- failedJeScheduleTransactionKeys.forEach((jeScheduleKey) => {
299
- const jeScheduleDetails = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleTransactionKey)(jeScheduleKey, state);
300
- failedJeScheduledTransaction.push(jeScheduleDetails);
294
+ // Sourced from the tenant-wide bucket, not the per-period one: a failed posting belongs to no
295
+ // close month, and windowing it is what kept older failures off the only tab that can resolve
296
+ // them.
297
+ failedJePostings.jeScheduleTransactionKeys.forEach((jeScheduleKey) => {
298
+ // getJEScheduledTransactionByJEScheduleTransactionKey throws three different ways: it
299
+ // destructures the result of recordGet without a null check, and it raises explicitly for a
300
+ // missing vendor and for a missing base transaction. Catching rather than pre-checking each
301
+ // one keeps this correct if a fourth is added, and none of the three is recoverable here --
302
+ // the row cannot be drawn either way.
303
+ //
304
+ // This matters more for this bucket than anywhere else on the page. It is tenant-wide, so it
305
+ // names schedules the close-month list never loaded, and the group is defined by deleted
306
+ // vendors and deleted categories -- precisely the rows whose entities are most likely to be
307
+ // missing. Unguarded, one such key takes down the whole JE tab instead of dropping one row.
308
+ try {
309
+ failedJeScheduledTransaction.push((0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleTransactionKey)(jeScheduleKey, state));
310
+ }
311
+ catch {
312
+ // Intentionally swallowed: a failed posting we cannot resolve is one missing row, and the
313
+ // alternative is a blank page for every other row too.
314
+ }
301
315
  });
316
+ // What the endpoint last reported as failing. The entity store keeps every month a schedule
317
+ // has and an entry resolved by someone else keeps its old `error` array, so `error` alone would
318
+ // leave a Retry button on a posting that is no longer failing.
319
+ const failedScheduledJournalEntryIDs = new Set(failedJePostings.scheduledJournalEntryIDs);
302
320
  const { sortKey, sortOrder, selectedJETypeFilter } = uiState;
321
+ const matchesTypeFilter = (schedule) => selectedJETypeFilter == null ||
322
+ getJEScheduleRowType(schedule) === selectedJETypeFilter;
303
323
  const unsortedResolveSchedules = [];
304
324
  failedJeScheduledTransaction.forEach((schedule) => {
305
- schedule.scheduledJournalEntry.forEach((journalEntry) => {
325
+ // Only the entries that actually carry an error. The schedule's entry array is shared state:
326
+ // opening a schedule's detail page or Quick View replaces it with every month the schedule
327
+ // has, posted ones included, so fanning out over all of them turned one failed posting into a
328
+ // row per month -- and a month that never failed has nothing to resolve, so it rendered with
329
+ // an empty action column.
330
+ //
331
+ // Intersected with the ids the endpoint actually returned, not just `error`: the entry array
332
+ // is a cache of every month, and an entry whose failure someone else resolved keeps its stale
333
+ // error array until something overwrites it. Only what the last fetch named is still failing.
334
+ schedule.scheduledJournalEntry
335
+ .filter((journalEntry) => journalEntry.error.length > 0 &&
336
+ failedScheduledJournalEntryIDs.has(journalEntry.scheduledJournalEntryID))
337
+ .forEach((journalEntry) => {
306
338
  unsortedResolveSchedules.push({
307
339
  ...schedule,
308
340
  scheduledJournalEntry: journalEntry,
309
341
  });
310
342
  });
311
343
  });
312
- const resolveSchedules = sortJEScheduledTransactions(unsortedResolveSchedules, sortKey, sortOrder);
313
- const validResolveForPending = unsortedResolveSchedules.filter((r) => jeScheduleLocalDataById[r.scheduledJournalEntry.scheduledJournalEntryID] != null);
314
- const matchesTypeFilter = (schedule) => selectedJETypeFilter == null ||
315
- getJEScheduleRowType(schedule) === selectedJETypeFilter;
344
+ const resolveSchedules = sortJEScheduledTransactions(unsortedResolveSchedules.filter(matchesTypeFilter), sortKey, sortOrder);
316
345
  const isCreatedStatus = (schedule) => {
317
346
  // An accrual is "created" once it is not review work: posted, reversing, reversed, or in a
318
347
  // transient posting claim.
@@ -330,7 +359,6 @@ function getExpenseAutomationJESchedulesView(state) {
330
359
  ];
331
360
  const pendingReviewSchedules = sortJEScheduledTransactions([
332
361
  ...allScheduleRows.filter((schedule) => isPendingReviewRow(schedule) && matchesTypeFilter(schedule)),
333
- ...validResolveForPending,
334
362
  ], sortKey, sortOrder);
335
363
  const createdSchedules = sortJEScheduledTransactions(allScheduleRows.filter((schedule) => isCreatedStatus(schedule) && matchesTypeFilter(schedule)), sortKey, sortOrder);
336
364
  // KPI summary — derived from unfiltered schedules so counts are always accurate
@@ -449,6 +477,13 @@ function getExpenseAutomationJESchedulesView(state) {
449
477
  kpiSummary,
450
478
  pendingReviewSchedules,
451
479
  pendingReviewTotal,
480
+ failedPostings: resolveSchedules,
481
+ // Exposed so a consumer can tell "still loading" and "the lookup failed" from "nothing has
482
+ // failed". The bucket keeps its rows on failure precisely so an error can be shown beside
483
+ // them, which is only possible if the state travels with them.
484
+ failedPostingsFetchState: failedJePostings.fetchState,
485
+ // Deprecated alias of failedPostings. Still read by the section's footer-form effect and by
486
+ // app-ui analytics; remove once both are repointed.
452
487
  resolveSchedules: resolveSchedules,
453
488
  accountSettingsView,
454
489
  newScheduleView,
@@ -19,6 +19,7 @@ export type JESchedulePeriodTabKey = `${JEPageTab}_${MonthYearPeriodId}`;
19
19
  export declare const getJESchedulePeriodTabKey: (selectedPageTab: JEPageTab, monthYearPeriodId: MonthYearPeriodId) => JESchedulePeriodTabKey;
20
20
  export interface JESchedulesViewUIState {
21
21
  createdGroupCollapsed: boolean;
22
+ failedGroupCollapsed: boolean;
22
23
  pendingGroupCollapsed: boolean;
23
24
  scrollPosition: {
24
25
  scrollTop: number;
@@ -41,8 +42,23 @@ export interface JEScheduleLocalData {
41
42
  updatedClassId?: ID;
42
43
  updatedVendor?: VendorBase;
43
44
  }
45
+ /**
46
+ * The Failed Postings bucket, and the only list on this page that is not scoped to a period.
47
+ *
48
+ * A failed posting is broken until someone resolves it, whatever month it belongs to, so windowing
49
+ * it the way the schedule lists are windowed is what hid a March failure from the September close.
50
+ * It therefore has no period-tab key, and its own fetch state rather than the slice's: the list is
51
+ * fetched separately from `/1.0/expenses_automation/failed_je_postings`, so a slow or failing
52
+ * lookup here must not blank the schedules table, or vice versa.
53
+ */
54
+ export interface FailedJePostingsState {
55
+ fetchState: FetchStateAndError;
56
+ jeScheduleTransactionKeys: JEScheduleTransactionKey[];
57
+ scheduledJournalEntryIDs: ID[];
58
+ }
44
59
  export interface JESchedulesViewState extends FetchedState {
45
60
  accountSettings: AccountSettingsState;
61
+ failedJePostings: FailedJePostingsState;
46
62
  failedJeScheduleTransactionKeysByPeriodAndTab: Record<JESchedulePeriodTabKey, JEScheduleTransactionKey[]>;
47
63
  ignoreStatusById: Record<JEScheduleTransactionKey, FetchStateAndError>;
48
64
  jeScheduleAccruedKeysByPeriodAndTab: Record<JESchedulePeriodTabKey, JEScheduleKey[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.2.55",
3
+ "version": "5.2.56-betaRD1",
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",