@zeniai/client-epic-state 5.2.52-betaRD1 → 5.2.53

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 (88) hide show
  1. package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +1 -4
  2. package/lib/entity/jeSchedules/jeSchedulesReducer.js +5 -47
  3. package/lib/epic.d.ts +1 -2
  4. package/lib/epic.js +4 -6
  5. package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +4 -46
  6. package/lib/esm/epic.js +4 -6
  7. package/lib/esm/index.js +3 -3
  8. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +1 -9
  9. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +13 -10
  10. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/initializeJeScheduleLocalDataEpic.js +15 -34
  11. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.js +1 -12
  12. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +15 -4
  13. package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +1 -60
  14. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +10 -0
  15. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +12 -20
  16. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +28 -11
  17. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +45 -21
  18. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.js +4 -1
  19. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +19 -3
  20. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +16 -3
  21. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +6 -2
  22. package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +4 -1
  23. package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +21 -21
  24. package/lib/esm/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js +6 -2
  25. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +10 -2
  26. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +33 -0
  27. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/initializeInvoicingCustomerAddressEpic.js +43 -17
  28. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.js +6 -2
  29. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.js +10 -2
  30. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +34 -0
  31. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddressEpic.js +44 -18
  32. package/lib/esm/view/invoicing/invoicingFormDraft.js +13 -0
  33. package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +57 -9
  34. package/lib/index.d.ts +3 -3
  35. package/lib/index.js +49 -50
  36. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.d.ts +2 -2
  37. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +0 -8
  38. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +11 -8
  39. package/lib/view/expenseAutomationView/epics/jeSchedule/initializeJeScheduleLocalDataEpic.js +15 -34
  40. package/lib/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.d.ts +2 -2
  41. package/lib/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.js +1 -12
  42. package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +15 -4
  43. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +0 -18
  44. package/lib/view/expenseAutomationView/payload/transactionCategorizationPayload.d.ts +18 -7
  45. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +2 -8
  46. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +3 -62
  47. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +10 -0
  48. package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +0 -2
  49. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +8 -4
  50. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +12 -20
  51. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +27 -10
  52. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +0 -15
  53. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +8 -5
  54. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.d.ts +22 -6
  55. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +47 -22
  56. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.js +3 -0
  57. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.d.ts +7 -0
  58. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +18 -2
  59. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +14 -1
  60. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +6 -2
  61. package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +3 -0
  62. package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.d.ts +3 -2
  63. package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +19 -19
  64. package/lib/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js +6 -2
  65. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.d.ts +3 -1
  66. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +10 -2
  67. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.d.ts +7 -7
  68. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +33 -0
  69. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewState.d.ts +6 -0
  70. package/lib/view/invoicing/editInvoicingCustomerDetailView/initializeInvoicingCustomerAddressEpic.d.ts +15 -10
  71. package/lib/view/invoicing/editInvoicingCustomerDetailView/initializeInvoicingCustomerAddressEpic.js +42 -16
  72. package/lib/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.js +6 -2
  73. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.d.ts +3 -1
  74. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.js +10 -2
  75. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.d.ts +7 -0
  76. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +34 -0
  77. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewState.d.ts +6 -0
  78. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddressEpic.d.ts +15 -11
  79. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddressEpic.js +42 -16
  80. package/lib/view/invoicing/invoicingFormDraft.d.ts +10 -1
  81. package/lib/view/invoicing/invoicingFormDraft.js +14 -0
  82. package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.d.ts +49 -0
  83. package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +59 -10
  84. package/package.json +1 -1
  85. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.js +0 -40
  86. package/lib/tsconfig.mocks.tsbuildinfo +0 -1
  87. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.d.ts +0 -20
  88. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.js +0 -44
@@ -7,41 +7,22 @@ export const initializeJeScheduleLocalDataEpic = (actions$, state$) => actions$.
7
7
  const actions = [];
8
8
  const { jeScheduleTransactionKeys } = action.payload;
9
9
  jeScheduleTransactionKeys.forEach((jeScheduleTransactionKey) => {
10
- // Checked before the selector runs, not after: the selector destructures the record it
11
- // looks up, so a key that is not in the store throws a TypeError rather than returning
12
- // undefined. This epic is a mergeMap with no catchError, so that throw would take its
13
- // subscription down for the rest of the session and silently stop local-data
14
- // initialisation everywhere -- not just for this row.
15
- if (state.jeSchedulesState.schedulesByTransactionKey[jeScheduleTransactionKey] == null) {
16
- return;
17
- }
18
10
  const jeScheduledTransaction = getJEScheduledTransactionByJEScheduleTransactionKey(jeScheduleTransactionKey, state);
19
- // One record per journal entry, not per schedule. A schedule that failed in two months is
20
- // two rows and each needs its own vendor / category edits -- keying only the first left
21
- // every later row without local data, which the list renders read-only and without a
22
- // Retry button. An empty array is possible when details have not landed yet; it must not
23
- // throw, because this runs in a mergeMap with no catchError and the throw would take the
24
- // epic's subscription down for the rest of the session.
25
- // Filtered on `error` for the same reason the selector is: this array is shared state, and
26
- // a schedule whose detail page has been opened holds every month it has, posted ones
27
- // included. The seeding and the rows must agree on which entries are failed postings.
28
- jeScheduledTransaction.scheduledJournalEntry
29
- .filter((journalEntry) => journalEntry.error.length > 0)
30
- .forEach((journalEntry) => {
31
- const { scheduledJournalEntryID } = journalEntry;
32
- actions.push(updateJeScheduleLocalDataById({
33
- localData: {
34
- jeScheduleType: jeScheduledTransaction.jeScheduleType,
35
- jeScheduleID: jeScheduledTransaction.jeScheduleId,
36
- scheduledJournalEntryID,
37
- updatedVendor: undefined,
38
- updatedCategoryId: undefined,
39
- updatedAccumulatedDepreciationCategoryID: undefined,
40
- updatedClassId: undefined,
41
- },
42
- scheduledJournalEntryID,
43
- }));
44
- });
11
+ const initLocalData = {
12
+ jeScheduleType: jeScheduledTransaction.jeScheduleType,
13
+ jeScheduleID: jeScheduledTransaction.jeScheduleId,
14
+ scheduledJournalEntryID: jeScheduledTransaction.scheduledJournalEntry[0]
15
+ .scheduledJournalEntryID,
16
+ updatedVendor: undefined,
17
+ updatedCategoryId: undefined,
18
+ updatedAccumulatedDepreciationCategoryID: undefined,
19
+ updatedClassId: undefined,
20
+ };
21
+ actions.push(updateJeScheduleLocalDataById({
22
+ localData: initLocalData,
23
+ scheduledJournalEntryID: jeScheduledTransaction.scheduledJournalEntry[0]
24
+ .scheduledJournalEntryID,
25
+ }));
45
26
  });
