@zeniai/client-epic-state 5.2.56 → 5.2.57

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 (31) 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/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.d.ts +20 -0
  18. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.js +43 -0
  19. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.d.ts +2 -2
  20. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +13 -0
  21. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +8 -11
  22. package/lib/view/expenseAutomationView/epics/jeSchedule/initializeJeScheduleLocalDataEpic.js +38 -17
  23. package/lib/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.d.ts +2 -2
  24. package/lib/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.js +17 -1
  25. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +18 -0
  26. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +10 -3
  27. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +76 -3
  28. package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +3 -0
  29. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +49 -14
  30. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +16 -0
  31. package/package.json +1 -1
@@ -3,6 +3,6 @@ import { Observable } from 'rxjs';
3
3
  import { RootState } from '../../../../rootStateTypes';
4
4
  import { fetchAccountList } from '../../../accountList/accountListReducer';
5
5
  import { fetchActualMatchingPage } from '../../reducers/actualMatchingViewReducer';
6
- import { fetchJeSchedules, fetchJeSchedulesPage, initializeAccountSettingsView } from '../../reducers/jeSchedulesViewReducer';
7
- export type ActionType = ReturnType<typeof fetchAccountList> | ReturnType<typeof fetchActualMatchingPage> | ReturnType<typeof fetchJeSchedules> | ReturnType<typeof fetchJeSchedulesPage> | ReturnType<typeof initializeAccountSettingsView>;
6
+ import { fetchFailedJePostings, fetchJeSchedules, fetchJeSchedulesPage, initializeAccountSettingsView } from '../../reducers/jeSchedulesViewReducer';
7
+ export type ActionType = ReturnType<typeof fetchAccountList> | ReturnType<typeof fetchActualMatchingPage> | ReturnType<typeof fetchFailedJePostings> | ReturnType<typeof fetchJeSchedules> | ReturnType<typeof fetchJeSchedulesPage> | ReturnType<typeof initializeAccountSettingsView>;
8
8
  export declare const fetchJeSchedulesPageEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
@@ -27,6 +27,19 @@ const fetchJeSchedulesPageEpic = (actions$, state$) => actions$.pipe((0, operato
27
27
  else {
28
28
  jeSchedulePageActions.push((0, jeSchedulesViewReducer_1.fetchJeSchedules)(period, refreshViewInBackground));
29
29
  }
30
+ // Failed postings are tenant-wide and carry no period, so a period change or a tab switch
31
+ // cannot invalidate them -- fetch once and let retry keep the list current from then on.
32
+ // Refreshes still refetch, silently, so a failure resolved elsewhere leaves eventually.
33
+ const { fetchState: failedPostingsFetchState } = state.expenseAutomationJESchedulesViewState.failedJePostings.fetchState;
34
+ const isBackgroundRefresh = refreshViewInBackground === true;
35
+ // 'Error' is retried, not just 'Not-Started'. A transient failure on first load would
36
+ // otherwise leave the bucket in Error, and a later period change -- which is not a
37
+ // background refresh -- would never ask again, so the tab stayed empty for the session.
38
+ if (failedPostingsFetchState === 'Not-Started' ||
39
+ failedPostingsFetchState === 'Error' ||
40
+ isBackgroundRefresh) {
41
+ jeSchedulePageActions.push((0, jeSchedulesViewReducer_1.fetchFailedJePostings)(isBackgroundRefresh));
42
+ }
30
43
  // Only on the first page load. Account settings cannot change from a tab switch or a
31
44
  // refresh, and re-initializing puts accountSettingsView back to 'In-Progress' -- which the
32
45
  // page reads as "still loading" and answers with a full skeleton over rows it already has.
@@ -84,8 +84,9 @@ const fetchJeSchedulesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, op
84
84
  one_time_accrual_service_month_end: parsedEndDate.format(jeSchedulesPayload_1.SERVICE_MONTH_FORMAT),
85
85
  // Existing lists what actually reached the books.
86
86
  one_time_accrual_statuses: ['posted'],
87
- // A failed posting from an earlier month still needs to surface here, so this list
88
- // is deliberately not windowed.
87
+ // Kept only so this tab's response shape is unchanged. Nothing reads the failed
88
+ // postings it returns any more -- they have their own endpoint and their own group
89
+ // on Review. Dropping the key from the response is a server-side follow-up.
89
90
  filter_failed_je_postings_by_date: false,
90
91
  }),
91
92
  };
@@ -96,12 +97,10 @@ const fetchJeSchedulesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, op
96
97
  const updateActions = [];
97
98
  const accruedJeSchedules = response.data.accrued_je_schedules?.je_schedules ?? [];
98
99
  const oneTimeAccruals = response.data.one_time_accruals ?? [];
99
- updateActions.push((0, jeSchedulesReducer_1.updateJESchedules)([
100
- ...response.data.je_schedules,
101
- ...response.data.failed_je_postings.je_schedules,
102
- ]), (0, jeSchedulesReducer_1.updateJESchedulesDetails)([...response.data.failed_je_postings.je_schedules], response.data.failed_je_postings.scheduled_journal_entries), (0, jeSchedulesViewReducer_1.initializeJeScheduleLocalData)([
103
- ...response.data.failed_je_postings.je_schedules,
104
- ]));
100
+ // failed_je_postings is deliberately ignored. This endpoint windows it to the close
101
+ // month, which is what hid older failures; fetchFailedJePostingsEpic owns that list
102
+ // now and fetches it unwindowed.
103
+ updateActions.push((0, jeSchedulesReducer_1.updateJESchedules)([...response.data.je_schedules]));
105
104
  if (accruedJeSchedules.length > 0) {
106
105
  updateActions.push((0, jeSchedulesReducer_1.updateAccruedJESchedules)(accruedJeSchedules), (0, jeSchedulesReducer_1.updateAccruedJESchedulesDetails)(accruedJeSchedules, response.data.accrued_je_schedules
107
106
  ?.scheduled_journal_entries));
@@ -114,9 +113,7 @@ const fetchJeSchedulesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, op
114
113
  }
