@zeniai/client-epic-state 5.2.11 → 5.2.12
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/invoicing/invoicingCommonPayload.d.ts +27 -29
- package/lib/entity/invoicing/invoicingCommonPayload.js +37 -75
- package/lib/entity/invoicing/product/productPayload.d.ts +10 -0
- package/lib/entity/invoicing/product/productPayload.js +14 -2
- package/lib/epic.d.ts +1 -1
- package/lib/epic.js +10 -5
- package/lib/esm/entity/invoicing/invoicingCommonPayload.js +33 -73
- package/lib/esm/entity/invoicing/product/productPayload.js +14 -2
- package/lib/esm/epic.js +6 -1
- package/lib/esm/index.js +5 -4
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +25 -9
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +6 -1
- package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +40 -0
- package/lib/esm/view/invoicing/settingsView/epics/connectInvoicingStripeEpic.js +27 -0
- package/lib/esm/view/invoicing/settingsView/epics/disconnectInvoicingStripeEpic.js +19 -0
- package/lib/esm/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.js +19 -0
- package/lib/esm/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.js +39 -0
- package/lib/esm/view/invoicing/settingsView/epics/settingsViewActionType.js +1 -0
- package/lib/esm/view/invoicing/settingsView/epics/submitInvoicingQboSettingsEpic.js +25 -0
- package/lib/esm/view/invoicing/settingsView/invoicingQboSettingsFormConfig.js +48 -0
- package/lib/esm/view/invoicing/settingsView/settingsViewReducer.js +25 -1
- package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +41 -0
- package/lib/index.d.ts +7 -5
- package/lib/index.js +13 -6
- package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.d.ts +12 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +25 -9
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +6 -1
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.d.ts +10 -1
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +43 -1
- package/lib/view/invoicing/settingsView/epics/connectInvoicingStripeEpic.d.ts +6 -0
- package/lib/view/invoicing/settingsView/epics/connectInvoicingStripeEpic.js +31 -0
- package/lib/view/invoicing/settingsView/epics/disconnectInvoicingStripeEpic.d.ts +6 -0
- package/lib/view/invoicing/settingsView/epics/disconnectInvoicingStripeEpic.js +23 -0
- package/lib/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.d.ts +6 -0
- package/lib/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.js +23 -0
- package/lib/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.d.ts +6 -0
- package/lib/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.js +43 -0
- package/lib/view/invoicing/settingsView/epics/settingsViewActionType.d.ts +5 -0
- package/lib/view/invoicing/settingsView/epics/settingsViewActionType.js +2 -0
- package/lib/view/invoicing/settingsView/epics/submitInvoicingQboSettingsEpic.d.ts +11 -0
- package/lib/view/invoicing/settingsView/epics/submitInvoicingQboSettingsEpic.js +29 -0
- package/lib/view/invoicing/settingsView/invoicingQboSettingsFormConfig.d.ts +34 -0
- package/lib/view/invoicing/settingsView/invoicingQboSettingsFormConfig.js +53 -0
- package/lib/view/invoicing/settingsView/settingsViewReducer.d.ts +4 -1
- package/lib/view/invoicing/settingsView/settingsViewReducer.js +26 -2
- package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +35 -0
- package/lib/view/invoicing/settingsView/settingsViewSelector.js +43 -1
- package/lib/view/invoicing/settingsView/settingsViewState.d.ts +8 -0
- package/package.json +1 -1
- package/lib/esm/view/invoicing/settingsView/settingsViewEpics.js +0 -92
- package/lib/view/invoicing/settingsView/settingsViewEpics.d.ts +0 -12
- package/lib/view/invoicing/settingsView/settingsViewEpics.js +0 -99
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
import { AccountBase } from '../../../entity/account/accountState';
|
|
2
|
+
import { ClassBase } from '../../../entity/class/classState';
|
|
1
3
|
import { InvoicingPlanPayload } from '../../../entity/invoicing/plan/planPayload';
|
|
2
4
|
import { ZeniAPIResponse } from '../../../responsePayload';
|
|
3
5
|
import { InvoicingCatalogItemFormLocalData } from './editInvoicingCatalogItemDetailViewState';
|
|
4
6
|
export type SaveInvoicingCatalogItemResponse = ZeniAPIResponse<InvoicingPlanPayload>;
|
|
7
|
+
/**
|
|
8
|
+
* Resolves the QuickBooks ids the pickers submit back to the entities they name.
|
|
9
|
+
* The payload carries the whole account and class, so the ids alone are not
|
|
10
|
+
* enough; `saveInvoicingCatalogItemEpic` builds this from the shared lists.
|
|
11
|
+
*/
|
|
12
|
+
export interface InvoicingCatalogAccountingLookup {
|
|
13
|
+
accountByQboId: (qboId: string) => AccountBase | undefined;
|
|
14
|
+
classByQboId: (qboId: string) => ClassBase | undefined;
|
|
15
|
+
}
|
|
5
16
|
/**
|
|
6
17
|
* Build the parent catalog-item request body from the form draft. Creates omit
|
|
7
18
|
* both parent and sub-family IDs; edits retain returned sub-family IDs.
|
|
8
19
|
*/
|
|
9
|
-
export declare const localDataToSaveInvoicingCatalogItemPayload: (localData: InvoicingCatalogItemFormLocalData, isCreate: boolean) => Record<string, unknown>;
|
|
20
|
+
export declare const localDataToSaveInvoicingCatalogItemPayload: (localData: InvoicingCatalogItemFormLocalData, isCreate: boolean, lookup: InvoicingCatalogAccountingLookup) => Record<string, unknown>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.localDataToSaveInvoicingCatalogItemPayload = void 0;
|
|
4
|
+
const accountPayload_1 = require("../../../entity/account/accountPayload");
|
|
5
|
+
const classPayload_1 = require("../../../entity/class/classPayload");
|
|
4
6
|
const invoicingCatalogItemFormConfig_1 = require("./invoicingCatalogItemFormConfig");
|
|
5
7
|
const CURRENCY_CODE = 'USD';
|
|
6
8
|
const trimOrUndefined = (value) => value.trim() !== '' ? value.trim() : undefined;
|
|
@@ -10,20 +12,26 @@ const toProductCode = (value) => value
|
|
|
10
12
|
.toLowerCase()
|
|
11
13
|
.replace(/[^a-z0-9]+/g, '-')
|
|
12
14
|
.replace(/^-|-$/g, '');
|
|
13
|
-
const buildAccountingDetail = (subFamily) => {
|
|
15
|
+
const buildAccountingDetail = (subFamily, lookup) => {
|
|
14
16
|
const detail = {};
|
|
15
17
|
if (subFamily.sku.trim() !== '') {
|
|
16
18
|
detail.sku = subFamily.sku.trim();
|
|
17
19
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
// The account and class travel as whole objects rather than bare codes, built
|
|
21
|
+
// by the same helpers the transaction and vendor payloads use. An id that no
|
|
22
|
+
// longer resolves is dropped: sending a code the service cannot expand is how
|
|
23
|
+
// a mapping silently lands on the wrong account.
|
|
24
|
+
const account = lookup.accountByQboId(subFamily.accountingCode.trim());
|
|
25
|
+
if (account != null) {
|
|
26
|
+
detail.account = (0, accountPayload_1.toAccountPayload)(account);
|
|
20
27
|
}
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
const accountingClass = lookup.classByQboId(subFamily.accountingCategory.trim());
|
|
29
|
+
if (accountingClass != null) {
|
|
30
|
+
detail.accounting_class = (0, classPayload_1.toClassBasePayload)(accountingClass);
|
|
23
31
|
}
|
|
24
32
|
return Object.keys(detail).length > 0 ? detail : undefined;
|
|
25
33
|
};
|
|
26
|
-
const buildSubFamilyPayload = (localData, subFamily, clearEmptyValues) => {
|
|
34
|
+
const buildSubFamilyPayload = (localData, subFamily, clearEmptyValues, lookup) => {
|
|
27
35
|
const isAddon = localData.catalogType === 'addon';
|
|
28
36
|
const tiered = (0, invoicingCatalogItemFormConfig_1.isTieredCatalogPricingModel)(subFamily.pricingModel);
|
|
29
37
|
const name = subFamily.name.trim();
|
|
@@ -77,7 +85,7 @@ const buildSubFamilyPayload = (localData, subFamily, clearEmptyValues) => {
|
|
|
77
85
|
starting_unit: Number(tier.startingUnit) || 1,
|
|
78
86
|
}));
|
|
79
87
|
}
|
|
80
|
-
const accountingDetail = buildAccountingDetail(subFamily);
|
|
88
|
+
const accountingDetail = buildAccountingDetail(subFamily, lookup);
|
|
81
89
|
if (accountingDetail != null) {
|
|
82
90
|
payload.accounting_detail = accountingDetail;
|
|
83
91
|
}
|
|
@@ -89,7 +97,7 @@ const DEFAULT_CATALOG_ITEM_UNIT = 'USD';
|
|
|
89
97
|
* Build the parent catalog-item request body from the form draft. Creates omit
|
|
90
98
|
* both parent and sub-family IDs; edits retain returned sub-family IDs.
|
|
91
99
|
*/
|
|
92
|
-
const localDataToSaveInvoicingCatalogItemPayload = (localData, isCreate) => {
|
|
100
|
+
const localDataToSaveInvoicingCatalogItemPayload = (localData, isCreate, lookup) => {
|
|
93
101
|
const description = trimOrUndefined(localData.description);
|
|
94
102
|
const productCode = trimOrUndefined(localData.productCode) ?? toProductCode(localData.name);
|
|
95
103
|
const itemPayload = {
|
|
@@ -117,7 +125,7 @@ const localDataToSaveInvoicingCatalogItemPayload = (localData, isCreate) => {
|
|
|
117
125
|
? localData.subFamilies
|
|
118
126
|
: [(0, invoicingCatalogItemFormConfig_1.blankInvoicingCatalogSubFamily)()];
|
|
119
127
|
itemPayload.sub_family_details = isCreate
|
|
120
|
-
? subFamilies.map((subFamily) => buildSubFamilyPayload(localData, subFamily, false))
|
|
128
|
+
? subFamilies.map((subFamily) => buildSubFamilyPayload(localData, subFamily, false, lookup))
|
|
121
129
|
: subFamilies.map((subFamily) => {
|
|
122
130
|
const priceCode = trimOrUndefined(subFamily.priceCode) ?? toProductCode(subFamily.name);
|
|
123
131
|
const detail = {
|
|
@@ -127,6 +135,14 @@ const localDataToSaveInvoicingCatalogItemPayload = (localData, isCreate) => {
|
|
|
127
135
|
price_code: priceCode,
|
|
128
136
|
show_description_in_invoices: subFamily.showDescriptionInInvoices,
|
|
129
137
|
};
|
|
138
|
+
// Edits send a narrower body than creates, but the accounting mapping
|
|
139
|
+
// is editable on this form, so leaving it out dropped the account and
|
|
140
|
+
// class the user had just picked. `null` rather than omitted when it is
|
|
141
|
+
// empty: an absent key on an update reads as "leave it alone", which
|
|
142
|
+
// would make a cleared mapping impossible to save — the same reason
|
|
143
|
+
// `description` and `invoice_notes` go through `trimOrNull`.
|
|
144
|
+
detail.accounting_detail =
|
|
145
|
+
buildAccountingDetail(subFamily, lookup) ?? null;
|
|
130
146
|
const id = trimOrUndefined(subFamily.id);
|
|
131
147
|
return id != null ? { ...detail, id } : detail;
|
|
132
148
|
});
|
package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js
CHANGED
|
@@ -9,6 +9,7 @@ const snackbarApiError_1 = require("../../../entity/snackbar/snackbarApiError");
|
|
|
9
9
|
const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
|
|
10
10
|
const responsePayload_1 = require("../../../responsePayload");
|
|
11
11
|
const invoicingCatalogListViewReducer_1 = require("../invoicingCatalogListView/invoicingCatalogListViewReducer");
|
|
12
|
+
const invoicingQboViewSelector_1 = require("../invoicingQboView/invoicingQboViewSelector");
|
|
12
13
|
const editInvoicingCatalogItemDetailViewPayload_1 = require("./editInvoicingCatalogItemDetailViewPayload");
|
|
13
14
|
const editInvoicingCatalogItemDetailViewReducer_1 = require("./editInvoicingCatalogItemDetailViewReducer");
|
|
14
15
|
const saveInvoicingCatalogItemEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)((action) => editInvoicingCatalogItemDetailViewReducer_1.submitInvoicingCatalogItemForm.match(action) ||
|
|
@@ -23,7 +24,11 @@ const saveInvoicingCatalogItemEpic = (actions$, state$, zeniAPI) => actions$.pip
|
|
|
23
24
|
const viewState = state$.value.editInvoicingCatalogItemDetailViewState;
|
|
24
25
|
const localData = (id != null ? viewState.editDraftById[id] : viewState.newItemDraft) ??
|
|
25
26
|
viewState.newItemDraft;
|
|
26
|
-
|
|
27
|
+
const state = state$.value;
|
|
28
|
+
data = (0, editInvoicingCatalogItemDetailViewPayload_1.localDataToSaveInvoicingCatalogItemPayload)(localData, id == null, {
|
|
29
|
+
accountByQboId: (qboId) => (0, invoicingQboViewSelector_1.invoicingQboAccountByQboId)(state, qboId),
|
|
30
|
+
classByQboId: (qboId) => (0, invoicingQboViewSelector_1.invoicingQboClassByQboId)(state, qboId),
|
|
31
|
+
});
|
|
27
32
|
}
|
|
28
33
|
const baseUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0`;
|
|
29
34
|
const path = id != null
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { NestedAccountHierarchyForReport } from '../../../commonStateTypes/accountView/nestedAccountID';
|
|
2
2
|
import { NestedClassHierarchyForReport } from '../../../commonStateTypes/classesView/nestedClassID';
|
|
3
3
|
import { FetchStateAndError } from '../../../commonStateTypes/common';
|
|
4
|
-
import { AccountType } from '../../../entity/account/accountState';
|
|
4
|
+
import { AccountBase, AccountType } from '../../../entity/account/accountState';
|
|
5
|
+
import { ClassBase } from '../../../entity/class/classState';
|
|
5
6
|
import { RootState } from '../../../rootStateTypes';
|
|
6
7
|
import { InvoicingQboConnection, InvoicingQboSyncHealth } from './invoicingQboViewPayload';
|
|
7
8
|
export declare const INVOICING_ACCOUNT_LIST_KEY: "accountList";
|
|
@@ -20,6 +21,14 @@ export declare const getInvoicingQboConnectionFetchState: (state: RootState) =>
|
|
|
20
21
|
* "income accounts" rather than repeating the accounting service's vocabulary.
|
|
21
22
|
*/
|
|
22
23
|
export declare const INVOICING_INCOME_ACCOUNT_TYPES: readonly AccountType[];
|
|
24
|
+
/**
|
|
25
|
+
* The account behind a picker value. The pickers submit the QuickBooks id, so
|
|
26
|
+
* that is what callers hold; the payload builders need the whole entity to send
|
|
27
|
+
* `toAccountPayload`, which is why the lookup lives here next to the options.
|
|
28
|
+
*/
|
|
29
|
+
export declare const invoicingQboAccountByQboId: (state: RootState, qboId: string | undefined) => AccountBase | undefined;
|
|
30
|
+
/** The class behind a picker value, for the same reason as the account above. */
|
|
31
|
+
export declare const invoicingQboClassByQboId: (state: RootState, qboId: string | undefined) => ClassBase | undefined;
|
|
23
32
|
/** An account or class as the invoicing pickers render and submit it. */
|
|
24
33
|
export interface InvoicingAccountingOption {
|
|
25
34
|
id: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getInvoicingQboView = exports.invoicingAccountHierarchyForTypes = exports.invoicingAccountsForQboAccountTypes = exports.INVOICING_INCOME_ACCOUNT_TYPES = exports.getInvoicingQboConnectionFetchState = exports.isInvoicingAccountingPickerDataLoading = exports.isInvoicingQboConnected = exports.INVOICING_ACCOUNT_LIST_KEY = void 0;
|
|
3
|
+
exports.getInvoicingQboView = exports.invoicingAccountHierarchyForTypes = exports.invoicingAccountsForQboAccountTypes = exports.invoicingQboClassByQboId = exports.invoicingQboAccountByQboId = exports.INVOICING_INCOME_ACCOUNT_TYPES = exports.getInvoicingQboConnectionFetchState = exports.isInvoicingAccountingPickerDataLoading = exports.isInvoicingQboConnected = exports.INVOICING_ACCOUNT_LIST_KEY = void 0;
|
|
4
4
|
const accountListSelector_1 = require("../../accountList/accountListSelector");
|
|
5
5
|
const classListSelector_1 = require("../../classList/classListSelector");
|
|
6
6
|
// The shared bucket, fetched with the same arguments as the other consumers so
|
|
@@ -43,6 +43,48 @@ exports.INVOICING_INCOME_ACCOUNT_TYPES = [
|
|
|
43
43
|
'income',
|
|
44
44
|
'other_income',
|
|
45
45
|
];
|
|
46
|
+
/**
|
|
47
|
+
* The account behind a picker value. The pickers submit the QuickBooks id, so
|
|
48
|
+
* that is what callers hold; the payload builders need the whole entity to send
|
|
49
|
+
* `toAccountPayload`, which is why the lookup lives here next to the options.
|
|
50
|
+
*/
|
|
51
|
+
const invoicingQboAccountByQboId = (state, qboId) => {
|
|
52
|
+
if (qboId == null || qboId === '') {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
// `getAccountList` throws when a listed id is missing from the entity slice.
|
|
56
|
+
// That is survivable when looking one account up — the caller falls back to
|
|
57
|
+
// the id it already had — but not when it happens inside an epic, where the
|
|
58
|
+
// throw would take the whole request with it.
|
|
59
|
+
try {
|
|
60
|
+
const { accounts } = (0, accountListSelector_1.getAccountList)(state.accountState, state.accountListState, exports.INVOICING_ACCOUNT_LIST_KEY);
|
|
61
|
+
// Matched on any id the account is known by. The pickers submit `qboId`,
|
|
62
|
+
// but a mapping that arrived from the service can name the account by its
|
|
63
|
+
// platform id instead, and an account we cannot resolve is a mapping that
|
|
64
|
+
// cannot be sent as a record.
|
|
65
|
+
return accounts.find((account) => account.qboId === qboId ||
|
|
66
|
+
account.accountId === qboId ||
|
|
67
|
+
account.coaId === qboId);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
exports.invoicingQboAccountByQboId = invoicingQboAccountByQboId;
|
|
74
|
+
/** The class behind a picker value, for the same reason as the account above. */
|
|
75
|
+
const invoicingQboClassByQboId = (state, qboId) => {
|
|
76
|
+
if (qboId == null || qboId === '') {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
const { classes } = (0, classListSelector_1.getClassList)(state.classState, state.classListState);
|
|
81
|
+
return classes.find((accountingClass) => accountingClass.qboId === qboId);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
exports.invoicingQboClassByQboId = invoicingQboClassByQboId;
|
|
46
88
|
/**
|
|
47
89
|
* Accounts and classes as the invoicing pickers need them. Both come from the
|
|
48
90
|
* shared accounting-service lists, so whatever another screen already loaded
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../../../rootStateTypes';
|
|
4
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
5
|
+
import { InvoicingSettingsViewActionType } from './settingsViewActionType';
|
|
6
|
+
export declare const connectInvoicingStripeEpic: (actions$: ActionsObservable<InvoicingSettingsViewActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<InvoicingSettingsViewActionType>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.connectInvoicingStripeEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const responsePayload_1 = require("../../../../responsePayload");
|
|
7
|
+
const settingsViewReducer_1 = require("../settingsViewReducer");
|
|
8
|
+
const connectInvoicingStripeEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(settingsViewReducer_1.connectInvoicingStripe.match), (0, operators_1.mergeMap)((action) => {
|
|
9
|
+
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings/stripe-connect/setup`;
|
|
10
|
+
const { api_key, publishable_key, webhook_secret } = action.payload;
|
|
11
|
+
const body = {
|
|
12
|
+
api_key,
|
|
13
|
+
publishable_key,
|
|
14
|
+
...(webhook_secret != null && webhook_secret !== ''
|
|
15
|
+
? { webhook_secret }
|
|
16
|
+
: {}),
|
|
17
|
+
};
|
|
18
|
+
return zeniAPI
|
|
19
|
+
.postAndGetJSON(apiUrl, body)
|
|
20
|
+
.pipe((0, operators_1.switchMap)((response) => {
|
|
21
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
22
|
+
return (0, rxjs_1.of)((0, settingsViewReducer_1.updateInvoicingStripeConnection)({
|
|
23
|
+
stripe_connected: response.data.stripe_connected,
|
|
24
|
+
publishable_key: response.data.publishable_key,
|
|
25
|
+
}), (0, settingsViewReducer_1.fetchInvoicingSettings)());
|
|
26
|
+
}
|
|
27
|
+
return (0, rxjs_1.of)((0, settingsViewReducer_1.invoicingStripeConnectionFailure)(response.status));
|
|
28
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, settingsViewReducer_1.invoicingStripeConnectionFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Stripe connect setup REST API call errored out ' +
|
|
29
|
+
JSON.stringify(error))))));
|
|
30
|
+
}));
|
|
31
|
+
exports.connectInvoicingStripeEpic = connectInvoicingStripeEpic;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../../../rootStateTypes';
|
|
4
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
5
|
+
import { InvoicingSettingsViewActionType } from './settingsViewActionType';
|
|
6
|
+
export declare const disconnectInvoicingStripeEpic: (actions$: ActionsObservable<InvoicingSettingsViewActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<InvoicingSettingsViewActionType>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.disconnectInvoicingStripeEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const responsePayload_1 = require("../../../../responsePayload");
|
|
7
|
+
const settingsViewReducer_1 = require("../settingsViewReducer");
|
|
8
|
+
const disconnectInvoicingStripeEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(settingsViewReducer_1.disconnectInvoicingStripe.match), (0, operators_1.mergeMap)(() => {
|
|
9
|
+
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings/stripe-connect/callback`;
|
|
10
|
+
return zeniAPI
|
|
11
|
+
.deleteAndGetJSON(apiUrl)
|
|
12
|
+
.pipe((0, operators_1.switchMap)((response) => {
|
|
13
|
+
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
14
|
+
return (0, rxjs_1.of)((0, settingsViewReducer_1.updateInvoicingStripeConnection)({
|
|
15
|
+
stripe_connected: false,
|
|
16
|
+
publishable_key: '',
|
|
17
|
+
}), (0, settingsViewReducer_1.fetchInvoicingSettings)());
|
|
18
|
+
}
|
|
19
|
+
return (0, rxjs_1.of)((0, settingsViewReducer_1.invoicingStripeConnectionFailure)(response.status));
|
|
20
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, settingsViewReducer_1.invoicingStripeConnectionFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Stripe disconnect REST API call errored out ' +
|
|
21
|
+
JSON.stringify(error))))));
|
|
22
|
+
}));
|
|
23
|
+
exports.disconnectInvoicingStripeEpic = disconnectInvoicingStripeEpic;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../../../rootStateTypes';
|
|
4
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
5
|
+
import { InvoicingSettingsViewActionType } from './settingsViewActionType';
|
|
6
|
+
export declare const fetchInvoicingSettingsEpic: (actions$: ActionsObservable<InvoicingSettingsViewActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<InvoicingSettingsViewActionType>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchInvoicingSettingsEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const addressReducer_1 = require("../../../../entity/address/addressReducer");
|
|
7
|
+
const responsePayload_1 = require("../../../../responsePayload");
|
|
8
|
+
const settingsViewReducer_1 = require("../settingsViewReducer");
|
|
9
|
+
const fetchInvoicingSettingsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(settingsViewReducer_1.fetchInvoicingSettings.match), (0, operators_1.switchMap)(() => {
|
|
10
|
+
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings`;
|
|
11
|
+
return zeniAPI.getJSON(apiUrl).pipe((0, operators_1.switchMap)((response) => {
|
|
12
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
13
|
+
const address = response.data.address;
|
|
14
|
+
return [
|
|
15
|
+
...(address != null ? [(0, addressReducer_1.updateAddresses)([address])] : []),
|
|
16
|
+
(0, settingsViewReducer_1.updateInvoicingSettings)(response.data),
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
return (0, rxjs_1.of)((0, settingsViewReducer_1.updateInvoicingSettingsFailure)(response.status));
|
|
20
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, settingsViewReducer_1.updateInvoicingSettingsFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch settings REST API call errored out ' +
|
|
21
|
+
JSON.stringify(error))))));
|
|
22
|
+
}));
|
|
23
|
+
exports.fetchInvoicingSettingsEpic = fetchInvoicingSettingsEpic;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../../../rootStateTypes';
|
|
4
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
5
|
+
import { InvoicingSettingsViewActionType } from './settingsViewActionType';
|
|
6
|
+
export declare const saveInvoicingSettingsEpic: (actions$: ActionsObservable<InvoicingSettingsViewActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<InvoicingSettingsViewActionType>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.saveInvoicingSettingsEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const snackbarApiError_1 = require("../../../../entity/snackbar/snackbarApiError");
|
|
7
|
+
const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
|
|
8
|
+
const responsePayload_1 = require("../../../../responsePayload");
|
|
9
|
+
const settingsViewReducer_1 = require("../settingsViewReducer");
|
|
10
|
+
const saveInvoicingSettingsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(settingsViewReducer_1.saveInvoicingSettings.match), (0, operators_1.mergeMap)((action) => {
|
|
11
|
+
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings`;
|
|
12
|
+
const { settings, snackbarSection } = action.payload;
|
|
13
|
+
/** `status` surfaces the platform's error text; omit it to keep the generic copy. */
|
|
14
|
+
const snackbar = (messageText, status) => snackbarSection == null
|
|
15
|
+
? []
|
|
16
|
+
: [
|
|
17
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
18
|
+
messageSection: snackbarSection,
|
|
19
|
+
messageText,
|
|
20
|
+
type: messageText === 'success' ? 'success' : 'error',
|
|
21
|
+
variables: (0, snackbarApiError_1.apiErrorSnackbarVariables)(status),
|
|
22
|
+
}),
|
|
23
|
+
];
|
|
24
|
+
return zeniAPI
|
|
25
|
+
.putAndGetJSON(apiUrl, { ...settings })
|
|
26
|
+
.pipe((0, operators_1.switchMap)((response) => {
|
|
27
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
28
|
+
return (0, rxjs_1.from)([
|
|
29
|
+
(0, settingsViewReducer_1.saveInvoicingSettingsSuccess)(response.data),
|
|
30
|
+
...snackbar('success'),
|
|
31
|
+
]);
|
|
32
|
+
}
|
|
33
|
+
return (0, rxjs_1.from)([
|
|
34
|
+
(0, settingsViewReducer_1.saveInvoicingSettingsFailure)(response.status),
|
|
35
|
+
...snackbar('failed', response.status),
|
|
36
|
+
]);
|
|
37
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
|
|
38
|
+
(0, settingsViewReducer_1.saveInvoicingSettingsFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Save settings REST API call errored out ' +
|
|
39
|
+
JSON.stringify(error))),
|
|
40
|
+
...snackbar('failed'),
|
|
41
|
+
])));
|
|
42
|
+
}));
|
|
43
|
+
exports.saveInvoicingSettingsEpic = saveInvoicingSettingsEpic;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { updateAddresses } from '../../../../entity/address/addressReducer';
|
|
2
|
+
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
3
|
+
import { connectInvoicingStripe, disconnectInvoicingStripe, fetchInvoicingSettings, invoicingStripeConnectionFailure, saveInvoicingSettings, saveInvoicingSettingsFailure, saveInvoicingSettingsSuccess, submitInvoicingQboSettings, updateInvoicingSettings, updateInvoicingSettingsFailure, updateInvoicingStripeConnection } from '../settingsViewReducer';
|
|
4
|
+
/** Every action the settings epics accept or emit. */
|
|
5
|
+
export type InvoicingSettingsViewActionType = ReturnType<typeof fetchInvoicingSettings> | ReturnType<typeof updateInvoicingSettings> | ReturnType<typeof updateInvoicingSettingsFailure> | ReturnType<typeof saveInvoicingSettings> | ReturnType<typeof saveInvoicingSettingsSuccess> | ReturnType<typeof submitInvoicingQboSettings> | ReturnType<typeof saveInvoicingSettingsFailure> | ReturnType<typeof connectInvoicingStripe> | ReturnType<typeof disconnectInvoicingStripe> | ReturnType<typeof updateInvoicingStripeConnection> | ReturnType<typeof invoicingStripeConnectionFailure> | ReturnType<typeof updateAddresses> | ReturnType<typeof openSnackbar>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../../../rootStateTypes';
|
|
4
|
+
import { InvoicingSettingsViewActionType } from './settingsViewActionType';
|
|
5
|
+
/**
|
|
6
|
+
* Saves the QBO local data. The screen fires this without a payload — the local
|
|
7
|
+
* data is already in the store, so sending it back through the action would make
|
|
8
|
+
* the page the carrier for state it does not own. Converting to the request body
|
|
9
|
+
* happens here too, keeping the wire shape out of the screen.
|
|
10
|
+
*/
|
|
11
|
+
export declare const submitInvoicingQboSettingsEpic: (actions$: ActionsObservable<InvoicingSettingsViewActionType>, state$: StateObservable<RootState>) => Observable<InvoicingSettingsViewActionType>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.submitInvoicingQboSettingsEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const invoicingQboViewSelector_1 = require("../../invoicingQboView/invoicingQboViewSelector");
|
|
7
|
+
const invoicingQboSettingsFormConfig_1 = require("../invoicingQboSettingsFormConfig");
|
|
8
|
+
const settingsViewReducer_1 = require("../settingsViewReducer");
|
|
9
|
+
/**
|
|
10
|
+
* Saves the QBO local data. The screen fires this without a payload — the local
|
|
11
|
+
* data is already in the store, so sending it back through the action would make
|
|
12
|
+
* the page the carrier for state it does not own. Converting to the request body
|
|
13
|
+
* happens here too, keeping the wire shape out of the screen.
|
|
14
|
+
*/
|
|
15
|
+
const submitInvoicingQboSettingsEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(settingsViewReducer_1.submitInvoicingQboSettings.match), (0, operators_1.withLatestFrom)(state$), (0, operators_1.mergeMap)(([, state]) => {
|
|
16
|
+
const { qboDraft } = state.invoicingSettingsViewState;
|
|
17
|
+
// No local data means the settings response has not landed, so there is
|
|
18
|
+
// nothing the user could have edited yet.
|
|
19
|
+
if (qboDraft == null) {
|
|
20
|
+
return rxjs_1.EMPTY;
|
|
21
|
+
}
|
|
22
|
+
return (0, rxjs_1.of)((0, settingsViewReducer_1.saveInvoicingSettings)({
|
|
23
|
+
settings: {
|
|
24
|
+
qbo: (0, invoicingQboSettingsFormConfig_1.invoicingQboSettingsLocalDataToPayload)(qboDraft, (accountId) => (0, invoicingQboViewSelector_1.invoicingQboAccountByQboId)(state, accountId)),
|
|
25
|
+
},
|
|
26
|
+
snackbarSection: 'invoicing_qbo_settings_save',
|
|
27
|
+
}));
|
|
28
|
+
}));
|
|
29
|
+
exports.submitInvoicingQboSettingsEpic = submitInvoicingQboSettingsEpic;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AccountBase } from '../../../entity/account/accountState';
|
|
2
|
+
import { InvoicingQboSettingsPayload } from '../../../entity/invoicing/invoicingCommonPayload';
|
|
3
|
+
/**
|
|
4
|
+
* The QBO configuration page's local data. A client shape, not the wire one: the
|
|
5
|
+
* page edits a flat `accountIdByMappingCode` map keyed by the config's mapping
|
|
6
|
+
* codes, where the payload carries one field pair per slot and two shapes for
|
|
7
|
+
* each. {@link entityToInvoicingQboSettingsLocalData} and
|
|
8
|
+
* {@link invoicingQboSettingsLocalDataToPayload} convert at the boundary.
|
|
9
|
+
*/
|
|
10
|
+
export interface InvoicingQboSettingsLocalData {
|
|
11
|
+
/**
|
|
12
|
+
* Mapping code to the QuickBooks account id the picker selected. Keyed by the
|
|
13
|
+
* config's own codes rather than a client-side list: the backend owns which
|
|
14
|
+
* slots exist, so anything narrower silently drops the ones it has not heard
|
|
15
|
+
* of.
|
|
16
|
+
*/
|
|
17
|
+
accountIdByMappingCode: Record<string, string>;
|
|
18
|
+
autoCreateItems: boolean;
|
|
19
|
+
closedPeriodVoidAsCreditMemo: boolean;
|
|
20
|
+
customerMatching: string;
|
|
21
|
+
isSyncEnabled: boolean;
|
|
22
|
+
/** ISO date, empty when unset — the picker clears to empty, not to null. */
|
|
23
|
+
syncStartDate: string;
|
|
24
|
+
trackingCategoriesEnabled: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare const initialInvoicingQboSettingsLocalData: InvoicingQboSettingsLocalData;
|
|
27
|
+
/** The settings response as the page edits it. */
|
|
28
|
+
export declare const entityToInvoicingQboSettingsLocalData: (qbo: InvoicingQboSettingsPayload | null | undefined) => InvoicingQboSettingsLocalData;
|
|
29
|
+
/**
|
|
30
|
+
* The local data as the request body. `accountForId` turns each picked id into
|
|
31
|
+
* the whole account the service stores; it comes from the epic, which is where
|
|
32
|
+
* the account list is in reach.
|
|
33
|
+
*/
|
|
34
|
+
export declare const invoicingQboSettingsLocalDataToPayload: (localData: InvoicingQboSettingsLocalData, accountForId: (accountId: string) => AccountBase | undefined) => InvoicingQboSettingsPayload;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.invoicingQboSettingsLocalDataToPayload = exports.entityToInvoicingQboSettingsLocalData = exports.initialInvoicingQboSettingsLocalData = void 0;
|
|
4
|
+
const invoicingCommonPayload_1 = require("../../../entity/invoicing/invoicingCommonPayload");
|
|
5
|
+
exports.initialInvoicingQboSettingsLocalData = {
|
|
6
|
+
accountIdByMappingCode: {},
|
|
7
|
+
autoCreateItems: false,
|
|
8
|
+
closedPeriodVoidAsCreditMemo: false,
|
|
9
|
+
customerMatching: '',
|
|
10
|
+
isSyncEnabled: false,
|
|
11
|
+
syncStartDate: '',
|
|
12
|
+
trackingCategoriesEnabled: false,
|
|
13
|
+
};
|
|
14
|
+
/** The settings response as the page edits it. */
|
|
15
|
+
const entityToInvoicingQboSettingsLocalData = (qbo) => {
|
|
16
|
+
const accountMappings = qbo?.account_mappings ?? {};
|
|
17
|
+
const accountIdByMappingCode = {};
|
|
18
|
+
// Keyed by the slot the payload used, which is the config code the page will
|
|
19
|
+
// ask for — the reader tolerates the older `_id` form on the way in.
|
|
20
|
+
Object.keys(accountMappings).forEach((key) => {
|
|
21
|
+
const accountId = (0, invoicingCommonPayload_1.getInvoicingQboAccountMappingId)(accountMappings, key);
|
|
22
|
+
if (accountId != null) {
|
|
23
|
+
accountIdByMappingCode[(0, invoicingCommonPayload_1.toInvoicingQboAccountMappingSlot)(key)] = accountId;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
accountIdByMappingCode,
|
|
28
|
+
autoCreateItems: qbo?.auto_create_items === true,
|
|
29
|
+
closedPeriodVoidAsCreditMemo: qbo?.closed_period_void_as_credit_memo === true,
|
|
30
|
+
customerMatching: qbo?.customer_matching ?? '',
|
|
31
|
+
isSyncEnabled: qbo?.enabled === true,
|
|
32
|
+
syncStartDate: qbo?.sync_start_date ?? '',
|
|
33
|
+
trackingCategoriesEnabled: qbo?.tracking_categories_enabled === true,
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.entityToInvoicingQboSettingsLocalData = entityToInvoicingQboSettingsLocalData;
|
|
37
|
+
/**
|
|
38
|
+
* The local data as the request body. `accountForId` turns each picked id into
|
|
39
|
+
* the whole account the service stores; it comes from the epic, which is where
|
|
40
|
+
* the account list is in reach.
|
|
41
|
+
*/
|
|
42
|
+
const invoicingQboSettingsLocalDataToPayload = (localData, accountForId) => {
|
|
43
|
+
return {
|
|
44
|
+
account_mappings: (0, invoicingCommonPayload_1.toInvoicingQboAccountMappingsPayload)(localData.accountIdByMappingCode, accountForId),
|
|
45
|
+
auto_create_items: localData.autoCreateItems,
|
|
46
|
+
closed_period_void_as_credit_memo: localData.closedPeriodVoidAsCreditMemo,
|
|
47
|
+
customer_matching: localData.customerMatching,
|
|
48
|
+
enabled: localData.isSyncEnabled,
|
|
49
|
+
sync_start_date: localData.syncStartDate !== '' ? localData.syncStartDate : null,
|
|
50
|
+
tracking_categories_enabled: localData.trackingCategoriesEnabled,
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
exports.invoicingQboSettingsLocalDataToPayload = invoicingQboSettingsLocalDataToPayload;
|
|
@@ -2,6 +2,7 @@ import { InvoicingSettingsPayload } from '../../../entity/invoicing/invoicingCom
|
|
|
2
2
|
import { SnackbarMessageSections } from '../../../entity/snackbar/snackbarTypes';
|
|
3
3
|
import { ZeniAPIStatus } from '../../../responsePayload';
|
|
4
4
|
import { InvoicingBrandingFormLocalData } from './invoicingBrandingFormConfig';
|
|
5
|
+
import { InvoicingQboSettingsLocalData } from './invoicingQboSettingsFormConfig';
|
|
5
6
|
import { StripeConnectCredentials } from './settingsViewPayload';
|
|
6
7
|
import { InvoicingSettingsViewState } from './settingsViewState';
|
|
7
8
|
export interface InvoicingStripeConnectionUpdate {
|
|
@@ -19,6 +20,8 @@ export interface SaveInvoicingSettingsPayload {
|
|
|
19
20
|
export declare const initialState: InvoicingSettingsViewState;
|
|
20
21
|
export declare const fetchInvoicingSettings: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingSettingsView/fetchInvoicingSettings">, updateInvoicingSettings: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingSettingsPayload, "invoicingSettingsView/updateInvoicingSettings">, updateInvoicingSettingsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingSettingsView/updateInvoicingSettingsFailure">, saveInvoicingSettings: import("@reduxjs/toolkit").ActionCreatorWithPayload<SaveInvoicingSettingsPayload, "invoicingSettingsView/saveInvoicingSettings">, saveInvoicingSettingsSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingSettingsPayload, "invoicingSettingsView/saveInvoicingSettingsSuccess">, saveInvoicingSettingsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingSettingsView/saveInvoicingSettingsFailure">, resetSaveInvoicingSettings: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingSettingsView/resetSaveInvoicingSettings">, updateInvoicingBrandingFormDraft: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
21
22
|
localData: InvoicingBrandingFormLocalData;
|
|
22
|
-
}, "invoicingSettingsView/updateInvoicingBrandingFormDraft">, submitInvoicingBrandingForm: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingSettingsView/submitInvoicingBrandingForm">, resetInvoicingBrandingFormDraft: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingSettingsView/resetInvoicingBrandingFormDraft">,
|
|
23
|
+
}, "invoicingSettingsView/updateInvoicingBrandingFormDraft">, submitInvoicingBrandingForm: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingSettingsView/submitInvoicingBrandingForm">, resetInvoicingBrandingFormDraft: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingSettingsView/resetInvoicingBrandingFormDraft">, updateInvoicingQboSettingsDraft: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
24
|
+
localData: InvoicingQboSettingsLocalData;
|
|
25
|
+
}, "invoicingSettingsView/updateInvoicingQboSettingsDraft">, submitInvoicingQboSettings: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingSettingsView/submitInvoicingQboSettings">, resetInvoicingQboSettingsDraft: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingSettingsView/resetInvoicingQboSettingsDraft">, connectInvoicingStripe: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[credentials: StripeConnectCredentials], StripeConnectCredentials, "invoicingSettingsView/connectInvoicingStripe", never, never>, disconnectInvoicingStripe: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingSettingsView/disconnectInvoicingStripe">, updateInvoicingStripeConnection: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingStripeConnectionUpdate, "invoicingSettingsView/updateInvoicingStripeConnection">, invoicingStripeConnectionFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingSettingsView/invoicingStripeConnectionFailure">;
|
|
23
26
|
declare const _default: import("redux").Reducer<InvoicingSettingsViewState>;
|
|
24
27
|
export default _default;
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.invoicingStripeConnectionFailure = exports.updateInvoicingStripeConnection = exports.disconnectInvoicingStripe = exports.connectInvoicingStripe = exports.resetInvoicingBrandingFormDraft = exports.submitInvoicingBrandingForm = exports.updateInvoicingBrandingFormDraft = exports.resetSaveInvoicingSettings = exports.saveInvoicingSettingsFailure = exports.saveInvoicingSettingsSuccess = exports.saveInvoicingSettings = exports.updateInvoicingSettingsFailure = exports.updateInvoicingSettings = exports.fetchInvoicingSettings = exports.initialState = void 0;
|
|
4
|
+
exports.invoicingStripeConnectionFailure = exports.updateInvoicingStripeConnection = exports.disconnectInvoicingStripe = exports.connectInvoicingStripe = exports.resetInvoicingQboSettingsDraft = exports.submitInvoicingQboSettings = exports.updateInvoicingQboSettingsDraft = exports.resetInvoicingBrandingFormDraft = exports.submitInvoicingBrandingForm = exports.updateInvoicingBrandingFormDraft = exports.resetSaveInvoicingSettings = exports.saveInvoicingSettingsFailure = exports.saveInvoicingSettingsSuccess = exports.saveInvoicingSettings = exports.updateInvoicingSettingsFailure = exports.updateInvoicingSettings = exports.fetchInvoicingSettings = exports.initialState = void 0;
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
6
|
const rootActions_1 = require("../../../rootActions");
|
|
7
|
+
const invoicingQboSettingsFormConfig_1 = require("./invoicingQboSettingsFormConfig");
|
|
7
8
|
exports.initialState = {
|
|
8
9
|
fetchState: 'Not-Started',
|
|
9
10
|
error: undefined,
|
|
10
11
|
saveFetchState: { fetchState: 'Not-Started', error: undefined },
|
|
11
12
|
stripeFetchState: { fetchState: 'Not-Started', error: undefined },
|
|
12
13
|
settings: undefined,
|
|
14
|
+
// Listed so `clearAll` resets them: an in-progress draft left behind by a
|
|
15
|
+
// tenant switch would be shown and saved against the tenant switched to.
|
|
16
|
+
brandingDraft: undefined,
|
|
17
|
+
qboDraft: undefined,
|
|
13
18
|
hasValidState() {
|
|
14
19
|
return this.fetchState === 'Completed' && this.settings != null;
|
|
15
20
|
},
|
|
@@ -26,6 +31,11 @@ const settingsView = (0, toolkit_1.createSlice)({
|
|
|
26
31
|
draft.settings = action.payload;
|
|
27
32
|
draft.fetchState = 'Completed';
|
|
28
33
|
draft.error = undefined;
|
|
34
|
+
// Seed the QBO page's local data from the response. An edit already in
|
|
35
|
+
// progress wins: a refetch behind the user must not discard it.
|
|
36
|
+
if (draft.qboDraft == null) {
|
|
37
|
+
draft.qboDraft = (0, invoicingQboSettingsFormConfig_1.entityToInvoicingQboSettingsLocalData)(action.payload.qbo);
|
|
38
|
+
}
|
|
29
39
|
},
|
|
30
40
|
updateInvoicingSettingsFailure(draft, action) {
|
|
31
41
|
draft.fetchState = 'Error';
|
|
@@ -40,6 +50,9 @@ const settingsView = (0, toolkit_1.createSlice)({
|
|
|
40
50
|
saveInvoicingSettingsSuccess(draft, action) {
|
|
41
51
|
draft.settings = action.payload;
|
|
42
52
|
draft.saveFetchState = { fetchState: 'Completed', error: undefined };
|
|
53
|
+
// Re-seeded from what was just persisted, so the page keeps working off
|
|
54
|
+
// local data while showing the server's version of it.
|
|
55
|
+
draft.qboDraft = (0, invoicingQboSettingsFormConfig_1.entityToInvoicingQboSettingsLocalData)(action.payload.qbo);
|
|
43
56
|
},
|
|
44
57
|
saveInvoicingSettingsFailure(draft, action) {
|
|
45
58
|
draft.saveFetchState = { fetchState: 'Error', error: action.payload };
|
|
@@ -58,6 +71,17 @@ const settingsView = (0, toolkit_1.createSlice)({
|
|
|
58
71
|
resetInvoicingBrandingFormDraft(draft) {
|
|
59
72
|
draft.brandingDraft = undefined;
|
|
60
73
|
},
|
|
74
|
+
updateInvoicingQboSettingsDraft(draft, action) {
|
|
75
|
+
draft.qboDraft = action.payload.localData;
|
|
76
|
+
},
|
|
77
|
+
// Trigger only — handled by submitInvoicingQboSettingsEpic, which reads the
|
|
78
|
+
// local data and converts it to the request body.
|
|
79
|
+
submitInvoicingQboSettings(draft) {
|
|
80
|
+
draft.saveFetchState = { fetchState: 'In-Progress', error: undefined };
|
|
81
|
+
},
|
|
82
|
+
resetInvoicingQboSettingsDraft(draft) {
|
|
83
|
+
draft.qboDraft = undefined;
|
|
84
|
+
},
|
|
61
85
|
connectInvoicingStripe: {
|
|
62
86
|
reducer(draft) {
|
|
63
87
|
draft.stripeFetchState = { fetchState: 'In-Progress', error: undefined };
|
|
@@ -89,5 +113,5 @@ const settingsView = (0, toolkit_1.createSlice)({
|
|
|
89
113
|
});
|
|
90
114
|
},
|
|
91
115
|
});
|
|
92
|
-
_a = settingsView.actions, exports.fetchInvoicingSettings = _a.fetchInvoicingSettings, exports.updateInvoicingSettings = _a.updateInvoicingSettings, exports.updateInvoicingSettingsFailure = _a.updateInvoicingSettingsFailure, exports.saveInvoicingSettings = _a.saveInvoicingSettings, exports.saveInvoicingSettingsSuccess = _a.saveInvoicingSettingsSuccess, exports.saveInvoicingSettingsFailure = _a.saveInvoicingSettingsFailure, exports.resetSaveInvoicingSettings = _a.resetSaveInvoicingSettings, exports.updateInvoicingBrandingFormDraft = _a.updateInvoicingBrandingFormDraft, exports.submitInvoicingBrandingForm = _a.submitInvoicingBrandingForm, exports.resetInvoicingBrandingFormDraft = _a.resetInvoicingBrandingFormDraft, exports.connectInvoicingStripe = _a.connectInvoicingStripe, exports.disconnectInvoicingStripe = _a.disconnectInvoicingStripe, exports.updateInvoicingStripeConnection = _a.updateInvoicingStripeConnection, exports.invoicingStripeConnectionFailure = _a.invoicingStripeConnectionFailure;
|
|
116
|
+
_a = settingsView.actions, exports.fetchInvoicingSettings = _a.fetchInvoicingSettings, exports.updateInvoicingSettings = _a.updateInvoicingSettings, exports.updateInvoicingSettingsFailure = _a.updateInvoicingSettingsFailure, exports.saveInvoicingSettings = _a.saveInvoicingSettings, exports.saveInvoicingSettingsSuccess = _a.saveInvoicingSettingsSuccess, exports.saveInvoicingSettingsFailure = _a.saveInvoicingSettingsFailure, exports.resetSaveInvoicingSettings = _a.resetSaveInvoicingSettings, exports.updateInvoicingBrandingFormDraft = _a.updateInvoicingBrandingFormDraft, exports.submitInvoicingBrandingForm = _a.submitInvoicingBrandingForm, exports.resetInvoicingBrandingFormDraft = _a.resetInvoicingBrandingFormDraft, exports.updateInvoicingQboSettingsDraft = _a.updateInvoicingQboSettingsDraft, exports.submitInvoicingQboSettings = _a.submitInvoicingQboSettings, exports.resetInvoicingQboSettingsDraft = _a.resetInvoicingQboSettingsDraft, exports.connectInvoicingStripe = _a.connectInvoicingStripe, exports.disconnectInvoicingStripe = _a.disconnectInvoicingStripe, exports.updateInvoicingStripeConnection = _a.updateInvoicingStripeConnection, exports.invoicingStripeConnectionFailure = _a.invoicingStripeConnectionFailure;
|
|
93
117
|
exports.default = settingsView.reducer;
|