@zeniai/client-epic-state 5.2.51-betaRD1 → 5.2.51

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 (70) 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 -29
  11. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.js +1 -12
  12. package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +1 -60
  13. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +11 -11
  14. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +45 -21
  15. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.js +4 -1
  16. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +16 -3
  17. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +6 -2
  18. package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +4 -1
  19. package/lib/esm/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js +6 -2
  20. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +10 -2
  21. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +33 -0
  22. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/initializeInvoicingCustomerAddressEpic.js +43 -17
  23. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.js +6 -2
  24. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.js +10 -2
  25. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +34 -0
  26. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddressEpic.js +44 -18
  27. package/lib/esm/view/invoicing/invoicingFormDraft.js +13 -0
  28. package/lib/index.d.ts +3 -3
  29. package/lib/index.js +49 -50
  30. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.d.ts +2 -2
  31. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +0 -8
  32. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +11 -8
  33. package/lib/view/expenseAutomationView/epics/jeSchedule/initializeJeScheduleLocalDataEpic.js +15 -29
  34. package/lib/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.d.ts +2 -2
  35. package/lib/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.js +1 -12
  36. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +0 -18
  37. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +2 -8
  38. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +3 -62
  39. package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +0 -2
  40. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +11 -11
  41. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +0 -15
  42. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.d.ts +22 -6
  43. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +47 -22
  44. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.js +3 -0
  45. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +14 -1
  46. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +6 -2
  47. package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +3 -0
  48. package/lib/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js +6 -2
  49. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.d.ts +3 -1
  50. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +10 -2
  51. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.d.ts +7 -7
  52. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +33 -0
  53. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewState.d.ts +6 -0
  54. package/lib/view/invoicing/editInvoicingCustomerDetailView/initializeInvoicingCustomerAddressEpic.d.ts +15 -10
  55. package/lib/view/invoicing/editInvoicingCustomerDetailView/initializeInvoicingCustomerAddressEpic.js +42 -16
  56. package/lib/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.js +6 -2
  57. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.d.ts +3 -1
  58. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.js +10 -2
  59. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.d.ts +7 -0
  60. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +34 -0
  61. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewState.d.ts +6 -0
  62. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddressEpic.d.ts +15 -11
  63. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddressEpic.js +42 -16
  64. package/lib/view/invoicing/invoicingFormDraft.d.ts +10 -1
  65. package/lib/view/invoicing/invoicingFormDraft.js +14 -0
  66. package/package.json +1 -1
  67. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.js +0 -40
  68. package/lib/tsconfig.mocks.tsbuildinfo +0 -1
  69. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.d.ts +0 -20
  70. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.js +0 -44
@@ -7,36 +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
- jeScheduledTransaction.scheduledJournalEntry.forEach((journalEntry) => {
26
- const { scheduledJournalEntryID } = journalEntry;
27
- actions.push(updateJeScheduleLocalDataById({
28
- localData: {
29
- jeScheduleType: jeScheduledTransaction.jeScheduleType,
30
- jeScheduleID: jeScheduledTransaction.jeScheduleId,
31
- scheduledJournalEntryID,
32
- updatedVendor: undefined,
33
- updatedCategoryId: undefined,
34
- updatedAccumulatedDepreciationCategoryID: undefined,
35
- updatedClassId: undefined,
36
- },
37
- scheduledJournalEntryID,
38
- }));
39
- });
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
+ }));
40
26
  });
41
27
  return from(actions);
42
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 {
@@ -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);
@@ -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,16 +280,11 @@ 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
290
  schedule.scheduledJournalEntry.forEach((journalEntry) => {
@@ -295,7 +294,10 @@ export function getExpenseAutomationJESchedulesView(state) {
295
294
  });
296
295
  });
297
296
  });