115
114
  updateActions.push((0, jeSchedulesViewReducer_1.fetchJeSchedulesSuccess)({
116
115
  jeSchedules: [...response.data.je_schedules],
117
- failedJeSchedules: [
118
- ...response.data.failed_je_postings.je_schedules,
119
- ],
116
+ failedJeSchedules: [],
120
117
  accruedJeSchedules: accruedJeSchedules,
121
118
  oneTimeAccruals: oneTimeAccruals,
122
119
  selectedPeriod: selectedPeriod,
@@ -3,29 +3,50 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initializeJeScheduleLocalDataEpic = void 0;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
- const jeSchedulesSelector_1 = require("../../../../entity/jeSchedules/jeSchedulesSelector");
7
6
  const jeSchedulesViewReducer_1 = require("../../reducers/jeSchedulesViewReducer");
8
7
  const initializeJeScheduleLocalDataEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.initializeJeScheduleLocalData.match), (0, operators_1.mergeMap)((action) => {
9
8
  const state = state$.value;
9
+ const { jeScheduleLocalDataById } = state.expenseAutomationJESchedulesViewState;
10
10
  const actions = [];
11
11
  const { jeScheduleTransactionKeys } = action.payload;
12
12
  jeScheduleTransactionKeys.forEach((jeScheduleTransactionKey) => {
13
- const jeScheduledTransaction = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleTransactionKey)(jeScheduleTransactionKey, state);
14
- const initLocalData = {
15
- jeScheduleType: jeScheduledTransaction.jeScheduleType,
16
- jeScheduleID: jeScheduledTransaction.jeScheduleId,
17
- scheduledJournalEntryID: jeScheduledTransaction.scheduledJournalEntry[0]
18
- .scheduledJournalEntryID,
19
- updatedVendor: undefined,
20
- updatedCategoryId: undefined,
21
- updatedAccumulatedDepreciationCategoryID: undefined,
22
- updatedClassId: undefined,
23
- };
24
- actions.push((0, jeSchedulesViewReducer_1.updateJeScheduleLocalDataById)({
25
- localData: initLocalData,
26
- scheduledJournalEntryID: jeScheduledTransaction.scheduledJournalEntry[0]
27
- .scheduledJournalEntryID,
28
- }));
13
+ // Read straight off the entity rather than through
14
+ // getJEScheduledTransactionByJEScheduleTransactionKey. That selector resolves the vendor,
15
+ // the base transaction and the accounts, and THROWS when any of them is not in the store
16
+ // yet -- a missing-schedule guard does not cover it. This epic is a mergeMap with no
17
+ // catchError, so one throw takes its subscription down for the rest of the session and
18
+ // every later row silently renders without a Retry button. The three fields below are all
19
+ // it has ever needed.
20
+ const jeSchedule = state.jeSchedulesState.schedulesByTransactionKey[jeScheduleTransactionKey];
21
+ if (jeSchedule == null) {
22
+ return;
23
+ }
24
+ // Filtered on `error` because the entry array is shared state: a schedule whose detail
25
+ // page or Quick View has been opened holds every month it has, posted ones included.
26
+ jeSchedule.scheduledJournalEntry
27
+ .filter((journalEntry) => journalEntry.error.length > 0)
28
+ .forEach((journalEntry) => {
29
+ const { scheduledJournalEntryID } = journalEntry;
30
+ // Seeded once and never re-seeded. updateJeScheduleLocalDataById merges what it is
31
+ // given over what is there, and the seed carries explicit undefined edits -- so
32
+ // re-running it on a background refresh wiped a category the user had already picked
33
+ // and Retry went on to post the original broken one.
34
+ if (jeScheduleLocalDataById[scheduledJournalEntryID] != null) {
35
+ return;
36
+ }
37
+ actions.push((0, jeSchedulesViewReducer_1.updateJeScheduleLocalDataById)({
38
+ localData: {
39
+ jeScheduleType: jeSchedule.jeScheduleType,
40
+ jeScheduleID: jeSchedule.jeScheduleId,
41
+ scheduledJournalEntryID,
42
+ updatedVendor: undefined,
43
+ updatedCategoryId: undefined,
44
+ updatedAccumulatedDepreciationCategoryID: undefined,
45
+ updatedClassId: undefined,
46
+ },
47
+ scheduledJournalEntryID,
48
+ }));
49
+ });
29
50
  });
30
51
  return (0, rxjs_1.from)(actions);
31
52
  }));
@@ -1,10 +1,10 @@
1
1
  import { ActionsObservable, StateObservable } from 'redux-observable';
2
2
  import { Observable } from 'rxjs';
3
- import { updateJESchedules, updateJESchedulesDetails } from '../../../../entity/jeSchedules/jeSchedulesReducer';
3
+ import { removeScheduledJournalEntryFromJESchedule, updateJESchedules, updateJESchedulesDetails } from '../../../../entity/jeSchedules/jeSchedulesReducer';
4
4
  import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
5
5
  import { RootState } from '../../../../rootStateTypes';
6
6
  import { ZeniAPI } from '../../../../zeniAPI';
7
7
  import { fetchMonthEndCloseChecks } from '../../../monthEndCloseChecksView/monthEndCloseChecksViewReducer';
8
8
  import { removeFailedJeScheduleTransactionKey, removeJeScheduleLocalDataById, retryJeSchedule, retryJeScheduleFailure, retryJeScheduleSuccess, updateJeScheduleTransactionKeys } from '../../reducers/jeSchedulesViewReducer';
