@zeniai/client-epic-state 5.2.14-betaRD0 → 5.2.14

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 (100) hide show
  1. package/lib/entity/jeSchedules/jeScheduleHelper.d.ts +0 -1
  2. package/lib/entity/jeSchedules/jeScheduleHelper.js +0 -7
  3. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +1 -78
  4. package/lib/entity/jeSchedules/jeSchedulesPayload.js +4 -183
  5. package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +2 -4
  6. package/lib/entity/jeSchedules/jeSchedulesReducer.js +2 -30
  7. package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +2 -11
  8. package/lib/entity/jeSchedules/jeSchedulesSelector.js +3 -38
  9. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +1 -123
  10. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +1 -24
  11. package/lib/entity/jeSchedules/jeSchedulesTypes.js +1 -96
  12. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  13. package/lib/entity/snackbar/snackbarTypes.js +0 -3
  14. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +0 -2
  15. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -2
  16. package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +0 -2
  17. package/lib/epic.d.ts +1 -9
  18. package/lib/epic.js +0 -16
  19. package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +0 -6
  20. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +5 -183
  21. package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +2 -30
  22. package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +2 -36
  23. package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +0 -86
  24. package/lib/esm/entity/snackbar/snackbarTypes.js +0 -3
  25. package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -2
  26. package/lib/esm/epic.js +0 -16
  27. package/lib/esm/index.js +8 -14
  28. package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +3 -6
  29. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +1 -9
  30. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +5 -41
  31. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +2 -14
  32. package/lib/esm/view/expenseAutomationView/payload/jeSchedulesPayload.js +0 -55
  33. package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +29 -319
  34. package/lib/esm/view/expenseAutomationView/selectors/jeAccountSettingsViewSelector.js +0 -1
  35. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +22 -327
  36. package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +6 -5
  37. package/lib/esm/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
  38. package/lib/esm/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +2 -7
  39. package/lib/esm/view/scheduleView/scheduleListView/scheduleListReducer.js +3 -5
  40. package/lib/index.d.ts +12 -17
  41. package/lib/index.js +47 -91
  42. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +3 -6
  43. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +1 -9
  44. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +2 -3
  45. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +3 -39
  46. package/lib/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +2 -14
  47. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  48. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +3 -86
  49. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.js +1 -58
  50. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +12 -93
  51. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +29 -321
  52. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -1
  53. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +2 -2
  54. package/lib/view/expenseAutomationView/selectorTypes/jeAccountSettingsViewSelectorTypes.d.ts +0 -1
  55. package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +7 -41
  56. package/lib/view/expenseAutomationView/selectors/jeAccountSettingsViewSelector.js +0 -1
  57. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +0 -34
  58. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +21 -335
  59. package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
  60. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +8 -83
  61. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -8
  62. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -1
  63. package/lib/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
  64. package/lib/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +2 -7
  65. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.d.ts +2 -4
  66. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.js +3 -5
  67. package/package.json +1 -1
  68. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +0 -45
  69. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +0 -104
  70. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +0 -25
  71. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +0 -138
  72. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +0 -79
  73. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +0 -180
  74. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +0 -111
  75. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +0 -28
  76. package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +0 -140
  77. package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +0 -1
  78. package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +0 -106
  79. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.d.ts +0 -21
  80. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +0 -49
  81. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.d.ts +0 -9
  82. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +0 -108
  83. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +0 -8
  84. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +0 -29
  85. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts +0 -9
  86. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +0 -142
  87. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +0 -8
  88. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +0 -83
  89. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.d.ts +0 -13
  90. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +0 -187
  91. package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.d.ts +0 -65
  92. package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +0 -115
  93. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +0 -6
  94. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +0 -32
  95. package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.d.ts +0 -36
  96. package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +0 -145
  97. package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +0 -42
  98. package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +0 -2
  99. package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +0 -21
  100. package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +0 -112
@@ -3,9 +3,7 @@ import orderBy from 'lodash/orderBy';
3
3
  import { reduceAnyFetchState } from '../../../commonStateTypes/reduceFetchState';
4
4
  import { LAST_SCHEDULE_DAY_OF_MONTH, toMonthYearPeriodId, } from '../../../commonStateTypes/timePeriod';
5
5
  import { getAccountIdsForTypes } from '../../../entity/account/accountSelector';
