@zeniai/client-epic-state 5.0.55 → 5.0.56
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/recommendationBase.d.ts +1 -2
- package/lib/commonStateTypes/viewAndReport/viewAndReport.d.ts +2 -2
- package/lib/commonStateTypes/viewAndReport/viewAndReport.js +0 -1
- 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/project/projectPayload.d.ts +1 -8
- package/lib/entity/project/projectPayload.js +1 -15
- package/lib/entity/project/projectState.d.ts +2 -4
- 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/tenant/clearAllEpic.d.ts +1 -2
- package/lib/entity/tenant/clearAllEpic.js +0 -2
- package/lib/entity/tenant/epic/deleteConnectionEpic.d.ts +1 -1
- package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.d.ts +1 -1
- package/lib/entity/tenant/epic/saveOAuthConnectionEpic.d.ts +1 -1
- package/lib/entity/tenant/tenantReducer.d.ts +16 -64
- package/lib/entity/tenant/tenantReducer.js +7 -86
- package/lib/entity/tenant/tenantState.d.ts +1 -3
- package/lib/entity/transaction/payloadTypes/transactionLinePayload.d.ts +0 -2
- package/lib/entity/transaction/payloadTypes/transactionLinePayload.js +0 -9
- package/lib/entity/transaction/payloadTypes/transactionPayload.d.ts +0 -2
- package/lib/entity/transaction/payloadTypes/transactionPayload.js +0 -6
- package/lib/entity/transaction/stateTypes/transaction.d.ts +0 -2
- package/lib/entity/transaction/stateTypes/transactionLine.d.ts +0 -2
- package/lib/epic.d.ts +1 -4
- package/lib/epic.js +1 -5
- package/lib/esm/commonStateTypes/viewAndReport/viewAndReport.js +0 -1
- package/lib/esm/entity/project/projectPayload.js +0 -12
- package/lib/esm/entity/tenant/clearAllEpic.js +0 -2
- package/lib/esm/entity/tenant/tenantReducer.js +5 -84
- package/lib/esm/entity/transaction/payloadTypes/transactionLinePayload.js +0 -9
- package/lib/esm/entity/transaction/payloadTypes/transactionPayload.js +0 -6
- package/lib/esm/epic.js +1 -5
- package/lib/esm/index.js +7 -11
- package/lib/esm/reducer.js +0 -3
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.js +0 -8
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/updateTransactionCategorizationEpic.js +0 -3
- package/lib/esm/view/expenseAutomationView/helpers/saveTransactionHelper.js +0 -1
- package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -11
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +4 -13
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +2 -7
- package/lib/esm/view/expenseAutomationView/types/transactionsViewState.js +0 -1
- package/lib/esm/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +0 -44
- package/lib/esm/view/spendManagement/zeniAccounts/depositAccountDetail/depositAccountDetailSelector.js +1 -1
- package/lib/esm/view/spendManagement/zeniAccounts/depositAccountDetail/fetchDepositAccountDetailEpic.js +2 -7
- package/lib/esm/view/transactionDetail/epics/saveTransactionHelper.js +0 -1
- package/lib/esm/view/transactionDetail/epics/transactionDetailEpic.js +0 -6
- package/lib/esm/view/transactionDetail/epics/updateTransactionDetailEpic.js +0 -3
- package/lib/esm/view/transactionDetail/transactionDetailSelector.js +2 -14
- package/lib/esm/view/transactionList/transactionListReducer.js +2 -83
- package/lib/esm/view/transactionList/transactionListState.js +0 -10
- package/lib/index.d.ts +9 -14
- package/lib/index.js +30 -44
- package/lib/reducer.d.ts +0 -3
- package/lib/reducer.js +0 -3
- 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/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.d.ts +1 -2
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.js +0 -8
- package/lib/view/expenseAutomationView/epics/transactionCategorization/updateTransactionCategorizationEpic.js +0 -3
- package/lib/view/expenseAutomationView/helpers/saveTransactionHelper.js +0 -1
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -2
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -11
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +1 -3
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +4 -13
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +0 -3
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +1 -6
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +1 -4
- package/lib/view/expenseAutomationView/types/transactionsViewState.js +0 -1
- package/lib/view/financeStatement/financeStatementReducer.d.ts +1 -1
- package/lib/view/globalMerchantView/globalMerchantViewReducer.d.ts +2 -2
- package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.d.ts +1 -15
- package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +0 -45
- package/lib/view/reimbursementCard/reimbursementCardSelector.d.ts +1 -1
- package/lib/view/reportsResync/reportsResyncReducer.d.ts +2 -2
- package/lib/view/spendManagement/zeniAccounts/depositAccountDetail/depositAccountDetailSelector.js +1 -1
- package/lib/view/spendManagement/zeniAccounts/depositAccountDetail/fetchDepositAccountDetailEpic.js +2 -7
- package/lib/view/tasksCard/tasksCardSelector.d.ts +1 -1
- package/lib/view/topEx/topExSelector.d.ts +1 -1
- package/lib/view/transactionDetail/epics/saveTransactionHelper.js +0 -1
- package/lib/view/transactionDetail/epics/transactionDetailEpic.d.ts +1 -2
- package/lib/view/transactionDetail/epics/transactionDetailEpic.js +0 -6
- package/lib/view/transactionDetail/epics/updateTransactionDetailEpic.js +0 -3
- package/lib/view/transactionDetail/transactionDetailSelector.d.ts +0 -3
- package/lib/view/transactionDetail/transactionDetailSelector.js +1 -13
- package/lib/view/transactionDetail/transactionDetailState.d.ts +0 -2
- package/lib/view/transactionDetail/transactionDetailTypes.d.ts +0 -2
- package/lib/view/transactionList/transactionListPayload.d.ts +0 -15
- package/lib/view/transactionList/transactionListReducer.d.ts +2 -25
- package/lib/view/transactionList/transactionListReducer.js +2 -83
- package/lib/view/transactionList/transactionListState.d.ts +0 -15
- package/lib/view/transactionList/transactionListState.js +1 -13
- package/package.json +1 -1
- package/lib/entity/tenant/epic/saveConnectorCredentialsEpic.d.ts +0 -21
- package/lib/entity/tenant/epic/saveConnectorCredentialsEpic.js +0 -42
- package/lib/esm/entity/tenant/epic/saveConnectorCredentialsEpic.js +0 -38
- package/lib/esm/view/projectList/fetchProjectListEpic.js +0 -38
- package/lib/esm/view/projectList/projectListPayload.js +0 -1
- package/lib/esm/view/projectList/projectListReducer.js +0 -39
- package/lib/esm/view/projectList/projectListSelector.js +0 -9
- package/lib/esm/view/projectList/projectListState.js +0 -1
- package/lib/esm/view/transactionList/fetchTransactionListByProjectEpic.js +0 -45
- package/lib/esm/view/transactionList/parallelFetchProjectTransactionListEpic.js +0 -32
- package/lib/esm/view/transactionList/transactionListByProjectSelector.js +0 -58
- package/lib/view/projectList/fetchProjectListEpic.d.ts +0 -8
- package/lib/view/projectList/fetchProjectListEpic.js +0 -42
- package/lib/view/projectList/projectListPayload.d.ts +0 -7
- package/lib/view/projectList/projectListPayload.js +0 -2
- package/lib/view/projectList/projectListReducer.d.ts +0 -9
- package/lib/view/projectList/projectListReducer.js +0 -43
- package/lib/view/projectList/projectListSelector.d.ts +0 -8
- package/lib/view/projectList/projectListSelector.js +0 -13
- package/lib/view/projectList/projectListState.d.ts +0 -4
- package/lib/view/projectList/projectListState.js +0 -2
- package/lib/view/transactionList/fetchTransactionListByProjectEpic.d.ts +0 -8
- package/lib/view/transactionList/fetchTransactionListByProjectEpic.js +0 -52
- package/lib/view/transactionList/parallelFetchProjectTransactionListEpic.d.ts +0 -6
- package/lib/view/transactionList/parallelFetchProjectTransactionListEpic.js +0 -36
- package/lib/view/transactionList/transactionListByProjectSelector.d.ts +0 -22
- package/lib/view/transactionList/transactionListByProjectSelector.js +0 -66
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap, switchMap, withLatestFrom, } from 'rxjs/operators';
|
|
3
|
-
import { updateProjects } from '../../entity/project/projectReducer';
|
|
4
|
-
import { getIsAccountingProjectsEnabled } from '../../entity/tenant/tenantSelector';
|
|
5
|
-
import { createZeniAPIStatus, isSuccessResponse } from '../../responsePayload';
|
|
6
|
-
import { fetchProjectList, updateProjectList, updateProjectListFailure, } from './projectListReducer';
|
|
7
|
-
const buildProjectListQuery = (isIncludeDeleted) => {
|
|
8
|
-
const query = {
|
|
9
|
-
is_deleted: isIncludeDeleted,
|
|
10
|
-
sort_by: 'project_name',
|
|
11
|
-
sort_order: 'asc',
|
|
12
|
-
is_full: true,
|
|
13
|
-
};
|
|
14
|
-
return `?query=${encodeURIComponent(JSON.stringify(query))}`;
|
|
15
|
-
};
|
|
16
|
-
export const fetchProjectListEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchProjectList.match), withLatestFrom(state$), switchMap(([action, state]) => {
|
|
17
|
-
if (!getIsAccountingProjectsEnabled(state)) {
|
|
18
|
-
return of(updateProjectList({
|
|
19
|
-
status: createZeniAPIStatus('Success', ''),
|
|
20
|
-
data: { projects: [] },
|
|
21
|
-
}));
|
|
22
|
-
}
|
|
23
|
-
const { isIncludeDeleted } = action.payload;
|
|
24
|
-
const queryParams = buildProjectListQuery(isIncludeDeleted);
|
|
25
|
-
return zeniAPI
|
|
26
|
-
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/projects${queryParams}`)
|
|
27
|
-
.pipe(mergeMap((response) => {
|
|
28
|
-
if (isSuccessResponse(response)) {
|
|
29
|
-
return of(updateProjects(response.data?.projects ?? []), updateProjectList(response));
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
return of(updateProjectListFailure(response.status));
|
|
33
|
-
}
|
|
34
|
-
}), catchError((error) => {
|
|
35
|
-
return of(updateProjectListFailure(createZeniAPIStatus('Unexpected Error', 'Fetch Projects REST API call errored out' +
|
|
36
|
-
JSON.stringify(error))));
|
|
37
|
-
}));
|
|
38
|
-
}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
-
export const initialState = {
|
|
3
|
-
fetchState: 'Not-Started',
|
|
4
|
-
error: undefined,
|
|
5
|
-
projectIds: [],
|
|
6
|
-
hasValidState() {
|
|
7
|
-
return this.fetchState == 'Completed';
|
|
8
|
-
},
|
|
9
|
-
};
|
|
10
|
-
const projectList = createSlice({
|
|
11
|
-
name: 'projectList',
|
|
12
|
-
initialState,
|
|
13
|
-
reducers: {
|
|
14
|
-
fetchProjectList: {
|
|
15
|
-
reducer(draft) {
|
|
16
|
-
draft.fetchState = 'In-Progress';
|
|
17
|
-
draft.error = undefined;
|
|
18
|
-
},
|
|
19
|
-
prepare(isIncludeDeleted) {
|
|
20
|
-
return { payload: { isIncludeDeleted: isIncludeDeleted ?? false } };
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
updateProjectList(draft, action) {
|
|
24
|
-
draft.projectIds =
|
|
25
|
-
action.payload.data?.projects?.map((project) => project.zeni_project_id) ?? [];
|
|
26
|
-
draft.fetchState = 'Completed';
|
|
27
|
-
draft.error = undefined;
|
|
28
|
-
},
|
|
29
|
-
updateProjectListFailure(draft, action) {
|
|
30
|
-
draft.fetchState = 'Error';
|
|
31
|
-
draft.error = action.payload;
|
|
32
|
-
},
|
|
33
|
-
clearProjectList(draft) {
|
|
34
|
-
Object.assign(draft, initialState);
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
export const { fetchProjectList, updateProjectList, updateProjectListFailure, clearProjectList, } = projectList.actions;
|
|
39
|
-
export default projectList.reducer;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { getProjectsByIds } from '../../entity/project/projectSelector';
|
|
2
|
-
export const getProjectList = (projectState, projectListState) => {
|
|
3
|
-
return {
|
|
4
|
-
projects: getProjectsByIds(projectState, projectListState.projectIds),
|
|
5
|
-
fetchState: projectListState.fetchState,
|
|
6
|
-
error: projectListState.error,
|
|
7
|
-
version: 0,
|
|
8
|
-
};
|
|
9
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,45 +0,0 @@
|
|
|
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
|
-
}));
|
|
@@ -1,32 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { updateProjects } from '../../entity/project/projectReducer';
|
|
4
|
-
import { RootState } from '../../reducer';
|
|
5
|
-
import { ZeniAPI } from '../../zeniAPI';
|
|
6
|
-
import { fetchProjectList, updateProjectList, updateProjectListFailure } from './projectListReducer';
|
|
7
|
-
export type ActionType = ReturnType<typeof fetchProjectList> | ReturnType<typeof updateProjects> | ReturnType<typeof updateProjectList> | ReturnType<typeof updateProjectListFailure>;
|
|
8
|
-
export declare const fetchProjectListEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchProjectListEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const projectReducer_1 = require("../../entity/project/projectReducer");
|
|
7
|
-
const tenantSelector_1 = require("../../entity/tenant/tenantSelector");
|
|
8
|
-
const responsePayload_1 = require("../../responsePayload");
|
|
9
|
-
const projectListReducer_1 = require("./projectListReducer");
|
|
10
|
-
const buildProjectListQuery = (isIncludeDeleted) => {
|
|
11
|
-
const query = {
|
|
12
|
-
is_deleted: isIncludeDeleted,
|
|
13
|
-
sort_by: 'project_name',
|
|
14
|
-
sort_order: 'asc',
|
|
15
|
-
is_full: true,
|
|
16
|
-
};
|
|
17
|
-
return `?query=${encodeURIComponent(JSON.stringify(query))}`;
|
|
18
|
-
};
|
|
19
|
-
const fetchProjectListEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(projectListReducer_1.fetchProjectList.match), (0, operators_1.withLatestFrom)(state$), (0, operators_1.switchMap)(([action, state]) => {
|
|
20
|
-
if (!(0, tenantSelector_1.getIsAccountingProjectsEnabled)(state)) {
|
|
21
|
-
return (0, rxjs_1.of)((0, projectListReducer_1.updateProjectList)({
|
|
22
|
-
status: (0, responsePayload_1.createZeniAPIStatus)('Success', ''),
|
|
23
|
-
data: { projects: [] },
|
|
24
|
-
}));
|
|
25
|
-
}
|
|
26
|
-
const { isIncludeDeleted } = action.payload;
|
|
27
|
-
const queryParams = buildProjectListQuery(isIncludeDeleted);
|
|
28
|
-
return zeniAPI
|
|
29
|
-
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/projects${queryParams}`)
|
|
30
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
31
|
-
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
32
|
-
return (0, rxjs_1.of)((0, projectReducer_1.updateProjects)(response.data?.projects ?? []), (0, projectListReducer_1.updateProjectList)(response));
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
return (0, rxjs_1.of)((0, projectListReducer_1.updateProjectListFailure)(response.status));
|
|
36
|
-
}
|
|
37
|
-
}), (0, operators_1.catchError)((error) => {
|
|
38
|
-
return (0, rxjs_1.of)((0, projectListReducer_1.updateProjectListFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch Projects REST API call errored out' +
|
|
39
|
-
JSON.stringify(error))));
|
|
40
|
-
}));
|
|
41
|
-
}));
|
|
42
|
-
exports.fetchProjectListEpic = fetchProjectListEpic;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ProjectMetadataPayload } from '../../entity/project/projectPayload';
|
|
2
|
-
import { ZeniAPIResponse } from '../../responsePayload';
|
|
3
|
-
interface ProjectListPayloadData {
|
|
4
|
-
projects: ProjectMetadataPayload[];
|
|
5
|
-
}
|
|
6
|
-
export type ProjectListResponse = ZeniAPIResponse<ProjectListPayloadData>;
|
|
7
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ZeniAPIStatus } from '../../responsePayload';
|
|
2
|
-
import { ProjectListResponse } from './projectListPayload';
|
|
3
|
-
import { ProjectListState } from './projectListState';
|
|
4
|
-
export declare const initialState: ProjectListState;
|
|
5
|
-
export declare const fetchProjectList: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[isIncludeDeleted?: boolean | undefined], {
|
|
6
|
-
isIncludeDeleted: boolean;
|
|
7
|
-
}, "projectList/fetchProjectList", never, never>, updateProjectList: import("@reduxjs/toolkit").ActionCreatorWithPayload<ProjectListResponse, "projectList/updateProjectList">, updateProjectListFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "projectList/updateProjectListFailure">, clearProjectList: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"projectList/clearProjectList">;
|
|
8
|
-
declare const _default: import("redux").Reducer<ProjectListState>;
|
|
9
|
-
export default _default;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.clearProjectList = exports.updateProjectListFailure = exports.updateProjectList = exports.fetchProjectList = exports.initialState = void 0;
|
|
5
|
-
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
-
exports.initialState = {
|
|
7
|
-
fetchState: 'Not-Started',
|
|
8
|
-
error: undefined,
|
|
9
|
-
projectIds: [],
|
|
10
|
-
hasValidState() {
|
|
11
|
-
return this.fetchState == 'Completed';
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
const projectList = (0, toolkit_1.createSlice)({
|
|
15
|
-
name: 'projectList',
|
|
16
|
-
initialState: exports.initialState,
|
|
17
|
-
reducers: {
|
|
18
|
-
fetchProjectList: {
|
|
19
|
-
reducer(draft) {
|
|
20
|
-
draft.fetchState = 'In-Progress';
|
|
21
|
-
draft.error = undefined;
|
|
22
|
-
},
|
|
23
|
-
prepare(isIncludeDeleted) {
|
|
24
|
-
return { payload: { isIncludeDeleted: isIncludeDeleted ?? false } };
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
updateProjectList(draft, action) {
|
|
28
|
-
draft.projectIds =
|
|
29
|
-
action.payload.data?.projects?.map((project) => project.zeni_project_id) ?? [];
|
|
30
|
-
draft.fetchState = 'Completed';
|
|
31
|
-
draft.error = undefined;
|
|
32
|
-
},
|
|
33
|
-
updateProjectListFailure(draft, action) {
|
|
34
|
-
draft.fetchState = 'Error';
|
|
35
|
-
draft.error = action.payload;
|
|
36
|
-
},
|
|
37
|
-
clearProjectList(draft) {
|
|
38
|
-
Object.assign(draft, exports.initialState);
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
_a = projectList.actions, exports.fetchProjectList = _a.fetchProjectList, exports.updateProjectList = _a.updateProjectList, exports.updateProjectListFailure = _a.updateProjectListFailure, exports.clearProjectList = _a.clearProjectList;
|
|
43
|
-
exports.default = projectList.reducer;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { SelectorView } from '../../commonStateTypes/viewAndReport/viewAndReport';
|
|
2
|
-
import { ProjectState } from '../../entity/project/projectReducer';
|
|
3
|
-
import { Project } from '../../entity/project/projectState';
|
|
4
|
-
import { ProjectListState } from './projectListState';
|
|
5
|
-
export interface ProjectListSelectorView extends SelectorView {
|
|
6
|
-
projects: Project[];
|
|
7
|
-
}
|
|
8
|
-
export declare const getProjectList: (projectState: ProjectState, projectListState: ProjectListState) => ProjectListSelectorView;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getProjectList = void 0;
|
|
4
|
-
const projectSelector_1 = require("../../entity/project/projectSelector");
|
|
5
|
-
const getProjectList = (projectState, projectListState) => {
|
|
6
|
-
return {
|
|
7
|
-
projects: (0, projectSelector_1.getProjectsByIds)(projectState, projectListState.projectIds),
|
|
8
|
-
fetchState: projectListState.fetchState,
|
|
9
|
-
error: projectListState.error,
|
|
10
|
-
version: 0,
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
exports.getProjectList = getProjectList;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { updateTransactions } from '../../entity/transaction/transactionReducer';
|
|
4
|
-
import { RootState } from '../../reducer';
|
|
5
|
-
import { ZeniAPI } from '../../zeniAPI';
|
|
6
|
-
import { fetchProjectTransactionList, updateTransactionListByProject, updateTransactionListByProjectFailure } from './transactionListReducer';
|
|
7
|
-
export type ActionType = ReturnType<typeof fetchProjectTransactionList> | ReturnType<typeof updateTransactions> | ReturnType<typeof updateTransactionListByProject> | ReturnType<typeof updateTransactionListByProjectFailure>;
|
|
8
|
-
export declare const fetchTransactionListByProjectEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.fetchTransactionListByProjectEpic = void 0;
|
|
7
|
-
const js_base64_1 = require("js-base64");
|
|
8
|
-
const get_1 = __importDefault(require("lodash/get"));
|
|
9
|
-
const rxjs_1 = require("rxjs");
|
|
10
|
-
const operators_1 = require("rxjs/operators");
|
|
11
|
-
const timePeriod_1 = require("../../commonStateTypes/timePeriod");
|
|
12
|
-
const transactionReducer_1 = require("../../entity/transaction/transactionReducer");
|
|
13
|
-
const responsePayload_1 = require("../../responsePayload");
|
|
14
|
-
const transactionListReducer_1 = require("./transactionListReducer");
|
|
15
|
-
const transactionListState_1 = require("./transactionListState");
|
|
16
|
-
const fetchTransactionListByProjectEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(transactionListReducer_1.fetchProjectTransactionList.match), (0, operators_1.mergeMap)((action) => {
|
|
17
|
-
const state = state$.value;
|
|
18
|
-
const key = (0, transactionListState_1.getProjectAcTranKey)(action.payload.accountId, action.payload.accountType, action.payload.projectId, action.payload.period);
|
|
19
|
-
const projectTransactions = (0, get_1.default)(state.transactionListState.byProject.transactionListByProjectKey, key, undefined);
|
|
20
|
-
if (action.payload.cacheOverride === true ||
|
|
21
|
-
projectTransactions == null ||
|
|
22
|
-
projectTransactions.hasValidState() === false) {
|
|
23
|
-
const queryParam = {
|
|
24
|
-
start_date: (0, timePeriod_1.toString)(action.payload.period.start),
|
|
25
|
-
end_date: (0, timePeriod_1.toString)(action.payload.period.end),
|
|
26
|
-
sort_by: 'create_time',
|
|
27
|
-
sort_order: 'desc',
|
|
28
|
-
account_id: action.payload.accountId,
|
|
29
|
-
account_type: action.payload.accountType,
|
|
30
|
-
zeni_project_id: action.payload.projectId,
|
|
31
|
-
};
|
|
32
|
-
const base64AccountId = (0, js_base64_1.toBase64)(action.payload.accountId);
|
|
33
|
-
return zeniAPI
|
|
34
|
-
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts/${base64AccountId}/transactions?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
35
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
36
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
37
|
-
const updateActions = [];
|
|
38
|
-
updateActions.push((0, transactionReducer_1.updateTransactions)(response.data.account.transactions, (value) => value.transaction_id));
|
|
39
|
-
updateActions.push((0, transactionListReducer_1.updateTransactionListByProject)(response.data));
|
|
40
|
-
return (0, rxjs_1.from)(updateActions);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
return (0, rxjs_1.of)((0, transactionListReducer_1.updateTransactionListByProjectFailure)(action.payload.accountId, action.payload.accountType, action.payload.projectId, action.payload.period, response.status));
|
|
44
|
-
}
|
|
45
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, transactionListReducer_1.updateTransactionListByProjectFailure)(action.payload.accountId, action.payload.accountType, action.payload.projectId, action.payload.period, (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'fetch transaction list REST API call errored out' +
|
|
46
|
-
JSON.stringify(error))))));
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
return (0, rxjs_1.from)([]);
|
|
50
|
-
}
|
|
51
|
-
}));
|
|
52
|
-
exports.fetchTransactionListByProjectEpic = fetchTransactionListByProjectEpic;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { RootState } from '../../reducer';
|
|
4
|
-
import { fetchProjectTransactionList, parallelFetchProjectTransactionList } from './transactionListReducer';
|
|
5
|
-
export type ActionType = ReturnType<typeof parallelFetchProjectTransactionList> | ReturnType<typeof fetchProjectTransactionList>;
|
|
6
|
-
export declare const parallelFetchProjectTransactionListEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parallelFetchProjectTransactionListEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const parallelFetchClassTransactionListEpic_1 = require("./parallelFetchClassTransactionListEpic");
|
|
7
|
-
const transactionListReducer_1 = require("./transactionListReducer");
|
|
8
|
-
const transactionListState_1 = require("./transactionListState");
|
|
9
|
-
const parallelFetchProjectTransactionListEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(transactionListReducer_1.parallelFetchProjectTransactionList.match), (0, operators_1.mergeMap)((action) => {
|
|
10
|
-
const state = state$.value.transactionListState;
|
|
11
|
-
const timePeriods = (0, parallelFetchClassTransactionListEpic_1.splitPeriod)(action.payload.period);
|
|
12
|
-
const filteredTimePeriods = timePeriods.filter((value) => {
|
|
13
|
-
if (action.payload.cacheOverride === false) {
|
|
14
|
-
return (isDataAvailableOrFetching(state.byProject, action.payload.accountId, action.payload.accountType, action.payload.projectId, value) === false);
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
if (filteredTimePeriods.length > 12) {
|
|
21
|
-
console.error('Only maximum 12 parallel fetch are allowed!');
|
|
22
|
-
return (0, rxjs_1.from)([]);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
const fetchActions = filteredTimePeriods.map((period) => (0, transactionListReducer_1.fetchProjectTransactionList)(action.payload.accountId, action.payload.accountType, action.payload.projectId, period, true));
|
|
26
|
-
return (0, rxjs_1.from)(fetchActions);
|
|
27
|
-
}
|
|
28
|
-
}));
|
|
29
|
-
exports.parallelFetchProjectTransactionListEpic = parallelFetchProjectTransactionListEpic;
|
|
30
|
-
function isDataAvailableOrFetching(state, accountId, accountType, projectId, period) {
|
|
31
|
-
const key = (0, transactionListState_1.getProjectAcTranKey)(accountId, accountType, projectId, period);
|
|
32
|
-
const projectTransactions = state.transactionListByProjectKey[key];
|
|
33
|
-
return (projectTransactions != null &&
|
|
34
|
-
(projectTransactions.fetchState === 'In-Progress' ||
|
|
35
|
-
projectTransactions.hasValidState()));
|
|
36
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { COABalanceTimeFrame } from '../../commonStateTypes/coaBalance/coaBalance';
|
|
2
|
-
import { ID } from '../../commonStateTypes/common';
|
|
3
|
-
import { EntityOrder } from '../../commonStateTypes/selectorTypes/selectorTypes';
|
|
4
|
-
import { TimePeriod } from '../../commonStateTypes/timePeriod';
|
|
5
|
-
import { SelectorView } from '../../commonStateTypes/viewAndReport/viewAndReport';
|
|
6
|
-
import { AccountBase, AccountType } from '../../entity/account/accountState';
|
|
7
|
-
import { Transaction } from '../../entity/transaction/stateTypes/transaction';
|
|
8
|
-
import { TransactionState } from '../../entity/transaction/transactionState';
|
|
9
|
-
import { TransactionListSelectorView, TransactionListState, TransactionListUIState } from './transactionListState';
|
|
10
|
-
export interface TransactionListByProjectReport extends SelectorView, TransactionListSelectorView {
|
|
11
|
-
accountId: ID;
|
|
12
|
-
accountType: AccountType;
|
|
13
|
-
filterByTimePeriod: TimePeriod;
|
|
14
|
-
projectId: ID;
|
|
15
|
-
timeframe: COABalanceTimeFrame;
|
|
16
|
-
transactionOrder: EntityOrder;
|
|
17
|
-
transactions: Transaction[];
|
|
18
|
-
uiState: TransactionListUIState;
|
|
19
|
-
account?: AccountBase;
|
|
20
|
-
}
|
|
21
|
-
export declare const getTransactionListByProject: (transactionState: TransactionState, transactionListState: TransactionListState, accountId: ID, accountType: AccountType, projectId: ID, timeframe: COABalanceTimeFrame, filterByTimePeriod: TimePeriod) => TransactionListByProjectReport;
|
|
22
|
-
export declare const getTransactionListUIStateByProjectKey: (transactionListState: TransactionListState, accountId: ID, accountType: AccountType, projectId: ID) => TransactionListUIState | undefined;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getTransactionListUIStateByProjectKey = exports.getTransactionListByProject = void 0;
|
|
7
|
-
const flatMap_1 = __importDefault(require("lodash/flatMap"));
|
|
8
|
-
const get_1 = __importDefault(require("lodash/get"));
|
|
9
|
-
const orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
10
|
-
const transactionSelector_1 = require("../../entity/transaction/transactionSelector");
|
|
11
|
-
const parallelFetchAccountTransactionListEpic_1 = require("./parallelFetchAccountTransactionListEpic");
|
|
12
|
-
const reduceTransactionListFetchState_1 = require("./reduceTransactionListFetchState");
|
|
13
|
-
const transactionListState_1 = require("./transactionListState");
|
|
14
|
-
const getTransactionListByProject = (transactionState, transactionListState, accountId, accountType, projectId, timeframe, filterByTimePeriod) => {
|
|
15
|
-
const timePeriods = (0, parallelFetchAccountTransactionListEpic_1.splitPeriod)(filterByTimePeriod); // Note: Split by months.
|
|
16
|
-
const accountTransactions = timePeriods
|
|
17
|
-
.map((thisTimePeriod) => {
|
|
18
|
-
const key = (0, transactionListState_1.getProjectAcTranKey)(accountId, accountType, projectId, thisTimePeriod);
|
|
19
|
-
return (0, get_1.default)(transactionListState.byProject.transactionListByProjectKey, key, undefined);
|
|
20
|
-
})
|
|
21
|
-
.filter((acTransaction) => acTransaction != null);
|
|
22
|
-
let account = undefined;
|
|
23
|
-
if (accountTransactions.length > 0) {
|
|
24
|
-
account = accountTransactions[0].account;
|
|
25
|
-
}
|
|
26
|
-
const fetchState = (0, reduceTransactionListFetchState_1.reduceFetchState)(accountTransactions);
|
|
27
|
-
let transactions = [];
|
|
28
|
-
if ((0, reduceTransactionListFetchState_1.isAnyFetchCompleted)(accountTransactions)) {
|
|
29
|
-
const allTransactionIDs = (0, flatMap_1.default)(accountTransactions, (value) => value.transactionIDs);
|
|
30
|
-
const transactionsUnsorted = allTransactionIDs
|
|
31
|
-
.map((transactionId) => (0, transactionSelector_1.getSupportedTransactionById)(transactionState, transactionId))
|
|
32
|
-
.filter((value) => {
|
|
33
|
-
if (value == null) {
|
|
34
|
-
console.error("Can't have null transaction at this stage!");
|
|
35
|
-
}
|
|
36
|
-
return value != null;
|
|
37
|
-
});
|
|
38
|
-
transactions = (0, orderBy_1.default)(transactionsUnsorted, (value) => value.date.valueOf(), 'desc');
|
|
39
|
-
}
|
|
40
|
-
const key = (0, transactionListState_1.getProjectAcKey)(accountId, accountType, projectId);
|
|
41
|
-
const uiState = (0, get_1.default)(transactionListState.byProject.transactionListUIStateByProjectKey, key, {});
|
|
42
|
-
return {
|
|
43
|
-
reportId: 'transaction_list_of_account_by_project',
|
|
44
|
-
reportTitle: 'Transaction List of Account By Project',
|
|
45
|
-
version: 1,
|
|
46
|
-
status: undefined,
|
|
47
|
-
fetchState: fetchState.fetchState,
|
|
48
|
-
error: fetchState.error,
|
|
49
|
-
timeframe,
|
|
50
|
-
filterByTimePeriod,
|
|
51
|
-
accountId,
|
|
52
|
-
accountType,
|
|
53
|
-
projectId,
|
|
54
|
-
account,
|
|
55
|
-
transactionOrder: 'descending_transaction_date',
|
|
56
|
-
transactions,
|
|
57
|
-
uiState,
|
|
58
|
-
latestTransactionId: transactionListState.latestTransactionId,
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
exports.getTransactionListByProject = getTransactionListByProject;
|
|
62
|
-
const getTransactionListUIStateByProjectKey = (transactionListState, accountId, accountType, projectId) => {
|
|
63
|
-
const key = (0, transactionListState_1.getProjectAcKey)(accountId, accountType, projectId);
|
|
64
|
-
return (0, get_1.default)(transactionListState.byProject.transactionListUIStateByProjectKey, key, undefined);
|
|
65
|
-
};
|
|
66
|
-
exports.getTransactionListUIStateByProjectKey = getTransactionListUIStateByProjectKey;
|