9
- export type ActionType = ReturnType<typeof fetchMonthEndCloseChecks> | ReturnType<typeof openSnackbar> | ReturnType<typeof removeFailedJeScheduleTransactionKey> | ReturnType<typeof removeJeScheduleLocalDataById> | ReturnType<typeof retryJeSchedule> | ReturnType<typeof retryJeScheduleFailure> | ReturnType<typeof retryJeScheduleSuccess> | ReturnType<typeof updateJESchedules> | ReturnType<typeof updateJESchedulesDetails> | ReturnType<typeof updateJeScheduleTransactionKeys>;
9
+ export type ActionType = ReturnType<typeof fetchMonthEndCloseChecks> | ReturnType<typeof openSnackbar> | ReturnType<typeof removeFailedJeScheduleTransactionKey> | ReturnType<typeof removeJeScheduleLocalDataById> | ReturnType<typeof removeScheduledJournalEntryFromJESchedule> | ReturnType<typeof retryJeSchedule> | ReturnType<typeof retryJeScheduleFailure> | ReturnType<typeof retryJeScheduleSuccess> | ReturnType<typeof updateJESchedules> | ReturnType<typeof updateJESchedulesDetails> | ReturnType<typeof updateJeScheduleTransactionKeys>;
10
10
  export declare const retryJeScheduleEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.retryJeScheduleEpic = void 0;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
+ const jeSchedulesReducer_1 = require("../../../../entity/jeSchedules/jeSchedulesReducer");
6
7
  const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
7
8
  const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
8
9
  const responsePayload_1 = require("../../../../responsePayload");
@@ -25,9 +26,21 @@ const retryJeScheduleEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, ope
25
26
  .pipe((0, operators_1.mergeMap)((response) => {
26
27
  if ((0, responsePayload_1.isSuccessStatus)(response)) {
27
28
  const updateActions = [];
29
+ // Retire this entry, and the schedule itself only when this was its last failed
30
+ // one. A schedule that failed in several months is several rows sharing one
31
+ // schedule key, so dropping the key outright took the still-failing months off the
32
+ // list with it and nothing would have surfaced them again.
33
+ // Counts only entries that actually carry an error, for the same reason the selector
34
+ // and the local-data seed do: opening a schedule's detail or Quick View replaces
35
+ // this array with every month it has, posted ones included. Counting those left the
36
+ // schedule key in the bucket after its last real failure was resolved, so a later
37
+ // details write could surface a resolved row again with nothing to retry.
38
+ const stillFailingEntriesForSchedule = state.jeSchedulesState.schedulesByTransactionKey[jeScheduleTransactionKey]?.scheduledJournalEntry.filter((journalEntry) => journalEntry.error.length > 0) ?? [];
39
+ const wasLastFailedEntryForSchedule = stillFailingEntriesForSchedule.filter((journalEntry) => journalEntry.scheduledJournalEntryID !==
40
+ scheduledJournalEntryID).length === 0;
28
41
  updateActions.push((0, jeSchedulesViewReducer_1.retryJeScheduleSuccess)({
29
42
  scheduledJournalEntryID,
30
- }), (0, jeSchedulesViewReducer_1.removeFailedJeScheduleTransactionKey)(jeScheduleTransactionKey, selectedPeriod), (0, jeSchedulesViewReducer_1.removeJeScheduleLocalDataById)({ scheduledJournalEntryID }), // Important to remove localdata after success.
43
+ }), (0, jeSchedulesReducer_1.removeScheduledJournalEntryFromJESchedule)(jeScheduleTransactionKey, scheduledJournalEntryID), (0, jeSchedulesViewReducer_1.removeJeScheduleLocalDataById)({ scheduledJournalEntryID }), // Important to remove localdata after success.
31
44
  (0, monthEndCloseChecksViewReducer_1.fetchMonthEndCloseChecks)({
32
45
  tenantId: currentTenant.tenantId,
33
46
  period: selectedPeriod,
@@ -37,6 +50,9 @@ const retryJeScheduleEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, ope
37
50
  messageText: 'success',
38
51
  type: 'success',
39
52
  }));
53
+ if (wasLastFailedEntryForSchedule) {
54
+ updateActions.push((0, jeSchedulesViewReducer_1.removeFailedJeScheduleTransactionKey)(jeScheduleTransactionKey, selectedPeriod));
55
+ }
40
56
  return (0, rxjs_1.from)(updateActions);
41
57
  }
42
58
  else {
@@ -78,6 +78,24 @@ interface ExpenseAutomationJESchedulesPayload {
78
78
  };
79
79
  }
80
80
  export type ExpenseAutomationJESchedulesResponse = ZeniAPIResponse<ExpenseAutomationJESchedulesPayload>;
81
+ /**
82
+ * `GET /1.0/expenses_automation/failed_je_postings`.
83
+ *
84
+ * Deliberately the same `failed_je_postings` shape the schedules endpoint sends under that key, so
85
+ * both responses feed the same mappers. The difference is what the server does before answering:
86
+ * this endpoint applies no date window, so a posting that failed months ago still comes back.
87
+ */
88
+ export interface FailedJePostingsPayload {
89
+ je_schedules: JEScheduledTransactionPayload[];
90
+ scheduled_journal_entries: ScheduledJournalEntryPayload[];
91
+ }
92
+ interface ExpenseAutomationFailedJePostingsPayload {
93
+ failed_je_postings: FailedJePostingsPayload;
94
+ query?: {
95
+ expected_post_start_date: string | null;
96
+ };
97
+ }
98
+ export type ExpenseAutomationFailedJePostingsResponse = ZeniAPIResponse<ExpenseAutomationFailedJePostingsPayload>;
81
99
  export declare const SERVICE_MONTH_FORMAT = "YYYY-MM";
82
100
  export interface CreateOneTimeAccrualPayload {
83
101
  amount: number;
@@ -1,7 +1,7 @@
1
1
  import { ID } from '../../../commonStateTypes/common';
2
2
  import { MonthYearPeriod, TimePeriod } from '../../../commonStateTypes/timePeriod';
3
3
  import { AccountMetadataPayload } from '../../../entity/account/accountPayload';
4
- import { JEAccruedScheduledTransactionPayload, JEOneTimeAccrualPayload, JEScheduledTransactionPayload } from '../../../entity/jeSchedules/jeSchedulesPayload';
4
+ import { JEAccruedScheduledTransactionPayload, JEOneTimeAccrualPayload, JEScheduledTransactionPayload, ScheduledJournalEntryPayload } from '../../../entity/jeSchedules/jeSchedulesPayload';
5
5
  import { OneTimeAccrualEdits } from '../../../entity/jeSchedules/jeSchedulesState';
6
6
  import { JEScheduleKey, JEScheduleTransactionKey, ScheduleTypes } from '../../../entity/jeSchedules/jeSchedulesTypes';
7
7
  import { ZeniAPIStatus } from '../../../responsePayload';
@@ -47,7 +47,14 @@ export declare const clearExpenseAutomationJESchedulesView: import("@reduxjs/too
47
47
  period: TimePeriod;
48
48
  refreshViewInBackground: any;
49
49
  selectedPageTab: "schedules" | "actual_matching" | "existing_schedules" | undefined;
50
- }, "expenseAutomationJESchedulesView/fetchJeSchedules", never, never>, fetchJeSchedulesFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
50
+ }, "expenseAutomationJESchedulesView/fetchJeSchedules", never, never>, fetchFailedJePostings: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[refreshInBackground?: any], {
51
+ refreshInBackground: any;
52
+ }, "expenseAutomationJESchedulesView/fetchFailedJePostings", never, never>, fetchFailedJePostingsFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[status: ZeniAPIStatus<Record<string, unknown>>], {
53
+ status: ZeniAPIStatus<Record<string, unknown>>;
54
+ }, "expenseAutomationJESchedulesView/fetchFailedJePostingsFailure", never, never>, fetchFailedJePostingsSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[failedJeSchedules: JEScheduledTransactionPayload[], failedScheduledJournalEntries: ScheduledJournalEntryPayload[]], {
55
+ failedJeSchedules: JEScheduledTransactionPayload[];
56
+ failedScheduledJournalEntries: ScheduledJournalEntryPayload[];
57
+ }, "expenseAutomationJESchedulesView/fetchFailedJePostingsSuccess", never, never>, fetchJeSchedulesFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
51
58
  selectedPageTab: JEPageTab;
52
59
  selectedPeriod: MonthYearPeriod;
53
60
  status: ZeniAPIStatus;
@@ -132,7 +139,7 @@ export declare const clearExpenseAutomationJESchedulesView: import("@reduxjs/too
132
139
  status: ZeniAPIStatus;
133
140
  }, "expenseAutomationJESchedulesView/searchTransactionsForNewScheduleFailure">, searchTransactionsForNewScheduleSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
134
141
  searchResults: JEScheduleTransactionKey[];
135
- }, "expenseAutomationJESchedulesView/searchTransactionsForNewScheduleSuccess">, toggleJECreatedGroupCollapsed: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationJESchedulesView/toggleJECreatedGroupCollapsed">, toggleJEPendingGroupCollapsed: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationJESchedulesView/toggleJEPendingGroupCollapsed">, updateAccountSettingsListForAccountTypes: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
142
+ }, "expenseAutomationJESchedulesView/searchTransactionsForNewScheduleSuccess">, toggleJECreatedGroupCollapsed: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationJESchedulesView/toggleJECreatedGroupCollapsed">, toggleJEFailedGroupCollapsed: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationJESchedulesView/toggleJEFailedGroupCollapsed">, toggleJEPendingGroupCollapsed: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationJESchedulesView/toggleJEPendingGroupCollapsed">, updateAccountSettingsListForAccountTypes: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
136
143
  accountPayload: AccountMetadataPayload[];