46
27
  return from(actions);
47
28
  }));
@@ -1,6 +1,5 @@
1
1
  import { from } from 'rxjs';
2
2
  import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { removeScheduledJournalEntryFromJESchedule, } from '../../../../entity/jeSchedules/jeSchedulesReducer';
4
3
  import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
5
4
  import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
6
5
  import { createZeniAPIStatus, isSuccessStatus, } from '../../../../responsePayload';
@@ -23,16 +22,9 @@ export const retryJeScheduleEpic = (actions$, state$, zeniAPI) => actions$.pipe(
23
22
  .pipe(mergeMap((response) => {
24
23
  if (isSuccessStatus(response)) {
25
24
  const updateActions = [];
26
- // Retire this entry, and the schedule itself only when this was its last failed
27
- // one. A schedule that failed in several months is several rows sharing one
28
- // schedule key, so dropping the key outright took the still-failing months off the
29
- // list with it and nothing would have surfaced them again.
30
- const failedEntriesForSchedule = state.jeSchedulesState.schedulesByTransactionKey[jeScheduleTransactionKey]?.scheduledJournalEntry ?? [];
31
- const wasLastFailedEntryForSchedule = failedEntriesForSchedule.filter((journalEntry) => journalEntry.scheduledJournalEntryID !==
32
- scheduledJournalEntryID).length === 0;
33
25
  updateActions.push(retryJeScheduleSuccess({
34
26
  scheduledJournalEntryID,
35
- }), removeScheduledJournalEntryFromJESchedule(jeScheduleTransactionKey, scheduledJournalEntryID), removeJeScheduleLocalDataById({ scheduledJournalEntryID }), // Important to remove localdata after success.
27
+ }), removeFailedJeScheduleTransactionKey(jeScheduleTransactionKey, selectedPeriod), removeJeScheduleLocalDataById({ scheduledJournalEntryID }), // Important to remove localdata after success.
36
28
  fetchMonthEndCloseChecks({
37
29
  tenantId: currentTenant.tenantId,
38
30
  period: selectedPeriod,
@@ -42,9 +34,6 @@ export const retryJeScheduleEpic = (actions$, state$, zeniAPI) => actions$.pipe(
42
34
  messageText: 'success',
43
35
  type: 'success',
44
36
  }));
45
- if (wasLastFailedEntryForSchedule) {
46
- updateActions.push(removeFailedJeScheduleTransactionKey(jeScheduleTransactionKey, selectedPeriod));
47
- }
48
37
  return from(updateActions);
49
38
  }
50
39
  else {
@@ -6,7 +6,6 @@ import { updateTransactions } from '../../../../entity/transaction/transactionRe
6
6
  import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
7
7
  import { getLineItemsByTransactionsIdsFromResponse } from '../../helpers/transactionCategorizationLocalDataHelper';
8
8
  import { fetchTransactionCategorization, fetchTransactionCategorizationFailure, fetchTransactionCategorizationSuccess, initializeTransactionCategorizationViewLocalData, resetOtherTabsFetchState, updateParentTotalCountForTab, updateTotalCountForTransactionCategorization, updateTransactionCategorizationUIState, } from '../../reducers/transactionsViewReducer';
9
- import { DEFAULT_COMPLETED_SUB_TAB } from '../../types/completedSubTab';
10
9
  import { TRANSACTIONS_TABS, toTransactionsSortKey, } from '../../types/transactionsViewState';
11
10
  export const fetchTransactionCategorizationEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchTransactionCategorization.match),
12
11
  // Per-tab switchMap: cancels in-flight requests for the same tab on a new
@@ -33,9 +32,10 @@ groupBy((action) => action.payload.selectedTab), mergeMap((group$) => group$.pip
33
32
  // cross-status search (omit or true) is reserved for Receipts
34
33
  // manual-match.
35
34
  search_all_statuses: false,
36
- sub_tab: selectedTab === 'autoCategorized'
37
- ? expenseAutomationTransactionsViewState.selectedTransactionCategorizationCompletedSubTab
38
- : DEFAULT_COMPLETED_SUB_TAB,
35
+ // Sent on both tabs: the backend ignores it for Review's own rows but uses
36
+ // it to scope the Completed badge it returns alongside them.
37
+ sub_tab: expenseAutomationTransactionsViewState
38
+ .selectedTransactionCategorizationCompletedSubTab,
39
39
  transaction_group: expenseAutomationTransactionsViewState.selectedTransactionGroup,
40
40
  };
41
41
  return zeniAPI
@@ -87,6 +87,17 @@ groupBy((action) => action.payload.selectedTab), mergeMap((group$) => group$.pip
87
87
  parentTotalCount: response.data.parent_tab_total_count ??
88
88
  response.data.total_count,
89
89
  }));
90
+ // The inactive tab's badge, counted under the same filters. Absent on
91
+ // pages after the first and on the cross-tab search path, where the
92
+ // last known value stays correct.
93
+ const otherTabTotalCount = response.data.other_tab_total_count;
94
+ if (otherTabTotalCount != null) {
95
+ updateActions.push(updateParentTotalCountForTab({
96
+ selectedPeriod,
97
+ selectedTab: selectedTab === 'review' ? 'autoCategorized' : 'review',
98
+ parentTotalCount: otherTabTotalCount,
99
+ }));
100
+ }
90
101
  updateActions.push(resetOtherTabsFetchState({
91
102
  refreshViewInBackground,
92
103
  tabs: TRANSACTIONS_TABS.filter((tab) => selectedTab !== tab),
@@ -62,10 +62,6 @@ export const initialState = {
62
62
  jeScheduleAccruedKeysByPeriodAndTab: {},
63
63
  jeScheduleOneTimeAccrualKeysByPeriodAndTab: {},
64
64
  failedJeScheduleTransactionKeysByPeriodAndTab: {},
65
- failedJePostings: {
66
- fetchState: { fetchState: 'Not-Started', error: undefined },
67
- jeScheduleTransactionKeys: [],
68
- },
69
65
  postStatusById: {},
70
66
  ignoreStatusById: {},
71
67
  revertStatusById: {},
@@ -75,9 +71,6 @@ export const initialState = {
75
71
  oneTimeAccrualFetchStatusById: {},
76
72
  uiState: {
77
73
  createdGroupCollapsed: false,
78
- // Expanded, like the other two. A failed posting is the only thing on this page that is
79
- // actively wrong, so folding it away by default would hide the reason to open the tab.
80
- failedGroupCollapsed: false,
81
74
  pendingGroupCollapsed: false,
82
75
  scrollPosition: { scrollTop: 0, scrollLeft: undefined },
83
76
  searchString: '',
@@ -149,53 +142,6 @@ const expenseAutomationJESchedulesView = createSlice({
149
142
  };
150
143
  },
151
144
  },
152
- /**
153
- * The Failed Postings list, fetched separately from the schedules it belongs to.
154
- *
155
- * No period and no tab in any of these three: the endpoint applies no date window, so there is
156
- * one list per tenant and one slot to hold it. `refreshInBackground` keeps a silent refetch
157
- * from dropping a skeleton over rows already on screen, the same way refreshStatus does for
158
- * the schedules list.
159
- */
160
- fetchFailedJePostings: {
161
- reducer(draft, action) {
162
- if (!action.payload.refreshInBackground) {
163
- draft.failedJePostings.fetchState = {
164
- fetchState: 'In-Progress',
165
- error: undefined,
166
- };
167
- }
168
- },
169
- prepare(refreshInBackground = false) {
170
- return { payload: { refreshInBackground } };
171
- },
172
- },
173
- fetchFailedJePostingsSuccess: {
174
- reducer(draft, action) {
175
- draft.failedJePostings = {
176
- fetchState: { fetchState: 'Completed', error: undefined },
177
- jeScheduleTransactionKeys: action.payload.failedJeSchedules.map((schedule) => getJEScheduleTransactionDetailKeyPayload(schedule.base_transaction)),
178
- };
179
- },
180
- prepare(failedJeSchedules) {
181
- return { payload: { failedJeSchedules } };
182
- },
183
- },
184
- fetchFailedJePostingsFailure: {
185
- reducer(draft, action) {
186
- // Keys are deliberately left alone. The schedules list clears its buckets on failure so an
187
- // errored tab cannot read as "these are all the schedules there are", but this list is a
188
- // set of outstanding problems -- showing the last known ones beside an error beats
189
- // implying there are none.
190
- draft.failedJePostings.fetchState = {
191
- fetchState: 'Error',
192
- error: action.payload.status,
193
- };
194
- },
195
- prepare(status) {
196
- return { payload: { status } };
197
- },
198
- },
199
145
  fetchJeSchedulesSuccess(draft, action) {
200
146
  const { jeSchedules, selectedPeriod, selectedPageTab, failedJeSchedules, accruedJeSchedules, oneTimeAccruals, refreshViewInBackground, } = action.payload;
201
147
  const periodTabKey = getJESchedulePeriodTabKey(selectedPageTab, toMonthYearPeriodId(selectedPeriod));
@@ -412,8 +358,6 @@ const expenseAutomationJESchedulesView = createSlice({
412
358
  reducer(draft, action) {
413
359
  const { failedJeScheduleKey } = action.payload;
414
360
  removeKeyFromEveryTabSlot(draft.failedJeScheduleTransactionKeysByPeriodAndTab, failedJeScheduleKey);
415
- draft.failedJePostings.jeScheduleTransactionKeys =
416
- draft.failedJePostings.jeScheduleTransactionKeys.filter((jeScheduleKey) => jeScheduleKey !== failedJeScheduleKey);
417
361
  },
418
362
  },
419
363
  initializeJeScheduleLocalData: {
@@ -756,9 +700,6 @@ const expenseAutomationJESchedulesView = createSlice({
756
700
  draft.uiState.createdGroupCollapsed =
757
701
  !draft.uiState.createdGroupCollapsed;
758
702
  },
759
- toggleJEFailedGroupCollapsed(draft) {
760
- draft.uiState.failedGroupCollapsed = !draft.uiState.failedGroupCollapsed;
761
- },
762
703
  clearExpenseAutomationJESchedulesView(draft) {
763
704
  Object.assign(draft, initialState);
764
705
  },
@@ -769,7 +710,7 @@ const expenseAutomationJESchedulesView = createSlice({
769
710
  });
770
711
  },
771
712
  });
772
- export const { clearExpenseAutomationJESchedulesView, clearJeAccountSettingsLocalData, clearJeScheduleLocalData, clearSearchTransactionsForNewSchedule, createOneTimeAccrual, createOneTimeAccrualFailure, createOneTimeAccrualSuccess, ignoreOneTimeAccrual, oneTimeAccrualActionFailure, oneTimeAccrualActionSuccess, promoteOneTimeAccrual, revertJeSchedule, revertJeScheduleFailure, revertJeScheduleSuccess, revertOneTimeAccrual, fetchAccountSettingsListForAccountTypes, fetchJeSchedules, fetchFailedJePostings, fetchFailedJePostingsFailure, fetchFailedJePostingsSuccess, fetchJeSchedulesFailure, fetchJeSchedulesPage, fetchJeSchedulesSuccess, fetchOneTimeAccrual, fetchOneTimeAccrualFailure, fetchOneTimeAccrualSuccess, fetchRecommendationForAccountSettings, ignoreRecommendedJeSchedule, ignoreRecommendedJeScheduleFailure, ignoreRecommendedJeScheduleSuccess, initializeAccountSettingsView, initializeJeScheduleLocalData, initializeNewSchedule, removeFailedJeScheduleTransactionKey, removeJeOneTimeAccrualLocalData, removeJeScheduleLocalDataById, removeJeAccruedScheduleKey, removeJeScheduleTransactionKey, resetNewScheduleLocalData, retryJeSchedule, retryJeScheduleFailure, retryJeScheduleSuccess, saveAccountSettings, saveAccountSettingsFailure, saveAccountSettingsLocalData, saveAccountSettingsSuccess, saveNewSchedule, saveNewScheduleFailure, saveNewScheduleSuccess, searchTransactionsForNewSchedule, searchTransactionsForNewScheduleFailure, searchTransactionsForNewScheduleSuccess, toggleJECreatedGroupCollapsed, toggleJEFailedGroupCollapsed, toggleJEPendingGroupCollapsed, updateAccountSettingsListForAccountTypes, updateAccountSettingsListForAccountTypesFailure, updateJESchedulesUIState, updateJEScheduleTypeFilter, updateJeOneTimeAccrualLocalData, updateJeScheduleLocalDataById, updateJeScheduleTransactionKeys, updateNewScheduleLocalData, updateRecommendationForAccountSettings, updateRecommendationForAccountSettingsFailure, } = expenseAutomationJESchedulesView.actions;
713
+ export const { clearExpenseAutomationJESchedulesView, clearJeAccountSettingsLocalData, clearJeScheduleLocalData, clearSearchTransactionsForNewSchedule, createOneTimeAccrual, createOneTimeAccrualFailure, createOneTimeAccrualSuccess, ignoreOneTimeAccrual, oneTimeAccrualActionFailure, oneTimeAccrualActionSuccess, promoteOneTimeAccrual, revertJeSchedule, revertJeScheduleFailure, revertJeScheduleSuccess, revertOneTimeAccrual, fetchAccountSettingsListForAccountTypes, fetchJeSchedules, fetchJeSchedulesFailure, fetchJeSchedulesPage, fetchJeSchedulesSuccess, fetchOneTimeAccrual, fetchOneTimeAccrualFailure, fetchOneTimeAccrualSuccess, fetchRecommendationForAccountSettings, ignoreRecommendedJeSchedule, ignoreRecommendedJeScheduleFailure, ignoreRecommendedJeScheduleSuccess, initializeAccountSettingsView, initializeJeScheduleLocalData, initializeNewSchedule, removeFailedJeScheduleTransactionKey, removeJeOneTimeAccrualLocalData, removeJeScheduleLocalDataById, removeJeAccruedScheduleKey, removeJeScheduleTransactionKey, resetNewScheduleLocalData, retryJeSchedule, retryJeScheduleFailure, retryJeScheduleSuccess, saveAccountSettings, saveAccountSettingsFailure, saveAccountSettingsLocalData, saveAccountSettingsSuccess, saveNewSchedule, saveNewScheduleFailure, saveNewScheduleSuccess, searchTransactionsForNewSchedule, searchTransactionsForNewScheduleFailure, searchTransactionsForNewScheduleSuccess, toggleJECreatedGroupCollapsed, toggleJEPendingGroupCollapsed, updateAccountSettingsListForAccountTypes, updateAccountSettingsListForAccountTypesFailure, updateJESchedulesUIState, updateJEScheduleTypeFilter, updateJeOneTimeAccrualLocalData, updateJeScheduleLocalDataById, updateJeScheduleTransactionKeys, updateNewScheduleLocalData, updateRecommendationForAccountSettings, updateRecommendationForAccountSettingsFailure, } = expenseAutomationJESchedulesView.actions;
773
714
  export default expenseAutomationJESchedulesView.reducer;
774
715
  const doUpdateRecommendationForAccountSettings = (draft, payload) => {
775
716
  const { prepaidExpensesRecommendations, fixedAssetsRecommendations, accruedExpensesRecommendations, } = mapAccountTypeRecommendationPayloadToAccountRecommendationByType(payload);
@@ -373,6 +373,16 @@ const expenseAutomationTransactionsView = createSlice({
373
373
  if (cached != null) {
374
374
  autoCat.uiState.pageToken = cached.pageToken;
375
375
  autoCat.uiState.totalCount = { ...cached.totalCount };
376
+ // Keep the stored badge in step with the restored sub-tab: the selector
377
+ // falls back to it for any period this sub-tab has not loaded. Merged,
378
+ // not replaced -- the snapshot only holds periods this sub-tab actually
379
+ // loaded, while the badge map also carries periods filled from a Review
380
+ // response's `other_tab_total_count`. Overwriting would drop those and
381
+ // leave the badge at 0 for any period this sub-tab never visited.
382
+ draft.parentTotalCountByTab.autoCategorized = {
383
+ ...draft.parentTotalCountByTab.autoCategorized,
384
+ ...cached.totalCount,
385
+ };
376
386
  autoCat.uiState.scrollPosition = cached.scrollPosition;
377
387
  autoCat.transactionIdsBySelectedPeriod = {
378
388
  ...cached.transactionIdsBySelectedPeriod,
@@ -210,7 +210,7 @@ export function getExpenseAutomationJESchedulesView(state) {
210
210
  const accruedSchedules = [];
211
211
  const oneTimeAccruals = [];
212
212
  const { accountState, accountListState, classState, classListState, expenseAutomationJESchedulesViewState, expenseAutomationViewState, monthEndCloseChecksState, } = state;
213
- const { jeScheduleTransactionKeysByPeriodAndTab, jeScheduleAccruedKeysByPeriodAndTab, jeScheduleOneTimeAccrualKeysByPeriodAndTab, failedJePostings, jeScheduleLocalDataById, postStatusById, ignoreStatusById, revertStatusById, oneTimeAccrualActionStatusById, uiState, error, fetchState, refreshStatus, newSchedule, } = expenseAutomationJESchedulesViewState;
213
+ const { jeScheduleTransactionKeysByPeriodAndTab, jeScheduleAccruedKeysByPeriodAndTab, jeScheduleOneTimeAccrualKeysByPeriodAndTab, failedJeScheduleTransactionKeysByPeriodAndTab, jeScheduleLocalDataById, postStatusById, ignoreStatusById, revertStatusById, oneTimeAccrualActionStatusById, uiState, error, fetchState, refreshStatus, newSchedule, } = expenseAutomationJESchedulesViewState;
214
214
  const accountSettingsView = getJEAccountSettingsView(state);
215
215
  const newScheduleView = newSchedule.selectedDetailScheduleType === 'fixed_assets' ||
216
216
  newSchedule.selectedDetailScheduleType === 'prepaid_expenses'
@@ -249,11 +249,15 @@ export function getExpenseAutomationJESchedulesView(state) {
249
249
  const jeScheduleTransactionKeysForSelectedTab = selectedPeriodTabKey != null
250
250
  ? jeScheduleTransactionKeysByPeriodAndTab[selectedPeriodTabKey]
251
251
  : undefined;
252
+ const failedJeScheduleTransactionKeysForSelectedTab = selectedPeriodTabKey != null
253
+ ? failedJeScheduleTransactionKeysByPeriodAndTab[selectedPeriodTabKey]
254
+ : undefined;
252
255
  // Distinguishes "this tab has never been fetched for this period" from "fetched and genuinely
253
256
  // empty". Without it the page cannot tell a first visit from a real empty state, and renders an
254
257
  // empty table where it should render a skeleton.
255
258
  const hasLoadedForSelectedTab = jeScheduleTransactionKeysForSelectedTab != null;
256
259
  const jeScheduleTransactionKeys = jeScheduleTransactionKeysForSelectedTab ?? [];
260
+ const failedJeScheduleTransactionKeys = failedJeScheduleTransactionKeysForSelectedTab ?? [];
257
261
  const jeScheduleAccruedKeys = (selectedPeriodTabKey != null
258
262
  ? jeScheduleAccruedKeysByPeriodAndTab[selectedPeriodTabKey]
259
263
  : undefined) ?? [];
@@ -276,34 +280,24 @@ export function getExpenseAutomationJESchedulesView(state) {
276
280
  accruedSchedules.push(accruedScheduleDetails);
277
281
  }
278
282
  });
279
- // Sourced from the tenant-wide bucket, not the per-period one: a failed posting belongs to no
280
- // close month, and windowing it is what kept older failures off the only tab that can resolve
281
- // them.
282
- failedJePostings.jeScheduleTransactionKeys.forEach((jeScheduleKey) => {
283
+ failedJeScheduleTransactionKeys.forEach((jeScheduleKey) => {
283
284
  const jeScheduleDetails = getJEScheduledTransactionByJEScheduleTransactionKey(jeScheduleKey, state);
284
285
  failedJeScheduledTransaction.push(jeScheduleDetails);
285
286
  });
286
287
  const { sortKey, sortOrder, selectedJETypeFilter } = uiState;
287
- const matchesTypeFilter = (schedule) => selectedJETypeFilter == null ||
288
- getJEScheduleRowType(schedule) === selectedJETypeFilter;
289
288
  const unsortedResolveSchedules = [];
290
289
  failedJeScheduledTransaction.forEach((schedule) => {
291
- // Only the entries that actually carry an error. The schedule's entry array is shared state:
292
- // opening a schedule's detail page or Quick View replaces it with every month the schedule
293
- // has, posted ones included, so fanning out over all of them turned one failed posting into a
294
- // row per month -- and a month that never failed has nothing to resolve, so it rendered with
295
- // an empty action column. Keying on `error` also makes the list self-correcting: an entry the
296
- // server no longer reports as failing drops out on the next fetch.
297
- schedule.scheduledJournalEntry
298
- .filter((journalEntry) => journalEntry.error.length > 0)
299
- .forEach((journalEntry) => {
290
+ schedule.scheduledJournalEntry.forEach((journalEntry) => {
300
291
  unsortedResolveSchedules.push({
301
292
  ...schedule,
302
293
  scheduledJournalEntry: journalEntry,
303
294
  });
304
295
  });
305
296
  });
306
- const resolveSchedules = sortJEScheduledTransactions(unsortedResolveSchedules.filter(matchesTypeFilter), sortKey, sortOrder);
297
+ const resolveSchedules = sortJEScheduledTransactions(unsortedResolveSchedules, sortKey, sortOrder);
298
+ const validResolveForPending = unsortedResolveSchedules.filter((r) => jeScheduleLocalDataById[r.scheduledJournalEntry.scheduledJournalEntryID] != null);
299
+ const matchesTypeFilter = (schedule) => selectedJETypeFilter == null ||
300
+ getJEScheduleRowType(schedule) === selectedJETypeFilter;
307
301
  const isCreatedStatus = (schedule) => {
308
302
  // An accrual is "created" once it is not review work: posted, reversing, reversed, or in a
309
303
  // transient posting claim.
@@ -321,6 +315,7 @@ export function getExpenseAutomationJESchedulesView(state) {
321
315
  ];
322
316
  const pendingReviewSchedules = sortJEScheduledTransactions([
323
317
  ...allScheduleRows.filter((schedule) => isPendingReviewRow(schedule) && matchesTypeFilter(schedule)),
318
+ ...validResolveForPending,
324
319
  ], sortKey, sortOrder);
325
320
  const createdSchedules = sortJEScheduledTransactions(allScheduleRows.filter((schedule) => isCreatedStatus(schedule) && matchesTypeFilter(schedule)), sortKey, sortOrder);
326
321
  // KPI summary — derived from unfiltered schedules so counts are always accurate
@@ -439,9 +434,6 @@ export function getExpenseAutomationJESchedulesView(state) {
439
434
  kpiSummary,
440
435
  pendingReviewSchedules,
441
436
  pendingReviewTotal,
442
- failedPostings: resolveSchedules,
443
- // Deprecated alias of failedPostings. Still read by the section's footer-form effect and by
444
- // app-ui analytics; remove once both are repointed.
445
437
  resolveSchedules: resolveSchedules,
446
438
  accountSettingsView,
447
439
  newScheduleView,
@@ -1,6 +1,6 @@
1
1
  import { createSelector } from '@reduxjs/toolkit';
2
2
  import omit from 'lodash/omit';
3
- import { toMonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
3
+ import { toMonthYearPeriodId, } from '../../../commonStateTypes/timePeriod';
4
4
  import { getCurrentTenant, getIsAccountingProjectsEnabled, } from '../../../entity/tenant/tenantSelector';
5
5
  import { getTransactionWithCOT } from '../../../entity/transaction/transactionHelper';
6
6
  import { getSupportedTransactionsByIds } from '../../../entity/transaction/transactionSelector';
@@ -172,18 +172,35 @@ export function getExpenseAutomationTransactionView(state) {
172
172
  review: monthYearPeriodId != null ? totalCountByReview[monthYearPeriodId] : 0,
173
173
  autoCategorized: monthYearPeriodId != null ? totalCountByAutoCat[monthYearPeriodId] : 0,
174
174
  };
175
- // Parent-tab badge counts. Sourced from `parent_tab_total_count` in the
176
- // listing response and used exclusively by the navbar / tab strip badges.
177
- // Independent of which Completed sub-tab is active so the badge stays
178
- // stable across sub-tab switches.
175
+ // Tab badge counts, used exclusively by the navbar / tab strip badges. Both
176
+ // tabs are counted under the filters applied to the list, so a badge always
177
+ // equals the number of rows that tab shows.
178
+ //
179
+ // The ACTIVE tab prefers its own list count: the two are the same number (the
180
+ // backend's parent_tab_total_count mirrors total_count), but `uiState.totalCount`
181
+ // is restored by every cache path that skips a fetch -- switching back to an
182
+ // already-loaded period, or to a cached Completed sub-tab -- whereas the stored
183
+ // badge is only written when a response lands, so on those paths it would keep
184
+ // showing whatever was fetched last.
185
+ //
186
+ // The `in` check is load-bearing, not defensive: `totalCount` is a per-period
187
+ // map typed as `Record<MonthYearPeriodId, number>`, so indexing it is typed
188
+ // `number` but is `undefined` for any period the active (sub-)tab has not
189
+ // loaded -- the window between switching to a fresh sub-tab and its response
190
+ // landing. Falling back to the stored badge there keeps a real number in the
191
+ // label instead of blanking it.
179
192
  const parentTotalCountByTab = expenseAutomationTransactionsViewState.parentTotalCountByTab;
193
+ const storedBadgeByTab = (tab) => monthYearPeriodId != null
194
+ ? (parentTotalCountByTab[tab][monthYearPeriodId] ?? 0)
195
+ : 0;
196
+ const badgeForTab = (tab, listCountByPeriod) => selectedTransactionCategorizationTab === tab &&
197
+ monthYearPeriodId != null &&
198
+ monthYearPeriodId in listCountByPeriod
199
+ ? listCountByPeriod[monthYearPeriodId]
200
+ : storedBadgeByTab(tab);
180
201
  const parentTabTotalCountByTab = {
181
- review: monthYearPeriodId != null
182
- ? (parentTotalCountByTab.review[monthYearPeriodId] ?? 0)
183
- : 0,
184
- autoCategorized: monthYearPeriodId != null
185
- ? (parentTotalCountByTab.autoCategorized[monthYearPeriodId] ?? 0)
186
- : 0,
202
+ review: badgeForTab('review', totalCountByReview),
203
+ autoCategorized: badgeForTab('autoCategorized', totalCountByAutoCat),
187
204
  };
188
205
  const fetchStateByTab = {
189
206
  review: {
@@ -130,26 +130,50 @@ export const localDataToSaveInvoicingCatalogItemPayload = (localData, isCreate,
130
130
  const subFamilies = localData.subFamilies.length > 0
131
131
  ? localData.subFamilies
132
132
  : [blankInvoicingCatalogSubFamily()];
133
- itemPayload.sub_families = isCreate
134
- ? subFamilies.map((subFamily) => buildSubFamilyPayload(localData, subFamily, false, lookup))
135
- : subFamilies.map((subFamily) => {
136
- // Edits send the same body a create does. The narrower hand-built one
137
- // this replaces had to be kept in step by hand and was not: it dropped
138
- // `accounting_detail` once, and `billing_cycles`, `price`,
139
- // `pricing_model`, `period`, the trial fields, `proration_type`,
140
- // `free_quantity`, `is_taxable` and `tiers` were never added at all, so
141
- // editing any of them looked saved and changed nothing.
142
- const detail = buildSubFamilyPayload(localData, subFamily, true, lookup);
143
- // `null` rather than omitted when empty: an absent key on an update
144
- // reads as "leave it alone", which would make a cleared mapping
145
- // impossible to save — the same reason `description` and
146
- // `invoice_notes` are cleared rather than dropped above.
147
- detail.accounting_detail = detail.accounting_detail ?? null;
148
- // A price point added on this form has no id yet, and travels with a
149
- // blank one. The update endpoint reads that as "create this one", so it
150
- // lands in the same request as the edits around it rather than a second
151
- // call that could fail on its own.
152
- return { ...detail, id: subFamily.id.trim() };
153
- });
133
+ if (isCreate) {
134
+ itemPayload.sub_families = subFamilies.map((subFamily) => buildSubFamilyPayload(localData, subFamily, false, lookup));
135
+ return itemPayload;
136
+ }
137
+ // Only price points the service has already stored travel in an update: it
138
+ // addresses them by id, and a blank one has nothing to address. A price point
139
+ // added on the form is created by its own request once the item is saved,
140
+ // rather than riding along as a row the update cannot place.
141
+ itemPayload.sub_families = subFamilies
142
+ .filter((subFamily) => subFamily.id !== '')
143
+ .map((subFamily) => {
144
+ // Edits send the same body a create does. The narrower hand-built one
145
+ // this replaces had to be kept in step by hand and was not: it dropped
146
+ // `accounting_detail` once, and `billing_cycles`, `price`,
147
+ // `pricing_model`, `period`, the trial fields, `proration_type`,
148
+ // `free_quantity`, `is_taxable` and `tiers` were never added at all, so
149
+ // editing any of them looked saved and changed nothing.
150
+ const detail = buildSubFamilyPayload(localData, subFamily, true, lookup);
151
+ // `null` rather than omitted when empty: an absent key on an update
152
+ // reads as "leave it alone", which would make a cleared mapping
153
+ // impossible to save — the same reason `description` and
154
+ // `invoice_notes` are cleared rather than dropped above.
155
+ detail.accounting_detail = detail.accounting_detail ?? null;
156
+ // Never blank: the filter above leaves only price points the service has
157
+ // already stored, which is the only kind an update can address.
158
+ return { ...detail, id: subFamily.id };
159
+ });
154
160
  return itemPayload;
155
161
  };
162
+ /**
163
+ * The bodies that create the price points added on an edit form, one per
164
+ * request to `/catalog/products`.
165
+ *
166
+ * An update cannot carry them: it addresses price points by id, and these have
167
+ * none until the service assigns one. They are bound to their item by
168
+ * `item_id`, so this needs the saved item's id and runs after the item itself
169
+ * is saved.
170
+ *
171
+ * Empty values are left off rather than sent as `null`: there is nothing on a
172
+ * price point that does not exist yet to clear.
173
+ */
174
+ export const localDataToCreateInvoicingCatalogProductPayloads = (localData, itemId, lookup) => localData.subFamilies
175
+ .filter((subFamily) => subFamily.id === '')
176
+ .map((subFamily) => ({
177
+ ...buildSubFamilyPayload(localData, subFamily, false, lookup),
178
+ item_id: itemId,
179
+ }));
@@ -1,6 +1,6 @@
1
1
  import { createSlice } from '@reduxjs/toolkit';
2
2
  import { clearAll } from '../../../rootActions';
3
- import { applyInvoicingFormDraftEdit, applyInvoicingFormDraftFailure, applyInvoicingFormDraftSeed, } from '../invoicingFormDraft';
3
+ import { applyInvoicingFormDraftEdit, applyInvoicingFormDraftFailure, applyInvoicingFormDraftSaved, applyInvoicingFormDraftSeed, } from '../invoicingFormDraft';
4
4
  import { initialInvoicingCatalogItemFormLocalData } from './invoicingCatalogItemFormHelper';
5
5
  export const initialState = {
6
6
  fetchState: 'Not-Started',
@@ -43,6 +43,9 @@ const editInvoicingCatalogItemDetailView = createSlice({
43
43
  draft.error = undefined;
44
44
  draft.savedItemId = action.payload.itemId;
45
45
  draft.savedKind = action.payload.kind;
46
+ // An edit is refetched on success; keep the saved values on screen until
47
+ // that lands, and let it replace them.
48
+ applyInvoicingFormDraftSaved(draft.editDraftById, action.payload.itemId);
46
49
  },
47
50
  submitInvoicingCatalogItemFormFailure(draft, action) {
48
51
  draft.fetchState = 'Error';
@@ -3,7 +3,7 @@ import { reduceAllFetchState } from '../../../commonStateTypes/reduceFetchState'
3
3
  import { getInvoicingPlanById, getInvoicingPlansByIds, } from '../../../entity/invoicing/plan/planSelector';
4
4
  import { getInvoicingConfigView, invoicingFieldHelpForGroup, } from '../invoicingConfigView/invoicingConfigViewSelector';
5
5
  import { getInvoicingFormDraftLocalData, isInvoicingFormDraftPending, } from '../invoicingFormDraft';
6
- import { getInvoicingQboView, isInvoicingAccountingPickerDataLoading, isInvoicingQboConnected, } from '../invoicingQboView/invoicingQboViewSelector';
6
+ import { INVOICING_DEFAULT_INCOME_ACCOUNT_TYPES, INVOICING_INCOME_ACCOUNT_MAPPING_SLOT, NO_INVOICING_ACCOUNT_HIERARCHY, NO_INVOICING_ACCOUNT_IDS, NO_INVOICING_CLASS_HIERARCHY, getInvoicingQboAccountOptions, getInvoicingQboView, invoicingQboAccountIdsForMappingSlot, isInvoicingAccountingPickerDataLoading, isInvoicingQboConnected, } from '../invoicingQboView/invoicingQboViewSelector';
7
7
  import { INVOICING_CATALOG_APPLICABILITY_VALUES, INVOICING_CATALOG_PRICING_MODEL_VALUES, INVOICING_CATALOG_PRORATION_VALUES, INVOICING_CATALOG_TIER_TYPE_VALUES, initialInvoicingCatalogItemFormLocalData, } from './invoicingCatalogItemFormHelper';
8
8
  export const getEditInvoicingCatalogItemDetailViewState = (state) => ({
9
9
  fetchState: state.editInvoicingCatalogItemDetailViewState.fetchState,
@@ -44,6 +44,21 @@ const NOT_STARTED = {
44
44
  error: undefined,
45
45
  fetchState: 'Not-Started',
46
46
  };
47
+ /**
48
+ * The QuickBooks ids a price point's income account may be picked from.
49
+ *
50
+ * Memoized, and collapsing to one shared empty array while QBO is disconnected:
51
+ * the pages turn this into their picker options and re-seed their form defaults
52
+ * when those change, so a fresh array on every store change would reset the form
53
+ * under the user — including mid-save.
54
+ */
55
+ const getInvoicingCatalogIncomeAccountIds = createSelector([
56
+ getInvoicingQboAccountOptions,
57
+ (state) => getInvoicingConfigView(state).qboAccountMappingKindOptions,
58
+ isInvoicingQboConnected,
59
+ ], (accounts, qboAccountMappingKindOptions, isQboConnected) => isQboConnected
60
+ ? invoicingQboAccountIdsForMappingSlot(accounts, qboAccountMappingKindOptions, INVOICING_INCOME_ACCOUNT_MAPPING_SLOT, INVOICING_DEFAULT_INCOME_ACCOUNT_TYPES)
61
+ : NO_INVOICING_ACCOUNT_IDS);
47
62
  export const getInvoicingCatalogItemFormView = (state, id) => {
48
63
  const { editDraftById, error, fetchState, newItemDraft, savedItemId, savedKind, } = state.editInvoicingCatalogItemDetailViewState;
49
64
  const plan = id != null ? getInvoicingPlanById(state.invoicingPlanState, id) : undefined;
@@ -94,8 +109,9 @@ export const getInvoicingCatalogItemFormView = (state, id) => {
94
109
  isFormLoading: isInvoicingAccountingPickerDataLoading(state) ||
95
110
  isInvoicingFormDraftPending(editDraftById, id),
96
111
  isQboPickerDataLoading: isInvoicingAccountingPickerDataLoading(state),
97
- qboAccountHierarchy: qboView?.nestedAccountHierarchy ?? [],
98
- qboClassHierarchy: qboView?.nestedClassHierarchy ?? [],
112
+ qboAccountHierarchy: qboView?.nestedAccountHierarchy ?? NO_INVOICING_ACCOUNT_HIERARCHY,
113
+ qboClassHierarchy: qboView?.nestedClassHierarchy ?? NO_INVOICING_CLASS_HIERARCHY,
114
+ qboIncomeAccountIds: getInvoicingCatalogIncomeAccountIds(state),
99
115
  applicabilityValues: INVOICING_CATALOG_APPLICABILITY_VALUES,
100
116
  applicableItemOptions,
101
117
  localData,
@@ -1,4 +1,4 @@
1
- import { from } from 'rxjs';
1
+ import { forkJoin, from } from 'rxjs';
2
2
  import { catchError, filter, mergeMap } from 'rxjs/operators';
3
3
  import { mergeInvoicingPlanSubFamily, updateInvoicingPlans, } from '../../../entity/invoicing/plan/planReducer';
4
4
  import { updateInvoicingProducts } from '../../../entity/invoicing/product/productReducer';
@@ -7,7 +7,7 @@ import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
7
7
  import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
8
8
  import { addInvoicingCatalogItem } from '../invoicingCatalogListView/invoicingCatalogListViewReducer';
9
9
  import { getInvoicingCatalogAccountingLookup } from '../invoicingQboView/invoicingQboViewSelector';
10
- import { localDataToSaveInvoicingCatalogItemPayload, } from './editInvoicingCatalogItemDetailViewPayload';
10
+ import { localDataToCreateInvoicingCatalogProductPayloads, localDataToSaveInvoicingCatalogItemPayload, } from './editInvoicingCatalogItemDetailViewPayload';
11
11
  import { submitInvoicingCatalogItemForm, submitInvoicingCatalogItemFormFailure, submitInvoicingCatalogItemFormSuccess, } from './editInvoicingCatalogItemDetailViewReducer';
12
12
  export const saveInvoicingCatalogItemEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter((action) => submitInvoicingCatalogItemForm.match(action)), mergeMap((action) => {
13
13
  const { id } = action.payload;
@@ -81,7 +81,20 @@ export const saveInvoicingCatalogItemEpic = (actions$, state$, zeniAPI) => actio
81
81
  }));
82
82
  return resultActions;
83
83
  };
84
- return completeSave([]);
84
+ // Price points added on an edit form cannot ride in the update:
85
+ // it addresses them by id and they have none yet. They are created
86
+ // against the item that was just saved, and their responses join
87
+ // the same success — one of them failing is the whole save
88
+ // failing, since the item on screen would otherwise claim price
89
+ // points the service never stored. A create needs none of this:
90
+ // its price points are nested in the item body.
91
+ const newProductPayloads = id != null
92
+ ? localDataToCreateInvoicingCatalogProductPayloads(localData, savedItem.id, accountingLookup)
93
+ : [];
94
+ if (newProductPayloads.length === 0) {
95
+ return completeSave([]);
96
+ }
97
+ return forkJoin(newProductPayloads.map((productPayload) => zeniAPI.postAndGetJSON(`${baseUrl}/catalog/products`, productPayload))).pipe(mergeMap((productResponses) => completeSave(productResponses)));
85
98
  }
86
99
  return from([
87
100
  submitInvoicingCatalogItemFormFailure(response.status),
@@ -23,9 +23,13 @@ export const seedInvoicingCatalogItemFormDraftEpic = (actions$, state$) => actio
23
23
  // endpoints merge their own list-shaped rows into the same store. Only a
24
24
  // completed detail load does, which is also exactly when the page's
25
25
  // cache-guarded fetch issues no request and this is the sole seed.
26
+ // A forced refetch is the caller asking for fresh data: the response will
27
+ // seed, and seeding first from the entity as it stands would mark the
28
+ // draft loaded and lock that response out.
26
29
  if (fetchInvoicingCatalogItemDetailPage.match(action) &&
27
- state.editInvoicingCatalogItemDetailViewState.recordStateById[id]
28
- ?.fetchState !== 'Completed') {
30
+ (action.payload.cacheOverride === true ||
31
+ state.editInvoicingCatalogItemDetailViewState.recordStateById[id]
32
+ ?.fetchState !== 'Completed')) {
29
33
  return EMPTY;
30
34
  }
31
35
  // Nothing to seed from on a cold open; the detail response triggers this
@@ -1,6 +1,6 @@
1
1
  import { createSlice } from '@reduxjs/toolkit';
2
2
  import { clearAll } from '../../../rootActions';
3
- import { applyInvoicingFormDraftEdit, applyInvoicingFormDraftFailure, applyInvoicingFormDraftSeed, } from '../invoicingFormDraft';
3
+ import { applyInvoicingFormDraftEdit, applyInvoicingFormDraftFailure, applyInvoicingFormDraftSaved, applyInvoicingFormDraftSeed, } from '../invoicingFormDraft';
4
4
  import { initialInvoicingCouponFormLocalData, } from './editInvoicingCouponDetailViewState';
5
5
  export const initialState = {
6
6
  fetchState: 'Not-Started',
@@ -51,6 +51,9 @@ const editInvoicingCouponDetailView = createSlice({
51
51
  draft.fetchState = 'Completed';
52
52
  draft.error = undefined;
53
53
  draft.savedCouponId = action.payload.couponId;
54
+ // An edit is refetched on success; keep the saved values on screen until
55
+ // that lands, and let it replace them.
56
+ applyInvoicingFormDraftSaved(draft.editDraftById, action.payload.couponId);
54
57
  },
55
58
  submitInvoicingCouponFormFailure(draft, action) {
56
59
  draft.fetchState = 'Error';