@zeniai/client-epic-state 5.3.20 → 5.3.21-beta0KB
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/genericEntity/customerWithSubCustomersId.d.ts +7 -0
- package/lib/entity/genericEntity/customerWithSubCustomersId.js +17 -0
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +1 -0
- package/lib/entity/tenant/epic/fetchAllTenantsEpic.js +6 -4
- package/lib/entity/tenant/tenantPayload.d.ts +6 -0
- package/lib/entity/tenant/tenantPayload.js +5 -0
- package/lib/entity/tenant/tenantReducer.d.ts +6 -2
- package/lib/entity/tenant/tenantReducer.js +32 -5
- package/lib/entity/tenant/tenantSelector.d.ts +2 -1
- package/lib/entity/tenant/tenantSelector.js +4 -1
- package/lib/entity/tenant/tenantState.d.ts +10 -0
- package/lib/entity/tenant/tenantState.js +5 -0
- package/lib/epic.d.ts +2 -1
- package/lib/epic.js +2 -0
- package/lib/esm/entity/genericEntity/customerWithSubCustomersId.js +12 -0
- package/lib/esm/entity/snackbar/snackbarTypes.js +1 -0
- package/lib/esm/entity/tenant/epic/fetchAllTenantsEpic.js +6 -4
- package/lib/esm/entity/tenant/tenantPayload.js +4 -1
- package/lib/esm/entity/tenant/tenantReducer.js +31 -4
- package/lib/esm/entity/tenant/tenantSelector.js +2 -0
- package/lib/esm/entity/tenant/tenantState.js +4 -1
- package/lib/esm/epic.js +2 -0
- package/lib/esm/index.js +7 -6
- package/lib/esm/view/companyView/companyViewReducer.js +26 -1
- package/lib/esm/view/companyView/epic/companyPassport/updateCustomersTabSettingEpic.js +47 -0
- package/lib/esm/view/companyView/selector/companyPassportViewSelector.js +2 -0
- package/lib/esm/view/companyView/types/companyPassport/companyPassportViewState.js +4 -0
- package/lib/esm/view/customerSummaryView/customerSummaryViewReducer.js +39 -6
- package/lib/esm/view/customerSummaryView/customerSummaryViewSelector.js +41 -11
- package/lib/esm/view/customerSummaryView/epic/fetchCustomerSummaryListEpic.js +6 -1
- package/lib/esm/view/transactionDetail/createTransaction/epics/createTransactionEpic.js +1 -5
- package/lib/esm/view/transactionList/fetchTransactionListByEntityEpic.js +11 -2
- package/lib/esm/view/transactionList/transactionListReducer.js +24 -15
- package/lib/esm/view/trend/fetchIncomeTrendEpic.js +6 -2
- package/lib/index.d.ts +9 -8
- package/lib/index.js +53 -46
- package/lib/view/companyView/companyViewReducer.d.ts +8 -1
- package/lib/view/companyView/companyViewReducer.js +28 -3
- package/lib/view/companyView/epic/companyPassport/updateCustomersTabSettingEpic.d.ts +11 -0
- package/lib/view/companyView/epic/companyPassport/updateCustomersTabSettingEpic.js +51 -0
- package/lib/view/companyView/selector/companyPassportViewSelector.d.ts +1 -0
- package/lib/view/companyView/selector/companyPassportViewSelector.js +4 -1
- package/lib/view/companyView/types/companyPassport/companyPassportViewState.d.ts +1 -0
- package/lib/view/companyView/types/companyPassport/companyPassportViewState.js +4 -0
- package/lib/view/customerSummaryView/customerSummaryViewPayload.d.ts +20 -1
- package/lib/view/customerSummaryView/customerSummaryViewReducer.d.ts +3 -1
- package/lib/view/customerSummaryView/customerSummaryViewReducer.js +42 -6
- package/lib/view/customerSummaryView/customerSummaryViewSelector.d.ts +13 -1
- package/lib/view/customerSummaryView/customerSummaryViewSelector.js +45 -12
- package/lib/view/customerSummaryView/customerSummaryViewState.d.ts +24 -10
- package/lib/view/customerSummaryView/epic/fetchCustomerSummaryListEpic.js +6 -1
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/transactionDetail/createTransaction/epics/createTransactionEpic.js +1 -5
- package/lib/view/transactionList/fetchTransactionListByEntityEpic.js +11 -2
- package/lib/view/transactionList/transactionListReducer.d.ts +3 -1
- package/lib/view/transactionList/transactionListReducer.js +24 -15
- package/lib/view/trend/fetchIncomeTrendEpic.js +6 -2
- package/package.json +1 -1
|
@@ -55,15 +55,11 @@ const createTransactionEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, o
|
|
|
55
55
|
// the working copy on unmount instead.
|
|
56
56
|
// Before the local-data init: it seeds the detail entry that init writes into.
|
|
57
57
|
(0, transactionDetailReducer_1.createTransactionSuccessOrFailure)('Completed', newTransactionId),
|
|
58
|
+
// No success snackbar here: the screen raises it once pending attachments upload.
|
|
58
59
|
(0, transactionDetailReducer_1.initializeTransactionDetailLocalData)({
|
|
59
60
|
transactionId: newTransactionId,
|
|
60
61
|
vendorId: created.vendor_id ?? undefined,
|
|
61
62
|
}),
|
|
62
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
63
|
-
messageSection: 'create_transaction',
|
|
64
|
-
messageText: 'success',
|
|
65
|
-
type: 'success',
|
|
66
|
-
}),
|
|
67
63
|
]);
|
|
68
64
|
}), (0, operators_1.catchError)((error) => {
|
|
69
65
|
const message = error instanceof createTransactionPayload_1.UnresolvedCreateTransactionIdError
|
|
@@ -8,6 +8,7 @@ const get_1 = __importDefault(require("lodash/get"));
|
|
|
8
8
|
const rxjs_1 = require("rxjs");
|
|
9
9
|
const operators_1 = require("rxjs/operators");
|
|
10
10
|
const timePeriod_1 = require("../../commonStateTypes/timePeriod");
|
|
11
|
+
const customerWithSubCustomersId_1 = require("../../entity/genericEntity/customerWithSubCustomersId");
|
|
11
12
|
const transactionReducer_1 = require("../../entity/transaction/transactionReducer");
|
|
12
13
|
const responsePayload_1 = require("../../responsePayload");
|
|
13
14
|
const transactionListReducer_1 = require("./transactionListReducer");
|
|
@@ -19,12 +20,20 @@ const fetchTransactionListByEntityEpic = (actions$, state$, zeniAPI) => actions$
|
|
|
19
20
|
if (action.payload.cacheOverride === true ||
|
|
20
21
|
entityTransactions == null ||
|
|
21
22
|
entityTransactions.hasValidState() === false) {
|
|
23
|
+
// Customers tab rolled-up view: cached under its own id, sent as the customer id plus the flag
|
|
24
|
+
const { customerId: entityId, includeSubCustomers } = action.payload.entity.type === 'customer'
|
|
25
|
+
? (0, customerWithSubCustomersId_1.fromCustomerEntityId)(action.payload.entity.id)
|
|
26
|
+
: {
|
|
27
|
+
customerId: action.payload.entity.id,
|
|
28
|
+
includeSubCustomers: false,
|
|
29
|
+
};
|
|
22
30
|
const queryParam = {
|
|
23
31
|
start_date: (0, timePeriod_1.toString)(action.payload.period.start),
|
|
24
32
|
end_date: (0, timePeriod_1.toString)(action.payload.period.end),
|
|
25
33
|
sort_by: 'create_time',
|
|
26
34
|
sort_order: 'desc',
|
|
27
|
-
entity_id:
|
|
35
|
+
entity_id: entityId,
|
|
36
|
+
...(includeSubCustomers ? { include_sub_customers: true } : {}),
|
|
28
37
|
entity_name: action.payload.entity.name,
|
|
29
38
|
entity_type: action.payload.entity.type,
|
|
30
39
|
is_fetch_all_transactions: action.payload.isFetchAllTransactions === true
|
|
@@ -37,7 +46,7 @@ const fetchTransactionListByEntityEpic = (actions$, state$, zeniAPI) => actions$
|
|
|
37
46
|
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
38
47
|
const updateActions = [];
|
|
39
48
|
updateActions.push((0, transactionReducer_1.updateTransactions)(response.data.transactions, (value) => value.transaction_id));
|
|
40
|
-
updateActions.push((0, transactionListReducer_1.updateTransactionListByEntity)(response.data));
|
|
49
|
+
updateActions.push((0, transactionListReducer_1.updateTransactionListByEntity)(response.data, action.payload.entity.id));
|
|
41
50
|
return (0, rxjs_1.from)(updateActions);
|
|
42
51
|
}
|
|
43
52
|
else {
|
|
@@ -38,7 +38,9 @@ export declare const parallelFetchAccountTransactionList: import("@reduxjs/toolk
|
|
|
38
38
|
period: TimePeriod;
|
|
39
39
|
cacheOverride: any;
|
|
40
40
|
isFetchAllTransactions: any;
|
|
41
|
-
}, "transactionList/fetchEntityTransactionList", never, never>, updateTransactionListByEntity: import("@reduxjs/toolkit").
|
|
41
|
+
}, "transactionList/fetchEntityTransactionList", never, never>, updateTransactionListByEntity: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: TransactionListByEntityPayload, entityId?: string | undefined], TransactionListByEntityPayload, "transactionList/updateTransactionListByEntity", never, {
|
|
42
|
+
entityId: string | undefined;
|
|
43
|
+
}>, updateTransactionListByEntityFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[entity: Entity, period: TimePeriod, error: ZeniAPIStatus<Record<string, unknown>>], {
|
|
42
44
|
entity: Entity;
|
|
43
45
|
period: TimePeriod;
|
|
44
46
|
error: ZeniAPIStatus<Record<string, unknown>>;
|
|
@@ -168,21 +168,30 @@ const transactionList = (0, toolkit_1.createSlice)({
|
|
|
168
168
|
};
|
|
169
169
|
},
|
|
170
170
|
},
|
|
171
|
-
updateTransactionListByEntity
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
171
|
+
updateTransactionListByEntity: {
|
|
172
|
+
// `entityId`: the requested entity's id when it differs from the query's (a rolled-up customer)
|
|
173
|
+
prepare(payload, entityId) {
|
|
174
|
+
return { payload, meta: { entityId } };
|
|
175
|
+
},
|
|
176
|
+
reducer(draft, action) {
|
|
177
|
+
const transactionIDs = action.payload.transactions.map((transactionPayload) => transactionPayload.transaction_id);
|
|
178
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
179
|
+
const entity = {
|
|
180
|
+
...mapTransactionQueryMetaDataToEntity(action.payload.query),
|
|
181
|
+
...(action.meta.entityId != null && { id: action.meta.entityId }),
|
|
182
|
+
};
|
|
183
|
+
const key = (0, transactionListState_1.getEntityTranKey)(entity, {
|
|
184
|
+
start: (0, timePeriod_1.toAbsoluteDay)(action.payload.query.start_date),
|
|
185
|
+
end: (0, timePeriod_1.toAbsoluteDay)(action.payload.query.end_date),
|
|
186
|
+
});
|
|
187
|
+
draft.byEntity.transactionListByEntityKey[key] = {
|
|
188
|
+
...transactionListState_1.initialEntityTransactionState,
|
|
189
|
+
fetchState: 'Completed',
|
|
190
|
+
error: undefined,
|
|
191
|
+
entity: entity,
|
|
192
|
+
transactionIDs,
|
|
193
|
+
};
|
|
194
|
+
},
|
|
186
195
|
},
|
|
187
196
|
updateTransactionListByEntityFailure: {
|
|
188
197
|
reducer(draft, action) {
|
|
@@ -6,6 +6,7 @@ const operators_1 = require("rxjs/operators");
|
|
|
6
6
|
const timeframeTick_1 = require("../../commonStateTypes/timeframeTick");
|
|
7
7
|
const customerIncomeTrendKey_1 = require("../../entity/customerIncome/customerIncomeTrendKey");
|
|
8
8
|
const customerIncomeTrendReducer_1 = require("../../entity/customerIncome/customerIncomeTrendReducer");
|
|
9
|
+
const customerWithSubCustomersId_1 = require("../../entity/genericEntity/customerWithSubCustomersId");
|
|
9
10
|
const responsePayload_1 = require("../../responsePayload");
|
|
10
11
|
const zeniDayJS_1 = require("../../zeniDayJS");
|
|
11
12
|
const trendReducer_1 = require("./trendReducer");
|
|
@@ -28,11 +29,14 @@ const fetchIncomeTrendEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, op
|
|
|
28
29
|
return (0, rxjs_1.of)((0, trendReducer_1.updateTrendSuccess)(requestedPeriod));
|
|
29
30
|
}
|
|
30
31
|
}
|
|
32
|
+
// The rolled-up view is cached under its own id; the API takes the customer id plus the flag
|
|
33
|
+
const { customerId: apiCustomerId, includeSubCustomers } = (0, customerWithSubCustomersId_1.fromCustomerEntityId)(customerId);
|
|
31
34
|
const query = {
|
|
32
|
-
entity_id:
|
|
35
|
+
entity_id: apiCustomerId,
|
|
33
36
|
entity_type: 'customer',
|
|
34
|
-
customer_id:
|
|
37
|
+
customer_id: apiCustomerId,
|
|
35
38
|
customer_name: customerName,
|
|
39
|
+
...(includeSubCustomers ? { include_sub_customers: true } : {}),
|
|
36
40
|
...(dateRange != null
|
|
37
41
|
? { start_date: dateRange.startDate, end_date: dateRange.endDate }
|
|
38
42
|
: {}),
|
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.21-beta0KB",
|
|
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",
|