137
144
  }, "expenseAutomationJESchedulesView/updateAccountSettingsListForAccountTypes">, updateAccountSettingsListForAccountTypesFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
138
145
  status: ZeniAPIStatus;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.saveNewScheduleFailure = exports.saveNewSchedule = exports.saveAccountSettingsSuccess = exports.saveAccountSettingsLocalData = exports.saveAccountSettingsFailure = exports.saveAccountSettings = exports.retryJeScheduleSuccess = exports.retryJeScheduleFailure = exports.retryJeSchedule = exports.resetNewScheduleLocalData = exports.removeJeScheduleTransactionKey = exports.removeJeAccruedScheduleKey = exports.removeJeScheduleLocalDataById = exports.removeJeOneTimeAccrualLocalData = exports.removeFailedJeScheduleTransactionKey = exports.initializeNewSchedule = exports.initializeJeScheduleLocalData = exports.initializeAccountSettingsView = exports.ignoreRecommendedJeScheduleSuccess = exports.ignoreRecommendedJeScheduleFailure = exports.ignoreRecommendedJeSchedule = exports.fetchRecommendationForAccountSettings = exports.fetchOneTimeAccrualSuccess = exports.fetchOneTimeAccrualFailure = exports.fetchOneTimeAccrual = exports.fetchJeSchedulesSuccess = exports.fetchJeSchedulesPage = exports.fetchJeSchedulesFailure = exports.fetchJeSchedules = exports.fetchAccountSettingsListForAccountTypes = exports.revertOneTimeAccrual = exports.revertJeScheduleSuccess = exports.revertJeScheduleFailure = exports.revertJeSchedule = exports.promoteOneTimeAccrual = exports.oneTimeAccrualActionSuccess = exports.oneTimeAccrualActionFailure = exports.ignoreOneTimeAccrual = exports.createOneTimeAccrualSuccess = exports.createOneTimeAccrualFailure = exports.createOneTimeAccrual = exports.clearSearchTransactionsForNewSchedule = exports.clearJeScheduleLocalData = exports.clearJeAccountSettingsLocalData = exports.clearExpenseAutomationJESchedulesView = exports.initialState = exports.searchTransactionsInitialState = exports.newScheduleInitialState = exports.getBaseNewScheduleLocalData = exports.accountSettingsInitialState = void 0;
