@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.
- 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 -34
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.js +1 -12
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +15 -4
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +1 -60
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +10 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +12 -20
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +28 -11
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +45 -21
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.js +4 -1
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +19 -3
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +16 -3
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +6 -2
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +4 -1
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +21 -21
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js +6 -2
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +10 -2
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +33 -0
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/initializeInvoicingCustomerAddressEpic.js +43 -17
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.js +6 -2
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.js +10 -2
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +34 -0
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddressEpic.js +44 -18
- package/lib/esm/view/invoicing/invoicingFormDraft.js +13 -0
- package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +57 -9
- 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 -34
- 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/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +15 -4
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +0 -18
- package/lib/view/expenseAutomationView/payload/transactionCategorizationPayload.d.ts +18 -7
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +2 -8
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +3 -62
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +10 -0
- package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +0 -2
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +8 -4
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +12 -20
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +27 -10
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +0 -15
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +8 -5
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.d.ts +22 -6
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +47 -22
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.js +3 -0
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.d.ts +7 -0
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +18 -2
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +14 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +6 -2
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +3 -0
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.d.ts +3 -2
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +19 -19
- package/lib/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js +6 -2
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +10 -2
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.d.ts +7 -7
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +33 -0
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewState.d.ts +6 -0
- package/lib/view/invoicing/editInvoicingCustomerDetailView/initializeInvoicingCustomerAddressEpic.d.ts +15 -10
- package/lib/view/invoicing/editInvoicingCustomerDetailView/initializeInvoicingCustomerAddressEpic.js +42 -16
- package/lib/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.js +6 -2
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.js +10 -2
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.d.ts +7 -0
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +34 -0
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewState.d.ts +6 -0
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddressEpic.d.ts +15 -11
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddressEpic.js +42 -16
- package/lib/view/invoicing/invoicingFormDraft.d.ts +10 -1
- package/lib/view/invoicing/invoicingFormDraft.js +14 -0
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.d.ts +49 -0
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +59 -10
- 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/view/invoicing/editInvoicingCustomerDetailView/initializeInvoicingCustomerAddressEpic.js
CHANGED
|
@@ -6,34 +6,60 @@ const operators_1 = require("rxjs/operators");
|
|
|
6
6
|
const addressSelector_1 = require("../../../entity/address/addressSelector");
|
|
7
7
|
const invoicingCustomerSelector_1 = require("../../../entity/invoicing/invoicingCustomer/invoicingCustomerSelector");
|
|
8
8
|
const addressViewReducer_1 = require("../../addressView/addressViewReducer");
|
|
9
|
-
const editInvoicingCustomerDetailViewReducer_1 = require("
|
|
10
|
-
const editInvoicingCustomerDetailViewReducer_2 = require("./editInvoicingCustomerDetailViewReducer");
|
|
9
|
+
const editInvoicingCustomerDetailViewReducer_1 = require("./editInvoicingCustomerDetailViewReducer");
|
|
11
10
|
const invoicingCustomerFormConfig_1 = require("./invoicingCustomerFormConfig");
|
|
12
11
|
/**
|
|
13
|
-
* Seed the shared Address screen with
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
12
|
+
* Seed the shared Address screen with the customer's saved billing address, and
|
|
13
|
+
* record that the slot is this customer's. Runs when a detail request is issued
|
|
14
|
+
* (every path that loads a record issues one — the detail page when not cached,
|
|
15
|
+
* the create/edit form always), when the page opens, when the detail load
|
|
16
|
+
* lands, and on an explicit initialize trigger.
|
|
17
|
+
*
|
|
18
|
+
* The address store slot is keyed by address type alone, so it can still hold
|
|
19
|
+
* another customer's draft. Only a draft this customer owns is left alone —
|
|
20
|
+
* that is what lets an address the user just entered survive a trip to the
|
|
21
|
+
* Address screen. Anything else is replaced by this customer's saved address,
|
|
22
|
+
* or cleared when it has none. Opening the page counts as a trigger because a
|
|
23
|
+
* record already loaded this session issues no detail request at all.
|
|
19
24
|
*/
|
|
20
|
-
const initializeInvoicingCustomerAddressEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)((action) =>
|
|
21
|
-
editInvoicingCustomerDetailViewReducer_1.updateInvoicingCustomerDetail.match(action)
|
|
25
|
+
const initializeInvoicingCustomerAddressEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)((action) => editInvoicingCustomerDetailViewReducer_1.initializeInvoicingCustomerAddress.match(action) ||
|
|
26
|
+
editInvoicingCustomerDetailViewReducer_1.updateInvoicingCustomerDetail.match(action) ||
|
|
27
|
+
editInvoicingCustomerDetailViewReducer_1.fetchInvoicingCustomerDetailPage.match(action) ||
|
|
28
|
+
editInvoicingCustomerDetailViewReducer_1.fetchInvoicingCustomerDetail.match(action)), (0, operators_1.mergeMap)((action) => {
|
|
22
29
|
const { id } = action.payload;
|
|
30
|
+
if (id == null) {
|
|
31
|
+
return rxjs_1.EMPTY;
|
|
32
|
+
}
|
|
23
33
|
const rootState = state$.value;
|
|
24
|
-
const
|
|
25
|
-
|
|
34
|
+
const pending = rootState.addressViewState.newAddressState?.[invoicingCustomerFormConfig_1.INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE]?.addressToCreate;
|
|
35
|
+
const ownerId = rootState.editInvoicingCustomerDetailViewState.billingAddressOwnerId;
|
|
36
|
+
// A detail response speaks for the record it loaded, which may no longer
|
|
37
|
+
// be the one on screen: its request keeps running when the user moves on
|
|
38
|
+
// to a cached record, which issues no request of its own to cancel it.
|
|
39
|
+
// Only the page-open and explicit triggers define the current record.
|
|
40
|
+
if (editInvoicingCustomerDetailViewReducer_1.updateInvoicingCustomerDetail.match(action) &&
|
|
41
|
+
ownerId != null &&
|
|
42
|
+
ownerId !== id) {
|
|
43
|
+
return rxjs_1.EMPTY;
|
|
44
|
+
}
|
|
45
|
+
if (pending != null && ownerId === id) {
|
|
26
46
|
return rxjs_1.EMPTY;
|
|
27
47
|
}
|
|
28
48
|
const customer = (0, invoicingCustomerSelector_1.getInvoicingCustomerById)(rootState.invoicingCustomerState, id);
|
|
29
49
|
const address = customer?.billingAddressId != null
|
|
30
50
|
? (0, addressSelector_1.getAddressByAddressId)(rootState.addressState, customer.billingAddressId)
|
|
31
51
|
: undefined;
|
|
32
|
-
|
|
33
|
-
|
|
52
|
+
const actions = [];
|
|
53
|
+
if (address != null) {
|
|
54
|
+
actions.push((0, addressViewReducer_1.newAddressInLocalStore)({
|
|
34
55
|
addressType: invoicingCustomerFormConfig_1.INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE,
|
|
35
56
|
addressToCreate: address,
|
|
36
|
-
}))
|
|
37
|
-
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
else if (pending != null) {
|
|
60
|
+
actions.push((0, addressViewReducer_1.removeNewAddressDataInLocalStore)(invoicingCustomerFormConfig_1.INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE));
|
|
61
|
+
}
|
|
62
|
+
actions.push((0, editInvoicingCustomerDetailViewReducer_1.claimInvoicingCustomerBillingAddress)({ id }));
|
|
63
|
+
return (0, rxjs_1.from)(actions);
|
|
38
64
|
}));
|
|
39
65
|
exports.initializeInvoicingCustomerAddressEpic = initializeInvoicingCustomerAddressEpic;
|
package/lib/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.js
CHANGED
|
@@ -26,9 +26,13 @@ const seedInvoicingCustomerFormDraftEpic = (actions$, state$) => actions$.pipe((
|
|
|
26
26
|
// endpoints merge their own list-shaped rows into the same store. Only a
|
|
27
27
|
// completed detail load does, which is also exactly when the page's
|
|
28
28
|
// cache-guarded fetch issues no request and this is the sole seed.
|
|
29
|
+
// A forced refetch is the caller asking for fresh data: the response will
|
|
30
|
+
// seed, and seeding first from the entity as it stands would mark the
|
|
31
|
+
// draft loaded and lock that response out.
|
|
29
32
|
if (editInvoicingCustomerDetailViewReducer_1.fetchInvoicingCustomerDetailPage.match(action) &&
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
(action.payload.cacheOverride === true ||
|
|
34
|
+
state.editInvoicingCustomerDetailViewState.recordStateById[id]
|
|
35
|
+
?.fetchState !== 'Completed')) {
|
|
32
36
|
return rxjs_1.EMPTY;
|
|
33
37
|
}
|
|
34
38
|
// Nothing to seed from on a cold open; the detail response triggers this
|
|
@@ -57,6 +57,8 @@ export declare const runInvoicingSubscriptionAction: import("@reduxjs/toolkit").
|
|
|
57
57
|
subscriptionId: ID;
|
|
58
58
|
}, "editInvoicingSubscriptionDetailView/submitInvoicingSubscriptionFormSuccess">, submitInvoicingSubscriptionFormFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "editInvoicingSubscriptionDetailView/submitInvoicingSubscriptionFormFailure">, resetEditInvoicingSubscriptionDetailView: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<{
|
|
59
59
|
id?: ID;
|
|
60
|
-
} | undefined, "editInvoicingSubscriptionDetailView/resetEditInvoicingSubscriptionDetailView">, initializeInvoicingSubscriptionAddress: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: InitializeInvoicingSubscriptionAddressPayload], InitializeInvoicingSubscriptionAddressPayload, "editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddress", never, never>,
|
|
60
|
+
} | undefined, "editInvoicingSubscriptionDetailView/resetEditInvoicingSubscriptionDetailView">, initializeInvoicingSubscriptionAddress: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: InitializeInvoicingSubscriptionAddressPayload], InitializeInvoicingSubscriptionAddressPayload, "editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddress", never, never>, claimInvoicingSubscriptionShippingAddress: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
61
|
+
id: ID;
|
|
62
|
+
}, "editInvoicingSubscriptionDetailView/claimInvoicingSubscriptionShippingAddress">, syncInvoicingSubscriptionCoupons: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: SyncInvoicingSubscriptionCouponsPayload], SyncInvoicingSubscriptionCouponsPayload, "editInvoicingSubscriptionDetailView/syncInvoicingSubscriptionCoupons", never, never>;
|
|
61
63
|
declare const _default: import("redux").Reducer<EditInvoicingSubscriptionDetailViewState>;
|
|
62
64
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.syncInvoicingSubscriptionCoupons = exports.initializeInvoicingSubscriptionAddress = exports.resetEditInvoicingSubscriptionDetailView = exports.submitInvoicingSubscriptionFormFailure = exports.submitInvoicingSubscriptionFormSuccess = exports.submitInvoicingSubscriptionForm = exports.updateInvoicingSubscriptionFormDraft = exports.updateInvoicingSubscriptionDetailFailure = exports.updateInvoicingSubscriptionDetail = exports.seedInvoicingSubscriptionFormDraft = exports.fetchInvoicingSubscriptionFormPage = exports.fetchInvoicingSubscriptionDetailPage = exports.fetchInvoicingSubscriptionDetail = exports.runInvoicingSubscriptionActionSuccess = exports.runInvoicingSubscriptionActionFailure = exports.runInvoicingSubscriptionAction = exports.initialState = void 0;
|
|
4
|
+
exports.syncInvoicingSubscriptionCoupons = exports.claimInvoicingSubscriptionShippingAddress = exports.initializeInvoicingSubscriptionAddress = exports.resetEditInvoicingSubscriptionDetailView = exports.submitInvoicingSubscriptionFormFailure = exports.submitInvoicingSubscriptionFormSuccess = exports.submitInvoicingSubscriptionForm = exports.updateInvoicingSubscriptionFormDraft = exports.updateInvoicingSubscriptionDetailFailure = exports.updateInvoicingSubscriptionDetail = exports.seedInvoicingSubscriptionFormDraft = exports.fetchInvoicingSubscriptionFormPage = exports.fetchInvoicingSubscriptionDetailPage = exports.fetchInvoicingSubscriptionDetail = exports.runInvoicingSubscriptionActionSuccess = exports.runInvoicingSubscriptionActionFailure = exports.runInvoicingSubscriptionAction = exports.initialState = void 0;
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
6
|
const rootActions_1 = require("../../../rootActions");
|
|
7
7
|
const invoicingFormDraft_1 = require("../invoicingFormDraft");
|
|
@@ -12,6 +12,7 @@ exports.initialState = {
|
|
|
12
12
|
editDraftById: {},
|
|
13
13
|
actionStateById: {},
|
|
14
14
|
recordStateById: {},
|
|
15
|
+
shippingAddressOwnerId: undefined,
|
|
15
16
|
newSubscriptionDraft: { ...invoicingSubscriptionFormConfig_1.initialInvoicingSubscriptionFormLocalData },
|
|
16
17
|
savedSubscriptionId: undefined,
|
|
17
18
|
hasValidState() {
|
|
@@ -109,6 +110,9 @@ const editInvoicingSubscriptionDetailView = (0, toolkit_1.createSlice)({
|
|
|
109
110
|
draft.fetchState = 'Completed';
|
|
110
111
|
draft.error = undefined;
|
|
111
112
|
draft.savedSubscriptionId = action.payload.subscriptionId;
|
|
113
|
+
// An edit is refetched on success; keep the saved values on screen until
|
|
114
|
+
// that lands, and let it replace them.
|
|
115
|
+
(0, invoicingFormDraft_1.applyInvoicingFormDraftSaved)(draft.editDraftById, action.payload.subscriptionId);
|
|
112
116
|
},
|
|
113
117
|
submitInvoicingSubscriptionFormFailure(draft, action) {
|
|
114
118
|
draft.fetchState = 'Error';
|
|
@@ -140,6 +144,10 @@ const editInvoicingSubscriptionDetailView = (0, toolkit_1.createSlice)({
|
|
|
140
144
|
return { payload };
|
|
141
145
|
},
|
|
142
146
|
},
|
|
147
|
+
/** Record which subscription the shared shipping-address slot now belongs to. */
|
|
148
|
+
claimInvoicingSubscriptionShippingAddress(draft, action) {
|
|
149
|
+
draft.shippingAddressOwnerId = action.payload.id;
|
|
150
|
+
},
|
|
143
151
|
// Trigger only — handled by syncInvoicingSubscriptionCouponsEpic.
|
|
144
152
|
syncInvoicingSubscriptionCoupons: {
|
|
145
153
|
reducer() { },
|
|
@@ -154,5 +162,5 @@ const editInvoicingSubscriptionDetailView = (0, toolkit_1.createSlice)({
|
|
|
154
162
|
});
|
|
155
163
|
},
|
|
156
164
|
});
|
|
157
|
-
_a = editInvoicingSubscriptionDetailView.actions, exports.runInvoicingSubscriptionAction = _a.runInvoicingSubscriptionAction, exports.runInvoicingSubscriptionActionFailure = _a.runInvoicingSubscriptionActionFailure, exports.runInvoicingSubscriptionActionSuccess = _a.runInvoicingSubscriptionActionSuccess, exports.fetchInvoicingSubscriptionDetail = _a.fetchInvoicingSubscriptionDetail, exports.fetchInvoicingSubscriptionDetailPage = _a.fetchInvoicingSubscriptionDetailPage, exports.fetchInvoicingSubscriptionFormPage = _a.fetchInvoicingSubscriptionFormPage, exports.seedInvoicingSubscriptionFormDraft = _a.seedInvoicingSubscriptionFormDraft, exports.updateInvoicingSubscriptionDetail = _a.updateInvoicingSubscriptionDetail, exports.updateInvoicingSubscriptionDetailFailure = _a.updateInvoicingSubscriptionDetailFailure, exports.updateInvoicingSubscriptionFormDraft = _a.updateInvoicingSubscriptionFormDraft, exports.submitInvoicingSubscriptionForm = _a.submitInvoicingSubscriptionForm, exports.submitInvoicingSubscriptionFormSuccess = _a.submitInvoicingSubscriptionFormSuccess, exports.submitInvoicingSubscriptionFormFailure = _a.submitInvoicingSubscriptionFormFailure, exports.resetEditInvoicingSubscriptionDetailView = _a.resetEditInvoicingSubscriptionDetailView, exports.initializeInvoicingSubscriptionAddress = _a.initializeInvoicingSubscriptionAddress, exports.syncInvoicingSubscriptionCoupons = _a.syncInvoicingSubscriptionCoupons;
|
|
165
|
+
_a = editInvoicingSubscriptionDetailView.actions, exports.runInvoicingSubscriptionAction = _a.runInvoicingSubscriptionAction, exports.runInvoicingSubscriptionActionFailure = _a.runInvoicingSubscriptionActionFailure, exports.runInvoicingSubscriptionActionSuccess = _a.runInvoicingSubscriptionActionSuccess, exports.fetchInvoicingSubscriptionDetail = _a.fetchInvoicingSubscriptionDetail, exports.fetchInvoicingSubscriptionDetailPage = _a.fetchInvoicingSubscriptionDetailPage, exports.fetchInvoicingSubscriptionFormPage = _a.fetchInvoicingSubscriptionFormPage, exports.seedInvoicingSubscriptionFormDraft = _a.seedInvoicingSubscriptionFormDraft, exports.updateInvoicingSubscriptionDetail = _a.updateInvoicingSubscriptionDetail, exports.updateInvoicingSubscriptionDetailFailure = _a.updateInvoicingSubscriptionDetailFailure, exports.updateInvoicingSubscriptionFormDraft = _a.updateInvoicingSubscriptionFormDraft, exports.submitInvoicingSubscriptionForm = _a.submitInvoicingSubscriptionForm, exports.submitInvoicingSubscriptionFormSuccess = _a.submitInvoicingSubscriptionFormSuccess, exports.submitInvoicingSubscriptionFormFailure = _a.submitInvoicingSubscriptionFormFailure, exports.resetEditInvoicingSubscriptionDetailView = _a.resetEditInvoicingSubscriptionDetailView, exports.initializeInvoicingSubscriptionAddress = _a.initializeInvoicingSubscriptionAddress, exports.claimInvoicingSubscriptionShippingAddress = _a.claimInvoicingSubscriptionShippingAddress, exports.syncInvoicingSubscriptionCoupons = _a.syncInvoicingSubscriptionCoupons;
|
|
158
166
|
exports.default = editInvoicingSubscriptionDetailView.reducer;
|
|
@@ -70,6 +70,13 @@ export interface InvoicingSubscriptionFormView extends SelectorView {
|
|
|
70
70
|
subscriptionCommercialEditAllowedFromStatuses: string[];
|
|
71
71
|
subscriptionLifecycleActionOptions: InvoicingSubscriptionLifecycleActionOption[];
|
|
72
72
|
subscriptionMetadataEditAllowedFromStatuses: string[];
|
|
73
|
+
/**
|
|
74
|
+
* A shipping address entered on the Address screen that the subscription has
|
|
75
|
+
* not saved yet. The inline-edit form cannot see it — the address lives in the
|
|
76
|
+
* shared address store, not in a field — so the detail page reads this to
|
|
77
|
+
* offer Save, or the address could never be linked.
|
|
78
|
+
*/
|
|
79
|
+
hasUnsavedShippingAddress?: boolean;
|
|
73
80
|
savedSubscriptionId?: ID;
|
|
74
81
|
shippingAddressLabel?: string;
|
|
75
82
|
subscription?: InvoicingSubscription;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getInvoicingSubscriptionFormView = exports.getEditInvoicingSubscriptionDetailViewState = void 0;
|
|
4
4
|
const reduceFetchState_1 = require("../../../commonStateTypes/reduceFetchState");
|
|
5
|
+
const addressSelector_1 = require("../../../entity/address/addressSelector");
|
|
5
6
|
const invoicingSubscriptionSelector_1 = require("../../../entity/invoicing/invoicingSubscription/invoicingSubscriptionSelector");
|
|
6
7
|
const addressViewSelector_1 = require("../../addressView/addressViewSelector");
|
|
7
8
|
const couponViewSelector_1 = require("../couponView/couponViewSelector");
|
|
@@ -28,6 +29,37 @@ const getEditInvoicingSubscriptionDetailViewState = (state, invoicingSubscriptio
|
|
|
28
29
|
};
|
|
29
30
|
};
|
|
30
31
|
exports.getEditInvoicingSubscriptionDetailViewState = getEditInvoicingSubscriptionDetailViewState;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the shipping address entered on the Address screen is a change the
|
|
34
|
+
* subscription has not saved. Presence alone cannot say so: the detail page seeds
|
|
35
|
+
* the address store with the saved address on load so the Address screen opens
|
|
36
|
+
* prefilled. Only a pending address that differs from the saved one — or one
|
|
37
|
+
* where nothing is saved yet — is an unsaved change. Compared on what the user
|
|
38
|
+
* enters; a saved address's coordinates and timestamps are left out.
|
|
39
|
+
*/
|
|
40
|
+
const isShippingAddressUnsaved = (state, id, savedShippingAddressId) => {
|
|
41
|
+
// The slot is keyed by address type alone; only a draft this subscription owns counts.
|
|
42
|
+
if (id == null ||
|
|
43
|
+
state.editInvoicingSubscriptionDetailViewState.shippingAddressOwnerId !== id) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
const pending = state.addressViewState.newAddressState?.[invoicingSubscriptionFormConfig_2.INVOICING_SUBSCRIPTION_SHIPPING_ADDRESS_TYPE]?.addressToCreate;
|
|
47
|
+
if (pending == null) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
const saved = savedShippingAddressId != null
|
|
51
|
+
? (0, addressSelector_1.getAddressByAddressId)(state.addressState, savedShippingAddressId)
|
|
52
|
+
: undefined;
|
|
53
|
+
if (saved == null) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
return !(pending.street.join('\u0000') === saved.street.join('\u0000') &&
|
|
57
|
+
pending.city === saved.city &&
|
|
58
|
+
pending.state === saved.state &&
|
|
59
|
+
pending.postalCode === saved.postalCode &&
|
|
60
|
+
pending.country === saved.country &&
|
|
61
|
+
(pending.countryCode ?? '') === (saved.countryCode ?? ''));
|
|
62
|
+
};
|
|
31
63
|
const getInvoicingSubscriptionFormView = (state, invoicingSubscriptionID) => {
|
|
32
64
|
const { editDraftById, error, fetchState, newSubscriptionDraft, savedSubscriptionId, } = state.editInvoicingSubscriptionDetailViewState;
|
|
33
65
|
const mode = invoicingSubscriptionID != null ? 'edit' : 'create';
|
|
@@ -47,6 +79,7 @@ const getInvoicingSubscriptionFormView = (state, invoicingSubscriptionID) => {
|
|
|
47
79
|
const shippingAddressLabel = newAddress?.addressToCreate != null
|
|
48
80
|
? (0, addressViewSelector_1.getFormattedAddress)(newAddress.addressToCreate)
|
|
49
81
|
: undefined;
|
|
82
|
+
const hasUnsavedShippingAddress = isShippingAddressUnsaved(state, invoicingSubscriptionID, subscription?.shippingAddressId);
|
|
50
83
|
const catalogListView = (0, invoicingCatalogListViewSelector_1.getInvoicingCatalogListView)(state);
|
|
51
84
|
const planPrices = (0, invoicingCatalogListViewSelector_1.getInvoicingCatalogPrices)(catalogListView.plans);
|
|
52
85
|
const addonAndChargePrices = (0, invoicingCatalogListViewSelector_1.getInvoicingCatalogPrices)(catalogListView.products);
|
|
@@ -79,6 +112,7 @@ const getInvoicingSubscriptionFormView = (state, invoicingSubscriptionID) => {
|
|
|
79
112
|
products: addonAndChargePrices,
|
|
80
113
|
savedSubscriptionId,
|
|
81
114
|
shippingAddressLabel,
|
|
115
|
+
hasUnsavedShippingAddress,
|
|
82
116
|
subscription,
|
|
83
117
|
fetchState,
|
|
84
118
|
error,
|
|
@@ -47,4 +47,10 @@ export interface EditInvoicingSubscriptionDetailViewState extends FetchedState {
|
|
|
47
47
|
/** Detail-load state per subscription id. */
|
|
48
48
|
recordStateById: Record<ID, FetchStateAndError>;
|
|
49
49
|
savedSubscriptionId?: ID;
|
|
50
|
+
/**
|
|
51
|
+
* The subscription whose shipping address currently occupies the shared address
|
|
52
|
+
* store slot. That slot is keyed by address type alone, so without this a
|
|
53
|
+
* draft seeded or edited for one subscription would pass for the next one's.
|
|
54
|
+
*/
|
|
55
|
+
shippingAddressOwnerId?: ID;
|
|
50
56
|
}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { RootState } from '../../../rootStateTypes';
|
|
4
|
-
import { newAddressInLocalStore } from '../../addressView/addressViewReducer';
|
|
5
|
-
import { updateInvoicingSubscriptionDetail } from './editInvoicingSubscriptionDetailViewReducer';
|
|
6
|
-
|
|
7
|
-
export type ActionType = ReturnType<typeof initializeInvoicingSubscriptionAddress> | ReturnType<typeof updateInvoicingSubscriptionDetail> | ReturnType<typeof newAddressInLocalStore>;
|
|
4
|
+
import { newAddressInLocalStore, removeNewAddressDataInLocalStore } from '../../addressView/addressViewReducer';
|
|
5
|
+
import { claimInvoicingSubscriptionShippingAddress, fetchInvoicingSubscriptionDetail, fetchInvoicingSubscriptionDetailPage, initializeInvoicingSubscriptionAddress, updateInvoicingSubscriptionDetail } from './editInvoicingSubscriptionDetailViewReducer';
|
|
6
|
+
export type ActionType = ReturnType<typeof initializeInvoicingSubscriptionAddress> | ReturnType<typeof updateInvoicingSubscriptionDetail> | ReturnType<typeof fetchInvoicingSubscriptionDetailPage> | ReturnType<typeof fetchInvoicingSubscriptionDetail> | ReturnType<typeof claimInvoicingSubscriptionShippingAddress> | ReturnType<typeof newAddressInLocalStore> | ReturnType<typeof removeNewAddressDataInLocalStore>;
|
|
8
7
|
/**
|
|
9
|
-
* Seed the shared Address screen with
|
|
10
|
-
*
|
|
11
|
-
* the
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
8
|
+
* Seed the shared Address screen with the subscription's saved shipping address, and
|
|
9
|
+
* record that the slot is this subscription's. Runs when a detail request is issued
|
|
10
|
+
* (every path that loads a record issues one — the detail page when not cached,
|
|
11
|
+
* the create/edit form always), when the page opens, when the detail load
|
|
12
|
+
* lands, and on an explicit initialize trigger.
|
|
13
|
+
*
|
|
14
|
+
* The address store slot is keyed by address type alone, so it can still hold
|
|
15
|
+
* another subscription's draft. Only a draft this subscription owns is left alone —
|
|
16
|
+
* that is what lets an address the user just entered survive a trip to the
|
|
17
|
+
* Address screen. Anything else is replaced by this subscription's saved address,
|
|
18
|
+
* or cleared when it has none. Opening the page counts as a trigger because a
|
|
19
|
+
* record already loaded this session issues no detail request at all.
|
|
16
20
|
*/
|
|
17
21
|
export declare const initializeInvoicingSubscriptionAddressEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
|
|
@@ -7,34 +7,60 @@ const addressSelector_1 = require("../../../entity/address/addressSelector");
|
|
|
7
7
|
const invoicingSubscriptionSelector_1 = require("../../../entity/invoicing/invoicingSubscription/invoicingSubscriptionSelector");
|
|
8
8
|
const addressViewReducer_1 = require("../../addressView/addressViewReducer");
|
|
9
9
|
const editInvoicingSubscriptionDetailViewReducer_1 = require("./editInvoicingSubscriptionDetailViewReducer");
|
|
10
|
-
const editInvoicingSubscriptionDetailViewReducer_2 = require("./editInvoicingSubscriptionDetailViewReducer");
|
|
11
10
|
const invoicingSubscriptionFormConfig_1 = require("./invoicingSubscriptionFormConfig");
|
|
12
11
|
/**
|
|
13
|
-
* Seed the shared Address screen with
|
|
14
|
-
*
|
|
15
|
-
* the
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
12
|
+
* Seed the shared Address screen with the subscription's saved shipping address, and
|
|
13
|
+
* record that the slot is this subscription's. Runs when a detail request is issued
|
|
14
|
+
* (every path that loads a record issues one — the detail page when not cached,
|
|
15
|
+
* the create/edit form always), when the page opens, when the detail load
|
|
16
|
+
* lands, and on an explicit initialize trigger.
|
|
17
|
+
*
|
|
18
|
+
* The address store slot is keyed by address type alone, so it can still hold
|
|
19
|
+
* another subscription's draft. Only a draft this subscription owns is left alone —
|
|
20
|
+
* that is what lets an address the user just entered survive a trip to the
|
|
21
|
+
* Address screen. Anything else is replaced by this subscription's saved address,
|
|
22
|
+
* or cleared when it has none. Opening the page counts as a trigger because a
|
|
23
|
+
* record already loaded this session issues no detail request at all.
|
|
20
24
|
*/
|
|
21
|
-
const initializeInvoicingSubscriptionAddressEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)((action) =>
|
|
22
|
-
editInvoicingSubscriptionDetailViewReducer_1.updateInvoicingSubscriptionDetail.match(action)
|
|
25
|
+
const initializeInvoicingSubscriptionAddressEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)((action) => editInvoicingSubscriptionDetailViewReducer_1.initializeInvoicingSubscriptionAddress.match(action) ||
|
|
26
|
+
editInvoicingSubscriptionDetailViewReducer_1.updateInvoicingSubscriptionDetail.match(action) ||
|
|
27
|
+
editInvoicingSubscriptionDetailViewReducer_1.fetchInvoicingSubscriptionDetailPage.match(action) ||
|
|
28
|
+
editInvoicingSubscriptionDetailViewReducer_1.fetchInvoicingSubscriptionDetail.match(action)), (0, operators_1.mergeMap)((action) => {
|
|
23
29
|
const { id } = action.payload;
|
|
30
|
+
if (id == null) {
|
|
31
|
+
return rxjs_1.EMPTY;
|
|
32
|
+
}
|
|
24
33
|
const rootState = state$.value;
|
|
25
|
-
const
|
|
26
|
-
|
|
34
|
+
const pending = rootState.addressViewState.newAddressState?.[invoicingSubscriptionFormConfig_1.INVOICING_SUBSCRIPTION_SHIPPING_ADDRESS_TYPE]?.addressToCreate;
|
|
35
|
+
const ownerId = rootState.editInvoicingSubscriptionDetailViewState
|
|
36
|
+
.shippingAddressOwnerId;
|
|
37
|
+
// A detail response speaks for the record it loaded, which may no longer
|
|
38
|
+
// be the one on screen: its request keeps running when the user moves on
|
|
39
|
+
// to a cached record, which issues no request of its own to cancel it.
|
|
40
|
+
// Only the page-open and explicit triggers define the current record.
|
|
41
|
+
if (editInvoicingSubscriptionDetailViewReducer_1.updateInvoicingSubscriptionDetail.match(action) &&
|
|
42
|
+
ownerId != null &&
|
|
43
|
+
ownerId !== id) {
|
|
44
|
+
return rxjs_1.EMPTY;
|
|
45
|
+
}
|
|
46
|
+
if (pending != null && ownerId === id) {
|
|
27
47
|
return rxjs_1.EMPTY;
|
|
28
48
|
}
|
|
29
49
|
const subscription = (0, invoicingSubscriptionSelector_1.getInvoicingSubscriptionById)(rootState.invoicingSubscriptionState, id);
|
|
30
50
|
const address = subscription?.shippingAddressId != null
|
|
31
51
|
? (0, addressSelector_1.getAddressByAddressId)(rootState.addressState, subscription.shippingAddressId)
|
|
32
52
|
: undefined;
|
|
33
|
-
|
|
34
|
-
|
|
53
|
+
const actions = [];
|
|
54
|
+
if (address != null) {
|
|
55
|
+
actions.push((0, addressViewReducer_1.newAddressInLocalStore)({
|
|
35
56
|
addressType: invoicingSubscriptionFormConfig_1.INVOICING_SUBSCRIPTION_SHIPPING_ADDRESS_TYPE,
|
|
36
57
|
addressToCreate: address,
|
|
37
|
-
}))
|
|
38
|
-
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
else if (pending != null) {
|
|
61
|
+
actions.push((0, addressViewReducer_1.removeNewAddressDataInLocalStore)(invoicingSubscriptionFormConfig_1.INVOICING_SUBSCRIPTION_SHIPPING_ADDRESS_TYPE));
|
|
62
|
+
}
|
|
63
|
+
actions.push((0, editInvoicingSubscriptionDetailViewReducer_1.claimInvoicingSubscriptionShippingAddress)({ id }));
|
|
64
|
+
return (0, rxjs_1.from)(actions);
|
|
39
65
|
}));
|
|
40
66
|
exports.initializeInvoicingSubscriptionAddressEpic = initializeInvoicingSubscriptionAddressEpic;
|
|
@@ -8,7 +8,9 @@ import { FetchState, ID } from '../../commonStateTypes/common';
|
|
|
8
8
|
* whole state back on every change, so a change made before the record landed
|
|
9
9
|
* leaves a draft that looks seeded but holds nothing.
|
|
10
10
|
*
|
|
11
|
-
* `Not-Started` —
|
|
11
|
+
* `Not-Started` — not (or no longer) the loaded record's values: written by the
|
|
12
|
+
* form before the record landed, or just saved and awaiting the
|
|
13
|
+
* refetch that follows. A successful load replaces it.
|
|
12
14
|
* `Completed` — filled from the loaded record; the form may have edited it since.
|
|
13
15
|
* `Error` — the record's fetch failed, so the form starts blank and a
|
|
14
16
|
* later successful fetch is still allowed to seed it.
|
|
@@ -41,6 +43,13 @@ export declare function applyInvoicingFormDraftSeed<TLocalData>(draftById: Invoi
|
|
|
41
43
|
* counting as still loading, and a later successful fetch can still seed it.
|
|
42
44
|
*/
|
|
43
45
|
export declare function applyInvoicingFormDraftFailure<TLocalData>(draftById: InvoicingFormDraftById<TLocalData>, id: ID, blankLocalData: TLocalData): void;
|
|
46
|
+
/**
|
|
47
|
+
* The record behind this draft was just saved and is about to be refetched.
|
|
48
|
+
* Keep the values on screen — dropping them would blank the form for the round
|
|
49
|
+
* trip, and the form remounts on the response anyway — but stop counting them
|
|
50
|
+
* as the loaded record's, so that response is allowed to replace them.
|
|
51
|
+
*/
|
|
52
|
+
export declare function applyInvoicingFormDraftSaved<TLocalData>(draftById: InvoicingFormDraftById<TLocalData>, id: ID): void;
|
|
44
53
|
/** The draft's values, or the blank form when nothing is drafted yet. */
|
|
45
54
|
export declare function getInvoicingFormDraftLocalData<TLocalData>(draftById: InvoicingFormDraftById<TLocalData>, id: ID | undefined, blankLocalData: TLocalData): TLocalData;
|
|
46
55
|
/**
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.applyInvoicingFormDraftEdit = applyInvoicingFormDraftEdit;
|
|
4
4
|
exports.applyInvoicingFormDraftSeed = applyInvoicingFormDraftSeed;
|
|
5
5
|
exports.applyInvoicingFormDraftFailure = applyInvoicingFormDraftFailure;
|
|
6
|
+
exports.applyInvoicingFormDraftSaved = applyInvoicingFormDraftSaved;
|
|
6
7
|
exports.getInvoicingFormDraftLocalData = getInvoicingFormDraftLocalData;
|
|
7
8
|
exports.isInvoicingFormDraftPending = isInvoicingFormDraftPending;
|
|
8
9
|
/**
|
|
@@ -48,6 +49,19 @@ function applyInvoicingFormDraftFailure(draftById, id, blankLocalData) {
|
|
|
48
49
|
}
|
|
49
50
|
existing.fetchState = 'Error';
|
|
50
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* The record behind this draft was just saved and is about to be refetched.
|
|
54
|
+
* Keep the values on screen — dropping them would blank the form for the round
|
|
55
|
+
* trip, and the form remounts on the response anyway — but stop counting them
|
|
56
|
+
* as the loaded record's, so that response is allowed to replace them.
|
|
57
|
+
*/
|
|
58
|
+
function applyInvoicingFormDraftSaved(draftById, id) {
|
|
59
|
+
const existing = draftById[id];
|
|
60
|
+
if (existing == null) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
existing.fetchState = 'Not-Started';
|
|
64
|
+
}
|
|
51
65
|
/** The draft's values, or the blank form when nothing is drafted yet. */
|
|
52
66
|
function getInvoicingFormDraftLocalData(draftById, id, blankLocalData) {
|
|
53
67
|
if (id == null) {
|
|
@@ -3,6 +3,7 @@ import { NestedClassHierarchyForReport } from '../../../commonStateTypes/classes
|
|
|
3
3
|
import { FetchStateAndError } from '../../../commonStateTypes/common';
|
|
4
4
|
import { AccountBase } from '../../../entity/account/accountState';
|
|
5
5
|
import { ClassBase } from '../../../entity/class/classState';
|
|
6
|
+
import { InvoicingQboAccountMappingKindOption } from '../../../entity/invoicing/invoicingCommonPayload';
|
|
6
7
|
import { RootState } from '../../../rootStateTypes';
|
|
7
8
|
import { InvoicingQboConnection, InvoicingQboSyncHealth } from './invoicingQboViewPayload';
|
|
8
9
|
export declare const INVOICING_ACCOUNT_LIST_KEY: "accountList";
|
|
@@ -60,6 +61,17 @@ export interface InvoicingQboView {
|
|
|
60
61
|
connection?: InvoicingQboConnection;
|
|
61
62
|
syncHealth?: InvoicingQboSyncHealth;
|
|
62
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Accounts as the invoicing pickers need them, from the shared
|
|
66
|
+
* accounting-service list, so whatever another screen already loaded is reused.
|
|
67
|
+
* `qboId` is the submitted value because that is what the invoicing API stores;
|
|
68
|
+
* an account without one cannot be posted, so it is dropped rather than offered.
|
|
69
|
+
*
|
|
70
|
+
* Memoized on the two slices it reads: the pickers and the lists derived from
|
|
71
|
+
* them are handed straight to forms, and a fresh array on every store change
|
|
72
|
+
* re-seeds a form the user is editing.
|
|
73
|
+
*/
|
|
74
|
+
export declare const getInvoicingQboAccountOptions: (state: RootState) => InvoicingAccountingOption[];
|
|
63
75
|
/**
|
|
64
76
|
* The accounts valid for one QBO mapping kind, whose `accountTypes` is a
|
|
65
77
|
* comma-separated list of QuickBooks type names. An unrecognised list yields no
|
|
@@ -67,6 +79,43 @@ export interface InvoicingQboView {
|
|
|
67
79
|
* required would post a mapping QuickBooks rejects.
|
|
68
80
|
*/
|
|
69
81
|
export declare const invoicingAccountsForQboAccountTypes: (accounts: InvoicingAccountingOption[], accountTypes: string) => InvoicingAccountingOption[];
|
|
82
|
+
/**
|
|
83
|
+
* The account-mapping slot a catalog price point's income account shares with
|
|
84
|
+
* the settings page, and the one a discount's account shares with it.
|
|
85
|
+
*/
|
|
86
|
+
export declare const INVOICING_INCOME_ACCOUNT_MAPPING_SLOT = "default_income_account";
|
|
87
|
+
export declare const INVOICING_DISCOUNTS_ACCOUNT_MAPPING_SLOT = "discounts_account";
|
|
88
|
+
/**
|
|
89
|
+
* The account types a slot falls back to when the config carries no kind for
|
|
90
|
+
* it. QuickBooks posts a product, a price and a discount line to an income
|
|
91
|
+
* account; offering every account instead would let a save be rejected.
|
|
92
|
+
*/
|
|
93
|
+
export declare const INVOICING_DEFAULT_INCOME_ACCOUNT_TYPES = "Income";
|
|
94
|
+
/**
|
|
95
|
+
* The QuickBooks ids a mapping slot's picker may offer, from the account types
|
|
96
|
+
* the config gives that slot — so every picker filling the same slot offers the
|
|
97
|
+
* same accounts, and widening one stays a config change.
|
|
98
|
+
*
|
|
99
|
+
* Ids rather than a filtered tree: the pickers flatten the tree into options by
|
|
100
|
+
* walking each node's children, so dropping a parent that is not itself of the
|
|
101
|
+
* wanted type would drop its matching descendants with it.
|
|
102
|
+
*
|
|
103
|
+
* Matched on the slot rather than the code as written, since a config naming
|
|
104
|
+
* the kind `discounts_account_id` means the same slot. A slot the config does
|
|
105
|
+
* not carry falls back to `defaultAccountTypes` rather than to every account.
|
|
106
|
+
*/
|
|
107
|
+
export declare const invoicingQboAccountIdsForMappingSlot: (accounts: InvoicingAccountingOption[], accountMappingKindOptions: InvoicingQboAccountMappingKindOption[], mappingSlot: string, defaultAccountTypes: string) => string[];
|
|
108
|
+
/**
|
|
109
|
+
* Stable empties for a tenant with no QBO connection.
|
|
110
|
+
*
|
|
111
|
+
* `?? []` builds a fresh array per call, and the invoicing forms re-seed their
|
|
112
|
+
* fields whenever their option lists change identity — so a form open against a
|
|
113
|
+
* disconnected tenant would reset itself on every unrelated store change, until
|
|
114
|
+
* the first edit disarms the re-seed.
|
|
115
|
+
*/
|
|
116
|
+
export declare const NO_INVOICING_ACCOUNT_HIERARCHY: NestedAccountHierarchyForReport[];
|
|
117
|
+
export declare const NO_INVOICING_CLASS_HIERARCHY: NestedClassHierarchyForReport[];
|
|
118
|
+
export declare const NO_INVOICING_ACCOUNT_IDS: string[];
|
|
70
119
|
/**
|
|
71
120
|
* Single bundled view for the QBO integration settings screen — the
|
|
72
121
|
* connection, the account and class options, sync health, and the fetch/action
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getInvoicingQboView = exports.invoicingAccountsForQboAccountTypes = exports.getInvoicingCatalogAccountingLookup = exports.invoicingQboClassByQboId = exports.invoicingQboAccountByQboId = exports.getInvoicingQboConnectionFetchState = exports.isInvoicingAccountingPickerDataLoading = exports.isInvoicingQboConnected = exports.INVOICING_ACCOUNT_LIST_KEY = void 0;
|
|
3
|
+
exports.getInvoicingQboView = exports.NO_INVOICING_ACCOUNT_IDS = exports.NO_INVOICING_CLASS_HIERARCHY = exports.NO_INVOICING_ACCOUNT_HIERARCHY = exports.invoicingQboAccountIdsForMappingSlot = exports.INVOICING_DEFAULT_INCOME_ACCOUNT_TYPES = exports.INVOICING_DISCOUNTS_ACCOUNT_MAPPING_SLOT = exports.INVOICING_INCOME_ACCOUNT_MAPPING_SLOT = exports.invoicingAccountsForQboAccountTypes = exports.getInvoicingQboAccountOptions = exports.getInvoicingCatalogAccountingLookup = exports.invoicingQboClassByQboId = exports.invoicingQboAccountByQboId = exports.getInvoicingQboConnectionFetchState = exports.isInvoicingAccountingPickerDataLoading = exports.isInvoicingQboConnected = exports.INVOICING_ACCOUNT_LIST_KEY = void 0;
|
|
4
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
5
|
+
const invoicingCommonPayload_1 = require("../../../entity/invoicing/invoicingCommonPayload");
|
|
4
6
|
const accountListSelector_1 = require("../../accountList/accountListSelector");
|
|
5
7
|
const classListSelector_1 = require("../../classList/classListSelector");
|
|
6
8
|
// The shared bucket, fetched with the same arguments as the other consumers so
|
|
@@ -91,14 +93,20 @@ const getInvoicingCatalogAccountingLookup = (state) => ({
|
|
|
91
93
|
});
|
|
92
94
|
exports.getInvoicingCatalogAccountingLookup = getInvoicingCatalogAccountingLookup;
|
|
93
95
|
/**
|
|
94
|
-
* Accounts
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
96
|
+
* Accounts as the invoicing pickers need them, from the shared
|
|
97
|
+
* accounting-service list, so whatever another screen already loaded is reused.
|
|
98
|
+
* `qboId` is the submitted value because that is what the invoicing API stores;
|
|
99
|
+
* an account without one cannot be posted, so it is dropped rather than offered.
|
|
100
|
+
*
|
|
101
|
+
* Memoized on the two slices it reads: the pickers and the lists derived from
|
|
102
|
+
* them are handed straight to forms, and a fresh array on every store change
|
|
103
|
+
* re-seeds a form the user is editing.
|
|
99
104
|
*/
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
exports.getInvoicingQboAccountOptions = (0, toolkit_1.createSelector)([
|
|
106
|
+
(state) => state.accountState,
|
|
107
|
+
(state) => state.accountListState,
|
|
108
|
+
], (accountState, accountListState) => {
|
|
109
|
+
const { accounts } = (0, accountListSelector_1.getAccountList)(accountState, accountListState, exports.INVOICING_ACCOUNT_LIST_KEY);
|
|
102
110
|
return accounts.flatMap((account) => {
|
|
103
111
|
if (account.qboId == null || account.isDeleted === true) {
|
|
104
112
|
return [];
|
|
@@ -111,7 +119,7 @@ const invoicingAccountingOptions = (state) => {
|
|
|
111
119
|
},
|
|
112
120
|
];
|
|
113
121
|
});
|
|
114
|
-
};
|
|
122
|
+
});
|
|
115
123
|
/**
|
|
116
124
|
* Normalises an account-type name for comparison. The config's mapping kinds
|
|
117
125
|
* name QuickBooks types the way QuickBooks displays them ("Other Current
|
|
@@ -148,6 +156,47 @@ const invoicingAccountsForQboAccountTypes = (accounts, accountTypes) => {
|
|
|
148
156
|
wanted.has(normalizeAccountTypeName(account.accountType)));
|
|
149
157
|
};
|
|
150
158
|
exports.invoicingAccountsForQboAccountTypes = invoicingAccountsForQboAccountTypes;
|
|
159
|
+
/**
|
|
160
|
+
* The account-mapping slot a catalog price point's income account shares with
|
|
161
|
+
* the settings page, and the one a discount's account shares with it.
|
|
162
|
+
*/
|
|
163
|
+
exports.INVOICING_INCOME_ACCOUNT_MAPPING_SLOT = 'default_income_account';
|
|
164
|
+
exports.INVOICING_DISCOUNTS_ACCOUNT_MAPPING_SLOT = 'discounts_account';
|
|
165
|
+
/**
|
|
166
|
+
* The account types a slot falls back to when the config carries no kind for
|
|
167
|
+
* it. QuickBooks posts a product, a price and a discount line to an income
|
|
168
|
+
* account; offering every account instead would let a save be rejected.
|
|
169
|
+
*/
|
|
170
|
+
exports.INVOICING_DEFAULT_INCOME_ACCOUNT_TYPES = 'Income';
|
|
171
|
+
/**
|
|
172
|
+
* The QuickBooks ids a mapping slot's picker may offer, from the account types
|
|
173
|
+
* the config gives that slot — so every picker filling the same slot offers the
|
|
174
|
+
* same accounts, and widening one stays a config change.
|
|
175
|
+
*
|
|
176
|
+
* Ids rather than a filtered tree: the pickers flatten the tree into options by
|
|
177
|
+
* walking each node's children, so dropping a parent that is not itself of the
|
|
178
|
+
* wanted type would drop its matching descendants with it.
|
|
179
|
+
*
|
|
180
|
+
* Matched on the slot rather than the code as written, since a config naming
|
|
181
|
+
* the kind `discounts_account_id` means the same slot. A slot the config does
|
|
182
|
+
* not carry falls back to `defaultAccountTypes` rather than to every account.
|
|
183
|
+
*/
|
|
184
|
+
const invoicingQboAccountIdsForMappingSlot = (accounts, accountMappingKindOptions, mappingSlot, defaultAccountTypes) => {
|
|
185
|
+
const accountTypes = accountMappingKindOptions.find((kindOption) => (0, invoicingCommonPayload_1.toInvoicingQboAccountMappingSlot)(kindOption.code) === mappingSlot)?.accountTypes ?? defaultAccountTypes;
|
|
186
|
+
return (0, exports.invoicingAccountsForQboAccountTypes)(accounts, accountTypes).map((account) => account.id);
|
|
187
|
+
};
|
|
188
|
+
exports.invoicingQboAccountIdsForMappingSlot = invoicingQboAccountIdsForMappingSlot;
|
|
189
|
+
/**
|
|
190
|
+
* Stable empties for a tenant with no QBO connection.
|
|
191
|
+
*
|
|
192
|
+
* `?? []` builds a fresh array per call, and the invoicing forms re-seed their
|
|
193
|
+
* fields whenever their option lists change identity — so a form open against a
|
|
194
|
+
* disconnected tenant would reset itself on every unrelated store change, until
|
|
195
|
+
* the first edit disarms the re-seed.
|
|
196
|
+
*/
|
|
197
|
+
exports.NO_INVOICING_ACCOUNT_HIERARCHY = [];
|
|
198
|
+
exports.NO_INVOICING_CLASS_HIERARCHY = [];
|
|
199
|
+
exports.NO_INVOICING_ACCOUNT_IDS = [];
|
|
151
200
|
/** Classes as the invoicing pickers need them, from the shared class list. */
|
|
152
201
|
const invoicingAccountingClassOptions = (state) => {
|
|
153
202
|
const { classes } = (0, classListSelector_1.getClassList)(state.classState, state.classListState);
|
|
@@ -169,7 +218,7 @@ const getInvoicingQboView = (state) => {
|
|
|
169
218
|
const qboState = state.invoicingQboViewState;
|
|
170
219
|
const accountList = state.accountListState.byReportId[exports.INVOICING_ACCOUNT_LIST_KEY];
|
|
171
220
|
return {
|
|
172
|
-
accounts:
|
|
221
|
+
accounts: (0, exports.getInvoicingQboAccountOptions)(state),
|
|
173
222
|
accountsFetchState: {
|
|
174
223
|
fetchState: accountList.fetchState,
|
|
175
224
|
error: accountList.error,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.53",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|