6
- import { generateJEOneTimeAccrualKey } from '../../../entity/jeSchedules/jeScheduleHelper';
7
- import { getJEAccruedScheduleByJEScheduleKey, getJEOneTimeAccrualByKey, getJEScheduledTransactionByJEScheduleTransactionKey, } from '../../../entity/jeSchedules/jeSchedulesSelector';
8
- import { ALL_SCHEDULES_TYPES, } from '../../../entity/jeSchedules/jeSchedulesTypes';
6
+ import { getJEScheduledTransactionByJEScheduleTransactionKey, } from '../../../entity/jeSchedules/jeSchedulesSelector';
9
7
  import { getCurrentTenant } from '../../../entity/tenant/tenantSelector';
10
8
  import { getAccountIdsForLabel, getAccountList, getNestedAccountListHierarchy, getUncategorizedAccounts, } from '../../accountList/accountListSelector';
11
9
  import { getClassList, getNestedClassListHierarchy, } from '../../classList/classListSelector';
@@ -13,143 +11,8 @@ import { getAccountsTypesForScheduleDetails } from '../../scheduleView/scheduleD
13
11
  import { filterNestedAccountHierarchyById } from '../../scheduleView/scheduleDetailView/scheduleDetailSelector';
14
12
  import { getAccountLabelForScheduleType, getAccountsTypesForScheduleList, } from '../../scheduleView/scheduleListView/scheduleListHelper';
15
13
  import { getAllSteps } from './getAllStepsHelper';
16
- import { ALL_JE_PAGE_TABS, getJESchedulePeriodTabKey, } from '../types/jeSchedulesViewState';
17
14
  import { getJEAccountSettingsView } from './jeAccountSettingsViewSelector';