5
- exports.updateRecommendationForAccountSettingsFailure = exports.updateRecommendationForAccountSettings = exports.updateNewScheduleLocalData = exports.updateJeScheduleTransactionKeys = exports.updateJeScheduleLocalDataById = exports.updateJeOneTimeAccrualLocalData = exports.updateJEScheduleTypeFilter = exports.updateJESchedulesUIState = exports.updateAccountSettingsListForAccountTypesFailure = exports.updateAccountSettingsListForAccountTypes = exports.toggleJEPendingGroupCollapsed = exports.toggleJECreatedGroupCollapsed = exports.searchTransactionsForNewScheduleSuccess = exports.searchTransactionsForNewScheduleFailure = exports.searchTransactionsForNewSchedule = exports.saveNewScheduleSuccess = void 0;
4
+ exports.saveAccountSettingsLocalData = exports.saveAccountSettingsFailure = exports.saveAccountSettings = exports.retryJeScheduleSuccess = exports.retryJeScheduleFailure = exports.retryJeSchedule = exports.resetNewScheduleLocalData = exports.removeJeScheduleTransactionKey = exports.removeJeAccruedScheduleKey = exports.removeJeScheduleLocalDataById = exports.removeJeOneTimeAccrualLocalData = exports.removeFailedJeScheduleTransactionKey = exports.initializeNewSchedule = exports.initializeJeScheduleLocalData = exports.initializeAccountSettingsView = exports.ignoreRecommendedJeScheduleSuccess = exports.ignoreRecommendedJeScheduleFailure = exports.ignoreRecommendedJeSchedule = exports.fetchRecommendationForAccountSettings = exports.fetchOneTimeAccrualSuccess = exports.fetchOneTimeAccrualFailure = exports.fetchOneTimeAccrual = exports.fetchJeSchedulesSuccess = exports.fetchJeSchedulesPage = exports.fetchJeSchedulesFailure = exports.fetchFailedJePostingsSuccess = exports.fetchFailedJePostingsFailure = exports.fetchFailedJePostings = exports.fetchJeSchedules = exports.fetchAccountSettingsListForAccountTypes = exports.revertOneTimeAccrual = exports.revertJeScheduleSuccess = exports.revertJeScheduleFailure = exports.revertJeSchedule = exports.promoteOneTimeAccrual = exports.oneTimeAccrualActionSuccess = exports.oneTimeAccrualActionFailure = exports.ignoreOneTimeAccrual = exports.createOneTimeAccrualSuccess = exports.createOneTimeAccrualFailure = exports.createOneTimeAccrual = exports.clearSearchTransactionsForNewSchedule = exports.clearJeScheduleLocalData = exports.clearJeAccountSettingsLocalData = exports.clearExpenseAutomationJESchedulesView = exports.initialState = exports.searchTransactionsInitialState = exports.newScheduleInitialState = exports.getBaseNewScheduleLocalData = exports.accountSettingsInitialState = void 0;
5
+ exports.updateRecommendationForAccountSettingsFailure = exports.updateRecommendationForAccountSettings = exports.updateNewScheduleLocalData = exports.updateJeScheduleTransactionKeys = exports.updateJeScheduleLocalDataById = exports.updateJeOneTimeAccrualLocalData = exports.updateJEScheduleTypeFilter = exports.updateJESchedulesUIState = exports.updateAccountSettingsListForAccountTypesFailure = exports.updateAccountSettingsListForAccountTypes = exports.toggleJEPendingGroupCollapsed = exports.toggleJEFailedGroupCollapsed = exports.toggleJECreatedGroupCollapsed = exports.searchTransactionsForNewScheduleSuccess = exports.searchTransactionsForNewScheduleFailure = exports.searchTransactionsForNewSchedule = exports.saveNewScheduleSuccess = exports.saveNewScheduleFailure = exports.saveNewSchedule = exports.saveAccountSettingsSuccess = void 0;
6
6
  const toolkit_1 = require("@reduxjs/toolkit");
7
7
  const getNestedAccountIDHierarchyForReport_1 = require("../../../commonStateTypes/accountView/getNestedAccountIDHierarchyForReport");
8
8
  const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