298
- 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;
299
301
  const isCreatedStatus = (schedule) => {
300
302
  // An accrual is "created" once it is not review work: posted, reversing, reversed, or in a
301
303
  // transient posting claim.
@@ -313,6 +315,7 @@ export function getExpenseAutomationJESchedulesView(state) {
313
315
  ];
314
316
  const pendingReviewSchedules = sortJEScheduledTransactions([
315
317
  ...allScheduleRows.filter((schedule) => isPendingReviewRow(schedule) && matchesTypeFilter(schedule)),
318
+ ...validResolveForPending,
316
319
  ], sortKey, sortOrder);
317
320
  const createdSchedules = sortJEScheduledTransactions(allScheduleRows.filter((schedule) => isCreatedStatus(schedule) && matchesTypeFilter(schedule)), sortKey, sortOrder);
318
321
  // KPI summary — derived from unfiltered schedules so counts are always accurate
@@ -431,9 +434,6 @@ export function getExpenseAutomationJESchedulesView(state) {
431
434
  kpiSummary,
432
435
  pendingReviewSchedules,
433
436
  pendingReviewTotal,
434
- failedPostings: resolveSchedules,
435
- // Deprecated alias of failedPostings. Still read by the section's footer-form effect and by
436
- // app-ui analytics; remove once both are repointed.
437
437
  resolveSchedules: resolveSchedules,
438
438
  accountSettingsView,
439
439
  newScheduleView,
@@ -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';
@@ -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';
@@ -23,9 +23,13 @@ export const seedInvoicingCouponFormDraftEpic = (actions$, state$) => actions$.p
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 (fetchInvoicingCouponDetailPage.match(action) &&
27
- state.editInvoicingCouponDetailViewState.recordStateById[id]
28
- ?.fetchState !== 'Completed') {
30
+ (action.payload.cacheOverride === true ||
31
+ state.editInvoicingCouponDetailViewState.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 { initialInvoicingCustomerFormLocalData } from './invoicingCustomerFormConfig';
5
5
  export const initialState = {
6
6
  emailPreviewFetchState: { fetchState: 'Not-Started', error: undefined },
@@ -8,6 +8,7 @@ export const initialState = {
8
8
  emailPreviewCustomerId: undefined,
9
9
  promotionalCreditSubmitState: { fetchState: 'Not-Started', error: undefined },
10
10
  recordStateById: {},
11
+ billingAddressOwnerId: undefined,
11
12
  fetchState: 'Not-Started',
12
13
  error: undefined,
13
14
  editDraftById: {},
@@ -154,6 +155,9 @@ const editInvoicingCustomerDetailView = createSlice({
154
155
  draft.fetchState = 'Completed';
155
156
  draft.error = undefined;
156
157
  draft.savedCustomerId = action.payload.customerId;
158
+ // An edit is refetched on success; keep the saved values on screen until
159
+ // that lands, and let it replace them.
160
+ applyInvoicingFormDraftSaved(draft.editDraftById, action.payload.customerId);
157
161
  },
158
162
  submitInvoicingCustomerFormFailure(draft, action) {
159
163
  draft.fetchState = 'Error';
@@ -183,6 +187,10 @@ const editInvoicingCustomerDetailView = createSlice({
183
187
  return { payload };
184
188
  },
185
189
  },
190
+ /** Record which customer the shared billing-address slot now belongs to. */
191
+ claimInvoicingCustomerBillingAddress(draft, action) {
192
+ draft.billingAddressOwnerId = action.payload.id;
193
+ },
186
194
  },
187
195
  extraReducers: (builder) => {
188
196
  builder.addCase(clearAll, (draft) => {
@@ -190,5 +198,5 @@ const editInvoicingCustomerDetailView = createSlice({
190
198
  });
191
199
  },
192
200
  });
193
- export const { fetchInvoicingPaymentLinkEmailPreview, fetchInvoicingPaymentLinkEmailPreviewPage, updateInvoicingPaymentLinkEmailPreview, updateInvoicingPaymentLinkEmailPreviewFailure, addPromotionalCreditsFailure, addPromotionalCreditsSuccess, fetchInvoicingCustomerDetail, fetchInvoicingCustomerDetailPage, seedInvoicingCustomerFormDraft, updateInvoicingCustomerDetail, resetPromotionalCreditAction, submitAddPromotionalCredits, updateInvoicingCustomerDetailFailure, updateInvoicingCustomerFormDraft, submitInvoicingCustomerForm, submitInvoicingCustomerFormSuccess, submitInvoicingCustomerFormFailure, resetEditInvoicingCustomerDetailView, initializeInvoicingCustomerAddress, } = editInvoicingCustomerDetailView.actions;
201
+ export const { fetchInvoicingPaymentLinkEmailPreview, fetchInvoicingPaymentLinkEmailPreviewPage, updateInvoicingPaymentLinkEmailPreview, updateInvoicingPaymentLinkEmailPreviewFailure, addPromotionalCreditsFailure, addPromotionalCreditsSuccess, fetchInvoicingCustomerDetail, fetchInvoicingCustomerDetailPage, seedInvoicingCustomerFormDraft, updateInvoicingCustomerDetail, resetPromotionalCreditAction, submitAddPromotionalCredits, updateInvoicingCustomerDetailFailure, updateInvoicingCustomerFormDraft, submitInvoicingCustomerForm, submitInvoicingCustomerFormSuccess, submitInvoicingCustomerFormFailure, resetEditInvoicingCustomerDetailView, initializeInvoicingCustomerAddress, claimInvoicingCustomerBillingAddress, } = editInvoicingCustomerDetailView.actions;
194
202
  export default editInvoicingCustomerDetailView.reducer;
@@ -1,4 +1,5 @@
1
1
  import { reduceAllFetchState } from '../../../commonStateTypes/reduceFetchState';
2
+ import { getAddressByAddressId } from '../../../entity/address/addressSelector';
2
3
  import { getInvoicesByIds } from '../../../entity/invoicing/invoice/invoiceSelector';
3
4
  import { getInvoicingCustomerById } from '../../../entity/invoicing/invoicingCustomer/invoicingCustomerSelector';
4
5
  import { invoicingCustomerPaymentMethods } from '../../../entity/invoicing/invoicingCustomer/invoicingCustomerSelector';
@@ -50,6 +51,37 @@ export const getInvoicingCustomerRecord = (state, invoicingCustomerID) => {
50
51
  * fetch state/error, and the id of the customer last saved — so the form screen
51
52
  * depends on this single selector.
52
53
  */
54
+ /**
55
+ * Whether the billing address entered on the Address screen is a change the
56
+ * customer has not saved. Presence alone cannot say so: the detail page seeds
57
+ * the address store with the saved address on load so the Address screen opens
58
+ * prefilled. Only a pending address that differs from the saved one — or one
59
+ * where nothing is saved yet — is an unsaved change. Compared on what the user
60
+ * enters; a saved address's coordinates and timestamps are left out.
61
+ */
62
+ const isBillingAddressUnsaved = (state, id, savedBillingAddressId) => {
63
+ // The slot is keyed by address type alone; only a draft this customer owns counts.
64
+ if (id == null ||
65
+ state.editInvoicingCustomerDetailViewState.billingAddressOwnerId !== id) {
66
+ return false;
67
+ }
68
+ const pending = state.addressViewState.newAddressState?.[INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE]?.addressToCreate;
69
+ if (pending == null) {
70
+ return false;
71
+ }
72
+ const saved = savedBillingAddressId != null
73
+ ? getAddressByAddressId(state.addressState, savedBillingAddressId)
74
+ : undefined;
75
+ if (saved == null) {
76
+ return true;
77
+ }
78
+ return !(pending.street.join('\u0000') === saved.street.join('\u0000') &&
79
+ pending.city === saved.city &&
80
+ pending.state === saved.state &&
81
+ pending.postalCode === saved.postalCode &&
82
+ pending.country === saved.country &&
83
+ (pending.countryCode ?? '') === (saved.countryCode ?? ''));
84
+ };
53
85
  export const getInvoicingCustomerFormView = (state, invoicingCustomerID) => {
54
86
  const { editDraftById, error, fetchState, newCustomerDraft, savedCustomerId } = state.editInvoicingCustomerDetailViewState;
55
87
  const mode = invoicingCustomerID != null ? 'edit' : 'create';
@@ -101,6 +133,7 @@ export const getInvoicingCustomerFormView = (state, invoicingCustomerID) => {
101
133
  taxabilityOptions,
102
134
  billingAddressId,
103
135
  billingAddressLabel,
136
+ hasUnsavedBillingAddress: isBillingAddressUnsaved(state, invoicingCustomerID, customer?.billingAddressId),
104
137
  savedCustomerId,
105
138
  fetchState,
106
139
  error,