18
- import { getNewScheduleView } from './jeNewScheduleViewSelector';
19
- // Matches the AI-automation user addresses webc's schedule list row already
20
- // checks (JEScheduleReadOnlyListRow/JEScheduleDraftListRow "Method" column,
21
- // strings.ts aiBotEmail/botEmail) to determine whether a schedule was
22
- // created by the AI accountant vs. a human.
23
- const AI_BOT_EMAIL = 'ai@zeni.ai';
24
- const BOT_EMAIL = 'bot@zeni.ai';
25
- // A one-time accrual has no jeScheduleType of its own — it is not a JE schedule. It is still an
26
- // accrued expense, so it counts and filters under that type on the page's type tabs.
27
- const ONE_TIME_ACCRUAL_SCHEDULE_TYPE = 'accrued_expenses';
28
- // Which of the two list buckets an accrual belongs in. `draft` still needs a human to post it;
29
- // everything else is already on the books or in a transient claim.
30
- const ONE_TIME_ACCRUAL_REVIEW_STATUSES = [
31
- 'draft',
32
- ];
33
- /**
34
- * `posting_blocked` is written by the posting Cron when a JE fails to post. It is an internal
35
- * failure state with no human action attached, so it is dropped here rather than hidden at render
36
- * time — filtering in the view would leave the group counts and KPI totals counting rows nobody
37
- * can see. The expense-automation endpoint applies no status filter on the close-period path, so
38
- * these rows do arrive.
39
- */
40
- export function isRenderableOneTimeAccrual(accrual) {
41
- return (accrual.accrualStatus !== 'posting_blocked' &&
42
- // Terminal states the user has already decided. The GET list excludes both server-side, so
43
- // these only appear in the window between an ignore/revert response being written back and the
44
- // background refresh landing -- during which an ignored row would otherwise sit in Pending
45
- // Review offering a Post button. Dropped here rather than at render time so group counts and
46
- // KPI totals do not count rows nobody can see.
47
- accrual.accrualStatus !== 'reverted' &&
48
- !accrual.isIgnored);
49
- }
50
- export function getJEScheduleRowType(schedule) {
51
- return isOneTimeAccrualRow(schedule)
52
- ? ONE_TIME_ACCRUAL_SCHEDULE_TYPE
53
- : schedule.jeScheduleType;
54
- }
55
- export function isPendingReviewRow(schedule) {
56
- return isOneTimeAccrualRow(schedule)
57
- ? ONE_TIME_ACCRUAL_REVIEW_STATUSES.includes(schedule.accrualStatus)
58
- : schedule.status.code === 'draft';
59
- }
60
- // Belongs on the Existing Schedules tab. For an accrual the endpoint has already filtered to
61
- // posted, so this only has to agree with that rather than re-derive it.
62
- export function isExistingTabRow(schedule) {
63
- return isOneTimeAccrualRow(schedule)
64
- ? schedule.accrualStatus === 'posted'
65
- : schedule.status.code === 'ongoing';
66
- }
67
- // Exported (rather than kept as a closure inside the selector) so it can be
68
- // unit-tested directly — confidenceScore is a separate, more narrowly
69
- // populated field that can be null on a schedule the bot user created,
70
- // which previously caused these schedules to display as "AI Accountant" in
71
- // the list but count under "Manual" in the KPI summary.
72
- export const isAiAccountantSchedule = (schedule) => {
73
- // A one-time accrual records who made it as `origin`, which is authoritative — no email
74
- // sniffing needed, and the JE bot is often absent from the user entity entirely.
75
- if (isOneTimeAccrualRow(schedule)) {
76
- return schedule.origin === 'agent';
77
- }
78
- return (schedule.createdByUser?.email === AI_BOT_EMAIL ||
79
- schedule.createdByUser?.email === BOT_EMAIL);
80
- };
81
- // Accrued schedules are structurally distinct — no baseTransaction, carrying recurringAmount and
82
- // memo in its place — so anything reading baseTransaction has to branch on this first.
83
- //
84
- // Discriminates on jeAccruedScheduleKey, which only JEAccruedSchedule carries. jeScheduleType
85
- // cannot be used: it is a data field present on BOTH row shapes, so an accrued-typed row that
86
- // arrived through the prepaid/fixed DTO (failed_je_postings, legacy fetches) would be
87
- // misclassified and then crash on recurringAmount / jeAccruedScheduleKey.
88
- export function isAccruedScheduleRow(schedule) {
89
- return 'jeAccruedScheduleKey' in schedule;
90
- }
91
- // Same structural approach as isAccruedScheduleRow, and for the same reason: jeOneTimeAccrualKey
92
- // exists only on this shape. Note the two guards are NOT interchangeable — a one-time accrual is
93
- // not an accrued *schedule*, and routing it into the accrued branch would read recurringAmount,
94
- // render postedCount/lifecycleTotal as a lifecycle and startDate–endDate as a period, none of
95
- // which it has.
96
- export function isOneTimeAccrualRow(schedule) {
97
- return 'jeOneTimeAccrualKey' in schedule;
98
- }
99
- /** The row's own Amount, so callers can read its currency and not just its value. */
100
- function getScheduleAmountObject(schedule) {
101
- if (isOneTimeAccrualRow(schedule)) {
102
- return schedule.estimatedAmount;
103
- }
104
- if (isAccruedScheduleRow(schedule)) {
105
- return schedule.recurringAmount;
106
- }
107
- return schedule.baseTransaction.amount;
108
- }
109
- function getScheduleAmount(schedule) {
110
- if (isOneTimeAccrualRow(schedule)) {
111
- return schedule.estimatedAmount.amount;
112
- }
113
- if (isAccruedScheduleRow(schedule)) {
114
- return schedule.recurringAmount.amount;
115
- }
116
- return schedule.baseTransaction.amount.amount;
117
- }
118
- // A one-time accrual shares almost no sortable field with a schedule, so it gets its own accessor
119
- // rather than a guard on each of the dozen cases below. Keys with no meaning for a single-month
120
- // accrual -- amortizationPeriod, remainingMonths, runningBalance, jePostingDate, scheduleCategory --
121
- // deliberately fall through to undefined, which sorts them together at one end.
122
- function getOneTimeAccrualSortValue(accrual, sortKey) {
123
- switch (sortKey) {
124
- case 'vendor':
125
- return accrual.vendorName.toLowerCase();
126
- case 'category':
127
- return accrual.jeDebitAccountName?.toLowerCase();
128
- case 'class':
129
- return accrual.jeDebitAccountingClassName?.toLowerCase();
130
- case 'depCategory':
131
- return accrual.jeCreditAccountName?.toLowerCase();
132
- case 'type':
133
- return ONE_TIME_ACCRUAL_SCHEDULE_TYPE;
134
- case 'totalAmount':
135
- return accrual.estimatedAmount.amount;
136
- case 'transactionDate':
137
- return accrual.postingDate?.valueOf();
138
- case 'memo':
139
- return accrual.memo.toLowerCase();
140
- case 'startMonth':
141
- return accrual.serviceMonth;
142
- default:
143
- return undefined;
144
- }
145
- }
146
15
  function getJEScheduleSortAccessor(sortKey) {
147
- const scheduleAccessor = getScheduleRowSortAccessor(sortKey);
148
- return (schedule) => isOneTimeAccrualRow(schedule)
149
- ? getOneTimeAccrualSortValue(schedule, sortKey)
150
- : scheduleAccessor(schedule);
151
- }
152
- function getScheduleRowSortAccessor(sortKey) {
153
16
  switch (sortKey) {
154
17
  case 'vendor':
155
18
  return (s) => s.vendor.name?.toLowerCase();
@@ -160,9 +23,7 @@ function getScheduleRowSortAccessor(sortKey) {
160
23
  case 'depCategory':
161
24
  return (s) => s.jeCredit.account?.accountName?.toLowerCase();
162
25
  case 'scheduleCategory':
163
- return (s) => isAccruedScheduleRow(s)
164
- ? undefined
165
- : s.baseTransaction.account?.accountName?.toLowerCase();
26
+ return (s) => s.baseTransaction.account?.accountName?.toLowerCase();
166
27
  case 'startMonth':
167
28
  return (s) => s.startDate?.valueOf();
168
29
  case 'type':
@@ -190,13 +51,11 @@ function getScheduleRowSortAccessor(sortKey) {
190
51
  return s.balanceAsOfToday?.amount ?? null;
191
52
  };
192
53
  case 'totalAmount':
193
- return (s) => getScheduleAmount(s);
54
+ return (s) => s.baseTransaction.amount.amount;
194
55
  case 'transactionDate':
195
- return (s) => s.createTime?.valueOf();
56
+ return (s) => s.baseTransaction.date.valueOf();
196
57
  case 'memo':
197
- return (s) => isAccruedScheduleRow(s)
198
- ? s.memo.toLowerCase()
199
- : s.baseTransaction.memo?.toLowerCase();
58
+ return (s) => s.baseTransaction.memo?.toLowerCase();
200
59
  default:
201
60
  return (s) => s.startDate?.valueOf();
202
61
  }
@@ -208,15 +67,9 @@ function sortJEScheduledTransactions(transactions, sortKey, sortOrder) {
208
67
  export function getExpenseAutomationJESchedulesView(state) {
209
68
  const jeScheduledTransaction = [];
210
69
  const failedJeScheduledTransaction = [];
211
- const accruedSchedules = [];
212
- const oneTimeAccruals = [];
213
70
  const { accountState, accountListState, classState, classListState, expenseAutomationJESchedulesViewState, expenseAutomationViewState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
214
- const { jeScheduleTransactionKeysByPeriodAndTab, jeScheduleAccruedKeysByPeriodAndTab, jeScheduleOneTimeAccrualKeysByPeriodAndTab, failedJeScheduleTransactionKeysByPeriodAndTab, jeScheduleLocalDataById, postStatusById, ignoreStatusById, revertStatusById, oneTimeAccrualActionStatusById, uiState, error, fetchState, refreshStatus, newSchedule, } = expenseAutomationJESchedulesViewState;
71
+ const { jeScheduleTransactionKeysByPeriod, failedJeScheduleTransactionKeysByPeriod, jeScheduleLocalDataById, postStatusById, ignoreStatusById, uiState, error, fetchState, refreshStatus, } = expenseAutomationJESchedulesViewState;
215
72
  const accountSettingsView = getJEAccountSettingsView(state);
216
- const newScheduleView = newSchedule.selectedDetailScheduleType === 'fixed_assets' ||
217
- newSchedule.selectedDetailScheduleType === 'prepaid_expenses'
218
- ? getNewScheduleView(state, newSchedule.selectedDetailScheduleType)
219
- : undefined;
220
73
  const currentTenant = getCurrentTenant(state);
221
74
  const { selectedPeriodByTenantId } = expenseAutomationViewState;
222
75
  const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
@@ -244,48 +97,27 @@ export function getExpenseAutomationJESchedulesView(state) {
244
97
  const filteredDepAccountListNestedAccountHierarchy = filterNestedAccountHierarchyById(depAccountListNestedAccountHierarchy, filteredDepAccounts.map((account) => account.accountId));
245
98
  const classListNestedAccountHierarchy = getNestedClassListHierarchy(classListState);
246
99
  const monthYearPeriodId = selectedPeriod != null ? toMonthYearPeriodId(selectedPeriod) : null;
247
- const selectedPeriodTabKey = monthYearPeriodId != null
248
- ? getJESchedulePeriodTabKey(uiState.selectedPageTab, monthYearPeriodId)
100
+ const jeScheduleTransactionKeysForSelectedPeriod = monthYearPeriodId != null
101
+ ? jeScheduleTransactionKeysByPeriod[monthYearPeriodId]
249
102
  : null;
250
- const jeScheduleTransactionKeysForSelectedTab = selectedPeriodTabKey != null
251
- ? jeScheduleTransactionKeysByPeriodAndTab[selectedPeriodTabKey]
252
- : undefined;
253
- const failedJeScheduleTransactionKeysForSelectedTab = selectedPeriodTabKey != null
254
- ? failedJeScheduleTransactionKeysByPeriodAndTab[selectedPeriodTabKey]
255
- : undefined;
256
- // Distinguishes "this tab has never been fetched for this period" from "fetched and genuinely
257
- // empty". Without it the page cannot tell a first visit from a real empty state, and renders an
258
- // empty table where it should render a skeleton.
259
- const hasLoadedForSelectedTab = jeScheduleTransactionKeysForSelectedTab != null;
260
- const jeScheduleTransactionKeys = jeScheduleTransactionKeysForSelectedTab ?? [];
261
- const failedJeScheduleTransactionKeys = failedJeScheduleTransactionKeysForSelectedTab ?? [];
262
- const jeScheduleAccruedKeys = (selectedPeriodTabKey != null
263
- ? jeScheduleAccruedKeysByPeriodAndTab[selectedPeriodTabKey]
264
- : undefined) ?? [];
265
- const jeScheduleOneTimeAccrualKeys = (selectedPeriodTabKey != null
266
- ? jeScheduleOneTimeAccrualKeysByPeriodAndTab[selectedPeriodTabKey]
267
- : undefined) ?? [];
268
- jeScheduleOneTimeAccrualKeys.forEach((jeOneTimeAccrualKey) => {
269
- const accrual = getJEOneTimeAccrualByKey(jeOneTimeAccrualKey, state.jeSchedulesState);
270
- if (accrual != null && isRenderableOneTimeAccrual(accrual)) {
271
- oneTimeAccruals.push(accrual);
272
- }
273
- });
103
+ const failedJeScheduleTransactionKeysForSelectedPeriod = monthYearPeriodId != null
104
+ ? failedJeScheduleTransactionKeysByPeriod[monthYearPeriodId]
105
+ : null;
106
+ const jeScheduleTransactionKeys = jeScheduleTransactionKeysForSelectedPeriod ?? [];
107
+ const failedJeScheduleTransactionKeys = failedJeScheduleTransactionKeysForSelectedPeriod ?? [];
274
108
  jeScheduleTransactionKeys.forEach((jeScheduleKey) => {
275
109
  const jeScheduleDetails = getJEScheduledTransactionByJEScheduleTransactionKey(jeScheduleKey, state);
276
110
  jeScheduledTransaction.push(jeScheduleDetails);
277
111
  });
278
- jeScheduleAccruedKeys.forEach((jeAccruedScheduleKey) => {
279
- const accruedScheduleDetails = getJEAccruedScheduleByJEScheduleKey(jeAccruedScheduleKey, state);
280
- if (accruedScheduleDetails != null) {
281
- accruedSchedules.push(accruedScheduleDetails);
282
- }
283
- });
284
112
  failedJeScheduleTransactionKeys.forEach((jeScheduleKey) => {
285
113
  const jeScheduleDetails = getJEScheduledTransactionByJEScheduleTransactionKey(jeScheduleKey, state);
286
114
  failedJeScheduledTransaction.push(jeScheduleDetails);
287
115
  });
288
- const { sortKey, sortOrder, selectedJETypeFilter } = uiState;
116
+ const { sortKey, sortOrder } = uiState;
117
+ const draftSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'draft'), sortKey, sortOrder);
118
+ const ongoingSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'ongoing'), sortKey, sortOrder);
119
+ const completedSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'completed' ||
120
+ schedule.status.code === 'marked_as_completed'), sortKey, sortOrder);
289
121
  const unsortedResolveSchedules = [];
