@zeniai/client-epic-state 5.0.44-betaML1 → 5.0.44-betaRD1
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/commonStateTypes/viewAndReport/viewAndReport.d.ts +2 -2
- package/lib/commonStateTypes/viewAndReport/viewAndReport.js +1 -0
- package/lib/entity/account/accountState.d.ts +1 -1
- package/lib/entity/accountGroup/accountGroupState.d.ts +1 -1
- package/lib/entity/class/classReducer.d.ts +4 -4
- package/lib/entity/class/classState.d.ts +1 -1
- package/lib/entity/forecast/forecastState.d.ts +1 -1
- package/lib/entity/sectionAccountsView/sectionAccountsView.d.ts +1 -1
- package/lib/entity/sectionClassesViewV2/sectionClassesView.d.ts +1 -1
- package/lib/entity/sectionClassesViewV2/sectionClassesViewReducer.d.ts +2 -2
- package/lib/entity/sectionProjectView/sectionProjectView.d.ts +1 -1
- package/lib/entity/sectionProjectView/sectionProjectViewReducer.d.ts +2 -2
- package/lib/entity/transaction/stateTypes/transactionType.d.ts +0 -1
- package/lib/entity/transaction/stateTypes/transactionType.js +1 -3
- package/lib/epic.d.ts +3 -1
- package/lib/epic.js +3 -1
- package/lib/esm/commonStateTypes/viewAndReport/viewAndReport.js +1 -0
- package/lib/esm/entity/transaction/stateTypes/transactionType.js +0 -1
- package/lib/esm/epic.js +3 -1
- package/lib/esm/index.js +6 -5
- package/lib/esm/view/transactionList/fetchTransactionListByProjectEpic.js +45 -0
- package/lib/esm/view/transactionList/parallelFetchProjectTransactionListEpic.js +32 -0
- package/lib/esm/view/transactionList/transactionListByProjectSelector.js +58 -0
- package/lib/esm/view/transactionList/transactionListReducer.js +83 -2
- package/lib/esm/view/transactionList/transactionListState.js +10 -0
- package/lib/index.d.ts +6 -5
- package/lib/index.js +30 -25
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
- package/lib/view/auditReportView/auditReportViewState.d.ts +1 -1
- package/lib/view/billPayCard/billPayCardSelector.d.ts +1 -1
- package/lib/view/cardBalance/cardBalanceSelector.d.ts +1 -1
- package/lib/view/cashBalance/cashBalanceSelector.d.ts +1 -1
- package/lib/view/cashInCashOut/cashInCashOutSelector.d.ts +1 -1
- package/lib/view/cashPosition/cashPositionSelector.d.ts +1 -1
- package/lib/view/dashboard/dashboardReducer.d.ts +2 -2
- package/lib/view/financeStatement/financeStatementReducer.d.ts +1 -1
- package/lib/view/globalMerchantView/globalMerchantViewReducer.d.ts +2 -2
- package/lib/view/reimbursementCard/reimbursementCardSelector.d.ts +1 -1
- package/lib/view/reportsResync/reportsResyncReducer.d.ts +2 -2
- package/lib/view/tasksCard/tasksCardSelector.d.ts +1 -1
- package/lib/view/topEx/topExSelector.d.ts +1 -1
- package/lib/view/transactionList/fetchTransactionListByProjectEpic.d.ts +8 -0
- package/lib/view/transactionList/fetchTransactionListByProjectEpic.js +52 -0
- package/lib/view/transactionList/parallelFetchProjectTransactionListEpic.d.ts +6 -0
- package/lib/view/transactionList/parallelFetchProjectTransactionListEpic.js +36 -0
- package/lib/view/transactionList/transactionListByProjectSelector.d.ts +22 -0
- package/lib/view/transactionList/transactionListByProjectSelector.js +66 -0
- package/lib/view/transactionList/transactionListPayload.d.ts +15 -0
- package/lib/view/transactionList/transactionListReducer.d.ts +25 -2
- package/lib/view/transactionList/transactionListReducer.js +83 -2
- package/lib/view/transactionList/transactionListState.d.ts +15 -0
- package/lib/view/transactionList/transactionListState.js +13 -1
- package/package.json +1 -1
package/lib/esm/index.js
CHANGED
|
@@ -67,7 +67,7 @@ import { mapFileEntityToAttachment, toContentType, toContentTypeStrict, } from '
|
|
|
67
67
|
import { isCustomerTransaction, } from './entity/transaction/stateTypes/customerTransaction';
|
|
68
68
|
import { isTransferTransaction, } from './entity/transaction/stateTypes/otherTransaction';
|
|
69
69
|
import { toPlatformLineDetailType, } from './entity/transaction/stateTypes/transactionLine';
|
|
70
|
-
import {
|
|
70
|
+
import { toTransactionCategory, toTransactionType, toTransactionTypeStrict, } from './entity/transaction/stateTypes/transactionType';
|
|
71
71
|
import { isVendorTransaction, isVendorTransactionWithCustomer, } from './entity/transaction/stateTypes/vendorTransaction';
|
|
72
72
|
import { getSupportedTransactionById } from './entity/transaction/transactionSelector';
|
|
73
73
|
import { getUserRoleByUserId, getUserRoleByUserIds, } from './entity/userRole/userRoleSelector';
|
|
@@ -381,8 +381,9 @@ import { getThirdPartyIdFromTransactionId, } from './view/transactionDetail/tran
|
|
|
381
381
|
import { getTransactionListByAccount, getTransactionListUIStateByAccountKey, } from './view/transactionList/transactionListByAccountSelector';
|
|
382
382
|
import { getTransactionListUIStateByCategoryType, getTransactionsListByCategoryType, } from './view/transactionList/transactionListByCategoryTypeSelector';
|
|
383
383
|
import { getTransactionListByClass, getTransactionListUIStateByClassKey, } from './view/transactionList/transactionListByClassSelector';
|
|
384
|
+
import { getTransactionListByProject, getTransactionListUIStateByProjectKey, } from './view/transactionList/transactionListByProjectSelector';
|
|
384
385
|
import { getTransactionListByEntity, getTransactionListByEntityForSinglePeriod, } from './view/transactionList/transactionListByEntitySelector';
|
|
385
|
-
import { clearTransactionList, fetchAccountTransactionList, fetchEntityTransactionList, parallelFetchAccountTransactionList, parallelFetchClassTransactionList, parallelFetchEntityTransactionList, parallelFetchTransactionListByCategoryType, updateLatestTransactionId, updateTransactionListByAccount, updateTransactionListByAccountFailure, updateTransactionListByAccountUIState, updateTransactionListByClass, updateTransactionListByClassUIState, updateTransactionListByEntity, updateTransactionListByEntityFailure, updateTransactionListUIStateByCategoryType, } from './view/transactionList/transactionListReducer';
|
|
386
|
+
import { clearTransactionList, fetchAccountTransactionList, fetchEntityTransactionList, parallelFetchAccountTransactionList, parallelFetchClassTransactionList, parallelFetchProjectTransactionList, parallelFetchEntityTransactionList, parallelFetchTransactionListByCategoryType, updateLatestTransactionId, updateTransactionListByAccount, updateTransactionListByAccountFailure, updateTransactionListByAccountUIState, updateTransactionListByClass, updateTransactionListByClassUIState, updateTransactionListByProject, updateTransactionListByProjectUIState, updateTransactionListByEntity, updateTransactionListByEntityFailure, updateTransactionListUIStateByCategoryType, } from './view/transactionList/transactionListReducer';
|
|
386
387
|
import { clearTrendData, fetchExpenseTrend, fetchIncomeTrend, } from './view/trend/trendReducer';
|
|
387
388
|
import { getCurrentFiscalQuarterDateRange, getTrendForEntity, } from './view/trend/trendSelector';
|
|
388
389
|
import { clearTrendWithTransactions, fetchTransactionsForEntity, fetchTrendForEntity, updateSelectedTimeperiod, } from './view/trendWithTransactions/trendWithTransactionsReducer';
|
|
@@ -486,17 +487,17 @@ export { defaultCustomerCurrency };
|
|
|
486
487
|
export { isCustomerTransaction };
|
|
487
488
|
export { toTransactionID, } from './entity/transaction/payloadTypes/transactionIDPayload';
|
|
488
489
|
export { toPlatformLineDetailType, };
|
|
489
|
-
export { toTransactionType, toTransactionTypeStrict, toTransactionCategory,
|
|
490
|
+
export { toTransactionType, toTransactionTypeStrict, toTransactionCategory, };
|
|
490
491
|
export { defaultVendorCurrency, updateVendors };
|
|
491
492
|
export { isVendorTransaction, isVendorTransactionWithCustomer, };
|
|
492
493
|
export { isTransferTransaction };
|
|
493
494
|
export { getSupportedTransactionById, };
|
|
494
|
-
export { clearTransactionList, updateLatestTransactionId, parallelFetchAccountTransactionList, parallelFetchEntityTransactionList, fetchAccountTransactionList, updateTransactionListByAccount, updateTransactionListByAccountFailure, updateTransactionListByAccountUIState, parallelFetchClassTransactionList, updateTransactionListByClassUIState, updateTransactionListByClass, updateTransactionListUIStateByCategoryType, parallelFetchTransactionListByCategoryType, };
|
|
495
|
+
export { clearTransactionList, updateLatestTransactionId, parallelFetchAccountTransactionList, parallelFetchEntityTransactionList, fetchAccountTransactionList, updateTransactionListByAccount, updateTransactionListByAccountFailure, updateTransactionListByAccountUIState, parallelFetchClassTransactionList, updateTransactionListByClassUIState, updateTransactionListByClass, parallelFetchProjectTransactionList, updateTransactionListByProjectUIState, updateTransactionListByProject, updateTransactionListUIStateByCategoryType, parallelFetchTransactionListByCategoryType, };
|
|
495
496
|
export { getTransactionListByAccount, getTransactionListUIStateByAccountKey, };
|
|
496
497
|
export { fetchEntityTransactionList, updateTransactionListByEntity, saveTransactionDetailLocalData, clearTransactionDetailSaveStatus, updateTransactionListByEntityFailure, resetLineItemsCategoryClassInLocalData, setAllLineItemsToCategoryClassInLocalData, saveTransactionDetail, setAllLineItemsLocalDataIsUpdateAllChecked, initializeTransactionDetailLocalData, removeEntityRecommendationForLineIdForTransactionDetail, updateSelectedVendor, updateSelectedCustomer, resetSelectedCustomer, resetVendor, updateLocalDataWithTransactionsUpdateWithVendorCheckbox, updateVendorToAllLineItems, resetAllLineItemsToVendor, updateLatestSelectedEntity, updateVendorBulkRecommendationsFetchStatus, setIsVendorUpdateAllChecked, };
|
|
497
498
|
export { downloadAccountingProviderAttachment, downloadAccountingProviderAttachmentSuccess, downloadAccountingProviderAttachmentFailure, fetchTransactionDetail, updateTransactionDetail, uploadMissingAttachmentSuccess, deleteTransactionAttachment, getThirdPartyIdFromTransactionId, };
|
|
498
499
|
export { getTransactionListByEntity };
|
|
499
|
-
export { getTransactionListByClass, getTransactionListUIStateByClassKey, getTransactionListByEntityForSinglePeriod, };
|
|
500
|
+
export { getTransactionListByClass, getTransactionListUIStateByClassKey, getTransactionListByProject, getTransactionListUIStateByProjectKey, getTransactionListByEntityForSinglePeriod, };
|
|
500
501
|
export { getTransactionDetail, getTransactionDetailForTransaction, getInitialUpdatablePeriodsForTransactionRecommendations as getUpdatablePeriodsForTransactionRecommendations, };
|
|
501
502
|
export { getInsights, fetchInsightsCard, updateSelectedInsightIndex, };
|
|
502
503
|
export { fetchForecastList } from './view/forecastList/forecastListReducer';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { toBase64 } from 'js-base64';
|
|
2
|
+
import lodashGet from 'lodash/get';
|
|
3
|
+
import { from, of } from 'rxjs';
|
|
4
|
+
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
5
|
+
import { toString } from '../../commonStateTypes/timePeriod';
|
|
6
|
+
import { updateTransactions } from '../../entity/transaction/transactionReducer';
|
|
7
|
+
import { createZeniAPIStatus, isSuccessResponse } from '../../responsePayload';
|
|
8
|
+
import { fetchProjectTransactionList, updateTransactionListByProject, updateTransactionListByProjectFailure, } from './transactionListReducer';
|
|
9
|
+
import { getProjectAcTranKey } from './transactionListState';
|
|
10
|
+
export const fetchTransactionListByProjectEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchProjectTransactionList.match), mergeMap((action) => {
|
|
11
|
+
const state = state$.value;
|
|
12
|
+
const key = getProjectAcTranKey(action.payload.accountId, action.payload.accountType, action.payload.projectId, action.payload.period);
|
|
13
|
+
const projectTransactions = lodashGet(state.transactionListState.byProject.transactionListByProjectKey, key, undefined);
|
|
14
|
+
if (action.payload.cacheOverride === true ||
|
|
15
|
+
projectTransactions == null ||
|
|
16
|
+
projectTransactions.hasValidState() === false) {
|
|
17
|
+
const queryParam = {
|
|
18
|
+
start_date: toString(action.payload.period.start),
|
|
19
|
+
end_date: toString(action.payload.period.end),
|
|
20
|
+
sort_by: 'create_time',
|
|
21
|
+
sort_order: 'desc',
|
|
22
|
+
account_id: action.payload.accountId,
|
|
23
|
+
account_type: action.payload.accountType,
|
|
24
|
+
zeni_project_id: action.payload.projectId,
|
|
25
|
+
};
|
|
26
|
+
const base64AccountId = toBase64(action.payload.accountId);
|
|
27
|
+
return zeniAPI
|
|
28
|
+
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts/${base64AccountId}/transactions?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
29
|
+
.pipe(mergeMap((response) => {
|
|
30
|
+
if (isSuccessResponse(response) && response.data != null) {
|
|
31
|
+
const updateActions = [];
|
|
32
|
+
updateActions.push(updateTransactions(response.data.account.transactions, (value) => value.transaction_id));
|
|
33
|
+
updateActions.push(updateTransactionListByProject(response.data));
|
|
34
|
+
return from(updateActions);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
return of(updateTransactionListByProjectFailure(action.payload.accountId, action.payload.accountType, action.payload.projectId, action.payload.period, response.status));
|
|
38
|
+
}
|
|
39
|
+
}), catchError((error) => of(updateTransactionListByProjectFailure(action.payload.accountId, action.payload.accountType, action.payload.projectId, action.payload.period, createZeniAPIStatus('Unexpected Error', 'fetch transaction list REST API call errored out' +
|
|
40
|
+
JSON.stringify(error))))));
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return from([]);
|
|
44
|
+
}
|
|
45
|
+
}));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { from } from 'rxjs';
|
|
2
|
+
import { filter, mergeMap } from 'rxjs/operators';
|
|
3
|
+
import { splitPeriod } from './parallelFetchClassTransactionListEpic';
|
|
4
|
+
import { fetchProjectTransactionList, parallelFetchProjectTransactionList, } from './transactionListReducer';
|
|
5
|
+
import { getProjectAcTranKey, } from './transactionListState';
|
|
6
|
+
export const parallelFetchProjectTransactionListEpic = (actions$, state$) => actions$.pipe(filter(parallelFetchProjectTransactionList.match), mergeMap((action) => {
|
|
7
|
+
const state = state$.value.transactionListState;
|
|
8
|
+
const timePeriods = splitPeriod(action.payload.period);
|
|
9
|
+
const filteredTimePeriods = timePeriods.filter((value) => {
|
|
10
|
+
if (action.payload.cacheOverride === false) {
|
|
11
|
+
return (isDataAvailableOrFetching(state.byProject, action.payload.accountId, action.payload.accountType, action.payload.projectId, value) === false);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
if (filteredTimePeriods.length > 12) {
|
|
18
|
+
console.error('Only maximum 12 parallel fetch are allowed!');
|
|
19
|
+
return from([]);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const fetchActions = filteredTimePeriods.map((period) => fetchProjectTransactionList(action.payload.accountId, action.payload.accountType, action.payload.projectId, period, true));
|
|
23
|
+
return from(fetchActions);
|
|
24
|
+
}
|
|
25
|
+
}));
|
|
26
|
+
function isDataAvailableOrFetching(state, accountId, accountType, projectId, period) {
|
|
27
|
+
const key = getProjectAcTranKey(accountId, accountType, projectId, period);
|
|
28
|
+
const projectTransactions = state.transactionListByProjectKey[key];
|
|
29
|
+
return (projectTransactions != null &&
|
|
30
|
+
(projectTransactions.fetchState === 'In-Progress' ||
|
|
31
|
+
projectTransactions.hasValidState()));
|
|
32
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import flatMap from 'lodash/flatMap';
|
|
2
|
+
import recordGet from 'lodash/get';
|
|
3
|
+
import orderBy from 'lodash/orderBy';
|
|
4
|
+
import { getSupportedTransactionById } from '../../entity/transaction/transactionSelector';
|
|
5
|
+
import { splitPeriod } from './parallelFetchAccountTransactionListEpic';
|
|
6
|
+
import { isAnyFetchCompleted, reduceFetchState, } from './reduceTransactionListFetchState';
|
|
7
|
+
import { getProjectAcKey, getProjectAcTranKey, } from './transactionListState';
|
|
8
|
+
export const getTransactionListByProject = (transactionState, transactionListState, accountId, accountType, projectId, timeframe, filterByTimePeriod) => {
|
|
9
|
+
const timePeriods = splitPeriod(filterByTimePeriod); // Note: Split by months.
|
|
10
|
+
const accountTransactions = timePeriods
|
|
11
|
+
.map((thisTimePeriod) => {
|
|
12
|
+
const key = getProjectAcTranKey(accountId, accountType, projectId, thisTimePeriod);
|
|
13
|
+
return recordGet(transactionListState.byProject.transactionListByProjectKey, key, undefined);
|
|
14
|
+
})
|
|
15
|
+
.filter((acTransaction) => acTransaction != null);
|
|
16
|
+
let account = undefined;
|
|
17
|
+
if (accountTransactions.length > 0) {
|
|
18
|
+
account = accountTransactions[0].account;
|
|
19
|
+
}
|
|
20
|
+
const fetchState = reduceFetchState(accountTransactions);
|
|
21
|
+
let transactions = [];
|
|
22
|
+
if (isAnyFetchCompleted(accountTransactions)) {
|
|
23
|
+
const allTransactionIDs = flatMap(accountTransactions, (value) => value.transactionIDs);
|
|
24
|
+
const transactionsUnsorted = allTransactionIDs
|
|
25
|
+
.map((transactionId) => getSupportedTransactionById(transactionState, transactionId))
|
|
26
|
+
.filter((value) => {
|
|
27
|
+
if (value == null) {
|
|
28
|
+
console.error("Can't have null transaction at this stage!");
|
|
29
|
+
}
|
|
30
|
+
return value != null;
|
|
31
|
+
});
|
|
32
|
+
transactions = orderBy(transactionsUnsorted, (value) => value.date.valueOf(), 'desc');
|
|
33
|
+
}
|
|
34
|
+
const key = getProjectAcKey(accountId, accountType, projectId);
|
|
35
|
+
const uiState = recordGet(transactionListState.byProject.transactionListUIStateByProjectKey, key, {});
|
|
36
|
+
return {
|
|
37
|
+
reportId: 'transaction_list_of_account_by_project',
|
|
38
|
+
reportTitle: 'Transaction List of Account By Project',
|
|
39
|
+
version: 1,
|
|
40
|
+
status: undefined,
|
|
41
|
+
fetchState: fetchState.fetchState,
|
|
42
|
+
error: fetchState.error,
|
|
43
|
+
timeframe,
|
|
44
|
+
filterByTimePeriod,
|
|
45
|
+
accountId,
|
|
46
|
+
accountType,
|
|
47
|
+
projectId,
|
|
48
|
+
account,
|
|
49
|
+
transactionOrder: 'descending_transaction_date',
|
|
50
|
+
transactions,
|
|
51
|
+
uiState,
|
|
52
|
+
latestTransactionId: transactionListState.latestTransactionId,
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export const getTransactionListUIStateByProjectKey = (transactionListState, accountId, accountType, projectId) => {
|
|
56
|
+
const key = getProjectAcKey(accountId, accountType, projectId);
|
|
57
|
+
return recordGet(transactionListState.byProject.transactionListUIStateByProjectKey, key, undefined);
|
|
58
|
+
};
|
|
@@ -2,7 +2,7 @@ import { createSlice } from '@reduxjs/toolkit';
|
|
|
2
2
|
import { toAbsoluteDay } from '../../commonStateTypes/timePeriod';
|
|
3
3
|
import { mapAccountBasePayloadToAccountBase } from '../../entity/account/accountPayload';
|
|
4
4
|
import { toEntityType } from '../../entity/genericEntity/entity';
|
|
5
|
-
import { accountTransactionsInitialState, getAcKey, getAcTranKey, getCategoryTypeTranKey, getClassAcKey, getClassAcTranKey, getEntityTranKey, initialClassTransactionState, initialEntityTransactionState, initialTransactionsStateByCategoryType, } from './transactionListState';
|
|
5
|
+
import { accountTransactionsInitialState, getAcKey, getAcTranKey, getCategoryTypeTranKey, getClassAcKey, getClassAcTranKey, getEntityTranKey, getProjectAcKey, getProjectAcTranKey, initialClassTransactionState, initialEntityTransactionState, initialProjectTransactionState, initialTransactionsStateByCategoryType, } from './transactionListState';
|
|
6
6
|
export const initialState = {
|
|
7
7
|
byAccount: {
|
|
8
8
|
transactionListByAccountKey: {},
|
|
@@ -37,6 +37,10 @@ export const initialState = {
|
|
|
37
37
|
transactionListByClassKey: {},
|
|
38
38
|
transactionListUIStateByClassKey: {},
|
|
39
39
|
},
|
|
40
|
+
byProject: {
|
|
41
|
+
transactionListByProjectKey: {},
|
|
42
|
+
transactionListUIStateByProjectKey: {},
|
|
43
|
+
},
|
|
40
44
|
};
|
|
41
45
|
const transactionList = createSlice({
|
|
42
46
|
name: 'transactionList',
|
|
@@ -246,6 +250,64 @@ const transactionList = createSlice({
|
|
|
246
250
|
return { payload: { accountId, accountType, classId, period, error } };
|
|
247
251
|
},
|
|
248
252
|
},
|
|
253
|
+
// Transaction list by project related reducers
|
|
254
|
+
//
|
|
255
|
+
// Mirrors the by-class set; the only behavioural difference is that the
|
|
256
|
+
// server query param is `zeni_project_id` (post-Ayon's accounting #3984
|
|
257
|
+
// rename) and there's no equivalent of `include_sub_class_transactions`
|
|
258
|
+
// — projects don't have a sub-project hierarchy in this layout yet.
|
|
259
|
+
parallelFetchProjectTransactionList: {
|
|
260
|
+
reducer() {
|
|
261
|
+
// Do nothing..
|
|
262
|
+
},
|
|
263
|
+
prepare(accountId, accountType, projectId, period, cacheOverride = false) {
|
|
264
|
+
return {
|
|
265
|
+
payload: { accountId, accountType, projectId, period, cacheOverride },
|
|
266
|
+
};
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
fetchProjectTransactionList: {
|
|
270
|
+
reducer(draft, action) {
|
|
271
|
+
const key = getProjectAcTranKey(action.payload.accountId, action.payload.accountType, action.payload.projectId, action.payload.period);
|
|
272
|
+
if (action.payload.cacheOverride === true ||
|
|
273
|
+
draft.byProject.transactionListByProjectKey[key] == null ||
|
|
274
|
+
(draft.byProject.transactionListByProjectKey[key]?.hasValidState() ===
|
|
275
|
+
false &&
|
|
276
|
+
draft.byProject.transactionListByProjectKey[key]?.fetchState !=
|
|
277
|
+
'In-Progress')) {
|
|
278
|
+
draft.byProject.transactionListByProjectKey[key] = {
|
|
279
|
+
...initialProjectTransactionState,
|
|
280
|
+
fetchState: 'In-Progress',
|
|
281
|
+
error: undefined,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
prepare(accountId, accountType, projectId, period, cacheOverride = false) {
|
|
286
|
+
return {
|
|
287
|
+
payload: { accountId, accountType, projectId, period, cacheOverride },
|
|
288
|
+
};
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
updateTransactionListByProject(draft, action) {
|
|
292
|
+
doUpdateTransactionListByProject(draft.byProject.transactionListByProjectKey, action.payload);
|
|
293
|
+
},
|
|
294
|
+
updateTransactionListByProjectUIState(draft, action) {
|
|
295
|
+
const key = getProjectAcKey(action.payload.accountId, action.payload.accountType, action.payload.projectId);
|
|
296
|
+
draft.byProject.transactionListUIStateByProjectKey[key] = Object.assign({}, draft.byProject.transactionListUIStateByProjectKey[key], action.payload.uiState);
|
|
297
|
+
},
|
|
298
|
+
updateTransactionListByProjectFailure: {
|
|
299
|
+
reducer(draft, action) {
|
|
300
|
+
const key = getProjectAcTranKey(action.payload.accountId, action.payload.accountType, action.payload.projectId, action.payload.period);
|
|
301
|
+
draft.byProject.transactionListByProjectKey[key] = {
|
|
302
|
+
...initialProjectTransactionState,
|
|
303
|
+
fetchState: 'Error',
|
|
304
|
+
error: action.payload.error,
|
|
305
|
+
};
|
|
306
|
+
},
|
|
307
|
+
prepare(accountId, accountType, projectId, period, error) {
|
|
308
|
+
return { payload: { accountId, accountType, projectId, period, error } };
|
|
309
|
+
},
|
|
310
|
+
},
|
|
249
311
|
parallelFetchTransactionListByCategoryType: {
|
|
250
312
|
reducer() {
|
|
251
313
|
// Do nothing..
|
|
@@ -340,7 +402,7 @@ const transactionList = createSlice({
|
|
|
340
402
|
},
|
|
341
403
|
},
|
|
342
404
|
});
|
|
343
|
-
export const { parallelFetchAccountTransactionList, fetchAccountTransactionList, updateTransactionListByAccount, updateTransactionListByAccountFailure, parallelFetchEntityTransactionList, fetchEntityTransactionList, updateTransactionListByEntity, updateTransactionListByEntityFailure, updateTransactionListByAccountUIState, parallelFetchClassTransactionList, fetchClassTransactionList, updateTransactionListByClass, updateTransactionListByClassUIState, updateTransactionListByClassFailure, parallelFetchTransactionListByCategoryType, fetchTransactionsListByCategoryType, updateTransactionListByCategoryType, updateTransactionsListByCategoryTypeFailure, updateTransactionListUIStateByCategoryType, clearTransactionList, updateLatestTransactionId, } = transactionList.actions;
|
|
405
|
+
export const { parallelFetchAccountTransactionList, fetchAccountTransactionList, updateTransactionListByAccount, updateTransactionListByAccountFailure, parallelFetchEntityTransactionList, fetchEntityTransactionList, updateTransactionListByEntity, updateTransactionListByEntityFailure, updateTransactionListByAccountUIState, parallelFetchClassTransactionList, fetchClassTransactionList, updateTransactionListByClass, updateTransactionListByClassUIState, updateTransactionListByClassFailure, parallelFetchProjectTransactionList, fetchProjectTransactionList, updateTransactionListByProject, updateTransactionListByProjectUIState, updateTransactionListByProjectFailure, parallelFetchTransactionListByCategoryType, fetchTransactionsListByCategoryType, updateTransactionListByCategoryType, updateTransactionsListByCategoryTypeFailure, updateTransactionListUIStateByCategoryType, clearTransactionList, updateLatestTransactionId, } = transactionList.actions;
|
|
344
406
|
export default transactionList.reducer;
|
|
345
407
|
/**
|
|
346
408
|
* Helper functions
|
|
@@ -390,3 +452,22 @@ function doUpdateTransactionListByClass(draft, payload) {
|
|
|
390
452
|
transactionIDs,
|
|
391
453
|
};
|
|
392
454
|
}
|
|
455
|
+
function doUpdateTransactionListByProject(draft, payload) {
|
|
456
|
+
const transactionIDs = payload.account.transactions.map((transactionPaylod) => transactionPaylod.transaction_id);
|
|
457
|
+
const account = mapAccountBasePayloadToAccountBase(payload.account);
|
|
458
|
+
const projectId = payload.query.zeni_project_id;
|
|
459
|
+
const start = toAbsoluteDay(payload.query.start_date);
|
|
460
|
+
const end = toAbsoluteDay(payload.query.end_date);
|
|
461
|
+
const key = getProjectAcTranKey(account.accountId, account.accountType, projectId, {
|
|
462
|
+
start,
|
|
463
|
+
end,
|
|
464
|
+
});
|
|
465
|
+
draft[key] = {
|
|
466
|
+
...initialProjectTransactionState,
|
|
467
|
+
fetchState: 'Completed',
|
|
468
|
+
error: undefined,
|
|
469
|
+
account: account,
|
|
470
|
+
projectId: projectId,
|
|
471
|
+
transactionIDs,
|
|
472
|
+
};
|
|
473
|
+
}
|
|
@@ -30,6 +30,16 @@ export const initialClassTransactionState = {
|
|
|
30
30
|
return this.fetchState == 'Completed';
|
|
31
31
|
},
|
|
32
32
|
};
|
|
33
|
+
export const getProjectAcTranKey = (accountId, accountType, projectId, period) => `${accountId}-${accountType}-${projectId}-${period.start.day}_${period.start.month}_${period.start.year}_${period.end.day}_${period.end.month}_${period.end.year}`;
|
|
34
|
+
export const getProjectAcKey = (accountId, accountType, projectId) => `${accountId}-${accountType}-${projectId}`;
|
|
35
|
+
export const initialProjectTransactionState = {
|
|
36
|
+
transactionIDs: [],
|
|
37
|
+
fetchState: 'Not-Started',
|
|
38
|
+
error: undefined,
|
|
39
|
+
hasValidState() {
|
|
40
|
+
return this.fetchState == 'Completed';
|
|
41
|
+
},
|
|
42
|
+
};
|
|
33
43
|
export const getCategoryTypeTranKey = (categoryType, period) => `${categoryType}_${period.start.day}_${period.start.month}_${period.start.year}_${period.end.day}_${period.end.month}_${period.end.year}`;
|
|
34
44
|
export const initialTransactionsStateByCategoryType = {
|
|
35
45
|
transactionIDs: [],
|
package/lib/index.d.ts
CHANGED
|
@@ -139,7 +139,7 @@ import { MatchedTransaction } from './entity/transaction/stateTypes/reconciliati
|
|
|
139
139
|
import { ScheduleTransaction } from './entity/transaction/stateTypes/scheduleTransaction';
|
|
140
140
|
import { RecommendationByLineId, RecommendationWithCOTByLineId, Transaction, TransactionID, TransactionWithCOT } from './entity/transaction/stateTypes/transaction';
|
|
141
141
|
import { BillableStatus, JournalEntryTransactionLine, Line, LineType, LinkedTransactionLine, PlatformLineDetailType, ProductOrService, TransactionInfoLine, TransactionLineBase, TransactionWithAccountAndClassLine, TransactionWithProductOrServiceLine, toPlatformLineDetailType } from './entity/transaction/stateTypes/transactionLine';
|
|
142
|
-
import { CustomerTransactionType, EmployeeTransactionType, OtherTransactionType, TransactionCategory, TransactionType, TransferTransactionType, VendorTransactionType,
|
|
142
|
+
import { CustomerTransactionType, EmployeeTransactionType, OtherTransactionType, TransactionCategory, TransactionType, TransferTransactionType, VendorTransactionType, toTransactionCategory, toTransactionType, toTransactionTypeStrict } from './entity/transaction/stateTypes/transactionType';
|
|
143
143
|
import { VendorTransaction, VendorTransactionWithCOT, VendorTransactionWithCustomer, VendorTransactionWithCustomerWithCOT, isVendorTransaction, isVendorTransactionWithCustomer } from './entity/transaction/stateTypes/vendorTransaction';
|
|
144
144
|
import { getSupportedTransactionById } from './entity/transaction/transactionSelector';
|
|
145
145
|
import { SupportedTransaction, SupportedTransactionPayload, SupportedTransactionWithCOT } from './entity/transaction/transactionState';
|
|
@@ -569,8 +569,9 @@ import { TransactionDetailLineItemData, TransactionDetailLocalData, TransactionV
|
|
|
569
569
|
import { TransactionListByAccountReport, getTransactionListByAccount, getTransactionListUIStateByAccountKey } from './view/transactionList/transactionListByAccountSelector';
|
|
570
570
|
import { TransactionListByCategoryType, getTransactionListUIStateByCategoryType, getTransactionsListByCategoryType } from './view/transactionList/transactionListByCategoryTypeSelector';
|
|
571
571
|
import { TransactionListByClassReport, getTransactionListByClass, getTransactionListUIStateByClassKey } from './view/transactionList/transactionListByClassSelector';
|
|
572
|
+
import { TransactionListByProjectReport, getTransactionListByProject, getTransactionListUIStateByProjectKey } from './view/transactionList/transactionListByProjectSelector';
|
|
572
573
|
import { TransactionListByEntityView, getTransactionListByEntity, getTransactionListByEntityForSinglePeriod } from './view/transactionList/transactionListByEntitySelector';
|
|
573
|
-
import { clearTransactionList, fetchAccountTransactionList, fetchEntityTransactionList, parallelFetchAccountTransactionList, parallelFetchClassTransactionList, parallelFetchEntityTransactionList, parallelFetchTransactionListByCategoryType, updateLatestTransactionId, updateTransactionListByAccount, updateTransactionListByAccountFailure, updateTransactionListByAccountUIState, updateTransactionListByClass, updateTransactionListByClassUIState, updateTransactionListByEntity, updateTransactionListByEntityFailure, updateTransactionListUIStateByCategoryType } from './view/transactionList/transactionListReducer';
|
|
574
|
+
import { clearTransactionList, fetchAccountTransactionList, fetchEntityTransactionList, parallelFetchAccountTransactionList, parallelFetchClassTransactionList, parallelFetchProjectTransactionList, parallelFetchEntityTransactionList, parallelFetchTransactionListByCategoryType, updateLatestTransactionId, updateTransactionListByAccount, updateTransactionListByAccountFailure, updateTransactionListByAccountUIState, updateTransactionListByClass, updateTransactionListByClassUIState, updateTransactionListByProject, updateTransactionListByProjectUIState, updateTransactionListByEntity, updateTransactionListByEntityFailure, updateTransactionListUIStateByCategoryType } from './view/transactionList/transactionListReducer';
|
|
574
575
|
import { TransactionCategoryType } from './view/transactionList/transactionListState';
|
|
575
576
|
import { clearTrendData, fetchExpenseTrend, fetchIncomeTrend } from './view/trend/trendReducer';
|
|
576
577
|
import { TrendView, getCurrentFiscalQuarterDateRange, getTrendForEntity } from './view/trend/trendSelector';
|
|
@@ -711,18 +712,18 @@ export { CustomerTransaction, CustomerTransactionWithCOT, isCustomerTransaction
|
|
|
711
712
|
export { TransactionID, TransactionWithCOT, Transaction, RecommendationWithCOTByLineId, RecommendationByLineId, };
|
|
712
713
|
export { TransactionIDPayload, toTransactionID, } from './entity/transaction/payloadTypes/transactionIDPayload';
|
|
713
714
|
export { TransactionLineBase, LinkedTransactionLine, TransactionWithAccountAndClassLine, TransactionWithProductOrServiceLine, JournalEntryTransactionLine, TransactionInfoLine, Line, LineType, ProductOrService, toPlatformLineDetailType, PlatformLineDetailType, };
|
|
714
|
-
export { CustomerTransactionType, VendorTransactionType, EmployeeTransactionType, TransferTransactionType, OtherTransactionType, TransactionType, toTransactionType, toTransactionTypeStrict, toTransactionCategory, TransactionCategory,
|
|
715
|
+
export { CustomerTransactionType, VendorTransactionType, EmployeeTransactionType, TransferTransactionType, OtherTransactionType, TransactionType, toTransactionType, toTransactionTypeStrict, toTransactionCategory, TransactionCategory, };
|
|
715
716
|
export { VendorBase, Vendor, defaultVendorCurrency, updateVendors };
|
|
716
717
|
export { VendorTransaction, VendorTransactionWithCOT, isVendorTransaction, VendorTransactionWithCustomer, VendorTransactionWithCustomerWithCOT, isVendorTransactionWithCustomer, };
|
|
717
718
|
export { TransferTransaction, isTransferTransaction };
|
|
718
719
|
export { MatchedTransaction };
|
|
719
720
|
export { SupportedTransaction, SupportedTransactionWithCOT, SupportedTransactionPayload, getSupportedTransactionById, };
|
|
720
|
-
export { clearTransactionList, updateLatestTransactionId, parallelFetchAccountTransactionList, parallelFetchEntityTransactionList, fetchAccountTransactionList, updateTransactionListByAccount, updateTransactionListByAccountFailure, updateTransactionListByAccountUIState, parallelFetchClassTransactionList, updateTransactionListByClassUIState, updateTransactionListByClass, updateTransactionListUIStateByCategoryType, parallelFetchTransactionListByCategoryType, };
|
|
721
|
+
export { clearTransactionList, updateLatestTransactionId, parallelFetchAccountTransactionList, parallelFetchEntityTransactionList, fetchAccountTransactionList, updateTransactionListByAccount, updateTransactionListByAccountFailure, updateTransactionListByAccountUIState, parallelFetchClassTransactionList, updateTransactionListByClassUIState, updateTransactionListByClass, parallelFetchProjectTransactionList, updateTransactionListByProjectUIState, updateTransactionListByProject, updateTransactionListUIStateByCategoryType, parallelFetchTransactionListByCategoryType, };
|
|
721
722
|
export { TransactionListByAccountReport, getTransactionListByAccount, getTransactionListUIStateByAccountKey, };
|
|
722
723
|
export { fetchEntityTransactionList, updateTransactionListByEntity, saveTransactionDetailLocalData, clearTransactionDetailSaveStatus, updateTransactionListByEntityFailure, resetLineItemsCategoryClassInLocalData, setAllLineItemsToCategoryClassInLocalData, saveTransactionDetail, setAllLineItemsLocalDataIsUpdateAllChecked, initializeTransactionDetailLocalData, removeEntityRecommendationForLineIdForTransactionDetail, updateSelectedVendor, updateSelectedCustomer, resetSelectedCustomer, resetVendor, updateLocalDataWithTransactionsUpdateWithVendorCheckbox, updateVendorToAllLineItems, resetAllLineItemsToVendor, updateLatestSelectedEntity, updateVendorBulkRecommendationsFetchStatus, setIsVendorUpdateAllChecked, };
|
|
723
724
|
export { TransactionUpdates, downloadAccountingProviderAttachment, downloadAccountingProviderAttachmentSuccess, downloadAccountingProviderAttachmentFailure, fetchTransactionDetail, updateTransactionDetail, uploadMissingAttachmentSuccess, deleteTransactionAttachment, getThirdPartyIdFromTransactionId, };
|
|
724
725
|
export { TransactionListByEntityView, getTransactionListByEntity };
|
|
725
|
-
export { TransactionListByClassReport, getTransactionListByClass, getTransactionListUIStateByClassKey, getTransactionListByEntityForSinglePeriod, };
|
|
726
|
+
export { TransactionListByClassReport, getTransactionListByClass, getTransactionListUIStateByClassKey, TransactionListByProjectReport, getTransactionListByProject, getTransactionListUIStateByProjectKey, getTransactionListByEntityForSinglePeriod, };
|
|
726
727
|
export { TransactionDetailReport, getTransactionDetail, getTransactionDetailForTransaction, VendorDetailsView, getInitialUpdatablePeriodsForTransactionRecommendations as getUpdatablePeriodsForTransactionRecommendations, };
|
|
727
728
|
export { getInsights, fetchInsightsCard, updateSelectedInsightIndex, InsightsView, };
|
|
728
729
|
export { fetchForecastList } from './view/forecastList/forecastListReducer';
|