@@ -68,6 +68,11 @@ exports.initialState = {
68
68
  jeScheduleAccruedKeysByPeriodAndTab: {},
69
69
  jeScheduleOneTimeAccrualKeysByPeriodAndTab: {},
70
70
  failedJeScheduleTransactionKeysByPeriodAndTab: {},
71
+ failedJePostings: {
72
+ fetchState: { fetchState: 'Not-Started', error: undefined },
73
+ jeScheduleTransactionKeys: [],
74
+ scheduledJournalEntryIDs: [],
75
+ },
71
76
  postStatusById: {},
72
77
  ignoreStatusById: {},
73
78
  revertStatusById: {},
@@ -77,6 +82,9 @@ exports.initialState = {
77
82
  oneTimeAccrualFetchStatusById: {},
78
83
  uiState: {
79
84
  createdGroupCollapsed: false,
85
+ // Expanded, like the other two. A failed posting is the only thing on this page that is
86
+ // actively wrong, so folding it away by default would hide the reason to open the tab.
87
+ failedGroupCollapsed: false,
80
88
  pendingGroupCollapsed: false,
81
89
  scrollPosition: { scrollTop: 0, scrollLeft: undefined },
82
90
  searchString: '',
@@ -148,6 +156,59 @@ const expenseAutomationJESchedulesView = (0, toolkit_1.createSlice)({
148
156
  };
149
157
  },
150
158
  },
159
+ /**
160
+ * The Failed Postings list, fetched separately from the schedules it belongs to.
161
+ *
162
+ * No period and no tab in any of these three: the endpoint applies no date window, so there is
163
+ * one list per tenant and one slot to hold it. `refreshInBackground` keeps a silent refetch
164
+ * from dropping a skeleton over rows already on screen, the same way refreshStatus does for
165
+ * the schedules list.
166
+ */
167
+ fetchFailedJePostings: {
168
+ reducer(draft, action) {
169
+ if (!action.payload.refreshInBackground) {
170
+ draft.failedJePostings.fetchState = {
171
+ fetchState: 'In-Progress',
172
+ error: undefined,
173
+ };
174
+ }
175
+ },
176
+ prepare(refreshInBackground = false) {
177
+ return { payload: { refreshInBackground } };
178
+ },
179
+ },
180
+ fetchFailedJePostingsSuccess: {
181
+ reducer(draft, action) {
182
+ // Both lists are replaced, never merged: this response is the whole current answer to
183
+ // "what is failing right now", so an entry it no longer names has stopped failing --
184
+ // resolved by someone else, or posted since -- and must drop out of the group.
185
+ draft.failedJePostings = {
186
+ fetchState: { fetchState: 'Completed', error: undefined },
187
+ jeScheduleTransactionKeys: action.payload.failedJeSchedules.map((schedule) => (0, jeSchedulesPayload_1.getJEScheduleTransactionDetailKeyPayload)(schedule.base_transaction)),
188
+ // `?? ''` mirrors toScheduledJournalEntryState, so an entry the server sent without an
189
+ // id lands on the same value on both sides and still matches itself.
190
+ scheduledJournalEntryIDs: action.payload.failedScheduledJournalEntries.map((journalEntry) => journalEntry.scheduled_journal_entry_id ?? ''),
191
+ };
192
+ },
193
+ prepare(failedJeSchedules, failedScheduledJournalEntries) {
194
+ return { payload: { failedJeSchedules, failedScheduledJournalEntries } };
195
+ },
196
+ },
197
+ fetchFailedJePostingsFailure: {
198
+ reducer(draft, action) {
199
+ // Keys are deliberately left alone. The schedules list clears its buckets on failure so an
200
+ // errored tab cannot read as "these are all the schedules there are", but this list is a
201
+ // set of outstanding problems -- showing the last known ones beside an error beats
202
+ // implying there are none.
203
+ draft.failedJePostings.fetchState = {
204
+ fetchState: 'Error',
205
+ error: action.payload.status,
206
+ };
207
+ },
208
+ prepare(status) {
209
+ return { payload: { status } };
210
+ },
211
+ },
151
212
  fetchJeSchedulesSuccess(draft, action) {
152
213
  const { jeSchedules, selectedPeriod, selectedPageTab, failedJeSchedules, accruedJeSchedules, oneTimeAccruals, refreshViewInBackground, } = action.payload;
153
214
  const periodTabKey = (0, jeSchedulesViewState_1.getJESchedulePeriodTabKey)(selectedPageTab, (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod));
@@ -210,6 +271,13 @@ const expenseAutomationJESchedulesView = (0, toolkit_1.createSlice)({
210
271
  error: undefined,
211
272
  },
212
273
  };
274
+ // This posting has just succeeded, so it is no longer part of the failing set. Removing the
275
+ // entry from the schedule entity is not enough on its own: a later detail or Quick View
276
+ // fetch re-adds that month from the server, and because is_posting_failed is never cleared
277
+ // it can still arrive carrying its old error array. With the id left in place the selector
278
+ // would match it again and put a Retry button back on a posting that already went through.
279
+ draft.failedJePostings.scheduledJournalEntryIDs =
280
+ draft.failedJePostings.scheduledJournalEntryIDs.filter((failedEntryID) => failedEntryID !== scheduledJournalEntryID);
213
281
  },
214
282
  retryJeScheduleFailure(draft, action) {
215
283
  const { status, scheduledJournalEntryID } = action.payload;
@@ -364,6 +432,8 @@ const expenseAutomationJESchedulesView = (0, toolkit_1.createSlice)({
364
432
  reducer(draft, action) {
365
433
  const { failedJeScheduleKey } = action.payload;
366
434
  removeKeyFromEveryTabSlot(draft.failedJeScheduleTransactionKeysByPeriodAndTab, failedJeScheduleKey);
435
+ draft.failedJePostings.jeScheduleTransactionKeys =
436
+ draft.failedJePostings.jeScheduleTransactionKeys.filter((jeScheduleKey) => jeScheduleKey !== failedJeScheduleKey);
367
437
  },
368
438
  },
369
439
  initializeJeScheduleLocalData: {
@@ -706,6 +776,9 @@ const expenseAutomationJESchedulesView = (0, toolkit_1.createSlice)({
706
776
  draft.uiState.createdGroupCollapsed =
707
777
  !draft.uiState.createdGroupCollapsed;
708
778
  },
779
+ toggleJEFailedGroupCollapsed(draft) {
780
+ draft.uiState.failedGroupCollapsed = !draft.uiState.failedGroupCollapsed;
781
+ },
709
782
  clearExpenseAutomationJESchedulesView(draft) {
710
783
  Object.assign(draft, exports.initialState);
711
784
  },
@@ -716,7 +789,7 @@ const expenseAutomationJESchedulesView = (0, toolkit_1.createSlice)({
716
789
  });
717
790
  },
718
791
  });
719
- _a = expenseAutomationJESchedulesView.actions, exports.clearExpenseAutomationJESchedulesView = _a.clearExpenseAutomationJESchedulesView, exports.clearJeAccountSettingsLocalData = _a.clearJeAccountSettingsLocalData, exports.clearJeScheduleLocalData = _a.clearJeScheduleLocalData, exports.clearSearchTransactionsForNewSchedule = _a.clearSearchTransactionsForNewSchedule, exports.createOneTimeAccrual = _a.createOneTimeAccrual, exports.createOneTimeAccrualFailure = _a.createOneTimeAccrualFailure, exports.createOneTimeAccrualSuccess = _a.createOneTimeAccrualSuccess, exports.ignoreOneTimeAccrual = _a.ignoreOneTimeAccrual, exports.oneTimeAccrualActionFailure = _a.oneTimeAccrualActionFailure, exports.oneTimeAccrualActionSuccess = _a.oneTimeAccrualActionSuccess, exports.promoteOneTimeAccrual = _a.promoteOneTimeAccrual, exports.revertJeSchedule = _a.revertJeSchedule, exports.revertJeScheduleFailure = _a.revertJeScheduleFailure, exports.revertJeScheduleSuccess = _a.revertJeScheduleSuccess, exports.revertOneTimeAccrual = _a.revertOneTimeAccrual, exports.fetchAccountSettingsListForAccountTypes = _a.fetchAccountSettingsListForAccountTypes, exports.fetchJeSchedules = _a.fetchJeSchedules, exports.fetchJeSchedulesFailure = _a.fetchJeSchedulesFailure, exports.fetchJeSchedulesPage = _a.fetchJeSchedulesPage, exports.fetchJeSchedulesSuccess = _a.fetchJeSchedulesSuccess, exports.fetchOneTimeAccrual = _a.fetchOneTimeAccrual, exports.fetchOneTimeAccrualFailure = _a.fetchOneTimeAccrualFailure, exports.fetchOneTimeAccrualSuccess = _a.fetchOneTimeAccrualSuccess, exports.fetchRecommendationForAccountSettings = _a.fetchRecommendationForAccountSettings, exports.ignoreRecommendedJeSchedule = _a.ignoreRecommendedJeSchedule, exports.ignoreRecommendedJeScheduleFailure = _a.ignoreRecommendedJeScheduleFailure, exports.ignoreRecommendedJeScheduleSuccess = _a.ignoreRecommendedJeScheduleSuccess, exports.initializeAccountSettingsView = _a.initializeAccountSettingsView, exports.initializeJeScheduleLocalData = _a.initializeJeScheduleLocalData, exports.initializeNewSchedule = _a.initializeNewSchedule, exports.removeFailedJeScheduleTransactionKey = _a.removeFailedJeScheduleTransactionKey, exports.removeJeOneTimeAccrualLocalData = _a.removeJeOneTimeAccrualLocalData, exports.removeJeScheduleLocalDataById = _a.removeJeScheduleLocalDataById, exports.removeJeAccruedScheduleKey = _a.removeJeAccruedScheduleKey, exports.removeJeScheduleTransactionKey = _a.removeJeScheduleTransactionKey, exports.resetNewScheduleLocalData = _a.resetNewScheduleLocalData, exports.retryJeSchedule = _a.retryJeSchedule, exports.retryJeScheduleFailure = _a.retryJeScheduleFailure, exports.retryJeScheduleSuccess = _a.retryJeScheduleSuccess, exports.saveAccountSettings = _a.saveAccountSettings, exports.saveAccountSettingsFailure = _a.saveAccountSettingsFailure, exports.saveAccountSettingsLocalData = _a.saveAccountSettingsLocalData, exports.saveAccountSettingsSuccess = _a.saveAccountSettingsSuccess, exports.saveNewSchedule = _a.saveNewSchedule, exports.saveNewScheduleFailure = _a.saveNewScheduleFailure, exports.saveNewScheduleSuccess = _a.saveNewScheduleSuccess, exports.searchTransactionsForNewSchedule = _a.searchTransactionsForNewSchedule, exports.searchTransactionsForNewScheduleFailure = _a.searchTransactionsForNewScheduleFailure, exports.searchTransactionsForNewScheduleSuccess = _a.searchTransactionsForNewScheduleSuccess, exports.toggleJECreatedGroupCollapsed = _a.toggleJECreatedGroupCollapsed, exports.toggleJEPendingGroupCollapsed = _a.toggleJEPendingGroupCollapsed, exports.updateAccountSettingsListForAccountTypes = _a.updateAccountSettingsListForAccountTypes, exports.updateAccountSettingsListForAccountTypesFailure = _a.updateAccountSettingsListForAccountTypesFailure, exports.updateJESchedulesUIState = _a.updateJESchedulesUIState, exports.updateJEScheduleTypeFilter = _a.updateJEScheduleTypeFilter, exports.updateJeOneTimeAccrualLocalData = _a.updateJeOneTimeAccrualLocalData, exports.updateJeScheduleLocalDataById = _a.updateJeScheduleLocalDataById, exports.updateJeScheduleTransactionKeys = _a.updateJeScheduleTransactionKeys, exports.updateNewScheduleLocalData = _a.updateNewScheduleLocalData, exports.updateRecommendationForAccountSettings = _a.updateRecommendationForAccountSettings, exports.updateRecommendationForAccountSettingsFailure = _a.updateRecommendationForAccountSettingsFailure;
792
+ _a = expenseAutomationJESchedulesView.actions, exports.clearExpenseAutomationJESchedulesView = _a.clearExpenseAutomationJESchedulesView, exports.clearJeAccountSettingsLocalData = _a.clearJeAccountSettingsLocalData, exports.clearJeScheduleLocalData = _a.clearJeScheduleLocalData, exports.clearSearchTransactionsForNewSchedule = _a.clearSearchTransactionsForNewSchedule, exports.createOneTimeAccrual = _a.createOneTimeAccrual, exports.createOneTimeAccrualFailure = _a.createOneTimeAccrualFailure, exports.createOneTimeAccrualSuccess = _a.createOneTimeAccrualSuccess, exports.ignoreOneTimeAccrual = _a.ignoreOneTimeAccrual, exports.oneTimeAccrualActionFailure = _a.oneTimeAccrualActionFailure, exports.oneTimeAccrualActionSuccess = _a.oneTimeAccrualActionSuccess, exports.promoteOneTimeAccrual = _a.promoteOneTimeAccrual, exports.revertJeSchedule = _a.revertJeSchedule, exports.revertJeScheduleFailure = _a.revertJeScheduleFailure, exports.revertJeScheduleSuccess = _a.revertJeScheduleSuccess, exports.revertOneTimeAccrual = _a.revertOneTimeAccrual, exports.fetchAccountSettingsListForAccountTypes = _a.fetchAccountSettingsListForAccountTypes, exports.fetchJeSchedules = _a.fetchJeSchedules, exports.fetchFailedJePostings = _a.fetchFailedJePostings, exports.fetchFailedJePostingsFailure = _a.fetchFailedJePostingsFailure, exports.fetchFailedJePostingsSuccess = _a.fetchFailedJePostingsSuccess, exports.fetchJeSchedulesFailure = _a.fetchJeSchedulesFailure, exports.fetchJeSchedulesPage = _a.fetchJeSchedulesPage, exports.fetchJeSchedulesSuccess = _a.fetchJeSchedulesSuccess, exports.fetchOneTimeAccrual = _a.fetchOneTimeAccrual, exports.fetchOneTimeAccrualFailure = _a.fetchOneTimeAccrualFailure, exports.fetchOneTimeAccrualSuccess = _a.fetchOneTimeAccrualSuccess, exports.fetchRecommendationForAccountSettings = _a.fetchRecommendationForAccountSettings, exports.ignoreRecommendedJeSchedule = _a.ignoreRecommendedJeSchedule, exports.ignoreRecommendedJeScheduleFailure = _a.ignoreRecommendedJeScheduleFailure, exports.ignoreRecommendedJeScheduleSuccess = _a.ignoreRecommendedJeScheduleSuccess, exports.initializeAccountSettingsView = _a.initializeAccountSettingsView, exports.initializeJeScheduleLocalData = _a.initializeJeScheduleLocalData, exports.initializeNewSchedule = _a.initializeNewSchedule, exports.removeFailedJeScheduleTransactionKey = _a.removeFailedJeScheduleTransactionKey, exports.removeJeOneTimeAccrualLocalData = _a.removeJeOneTimeAccrualLocalData, exports.removeJeScheduleLocalDataById = _a.removeJeScheduleLocalDataById, exports.removeJeAccruedScheduleKey = _a.removeJeAccruedScheduleKey, exports.removeJeScheduleTransactionKey = _a.removeJeScheduleTransactionKey, exports.resetNewScheduleLocalData = _a.resetNewScheduleLocalData, exports.retryJeSchedule = _a.retryJeSchedule, exports.retryJeScheduleFailure = _a.retryJeScheduleFailure, exports.retryJeScheduleSuccess = _a.retryJeScheduleSuccess, exports.saveAccountSettings = _a.saveAccountSettings, exports.saveAccountSettingsFailure = _a.saveAccountSettingsFailure, exports.saveAccountSettingsLocalData = _a.saveAccountSettingsLocalData, exports.saveAccountSettingsSuccess = _a.saveAccountSettingsSuccess, exports.saveNewSchedule = _a.saveNewSchedule, exports.saveNewScheduleFailure = _a.saveNewScheduleFailure, exports.saveNewScheduleSuccess = _a.saveNewScheduleSuccess, exports.searchTransactionsForNewSchedule = _a.searchTransactionsForNewSchedule, exports.searchTransactionsForNewScheduleFailure = _a.searchTransactionsForNewScheduleFailure, exports.searchTransactionsForNewScheduleSuccess = _a.searchTransactionsForNewScheduleSuccess, exports.toggleJECreatedGroupCollapsed = _a.toggleJECreatedGroupCollapsed, exports.toggleJEFailedGroupCollapsed = _a.toggleJEFailedGroupCollapsed, exports.toggleJEPendingGroupCollapsed = _a.toggleJEPendingGroupCollapsed, exports.updateAccountSettingsListForAccountTypes = _a.updateAccountSettingsListForAccountTypes, exports.updateAccountSettingsListForAccountTypesFailure = _a.updateAccountSettingsListForAccountTypesFailure, exports.updateJESchedulesUIState = _a.updateJESchedulesUIState, exports.updateJEScheduleTypeFilter = _a.updateJEScheduleTypeFilter, exports.updateJeOneTimeAccrualLocalData = _a.updateJeOneTimeAccrualLocalData, exports.updateJeScheduleLocalDataById = _a.updateJeScheduleLocalDataById, exports.updateJeScheduleTransactionKeys = _a.updateJeScheduleTransactionKeys, exports.updateNewScheduleLocalData = _a.updateNewScheduleLocalData, exports.updateRecommendationForAccountSettings = _a.updateRecommendationForAccountSettings, exports.updateRecommendationForAccountSettingsFailure = _a.updateRecommendationForAccountSettingsFailure;
720
793
  exports.default = expenseAutomationJESchedulesView.reducer;
721
794
  const doUpdateRecommendationForAccountSettings = (draft, payload) => {
722
795
  const { prepaidExpensesRecommendations, fixedAssetsRecommendations, accruedExpensesRecommendations, } = (0, accountTypeRecommendationPayload_1.mapAccountTypeRecommendationPayloadToAccountRecommendationByType)(payload);
@@ -47,6 +47,8 @@ export interface ExpenseAutomationJESchedulesViewSelector extends SelectorView {
47
47
  completionStatus: CompletionStatusType;
48
48
  createdSchedules: JEScheduleRow[];
49
49
  createdTotal: number;
50
+ failedPostings: JEScheduledTransactionWithFailedEntries[];
51
+ failedPostingsFetchState: FetchStateAndError;
50
52
  hasLoadedForSelectedTab: boolean;
51
53
  ignoreStatusById: Record<JEScheduleTransactionKey, FetchStateAndError>;
52
54
  jeScheduleLocalDataById: Record<ID, JEScheduleLocalData>;
@@ -61,6 +63,7 @@ export interface ExpenseAutomationJESchedulesViewSelector extends SelectorView {
61
63
  pendingReviewTotal: number;
62
64
  postStatusById: Record<ID, FetchStateAndError>;
63
65
  refreshStatus: FetchStateAndError;
66
+ /** @deprecated Alias of `failedPostings`. Remove once webc and app-ui are repointed. */
64
67
  resolveSchedules: JEScheduledTransactionWithFailedEntries[];
65
68
  revertStatusById: Record<JEScheduleKey | JEScheduleTransactionKey, FetchStateAndError>;
66
69
  scheduleCountsByTab: Partial<Record<JEPageTab, number>>;
@@ -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.56",
3
+ "version": "5.2.57",
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",