290
122
  failedJeScheduledTransaction.forEach((schedule) => {
291
123
  schedule.scheduledJournalEntry.forEach((journalEntry) => {
@@ -297,103 +129,10 @@ export function getExpenseAutomationJESchedulesView(state) {
297
129
  });
298
130
  const resolveSchedules = sortJEScheduledTransactions(unsortedResolveSchedules, sortKey, sortOrder);
299
131
  const validResolveForPending = unsortedResolveSchedules.filter((r) => jeScheduleLocalDataById[r.scheduledJournalEntry.scheduledJournalEntryID] != null);
300
- const matchesTypeFilter = (schedule) => selectedJETypeFilter == null ||
301
- getJEScheduleRowType(schedule) === selectedJETypeFilter;
302
- const isCreatedStatus = (schedule) => {
303
- // An accrual is "created" once it is not review work: posted, reversing, reversed, or in a
304
- // transient posting claim.
305
- if (isOneTimeAccrualRow(schedule)) {
306
- return !isPendingReviewRow(schedule);
307
- }
308
- return (schedule.status.code === 'ongoing' ||
309
- schedule.status.code === 'completed' ||
310
- schedule.status.code === 'marked_as_completed');
311
- };
312
- const allScheduleRows = [
313
- ...jeScheduledTransaction,
314
- ...accruedSchedules,
315
- ...oneTimeAccruals,
316
- ];
317
132
  const pendingReviewSchedules = sortJEScheduledTransactions([
318
- ...allScheduleRows.filter((schedule) => isPendingReviewRow(schedule) && matchesTypeFilter(schedule)),
133
+ ...jeScheduledTransaction.filter((schedule) => schedule.status.code === 'draft'),
319
134
  ...validResolveForPending,
320
135
  ], sortKey, sortOrder);
321
- const createdSchedules = sortJEScheduledTransactions(allScheduleRows.filter((schedule) => isCreatedStatus(schedule) && matchesTypeFilter(schedule)), sortKey, sortOrder);
322
- // KPI summary — derived from unfiltered schedules so counts are always accurate
323
- const allSchedules = allScheduleRows;
324
- const sumAmount = (schedules) => schedules.reduce((total, schedule) => total + (getScheduleAmount(schedule) ?? 0), 0);
325
- const pendingReviewTotal = sumAmount(pendingReviewSchedules);
326
- const createdTotal = sumAmount(createdSchedules);
327
- /**
328
- * The currency the tiles render in. Taken from the schedules themselves rather than assumed:
329
- * every row on a tab shares a tenant currency, so the first one that states it is the answer.
330
- */
331
- const sumToAmount = (schedules) => {
332
- const first = schedules[0];
333
- const currency = first != null ? getScheduleAmountObject(first) : allScheduleAmountFallback;
334
- return {
335
- ...currency,
336
- amount: sumAmount(schedules),
337
- };
338
- };
339
- // An empty bucket still has to render a currency; borrow it from any row on the page.
340
- const allScheduleAmountFallback = allScheduleRows.length > 0
341
- ? getScheduleAmountObject(allScheduleRows[0])
342
- : { amount: 0, currencyCode: '', currencySymbol: '' };
343
- const aiAccountantSchedules = allSchedules.filter(isAiAccountantSchedule);
344
- const manualSchedules = allSchedules.filter((schedule) => !isAiAccountantSchedule(schedule));
345
- const pendingUnfiltered = allSchedules.filter((schedule) => isPendingReviewRow(schedule));
346
- const kpiSummary = {
347
- aiAccountant: {
348
- count: aiAccountantSchedules.length,
349
- amount: sumToAmount(aiAccountantSchedules),
350
- },
351
- manual: {
352
- count: manualSchedules.length,
353
- amount: sumToAmount(manualSchedules),
354
- },
355
- needsReview: {
356
- count: pendingUnfiltered.length,
357
- amount: sumToAmount(pendingUnfiltered),
358
- },
359
- total: {
360
- count: allSchedules.length,
361
- amount: sumToAmount(allSchedules),
362
- },
363
- };
364
- // Each tab's badge counts from that tab's own bucket. A tab that has not been fetched yet
365
- // reports undefined rather than 0, so the UI can hide the badge instead of asserting "none".
366
- const scheduleCountsByTab = {};
367
- ALL_JE_PAGE_TABS.forEach((pageTab) => {
368
- const periodTabKey = monthYearPeriodId != null
369
- ? getJESchedulePeriodTabKey(pageTab, monthYearPeriodId)
370
- : null;
371
- const transactionKeys = periodTabKey != null
372
- ? jeScheduleTransactionKeysByPeriodAndTab[periodTabKey]
373
- : undefined;
374
- if (transactionKeys == null) {
375
- return;
376
- }
377
- const accruedKeys = (periodTabKey != null
378
- ? jeScheduleAccruedKeysByPeriodAndTab[periodTabKey]
379
- : undefined) ?? [];
380
- const oneTimeAccrualKeys = (periodTabKey != null
381
- ? jeScheduleOneTimeAccrualKeysByPeriodAndTab[periodTabKey]
382
- : undefined) ?? [];
383
- const rowsForTab = [
384
- ...transactionKeys.map((transactionKey) => getJEScheduledTransactionByJEScheduleTransactionKey(transactionKey, state)),
385
- ...accruedKeys
386
- .map((accruedKey) => getJEAccruedScheduleByJEScheduleKey(accruedKey, state))
387
- .filter((accruedRow) => accruedRow != null),
388
- ...oneTimeAccrualKeys
389
- .map((accrualKey) => getJEOneTimeAccrualByKey(accrualKey, state.jeSchedulesState))
390
- .filter((accrualRow) => accrualRow != null && isRenderableOneTimeAccrual(accrualRow)),
391
- ];
392
- scheduleCountsByTab[pageTab] =
393
- pageTab === 'existing_schedules'
394
- ? rowsForTab.filter((row) => isExistingTabRow(row)).length
395
- : rowsForTab.filter((row) => isPendingReviewRow(row) || isCreatedStatus(row)).length;
396
- });
397
136
  const allSteps = monthYearPeriodId != null
398
137
  ? getAllSteps(monthEndCloseChecksState, monthYearPeriodId, currentTenant.tenantId)
399
138
  : [];
@@ -406,20 +145,6 @@ export function getExpenseAutomationJESchedulesView(state) {
406
145
  { fetchState, error },
407
146
  monthEndFetchState,
408
147
  ]);
409
- const countByType = (schedules) => {
410
- const counts = ALL_SCHEDULES_TYPES.reduce((acc, type) => ({ ...acc, [type]: 0 }), {});
411
- schedules.forEach((schedule) => {
412
- const scheduleType = getJEScheduleRowType(schedule);
413
- if (scheduleType != null) {
414
- counts[scheduleType] += 1;
415
- }
416
- });
417
- return counts;
418
- };
419
- const jeScheduleTypeCounts = {
420
- active: countByType(allSchedules.filter((schedule) => isPendingReviewRow(schedule) || isCreatedStatus(schedule))),
421
- ongoing: countByType(allSchedules.filter((schedule) => isExistingTabRow(schedule))),
422
- };
423
148
  return {
424
149
  uncategorizedAccounts,
425
150
  allDepreciationAccountList: filteredDepAccounts,
@@ -428,21 +153,14 @@ export function getExpenseAutomationJESchedulesView(state) {
428
153
  allAccountList: filteredAccounts,
429
154
  accountListNestedAccountHierarchy,
430
155
  allClassList: allClasses,
431
- createdSchedules,
432
- createdTotal,
433
- hasLoadedForSelectedTab,
434
- jeScheduleTypeCounts,
435
- scheduleCountsByTab,
436
- kpiSummary,
156
+ completedSchedules,
157
+ draftSchedules,
158
+ ongoingSchedules,
437
159
  pendingReviewSchedules,
438
- pendingReviewTotal,
439
160
  resolveSchedules: resolveSchedules,
440
161
  accountSettingsView,
441
- newScheduleView,
442
162
  postStatusById: postStatusById,
443
163
  ignoreStatusById: ignoreStatusById,
444
- revertStatusById: revertStatusById,
445
- oneTimeAccrualActionStatusById: oneTimeAccrualActionStatusById,
446
164
  fetchState: reducedFetchStatus.fetchState,
447
165
  jeScheduleLocalDataById: jeScheduleLocalDataById,
448
166
  uiState: uiState,
@@ -451,26 +169,3 @@ export function getExpenseAutomationJESchedulesView(state) {
451
169
  completionStatus,
452
170
  };
453
171
  }
454
- /**
455
- * One accrual plus the status of its promote / ignore request, for the detail screen.
456
- *
457
- * `accrual` is undefined on a cold load — a refresh or a shared link, where the list has never run
458
- * — so the screen dispatches `fetchOneTimeAccrual` and waits on `detailFetchState`. The two states
459
- * are separate on purpose: `actionFetchState` drives the row spinner and the post-revert navigation,
460
- * and a page load must not look like an action that just finished.
461
- */
462
- export function getExpenseAutomationJEOneTimeAccrualDetailView(state, accrualId) {
463
- return {
464
- accrual: getJEOneTimeAccrualByKey(generateJEOneTimeAccrualKey(accrualId), state.jeSchedulesState),
465
- actionFetchState: state.expenseAutomationJESchedulesViewState
466
- .oneTimeAccrualActionStatusById[accrualId] ?? {
467
- fetchState: 'Not-Started',
468
- error: undefined,
469
- },
470
- detailFetchState: state.expenseAutomationJESchedulesViewState
471
- .oneTimeAccrualFetchStatusById[accrualId] ?? {
472
- fetchState: 'Not-Started',
473
- error: undefined,
474
- },
475
- };
476
- }
@@ -16,8 +16,9 @@ const JE_SCHEDULE_SORT_KEYS = [
16
16
  'memo',
17
17
  ];
18
18
  export const toJEScheduleSortKey = (v) => stringToUnion(v, JE_SCHEDULE_SORT_KEYS);
19
- const JE_PAGE_TABS = ['schedules', 'existing_schedules'];
20
- export const toJEPageTab = (v) => stringToUnion(v, JE_PAGE_TABS);
21
- export const ALL_JE_PAGE_TABS = JE_PAGE_TABS;
22
- export const getJESchedulePeriodTabKey = (selectedPageTab, monthYearPeriodId) => `${selectedPageTab}_${monthYearPeriodId}`;
23
- export const MIN_NEW_SCHEDULE_SEARCH_LENGTH = 2;
19
+ const JE_SCHEDULE_MAIN_TABS = [
20
+ 'pending_review',
21
+ 'ongoing',
22
+ 'completed',
23
+ ];
24
+ export const toJEScheduleMainTab = (v) => stringToUnion(v, JE_SCHEDULE_MAIN_TABS);
@@ -30,7 +30,7 @@ export const fetchAccruedScheduleListEpic = (actions$, state$, zeniAPI) => actio
30
30
  je_schedule_type: scheduleType,
31
31
  sort_by: 'transaction_date',
32
32
  sort_order: 'desc',
33
- filter: action.payload.statusFilter,
33
+ filter: 'all',
34
34
  };
35
35
  return zeniAPI
36
36
  .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
@@ -7,14 +7,9 @@ import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePay
7
7
  import { fetchDownloadSchedules, getState, updateDownloadScheduleFailure, updateDownloadScheduleSuccess, } from '../scheduleListReducer';
8
8
  import { getScheduleListKey } from '../scheduleListTypes';
9
9
  export const fetchDownloadSchedulesEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchDownloadSchedules.match), mergeMap((action) => {
10
- const { scheduleType, downloadCategories, statusFilter } = action.payload;
10
+ const { scheduleType, downloadCategories } = action.payload;
11
11
  const scheduleListState = state$.value.scheduleListState;
12
12
  // if parameters are provided, use those. else go to localdata
13
- // Accrued is deliberately not served here. Its rows come back in a different shape, this
14
- // epic writes them through updateJESchedules (the prepaid / fixed mapper), and
15
- // doUpdateScheduleList never flips downloadState for accrued -- so a request would store the
16
- // wrong data and then never report completion. Accrued downloads go through
17
- // fetchAccruedScheduleList, which owns that shape end to end.
18
13
  let scheduleState;
19
14
  if (scheduleType !== 'accrued_expenses') {
20
15
  scheduleState = getState(scheduleListState, scheduleType);
@@ -39,7 +34,7 @@ export const fetchDownloadSchedulesEpic = (actions$, state$, zeniAPI) => actions
39
34
  base_txn_account_ids: downloadCategories,
40
35
  sort_by: 'transaction_date',
41
36
  sort_order: 'desc',
42
- filter: statusFilter,
37
+ filter: 'all',
43
38
  };
44
39
  return zeniAPI
45
40
  .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/download?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
@@ -84,8 +84,8 @@ const scheduleListView = createSlice({
84
84
  reducers: {
85
85
  fetchDownloadSchedules: {
86
86
  reducer(draft, action) {
87
- // Accrued is not downloaded through this action -- see fetchDownloadSchedulesEpic for why.
88
87
  if (action.payload.scheduleType !== 'accrued_expenses') {
88
+ //if condition added for type narrowing
89
89
  const state = getState(draft, action.payload.scheduleType);
90
90
  const selectedTimeframe = action.payload.timeframeAndCategory.selectedTimeframe;
91
91
  const selectedCategoryId = action.payload.timeframeAndCategory.selectedCategoryId;
@@ -109,14 +109,13 @@ const scheduleListView = createSlice({
109
109
  updateState(draft, action.payload.scheduleType, state);
110
110
  }
111
111
  },
112
- prepare(scheduleType, timeframeAndCategory, downloadCategories, statusFilter = 'all', cacheOverride = false) {
112
+ prepare(scheduleType, timeframeAndCategory, downloadCategories, cacheOverride = false) {
113
113
  return {
114
114
  payload: {
115
115
  timeframeAndCategory,
116
116
  scheduleType,
117
117
  cacheOverride,
118
118
  downloadCategories,
119
- statusFilter,
120
119
  },
121
120
  };
122
121
  },
@@ -152,13 +151,12 @@ const scheduleListView = createSlice({
152
151
  updateState(draft, action.payload.scheduleType, state);
153
152
  }
154
153
  },
155
- prepare(scheduleType, timeframeAndCategory, cacheOverride = false, statusFilter = 'all') {
154
+ prepare(scheduleType, timeframeAndCategory, cacheOverride = false) {
156
155
  return {
157
156
  payload: {
158
157
  timeframeAndCategory,
159
158
  scheduleType,
160
159
  cacheOverride,
161
- statusFilter,
162
160
  },
163
161
  };
164
162
  },