@zeniai/client-epic-state 5.2.50-betaRD1 → 5.2.50
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.
- package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +1 -4
- package/lib/entity/jeSchedules/jeSchedulesReducer.js +5 -47
- package/lib/epic.d.ts +1 -2
- package/lib/epic.js +4 -6
- package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +4 -46
- package/lib/esm/epic.js +4 -6
- package/lib/esm/index.js +3 -3
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +1 -9
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +13 -10
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/initializeJeScheduleLocalDataEpic.js +15 -29
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.js +1 -12
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +1 -60
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +11 -11
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.js +19 -11
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +4 -1
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +3 -2
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +26 -7
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +19 -11
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +3 -1
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +1 -1
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js +25 -6
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +19 -11
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +4 -2
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +1 -1
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.js +25 -6
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.js +21 -13
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +3 -2
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/fetchInvoicingSubscriptionFormPageEpic.js +4 -1
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +1 -1
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/seedInvoicingSubscriptionFormDraftEpic.js +29 -8
- package/lib/esm/view/invoicing/invoicingFormDraft.js +65 -0
- package/lib/index.d.ts +3 -3
- package/lib/index.js +49 -50
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +0 -8
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +11 -8
- package/lib/view/expenseAutomationView/epics/jeSchedule/initializeJeScheduleLocalDataEpic.js +15 -29
- package/lib/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.js +1 -12
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +0 -18
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +2 -8
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +3 -62
- package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +0 -2
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +11 -11
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +0 -15
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.js +19 -11
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.d.ts +10 -0
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +4 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewState.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +3 -2
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.d.ts +10 -6
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +25 -6
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +19 -11
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.d.ts +13 -0
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +3 -1
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +1 -1
- package/lib/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.d.ts +10 -6
- package/lib/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js +24 -5
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +19 -11
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.d.ts +9 -0
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +4 -2
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewState.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +1 -1
- package/lib/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.d.ts +10 -6
- package/lib/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.js +24 -5
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.js +21 -13
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.d.ts +9 -0
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +3 -2
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewState.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/fetchInvoicingSubscriptionFormPageEpic.js +4 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +1 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/seedInvoicingSubscriptionFormDraftEpic.d.ts +10 -6
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/seedInvoicingSubscriptionFormDraftEpic.js +28 -7
- package/lib/view/invoicing/invoicingFormDraft.d.ts +54 -0
- package/lib/view/invoicing/invoicingFormDraft.js +72 -0
- package/package.json +1 -1
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.js +0 -40
- package/lib/tsconfig.mocks.tsbuildinfo +0 -1
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.d.ts +0 -20
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.js +0 -44
package/lib/esm/view/expenseAutomationView/epics/jeSchedule/initializeJeScheduleLocalDataEpic.js
CHANGED
|
@@ -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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
}),
|
|
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,
|
|
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,
|
|
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
|
-
|
|
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
|
|
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,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createSlice } from '@reduxjs/toolkit';
|
|
2
2
|
import { clearAll } from '../../../rootActions';
|
|
3
|
+
import { applyInvoicingFormDraftEdit, applyInvoicingFormDraftFailure, applyInvoicingFormDraftSeed, } from '../invoicingFormDraft';
|
|
3
4
|
import { initialInvoicingCatalogItemFormLocalData } from './invoicingCatalogItemFormHelper';
|
|
4
5
|
export const initialState = {
|
|
5
6
|
fetchState: 'Not-Started',
|
|
@@ -21,7 +22,7 @@ const editInvoicingCatalogItemDetailView = createSlice({
|
|
|
21
22
|
updateInvoicingCatalogItemFormDraft(draft, action) {
|
|
22
23
|
const { id, localData } = action.payload;
|
|
23
24
|
if (id != null) {
|
|
24
|
-
draft.editDraftById
|
|
25
|
+
applyInvoicingFormDraftEdit(draft.editDraftById, id, localData);
|
|
25
26
|
}
|
|
26
27
|
else {
|
|
27
28
|
draft.newItemDraft = localData;
|
|
@@ -64,6 +65,7 @@ const editInvoicingCatalogItemDetailView = createSlice({
|
|
|
64
65
|
fetchState: 'Error',
|
|
65
66
|
error: action.payload.error,
|
|
66
67
|
};
|
|
68
|
+
applyInvoicingFormDraftFailure(draft.editDraftById, action.payload.id, initialInvoicingCatalogItemFormLocalData);
|
|
67
69
|
},
|
|
68
70
|
fetchInvoicingCatalogItemDetailPage: {
|
|
69
71
|
reducer() {
|
|
@@ -79,14 +81,10 @@ const editInvoicingCatalogItemDetailView = createSlice({
|
|
|
79
81
|
};
|
|
80
82
|
},
|
|
81
83
|
},
|
|
82
|
-
/**
|
|
83
|
-
* Seed the draft from the loaded record, once. Skipped when a draft already
|
|
84
|
-
* exists so a late-arriving refetch cannot overwrite in-progress edits.
|
|
85
|
-
*/
|
|
84
|
+
/** Fill the draft from the loaded record — see `applyInvoicingFormDraftSeed`. */
|
|
86
85
|
seedInvoicingCatalogItemFormDraft(draft, action) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
86
|
+
const { id, localData } = action.payload;
|
|
87
|
+
applyInvoicingFormDraftSeed(draft.editDraftById, id, localData);
|
|
90
88
|
},
|
|
91
89
|
runInvoicingCatalogPlanAction(draft, action) {
|
|
92
90
|
draft.actionStateById[action.payload.id] = {
|
|
@@ -125,13 +123,23 @@ const editInvoicingCatalogItemDetailView = createSlice({
|
|
|
125
123
|
error: action.payload.error,
|
|
126
124
|
};
|
|
127
125
|
},
|
|
128
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Discard a form's draft — the catalog item's own when `id` is given,
|
|
128
|
+
* the create draft otherwise. Scoped to the one form on purpose: another
|
|
129
|
+
* catalog item's half-finished edit is not this form's to throw away.
|
|
130
|
+
* Clearing every draft at once is what `clearAll` is for.
|
|
131
|
+
*/
|
|
132
|
+
resetEditInvoicingCatalogItemDetailView(draft, action) {
|
|
129
133
|
draft.fetchState = 'Not-Started';
|
|
130
134
|
draft.error = undefined;
|
|
131
135
|
draft.savedItemId = undefined;
|
|
132
136
|
draft.savedKind = undefined;
|
|
133
|
-
|
|
134
|
-
|
|
137
|
+
const id = action.payload?.id;
|
|
138
|
+
if (id == null) {
|
|
139
|
+
draft.newItemDraft = { ...initialInvoicingCatalogItemFormLocalData };
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
delete draft.editDraftById[id];
|
|
135
143
|
},
|
|
136
144
|
},
|
|
137
145
|
extraReducers: (builder) => {
|
|
@@ -2,6 +2,7 @@ import { createSelector } from '@reduxjs/toolkit';
|
|
|
2
2
|
import { reduceAllFetchState } from '../../../commonStateTypes/reduceFetchState';
|
|
3
3
|
import { getInvoicingPlanById, getInvoicingPlansByIds, } from '../../../entity/invoicing/plan/planSelector';
|
|
4
4
|
import { getInvoicingConfigView, invoicingFieldHelpForGroup, } from '../invoicingConfigView/invoicingConfigViewSelector';
|
|
5
|
+
import { getInvoicingFormDraftLocalData, isInvoicingFormDraftPending, } from '../invoicingFormDraft';
|
|
5
6
|
import { getInvoicingQboView, isInvoicingAccountingPickerDataLoading, isInvoicingQboConnected, } from '../invoicingQboView/invoicingQboViewSelector';
|
|
6
7
|
import { INVOICING_CATALOG_APPLICABILITY_VALUES, INVOICING_CATALOG_PRICING_MODEL_VALUES, INVOICING_CATALOG_PRORATION_VALUES, INVOICING_CATALOG_TIER_TYPE_VALUES, initialInvoicingCatalogItemFormLocalData, } from './invoicingCatalogItemFormHelper';
|
|
7
8
|
export const getEditInvoicingCatalogItemDetailViewState = (state) => ({
|
|
@@ -52,7 +53,7 @@ export const getInvoicingCatalogItemFormView = (state, id) => {
|
|
|
52
53
|
// lands. Until then the page is showing its skeleton, so the blank shape here
|
|
53
54
|
// is never rendered.
|
|
54
55
|
const localData = id != null
|
|
55
|
-
? (editDraftById
|
|
56
|
+
? getInvoicingFormDraftLocalData(editDraftById, id, initialInvoicingCatalogItemFormLocalData)
|
|
56
57
|
: newItemDraft;
|
|
57
58
|
const allApplicableItemOptions = getInvoicingApplicableCatalogItemOptions(state);
|
|
58
59
|
const applicableItemOptions = id != null
|
|
@@ -90,6 +91,8 @@ export const getInvoicingCatalogItemFormView = (state, id) => {
|
|
|
90
91
|
catalogProductLifecycleActionOptions,
|
|
91
92
|
recordState,
|
|
92
93
|
fieldHelp: invoicingFieldHelpForGroup(state, 'catalog'),
|
|
94
|
+
isFormLoading: isInvoicingAccountingPickerDataLoading(state) ||
|
|
95
|
+
isInvoicingFormDraftPending(editDraftById, id),
|
|
93
96
|
isQboPickerDataLoading: isInvoicingAccountingPickerDataLoading(state),
|
|
94
97
|
qboAccountHierarchy: qboView?.nestedAccountHierarchy ?? [],
|
|
95
98
|
qboClassHierarchy: qboView?.nestedClassHierarchy ?? [],
|
package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js
CHANGED
|
@@ -17,8 +17,9 @@ export const saveInvoicingCatalogItemEpic = (actions$, state$, zeniAPI) => actio
|
|
|
17
17
|
// class become the records the service stores. Price points ride along
|
|
18
18
|
// nested, so the detail page and the create/edit form share one request.
|
|
19
19
|
const viewState = state.editInvoicingCatalogItemDetailViewState;
|
|
20
|
-
const localData = (id != null
|
|
21
|
-
viewState.
|
|
20
|
+
const localData = (id != null
|
|
21
|
+
? viewState.editDraftById[id]?.localData
|
|
22
|
+
: viewState.newItemDraft) ?? viewState.newItemDraft;
|
|
22
23
|
const data = localDataToSaveInvoicingCatalogItemPayload(localData, id == null, accountingLookup);
|
|
23
24
|
const baseUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0`;
|
|
24
25
|
const path = id != null
|
|
@@ -1,16 +1,35 @@
|
|
|
1
1
|
import { EMPTY, of } from 'rxjs';
|
|
2
2
|
import { filter, mergeMap, withLatestFrom } from 'rxjs/operators';
|
|
3
3
|
import { getInvoicingPlanById } from '../../../entity/invoicing/plan/planSelector';
|
|
4
|
-
import { seedInvoicingCatalogItemFormDraft, updateInvoicingCatalogItemDetail, } from './editInvoicingCatalogItemDetailViewReducer';
|
|
4
|
+
import { fetchInvoicingCatalogItemDetailPage, seedInvoicingCatalogItemFormDraft, updateInvoicingCatalogItemDetail, } from './editInvoicingCatalogItemDetailViewReducer';
|
|
5
5
|
import { entityToInvoicingCatalogItemFormLocalData } from './invoicingCatalogItemFormHelper';
|
|
6
6
|
/**
|
|
7
|
-
* Seeds the edit draft from the record the
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Seeds the edit draft from the record, so the form has its values before it
|
|
8
|
+
* mounts. The reducer ignores a seed once the draft holds the record, which is
|
|
9
|
+
* what stops a background refetch from overwriting edits in progress.
|
|
10
|
+
*
|
|
11
|
+
* Opening the page counts as a trigger, not just the detail response: the page
|
|
12
|
+
* fetch is cache-guarded, so re-opening a form for a record already loaded this
|
|
13
|
+
* session issues no request at all — and a draft cleared in between (by a save
|
|
14
|
+
* or a cancel) would have nothing left to seed it.
|
|
11
15
|
*/
|
|
12
|
-
export const seedInvoicingCatalogItemFormDraftEpic = (actions$, state$) => actions$.pipe(filter(updateInvoicingCatalogItemDetail.match
|
|
13
|
-
|
|
16
|
+
export const seedInvoicingCatalogItemFormDraftEpic = (actions$, state$) => actions$.pipe(filter((action) => updateInvoicingCatalogItemDetail.match(action) ||
|
|
17
|
+
fetchInvoicingCatalogItemDetailPage.match(action)), withLatestFrom(state$), mergeMap(([action, state]) => {
|
|
18
|
+
const id = action.payload.id;
|
|
19
|
+
if (id == null) {
|
|
20
|
+
return EMPTY;
|
|
21
|
+
}
|
|
22
|
+
// The entity alone does not say the whole record is loaded — the list
|
|
23
|
+
// endpoints merge their own list-shaped rows into the same store. Only a
|
|
24
|
+
// completed detail load does, which is also exactly when the page's
|
|
25
|
+
// cache-guarded fetch issues no request and this is the sole seed.
|
|
26
|
+
if (fetchInvoicingCatalogItemDetailPage.match(action) &&
|
|
27
|
+
state.editInvoicingCatalogItemDetailViewState.recordStateById[id]
|
|
28
|
+
?.fetchState !== 'Completed') {
|
|
29
|
+
return EMPTY;
|
|
30
|
+
}
|
|
31
|
+
// Nothing to seed from on a cold open; the detail response triggers this
|
|
32
|
+
// again once it lands.
|
|
14
33
|
const plan = getInvoicingPlanById(state.invoicingPlanState, id);
|
|
15
34
|
if (plan == null) {
|
|
16
35
|
return EMPTY;
|
package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createSlice } from '@reduxjs/toolkit';
|
|
2
2
|
import { clearAll } from '../../../rootActions';
|
|
3
|
+
import { applyInvoicingFormDraftEdit, applyInvoicingFormDraftFailure, applyInvoicingFormDraftSeed, } from '../invoicingFormDraft';
|
|
3
4
|
import { initialInvoicingCouponFormLocalData, } from './editInvoicingCouponDetailViewState';
|
|
4
5
|
export const initialState = {
|
|
5
6
|
fetchState: 'Not-Started',
|
|
@@ -20,7 +21,7 @@ const editInvoicingCouponDetailView = createSlice({
|
|
|
20
21
|
updateInvoicingCouponFormDraft(draft, action) {
|
|
21
22
|
const { id, localData } = action.payload;
|
|
22
23
|
if (id != null) {
|
|
23
|
-
draft.editDraftById
|
|
24
|
+
applyInvoicingFormDraftEdit(draft.editDraftById, id, localData);
|
|
24
25
|
}
|
|
25
26
|
else {
|
|
26
27
|
draft.newCouponDraft = localData;
|
|
@@ -85,15 +86,12 @@ const editInvoicingCouponDetailView = createSlice({
|
|
|
85
86
|
fetchState: 'Error',
|
|
86
87
|
error: action.payload.status,
|
|
87
88
|
};
|
|
89
|
+
applyInvoicingFormDraftFailure(draft.editDraftById, action.payload.id, initialInvoicingCouponFormLocalData);
|
|
88
90
|
},
|
|
89
|
-
/**
|
|
90
|
-
* Seed the draft from the loaded record, once. Skipped when a draft already
|
|
91
|
-
* exists so a late refetch cannot overwrite in-progress edits.
|
|
92
|
-
*/
|
|
91
|
+
/** Fill the draft from the loaded record — see `applyInvoicingFormDraftSeed`. */
|
|
93
92
|
seedInvoicingCouponFormDraft(draft, action) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
93
|
+
const { id, localData } = action.payload;
|
|
94
|
+
applyInvoicingFormDraftSeed(draft.editDraftById, id, localData);
|
|
97
95
|
},
|
|
98
96
|
runInvoicingDiscountAction(draft, action) {
|
|
99
97
|
draft.actionStateById[action.payload.id] = {
|
|
@@ -113,12 +111,22 @@ const editInvoicingCouponDetailView = createSlice({
|
|
|
113
111
|
error: action.payload.error,
|
|
114
112
|
};
|
|
115
113
|
},
|
|
116
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Discard a form's draft — the coupon's own when `id` is given,
|
|
116
|
+
* the create draft otherwise. Scoped to the one form on purpose: another
|
|
117
|
+
* coupon's half-finished edit is not this form's to throw away.
|
|
118
|
+
* Clearing every draft at once is what `clearAll` is for.
|
|
119
|
+
*/
|
|
120
|
+
resetEditInvoicingCouponDetailView(draft, action) {
|
|
117
121
|
draft.fetchState = 'Not-Started';
|
|
118
122
|
draft.error = undefined;
|
|
119
123
|
draft.savedCouponId = undefined;
|
|
120
|
-
|
|
121
|
-
|
|
124
|
+
const id = action.payload?.id;
|
|
125
|
+
if (id == null) {
|
|
126
|
+
draft.newCouponDraft = { ...initialInvoicingCouponFormLocalData };
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
delete draft.editDraftById[id];
|
|
122
130
|
},
|
|
123
131
|
},
|
|
124
132
|
extraReducers: (builder) => {
|
|
@@ -2,6 +2,7 @@ import { reduceAllFetchState } from '../../../commonStateTypes/reduceFetchState'
|
|
|
2
2
|
import { getInvoicingCouponById } from '../../../entity/invoicing/coupon/couponSelector';
|
|
3
3
|
import { toInvoicingFormOption, toInvoicingQboAccountMappingSlot, } from '../../../entity/invoicing/invoicingCommonPayload';
|
|
4
4
|
import { getInvoicingConfigView, invoicingFieldHelpForGroup, } from '../invoicingConfigView/invoicingConfigViewSelector';
|
|
5
|
+
import { getInvoicingFormDraftLocalData, isInvoicingFormDraftPending, } from '../invoicingFormDraft';
|
|
5
6
|
import { getInvoicingQboView, invoicingAccountsForQboAccountTypes, invoicingQboAccountByQboId, isInvoicingAccountingPickerDataLoading, isInvoicingQboConnected, } from '../invoicingQboView/invoicingQboViewSelector';
|
|
6
7
|
import { getInvoicingSettings, getInvoicingSettingsFetchState, } from '../settingsView/settingsViewSelector';
|
|
7
8
|
import { initialInvoicingCouponFormLocalData, invoicingCouponDiscountsAccountIdForCreate, } from './editInvoicingCouponDetailViewState';
|
|
@@ -41,6 +42,7 @@ export const getEditInvoicingCouponDetailViewState = (state, couponId) => {
|
|
|
41
42
|
{ error: undefined, fetchState: configFetchState },
|
|
42
43
|
]),
|
|
43
44
|
recordState,
|
|
45
|
+
isFormLoading: isInvoicingFormDraftPending(state.editInvoicingCouponDetailViewState.editDraftById, couponId),
|
|
44
46
|
coupon,
|
|
45
47
|
discountsAccountName: invoicingQboAccountByQboId(state, coupon?.discountsAccountId)?.accountName,
|
|
46
48
|
savedCouponId,
|
|
@@ -70,7 +72,7 @@ export const getInvoicingCouponFormView = (state, couponId) => {
|
|
|
70
72
|
// `seedInvoicingCouponFormDraftEpic` when the detail load lands. Until then
|
|
71
73
|
// the page is showing its skeleton.
|
|
72
74
|
const localData = couponId != null
|
|
73
|
-
? (editDraftById
|
|
75
|
+
? getInvoicingFormDraftLocalData(editDraftById, couponId, initialInvoicingCouponFormLocalData)
|
|
74
76
|
: newCouponDraft;
|
|
75
77
|
const { billingPeriodUnitOptions, discountApplyOnOptions, discountDurationTypeOptions, discountTypeOptions, qboAccountMappingKindOptions, } = getInvoicingConfigView(state);
|
|
76
78
|
const isQboConnected = isInvoicingQboConnected(state);
|
|
@@ -20,7 +20,7 @@ export const saveInvoicingCouponEpic = (actions$, state$, zeniAPI) => actions$.p
|
|
|
20
20
|
const state = state$.value;
|
|
21
21
|
const viewState = state.editInvoicingCouponDetailViewState;
|
|
22
22
|
const draft = (id != null
|
|
23
|
-
? viewState.editDraftById[id]
|
|
23
|
+
? viewState.editDraftById[id]?.localData
|
|
24
24
|
: viewState.newCouponDraft) ?? viewState.newCouponDraft;
|
|
25
25
|
// The create default is resolved here as well as in the form view,
|
|
26
26
|
// so a create that never touched the picker still persists the
|
package/lib/esm/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js
CHANGED
|
@@ -1,16 +1,35 @@
|
|
|
1
1
|
import { EMPTY, of } from 'rxjs';
|
|
2
2
|
import { filter, mergeMap, withLatestFrom } from 'rxjs/operators';
|
|
3
3
|
import { getInvoicingCouponById } from '../../../entity/invoicing/coupon/couponSelector';
|
|
4
|
-
import { seedInvoicingCouponFormDraft, updateInvoicingCouponDetail, } from './editInvoicingCouponDetailViewReducer';
|
|
4
|
+
import { fetchInvoicingCouponDetailPage, seedInvoicingCouponFormDraft, updateInvoicingCouponDetail, } from './editInvoicingCouponDetailViewReducer';
|
|
5
5
|
import { entityToInvoicingCouponFormLocalData } from './editInvoicingCouponDetailViewState';
|
|
6
6
|
/**
|
|
7
|
-
* Seeds the edit draft from the record the
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Seeds the edit draft from the record, so the form has its values before it
|
|
8
|
+
* mounts. The reducer ignores a seed once the draft holds the record, which is
|
|
9
|
+
* what stops a background refetch from overwriting edits in progress.
|
|
10
|
+
*
|
|
11
|
+
* Opening the page counts as a trigger, not just the detail response: the page
|
|
12
|
+
* fetch is cache-guarded, so re-opening a form for a record already loaded this
|
|
13
|
+
* session issues no request at all — and a draft cleared in between (by a save
|
|
14
|
+
* or a cancel) would have nothing left to seed it.
|
|
11
15
|
*/
|
|
12
|
-
export const seedInvoicingCouponFormDraftEpic = (actions$, state$) => actions$.pipe(filter(updateInvoicingCouponDetail.match
|
|
16
|
+
export const seedInvoicingCouponFormDraftEpic = (actions$, state$) => actions$.pipe(filter((action) => updateInvoicingCouponDetail.match(action) ||
|
|
17
|
+
fetchInvoicingCouponDetailPage.match(action)), withLatestFrom(state$), mergeMap(([action, state]) => {
|
|
13
18
|
const { id } = action.payload;
|
|
19
|
+
if (id == null) {
|
|
20
|
+
return EMPTY;
|
|
21
|
+
}
|
|
22
|
+
// The entity alone does not say the whole record is loaded — the list
|
|
23
|
+
// endpoints merge their own list-shaped rows into the same store. Only a
|
|
24
|
+
// completed detail load does, which is also exactly when the page's
|
|
25
|
+
// cache-guarded fetch issues no request and this is the sole seed.
|
|
26
|
+
if (fetchInvoicingCouponDetailPage.match(action) &&
|
|
27
|
+
state.editInvoicingCouponDetailViewState.recordStateById[id]
|
|
28
|
+
?.fetchState !== 'Completed') {
|
|
29
|
+
return EMPTY;
|
|
30
|
+
}
|
|
31
|
+
// Nothing to seed from on a cold open; the detail response triggers this
|
|
32
|
+
// again once it lands.
|
|
14
33
|
const coupon = getInvoicingCouponById(state.invoicingCouponState, id);
|
|
15
34
|
if (coupon == null) {
|
|
16
35
|
return EMPTY;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createSlice } from '@reduxjs/toolkit';
|
|
2
2
|
import { clearAll } from '../../../rootActions';
|
|
3
|
+
import { applyInvoicingFormDraftEdit, applyInvoicingFormDraftFailure, applyInvoicingFormDraftSeed, } from '../invoicingFormDraft';
|
|
3
4
|
import { initialInvoicingCustomerFormLocalData } from './invoicingCustomerFormConfig';
|
|
4
5
|
export const initialState = {
|
|
5
6
|
emailPreviewFetchState: { fetchState: 'Not-Started', error: undefined },
|
|
@@ -123,20 +124,17 @@ const editInvoicingCustomerDetailView = createSlice({
|
|
|
123
124
|
fetchState: 'Error',
|
|
124
125
|
error: action.payload.status,
|
|
125
126
|
};
|
|
127
|
+
applyInvoicingFormDraftFailure(draft.editDraftById, action.payload.id, initialInvoicingCustomerFormLocalData);
|
|
126
128
|
},
|
|
127
|
-
/**
|
|
128
|
-
* Seed the draft from the loaded record, once. Skipped when a draft already
|
|
129
|
-
* exists so a late refetch cannot overwrite in-progress edits.
|
|
130
|
-
*/
|
|
129
|
+
/** Fill the draft from the loaded record — see `applyInvoicingFormDraftSeed`. */
|
|
131
130
|
seedInvoicingCustomerFormDraft(draft, action) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
131
|
+
const { id, localData } = action.payload;
|
|
132
|
+
applyInvoicingFormDraftSeed(draft.editDraftById, id, localData);
|
|
135
133
|
},
|
|
136
134
|
updateInvoicingCustomerFormDraft(draft, action) {
|
|
137
135
|
const { id, localData } = action.payload;
|
|
138
136
|
if (id != null) {
|
|
139
|
-
draft.editDraftById
|
|
137
|
+
applyInvoicingFormDraftEdit(draft.editDraftById, id, localData);
|
|
140
138
|
}
|
|
141
139
|
else {
|
|
142
140
|
draft.newCustomerDraft = localData;
|
|
@@ -161,12 +159,22 @@ const editInvoicingCustomerDetailView = createSlice({
|
|
|
161
159
|
draft.fetchState = 'Error';
|
|
162
160
|
draft.error = action.payload;
|
|
163
161
|
},
|
|
164
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Discard a form's draft — the customer's own when `id` is given,
|
|
164
|
+
* the create draft otherwise. Scoped to the one form on purpose: another
|
|
165
|
+
* customer's half-finished edit is not this form's to throw away.
|
|
166
|
+
* Clearing every draft at once is what `clearAll` is for.
|
|
167
|
+
*/
|
|
168
|
+
resetEditInvoicingCustomerDetailView(draft, action) {
|
|
165
169
|
draft.fetchState = 'Not-Started';
|
|
166
170
|
draft.error = undefined;
|
|
167
171
|
draft.savedCustomerId = undefined;
|
|
168
|
-
|
|
169
|
-
|
|
172
|
+
const id = action.payload?.id;
|
|
173
|
+
if (id == null) {
|
|
174
|
+
draft.newCustomerDraft = { ...initialInvoicingCustomerFormLocalData };
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
delete draft.editDraftById[id];
|
|
170
178
|
},
|
|
171
179
|
// Trigger only — handled by initializeInvoicingCustomerAddressEpic.
|
|
172
180
|
initializeInvoicingCustomerAddress: {
|