@zeniai/client-epic-state 5.3.7 → 5.3.8
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/invoice/invoicePayload.d.ts +1 -0
- package/lib/entity/invoicing/invoice/invoicePayload.js +3 -0
- package/lib/entity/invoicing/invoice/invoiceState.d.ts +2 -0
- package/lib/entity/tenant/epic/fetchAllTenantsEpic.js +45 -38
- package/lib/esm/entity/invoicing/invoice/invoicePayload.js +3 -0
- package/lib/esm/entity/tenant/epic/fetchAllTenantsEpic.js +46 -39
- package/lib/esm/index.js +2 -2
- package/lib/esm/init.js +14 -3
- package/lib/esm/sessionEndpointsLoader.js +7 -0
- package/lib/esm/view/expenseAutomationView/epics/accountRecon/fetchReconciliationViewEpic.js +2 -1
- package/lib/esm/view/transactionDetail/createTransaction/createTransactionPayload.js +14 -2
- package/lib/esm/view/transactionDetail/createTransaction/createTransactionSelector.js +21 -2
- package/lib/index.d.ts +3 -2
- package/lib/index.js +53 -51
- package/lib/init.d.ts +9 -0
- package/lib/init.js +17 -4
- package/lib/sessionEndpointsLoader.d.ts +9 -0
- package/lib/sessionEndpointsLoader.js +11 -0
- package/lib/view/expenseAutomationView/epics/accountRecon/fetchReconciliationViewEpic.js +2 -1
- package/lib/view/transactionDetail/createTransaction/createTransactionPayload.d.ts +10 -6
- package/lib/view/transactionDetail/createTransaction/createTransactionPayload.js +14 -2
- package/lib/view/transactionDetail/createTransaction/createTransactionSelector.d.ts +4 -1
- package/lib/view/transactionDetail/createTransaction/createTransactionSelector.js +21 -2
- package/lib/view/transactionDetail/createTransaction/createTransactionState.d.ts +1 -1
- package/lib/zeniAPI.d.ts +2 -2
- package/package.json +1 -1
package/lib/init.js
CHANGED
|
@@ -36,9 +36,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.injectFeatureEpics = exports.injectFeatureModules = exports.store = exports.pusher = exports.initializePusher = exports.disconnectPusher = exports.zeniAPI = void 0;
|
|
39
|
+
exports.injectFeatureEpics = exports.injectFeatureModules = exports.store = exports.pusher = exports.initializePusher = exports.disconnectPusher = exports.setSessionEndpointsLoader = exports.zeniAPI = void 0;
|
|
40
40
|
exports.default = initialize;
|
|
41
41
|
exports.updateZeniAPIClientConfig = updateZeniAPIClientConfig;
|
|
42
|
+
exports.updateZeniAPIEndpoints = updateZeniAPIEndpoints;
|
|
42
43
|
exports.zeniAPIClientConfig = zeniAPIClientConfig;
|
|
43
44
|
exports.initializeWithNewStore = initializeWithNewStore;
|
|
44
45
|
exports.initialize3rdPartyExtensions = initialize3rdPartyExtensions;
|
|
@@ -47,6 +48,8 @@ const zeniAPI_1 = require("./zeniAPI");
|
|
|
47
48
|
const zeniAPIClientState_1 = require("./zeniAPIClientState");
|
|
48
49
|
var zeniAPIClientState_2 = require("./zeniAPIClientState");
|
|
49
50
|
Object.defineProperty(exports, "zeniAPI", { enumerable: true, get: function () { return zeniAPIClientState_2.zeniAPI; } });
|
|
51
|
+
var sessionEndpointsLoader_1 = require("./sessionEndpointsLoader");
|
|
52
|
+
Object.defineProperty(exports, "setSessionEndpointsLoader", { enumerable: true, get: function () { return sessionEndpointsLoader_1.setSessionEndpointsLoader; } });
|
|
50
53
|
var pusherClient_1 = require("./pusherClient");
|
|
51
54
|
Object.defineProperty(exports, "disconnectPusher", { enumerable: true, get: function () { return pusherClient_1.disconnectPusher; } });
|
|
52
55
|
Object.defineProperty(exports, "initializePusher", { enumerable: true, get: function () { return pusherClient_1.initializePusher; } });
|
|
@@ -60,11 +63,10 @@ let initialized = false;
|
|
|
60
63
|
*/
|
|
61
64
|
function initialize(restEndPoints, userId, sessionId, tenantId, isSandboxEnv, onSessionInvalidated) {
|
|
62
65
|
if (initialized) {
|
|
63
|
-
console.warn(
|
|
66
|
+
console.warn('client-epic-state is already initialized');
|
|
64
67
|
return exports.store;
|
|
65
68
|
}
|
|
66
69
|
initialized = true;
|
|
67
|
-
console.info(`initializing with ${JSON.stringify(restEndPoints)}`);
|
|
68
70
|
initialize3rdPartyExtensions();
|
|
69
71
|
(0, zeniAPIClientState_1.setZeniAPIClient)(new zeniAPI_1.ZeniAPIClient(restEndPoints, userId, sessionId, tenantId, onSessionInvalidated));
|
|
70
72
|
exports.store = (0, configureStore_1.default)(zeniAPIClientState_1.zeniAPI, isSandboxEnv);
|
|
@@ -84,6 +86,18 @@ Object.defineProperty(exports, "injectFeatureEpics", { enumerable: true, get: fu
|
|
|
84
86
|
function updateZeniAPIClientConfig(userId, sessionId, tenantId) {
|
|
85
87
|
zeniAPIClientState_1.zeniAPI.update(userId, sessionId, tenantId);
|
|
86
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Replace the REST endpoints the API client calls. Epics read the endpoints
|
|
91
|
+
* at request time, so every request made after this uses the new ones.
|
|
92
|
+
* Note: This version SHOULD BE used only in the client side.
|
|
93
|
+
* @param restEndPoints
|
|
94
|
+
*/
|
|
95
|
+
function updateZeniAPIEndpoints(restEndPoints) {
|
|
96
|
+
if (zeniAPIClientState_1.zeniAPI == null) {
|
|
97
|
+
throw new Error('Call initialize() before updateZeniAPIEndpoints()');
|
|
98
|
+
}
|
|
99
|
+
zeniAPIClientState_1.zeniAPI.apiEndPoints = restEndPoints;
|
|
100
|
+
}
|
|
87
101
|
/**
|
|
88
102
|
* Returns current Zeni REST API client config.
|
|
89
103
|
* @returns
|
|
@@ -110,7 +124,6 @@ function zeniAPIClientConfig() {
|
|
|
110
124
|
* @param tenantId tenant id
|
|
111
125
|
*/
|
|
112
126
|
async function initializeWithNewStore(restEndPoints, userId, sessionId, tenantId) {
|
|
113
|
-
console.info(`initializeWithNewStore with ${JSON.stringify(restEndPoints)}`);
|
|
114
127
|
initialize3rdPartyExtensions();
|
|
115
128
|
const zeniHttpClient = new zeniAPI_1.ZeniAPIClient(restEndPoints, userId, sessionId, tenantId);
|
|
116
129
|
const store = (0, configureStore_1.default)(zeniHttpClient, false);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Called after sign-in, before the user's tenants are fetched. The app uses it
|
|
3
|
+
* to fetch the endpoints that are only served to a signed-in session and to
|
|
4
|
+
* hand them to `updateZeniAPIEndpoints`. Without a loader, tenants are fetched
|
|
5
|
+
* straight away with the endpoints given to `initialize`.
|
|
6
|
+
*/
|
|
7
|
+
export type SessionEndpointsLoader = (userId: string, sessionId?: string) => Promise<void>;
|
|
8
|
+
export declare function setSessionEndpointsLoader(loader: SessionEndpointsLoader | undefined): void;
|
|
9
|
+
export declare function getSessionEndpointsLoader(): SessionEndpointsLoader | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setSessionEndpointsLoader = setSessionEndpointsLoader;
|
|
4
|
+
exports.getSessionEndpointsLoader = getSessionEndpointsLoader;
|
|
5
|
+
let sessionEndpointsLoader;
|
|
6
|
+
function setSessionEndpointsLoader(loader) {
|
|
7
|
+
sessionEndpointsLoader = loader;
|
|
8
|
+
}
|
|
9
|
+
function getSessionEndpointsLoader() {
|
|
10
|
+
return sessionEndpointsLoader;
|
|
11
|
+
}
|
|
@@ -29,9 +29,10 @@ const fetchReconciliationViewEpic = (actions$, state$, zeniAPI) => actions$.pipe
|
|
|
29
29
|
}
|
|
30
30
|
let fetchState;
|
|
31
31
|
if (accountId != null) {
|
|
32
|
+
// Period bucket can be unhydrated during app-shell load.
|
|
32
33
|
fetchState =
|
|
33
34
|
accountReconciliationRecords[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)]
|
|
34
|
-
|
|
35
|
+
?.reconciliationByAccountID[accountId]?.transactionFetchState
|
|
35
36
|
.fetchState;
|
|
36
37
|
}
|
|
37
38
|
else {
|
|
@@ -12,8 +12,9 @@ import { CreateTransactionLocalData } from './createTransactionState';
|
|
|
12
12
|
* 1. `line_detail_type` is snake_case. The PascalCase strings in the backend are Python
|
|
13
13
|
* constant NAMES; ZENI_LINE_DETAIL_TYPE_TO_QBO_LINE_DETAIL_TYPE_MAP converts them for the
|
|
14
14
|
* body the backend sends on to QuickBooks, never for ours.
|
|
15
|
-
* 2.
|
|
16
|
-
* `document_number
|
|
15
|
+
* 2. The QBO Purchases (check, credit_card_credit) send their reference number as
|
|
16
|
+
* `document_number`; a journal entry sends its entry name as `document_id`. Both land on
|
|
17
|
+
* QBO's DocNumber, but QBOJournalEntry reads only `document_id`.
|
|
17
18
|
*/
|
|
18
19
|
export interface CreateTransactionAccountPayload {
|
|
19
20
|
qbo_id: ID;
|
|
@@ -25,14 +26,15 @@ export interface CreateTransactionLineDetailPayload {
|
|
|
25
26
|
qbo_id: ID;
|
|
26
27
|
};
|
|
27
28
|
/**
|
|
28
|
-
* journal_entry only,
|
|
29
|
-
*
|
|
29
|
+
* journal_entry only, inside line_detail. QBOJournalEntry reads only posting_type_name; a
|
|
30
|
+
* lowercase posting_type is dropped and QBO then rejects the line.
|
|
30
31
|
*/
|
|
31
|
-
|
|
32
|
+
posting_type_name?: 'Credit' | 'Debit';
|
|
32
33
|
/** Same shape the transaction update sends on a vendor line. */
|
|
33
34
|
project?: ProjectBasePayload;
|
|
35
|
+
/** journal_entry only. The backend reads the QBO vendor id from `vendor_id`, not `qbo_id`. */
|
|
34
36
|
vendor?: {
|
|
35
|
-
|
|
37
|
+
vendor_id: ID;
|
|
36
38
|
};
|
|
37
39
|
}
|
|
38
40
|
export interface CreateTransactionLinePayload {
|
|
@@ -51,6 +53,8 @@ export interface CreateTransactionRemitToAddressPayload {
|
|
|
51
53
|
export interface CreateTransactionRequest extends Record<string, unknown> {
|
|
52
54
|
transaction_date: string;
|
|
53
55
|
transaction_type: string;
|
|
56
|
+
/** journal_entry entry name (QBO DocNumber). */
|
|
57
|
+
document_id?: string;
|
|
54
58
|
/** check / credit_card_credit reference number (QBO Purchase). */
|
|
55
59
|
document_number?: string;
|
|
56
60
|
from_account_id?: ID;
|
|
@@ -7,6 +7,10 @@ const classSelector_1 = require("../../../entity/class/classSelector");
|
|
|
7
7
|
const projectPayload_1 = require("../../../entity/project/projectPayload");
|
|
8
8
|
const projectSelector_1 = require("../../../entity/project/projectSelector");
|
|
9
9
|
const vendorSelector_1 = require("../../../entity/vendor/vendorSelector");
|
|
10
|
+
const POSTING_TYPE_NAME = {
|
|
11
|
+
credit: 'Credit',
|
|
12
|
+
debit: 'Debit',
|
|
13
|
+
};
|
|
10
14
|
const toRemitToAddressPayload = (address) => {
|
|
11
15
|
if (address == null) {
|
|
12
16
|
return undefined;
|
|
@@ -38,10 +42,12 @@ const toLinePayload = (state, line, transactionType) => {
|
|
|
38
42
|
});
|
|
39
43
|
}
|
|
40
44
|
if (transactionType === 'journal_entry') {
|
|
41
|
-
|
|
45
|
+
if (line.postingType != null) {
|
|
46
|
+
lineDetail.posting_type_name = POSTING_TYPE_NAME[line.postingType];
|
|
47
|
+
}
|
|
42
48
|
const vendorQboId = toQboLineVendorId(state, line.vendorQboId);
|
|
43
49
|
if (vendorQboId != null) {
|
|
44
|
-
lineDetail.vendor = {
|
|
50
|
+
lineDetail.vendor = { vendor_id: vendorQboId };
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
53
|
return {
|
|
@@ -132,6 +138,10 @@ const prepareCreateTransactionPayload = (state, localData) => {
|
|
|
132
138
|
if (transactionType === 'journal_entry') {
|
|
133
139
|
return {
|
|
134
140
|
...base,
|
|
141
|
+
...(localData.documentNumber != null &&
|
|
142
|
+
localData.documentNumber !== '' && {
|
|
143
|
+
document_id: localData.documentNumber,
|
|
144
|
+
}),
|
|
135
145
|
lines,
|
|
136
146
|
};
|
|
137
147
|
}
|
|
@@ -145,6 +155,8 @@ const prepareCreateTransactionPayload = (state, localData) => {
|
|
|
145
155
|
if (transactionType === 'check') {
|
|
146
156
|
return {
|
|
147
157
|
...purchaseBase,
|
|
158
|
+
// The form has no payment method field for a check; qbo_purchase.py still requires it.
|
|
159
|
+
payment_type: 'check',
|
|
148
160
|
document_number: localData.documentNumber,
|
|
149
161
|
print_status: localData.printStatus,
|
|
150
162
|
remit_to_address: toRemitToAddressPayload(localData.remitToAddress),
|
|
@@ -22,7 +22,10 @@ export interface CreateTransactionView extends SelectorView {
|
|
|
22
22
|
lineAccountListFetchState: FetchState;
|
|
23
23
|
localData: CreateTransactionLocalData;
|
|
24
24
|
paymentAccountListFetchState: FetchState;
|
|
25
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Bank, credit card and other current asset accounts for the header payment account; bank
|
|
27
|
+
* accounts only for a check.
|
|
28
|
+
*/
|
|
26
29
|
paymentAccountListNestedAccountHierarchy: NestedAccountHierarchyForReport[];
|
|
27
30
|
transactionType: CreatableTransactionType;
|
|
28
31
|
/** Populated for transfer only; the COA would offer ineligible accounts. */
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCreateTransactionView = exports.getCreateTransactionVendorRecommendations = exports.getCreateTransactionStatus = exports.getCreateTransactionLocalData = void 0;
|
|
4
4
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
5
|
+
const accountSelector_1 = require("../../../entity/account/accountSelector");
|
|
5
6
|
const accountListSelector_1 = require("../../accountList/accountListSelector");
|
|
6
7
|
const classListSelector_1 = require("../../classList/classListSelector");
|
|
7
8
|
const createTransferEntrySelector_1 = require("../../createTransferEntry/createTransferEntrySelector");
|
|
@@ -28,6 +29,23 @@ const getCreateTransactionVendorRecommendations = (state, vendorQboId) => {
|
|
|
28
29
|
};
|
|
29
30
|
};
|
|
30
31
|
exports.getCreateTransactionVendorRecommendations = getCreateTransactionVendorRecommendations;
|
|
32
|
+
/**
|
|
33
|
+
* QBO sub-accounts share their parent's type, so filtering the root nodes keeps whole subtrees.
|
|
34
|
+
*
|
|
35
|
+
* Memoized on its own: createTransactionsState changes on every keystroke, which re-runs the view
|
|
36
|
+
* projection, and the filter would otherwise hand the dropdown a new array each time.
|
|
37
|
+
*/
|
|
38
|
+
const getPaymentAccountListNestedAccountHierarchy = (0, toolkit_1.createSelector)([
|
|
39
|
+
(state) => (0, accountListSelector_1.getNestedAccountListHierarchy)(state.accountListState, 'createTransactionPaymentAccountList'),
|
|
40
|
+
(state) => state.accountState,
|
|
41
|
+
(_state, transactionType) => transactionType,
|
|
42
|
+
], (hierarchy, accountState, transactionType) => {
|
|
43
|
+
if (transactionType !== 'check') {
|
|
44
|
+
return hierarchy;
|
|
45
|
+
}
|
|
46
|
+
return hierarchy.filter((node) => (0, accountSelector_1.getAccountBase)(accountState, node.accountId[0], 'account_list')
|
|
47
|
+
?.accountType === 'bank');
|
|
48
|
+
});
|
|
31
49
|
/**
|
|
32
50
|
* Memoized: app-ui reads this straight from useSelector, and the vendor list and hierarchies are
|
|
33
51
|
* rebuilt on every call, so an unmemoized version re-renders the page on every store action.
|
|
@@ -36,10 +54,11 @@ exports.getCreateTransactionView = (0, toolkit_1.createSelector)([
|
|
|
36
54
|
(state) => state.transactionDetailState.createTransactionsState,
|
|
37
55
|
(state) => state.vendorState.vendorByID,
|
|
38
56
|
(state) => state.accountListState,
|
|
57
|
+
getPaymentAccountListNestedAccountHierarchy,
|
|
39
58
|
(state) => state.classListState,
|
|
40
59
|
(state) => (0, createTransferEntrySelector_1.getResolvedTransferAccounts)(state).transferAccountsList,
|
|
41
60
|
(_state, transactionType) => transactionType,
|
|
42
|
-
], (createTransactionsState, vendorByID, accountListState, classListState, transferAccountsList, transactionType) => ({
|
|
61
|
+
], (createTransactionsState, vendorByID, accountListState, paymentAccountListNestedAccountHierarchy, classListState, transferAccountsList, transactionType) => ({
|
|
43
62
|
transactionType,
|
|
44
63
|
localData: createTransactionsState.newTransactionState[transactionType],
|
|
45
64
|
createStatus: createTransactionsState.createStatus,
|
|
@@ -49,7 +68,7 @@ exports.getCreateTransactionView = (0, toolkit_1.createSelector)([
|
|
|
49
68
|
lineAccountListFetchState: (0, accountListSelector_1.getAccountListFetchState)(accountListState, 'createTransactionLineAccountList'),
|
|
50
69
|
paymentAccountListFetchState: (0, accountListSelector_1.getAccountListFetchState)(accountListState, 'createTransactionPaymentAccountList'),
|
|
51
70
|
accountListNestedAccountHierarchy: (0, accountListSelector_1.getNestedAccountListHierarchy)(accountListState, 'createTransactionLineAccountList'),
|
|
52
|
-
paymentAccountListNestedAccountHierarchy
|
|
71
|
+
paymentAccountListNestedAccountHierarchy,
|
|
53
72
|
classListNestedAccountHierarchy: (0, classListSelector_1.getNestedClassListHierarchy)(classListState),
|
|
54
73
|
transferAccountsList: transactionType === 'transfer' ? transferAccountsList : [],
|
|
55
74
|
fetchState: createTransactionsState.createStatus.fetchState,
|
|
@@ -54,7 +54,7 @@ export interface CreateTransactionLocalData {
|
|
|
54
54
|
/** Empty for transfer, which has no lines at all. */
|
|
55
55
|
lines: CreateTransactionLineLocalData[];
|
|
56
56
|
transactionType: CreatableTransactionType;
|
|
57
|
-
/** check / credit_card_credit reference number. */
|
|
57
|
+
/** check / credit_card_credit reference number, or the journal_entry entry name. */
|
|
58
58
|
documentNumber?: string;
|
|
59
59
|
/** transfer */
|
|
60
60
|
fromAccountId?: ID;
|
package/lib/zeniAPI.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export interface RESTAPIEndpoints {
|
|
|
25
25
|
readonly tenantMicroServiceBaseUrl: string;
|
|
26
26
|
}
|
|
27
27
|
export interface ZeniAPI<ResponseType = FetchResponse> {
|
|
28
|
-
|
|
28
|
+
apiEndPoints: RESTAPIEndpoints;
|
|
29
29
|
readonly sessionId?: string;
|
|
30
30
|
readonly tenantId?: string;
|
|
31
31
|
readonly userId?: string;
|
|
@@ -40,7 +40,7 @@ export interface ZeniAPI<ResponseType = FetchResponse> {
|
|
|
40
40
|
update(userId?: string, sessionId?: string, tenantId?: string): void;
|
|
41
41
|
}
|
|
42
42
|
export declare class ZeniAPIClient implements ZeniAPI {
|
|
43
|
-
|
|
43
|
+
apiEndPoints: RESTAPIEndpoints;
|
|
44
44
|
userId?: string | undefined;
|
|
45
45
|
sessionId?: string | undefined;
|
|
46
46
|
tenantId?: string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.8",
|
|
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",
|