@zeniai/client-epic-state 5.0.0-betaRD2 → 5.0.0
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/commonPayloadTypes/subAccountView/reportBySubAccountPayload.d.ts +0 -2
- package/lib/commonStateTypes/common.d.ts +1 -1
- package/lib/commonStateTypes/viewAndReport/reportIDHelper.d.ts +0 -1
- package/lib/commonStateTypes/viewAndReport/reportIDHelper.js +1 -3
- package/lib/commonStateTypes/viewAndReport/viewAndReport.d.ts +2 -2
- package/lib/commonStateTypes/viewAndReport/viewAndReport.js +0 -1
- package/lib/entity/account/accountReducer.js +3 -5
- package/lib/entity/account/accountSelector.d.ts +0 -7
- package/lib/entity/account/accountSelector.js +2 -4
- package/lib/entity/account/accountState.d.ts +1 -3
- package/lib/entity/account/accountState.js +1 -4
- package/lib/entity/account/pickAndMergeForecastAccountReport.d.ts +0 -1
- package/lib/entity/account/subAccountSelector.d.ts +0 -2
- package/lib/entity/account/subAccountSelector.js +0 -2
- package/lib/entity/accountGroup/accountGroupSelector.d.ts +0 -22
- 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/tenant/clearAllEpic.d.ts +2 -5
- package/lib/entity/tenant/clearAllEpic.js +0 -6
- package/lib/entity/tenant/tenantPayload.d.ts +0 -1
- package/lib/entity/tenant/tenantReducer.js +0 -1
- package/lib/entity/tenant/tenantSelector.d.ts +0 -1
- package/lib/entity/tenant/tenantSelector.js +1 -9
- package/lib/entity/tenant/tenantState.d.ts +0 -1
- package/lib/epic.d.ts +1 -4
- package/lib/epic.js +1 -4
- package/lib/esm/commonStateTypes/viewAndReport/reportIDHelper.js +0 -1
- package/lib/esm/commonStateTypes/viewAndReport/viewAndReport.js +0 -1
- package/lib/esm/entity/account/accountReducer.js +3 -5
- package/lib/esm/entity/account/accountSelector.js +2 -4
- package/lib/esm/entity/account/accountState.js +1 -4
- package/lib/esm/entity/account/subAccountSelector.js +0 -2
- package/lib/esm/entity/tenant/clearAllEpic.js +0 -6
- package/lib/esm/entity/tenant/tenantReducer.js +0 -1
- package/lib/esm/entity/tenant/tenantSelector.js +0 -7
- package/lib/esm/epic.js +1 -4
- package/lib/esm/index.js +4 -7
- package/lib/esm/reducer.js +0 -9
- package/lib/esm/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +1 -1
- package/lib/esm/view/financeStatement/financeStatementSelector.js +1 -12
- package/lib/esm/view/reportsResync/reportsClassViewRefetchingEpic.js +0 -4
- package/lib/index.d.ts +4 -11
- package/lib/index.js +34 -46
- package/lib/reducer.d.ts +0 -9
- package/lib/reducer.js +0 -9
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
- package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +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 -2
- package/lib/view/cashBalance/cashBalanceSelector.d.ts +1 -2
- 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/financeStatement/financeStatementSelector.d.ts +0 -2
- package/lib/view/financeStatement/financeStatementSelector.js +1 -12
- package/lib/view/globalMerchantView/globalMerchantViewReducer.d.ts +2 -2
- package/lib/view/reimbursementCard/reimbursementCardSelector.d.ts +1 -1
- package/lib/view/reportsResync/reportsClassViewRefetchingEpic.d.ts +1 -2
- package/lib/view/reportsResync/reportsClassViewRefetchingEpic.js +0 -4
- 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/package.json +1 -1
- package/lib/commonStateTypes/coaBalance/coaBalancesFilterProjectView.d.ts +0 -13
- package/lib/commonStateTypes/coaBalance/coaBalancesFilterProjectView.js +0 -9
- package/lib/commonStateTypes/projectView/projectViewParentID.d.ts +0 -5
- package/lib/commonStateTypes/projectView/projectViewParentID.js +0 -2
- package/lib/entity/project/projectPayload.d.ts +0 -13
- package/lib/entity/project/projectPayload.js +0 -30
- package/lib/entity/project/projectReducer.d.ts +0 -10
- package/lib/entity/project/projectReducer.js +0 -31
- package/lib/entity/project/projectSelector.d.ts +0 -5
- package/lib/entity/project/projectSelector.js +0 -12
- package/lib/entity/project/projectState.d.ts +0 -13
- package/lib/entity/project/projectState.js +0 -2
- package/lib/entity/sectionProjectView/sectionProjectView.d.ts +0 -11
- package/lib/entity/sectionProjectView/sectionProjectView.js +0 -6
- package/lib/entity/sectionProjectView/sectionProjectViewEpic.d.ts +0 -6
- package/lib/entity/sectionProjectView/sectionProjectViewEpic.js +0 -56
- package/lib/entity/sectionProjectView/sectionProjectViewHelper.d.ts +0 -10
- package/lib/entity/sectionProjectView/sectionProjectViewHelper.js +0 -14
- package/lib/entity/sectionProjectView/sectionProjectViewReducer.d.ts +0 -15
- package/lib/entity/sectionProjectView/sectionProjectViewReducer.js +0 -56
- package/lib/entity/sectionProjectView/sectionProjectViewSelector.d.ts +0 -11
- package/lib/entity/sectionProjectView/sectionProjectViewSelector.js +0 -94
- package/lib/entity/sectionProjectView/sectionProjectViewSelectorTypes.d.ts +0 -16
- package/lib/entity/sectionProjectView/sectionProjectViewSelectorTypes.js +0 -2
- package/lib/entity/sectionProjectView/sectionProjectViewState.d.ts +0 -4
- package/lib/entity/sectionProjectView/sectionProjectViewState.js +0 -2
- package/lib/esm/commonStateTypes/coaBalance/coaBalancesFilterProjectView.js +0 -5
- package/lib/esm/commonStateTypes/projectView/projectViewParentID.js +0 -1
- package/lib/esm/entity/project/projectPayload.js +0 -26
- package/lib/esm/entity/project/projectReducer.js +0 -27
- package/lib/esm/entity/project/projectSelector.js +0 -8
- package/lib/esm/entity/project/projectState.js +0 -1
- package/lib/esm/entity/sectionProjectView/sectionProjectView.js +0 -3
- package/lib/esm/entity/sectionProjectView/sectionProjectViewEpic.js +0 -52
- package/lib/esm/entity/sectionProjectView/sectionProjectViewHelper.js +0 -10
- package/lib/esm/entity/sectionProjectView/sectionProjectViewReducer.js +0 -52
- package/lib/esm/entity/sectionProjectView/sectionProjectViewSelector.js +0 -87
- package/lib/esm/entity/sectionProjectView/sectionProjectViewSelectorTypes.js +0 -1
- package/lib/esm/entity/sectionProjectView/sectionProjectViewState.js +0 -1
- package/lib/esm/view/profitAndLossProjectView/profitAndLossForTimeframeProjectViewEpic.js +0 -47
- package/lib/esm/view/profitAndLossProjectView/profitAndLossProjectViewEpic.js +0 -30
- package/lib/esm/view/profitAndLossProjectView/profitAndLossProjectViewPayload.js +0 -1
- package/lib/esm/view/profitAndLossProjectView/profitAndLossProjectViewReducer.js +0 -113
- package/lib/esm/view/profitAndLossProjectView/profitAndLossProjectViewSelector.js +0 -67
- package/lib/esm/view/profitAndLossProjectView/profitAndLossProjectViewSelectorTypes.js +0 -1
- package/lib/esm/view/profitAndLossProjectView/profitAndLossProjectViewState.js +0 -1
- package/lib/view/profitAndLossProjectView/profitAndLossForTimeframeProjectViewEpic.d.ts +0 -9
- package/lib/view/profitAndLossProjectView/profitAndLossForTimeframeProjectViewEpic.js +0 -51
- package/lib/view/profitAndLossProjectView/profitAndLossProjectViewEpic.d.ts +0 -6
- package/lib/view/profitAndLossProjectView/profitAndLossProjectViewEpic.js +0 -34
- package/lib/view/profitAndLossProjectView/profitAndLossProjectViewPayload.d.ts +0 -33
- package/lib/view/profitAndLossProjectView/profitAndLossProjectViewPayload.js +0 -2
- package/lib/view/profitAndLossProjectView/profitAndLossProjectViewReducer.d.ts +0 -33
- package/lib/view/profitAndLossProjectView/profitAndLossProjectViewReducer.js +0 -117
- package/lib/view/profitAndLossProjectView/profitAndLossProjectViewSelector.d.ts +0 -9
- package/lib/view/profitAndLossProjectView/profitAndLossProjectViewSelector.js +0 -71
- package/lib/view/profitAndLossProjectView/profitAndLossProjectViewSelectorTypes.d.ts +0 -19
- package/lib/view/profitAndLossProjectView/profitAndLossProjectViewSelectorTypes.js +0 -2
- package/lib/view/profitAndLossProjectView/profitAndLossProjectViewState.d.ts +0 -22
- package/lib/view/profitAndLossProjectView/profitAndLossProjectViewState.js +0 -2
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { from, of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { updateProjects } from '../../entity/project/projectReducer';
|
|
4
|
-
import { updateSectionProjectView } from '../../entity/sectionProjectView/sectionProjectViewReducer';
|
|
5
|
-
import { createZeniAPIStatus, isSuccessResponse } from '../../responsePayload';
|
|
6
|
-
import { fetchProfitAndLossForTimeframeProjectView, updateProfitAndLossForTimeframeProjectView, updateProfitAndLossForTimeframeProjectViewFailure, } from './profitAndLossProjectViewReducer';
|
|
7
|
-
export const fetchProfitAndLossForTimeframeProjectViewEpic = (actions$, _, zeniAPI) => actions$.pipe(filter(fetchProfitAndLossForTimeframeProjectView.match), mergeMap((action) => {
|
|
8
|
-
const getTimeSeriesGroup = (timeframe) => {
|
|
9
|
-
switch (timeframe) {
|
|
10
|
-
case 'month':
|
|
11
|
-
return 'months';
|
|
12
|
-
case 'quarter':
|
|
13
|
-
return 'quarters';
|
|
14
|
-
case 'year':
|
|
15
|
-
return 'years';
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
const queryValue = {
|
|
19
|
-
is_full_response: action.payload.fetchFullReport,
|
|
20
|
-
time_series_groups: [getTimeSeriesGroup(action.payload.timeframe)],
|
|
21
|
-
is_group_by_project: true,
|
|
22
|
-
};
|
|
23
|
-
return zeniAPI
|
|
24
|
-
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/profit_and_loss?query=${encodeURIComponent(JSON.stringify(queryValue))}`)
|
|
25
|
-
.pipe(mergeMap((response) => {
|
|
26
|
-
if (response.data != null && isSuccessResponse(response)) {
|
|
27
|
-
const actions = [];
|
|
28
|
-
const report = response.data.report;
|
|
29
|
-
const currency = report.currency;
|
|
30
|
-
actions.push(updateProjects(report.projects));
|
|
31
|
-
actions.push(updateSectionProjectView(action.payload.timeframe, 'cogs', 'profit_and_loss_by_projects', report.cogs, report.accounts, currency));
|
|
32
|
-
actions.push(updateSectionProjectView(action.payload.timeframe, 'expenses', 'profit_and_loss_by_projects', report.expenses, report.accounts, currency));
|
|
33
|
-
actions.push(updateSectionProjectView(action.payload.timeframe, 'income', 'profit_and_loss_by_projects', report.income, report.accounts, currency));
|
|
34
|
-
actions.push(updateSectionProjectView(action.payload.timeframe, 'otherExpenses', 'profit_and_loss_by_projects', report.other_expenses, report.accounts, currency));
|
|
35
|
-
actions.push(updateSectionProjectView(action.payload.timeframe, 'otherIncome', 'profit_and_loss_by_projects', report.other_income, report.accounts, currency));
|
|
36
|
-
actions.push(updateProfitAndLossForTimeframeProjectView({
|
|
37
|
-
timeframe: action.payload.timeframe,
|
|
38
|
-
report: response.data,
|
|
39
|
-
}));
|
|
40
|
-
return from(actions);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
return of(updateProfitAndLossForTimeframeProjectViewFailure(response.status, action.payload.timeframe));
|
|
44
|
-
}
|
|
45
|
-
}), catchError((error) => of(updateProfitAndLossForTimeframeProjectViewFailure(createZeniAPIStatus('Unexpected Error', 'P&L by Projects REST API call errored out' +
|
|
46
|
-
JSON.stringify(error)), action.payload.timeframe))));
|
|
47
|
-
}));
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { from } from 'rxjs';
|
|
2
|
-
import { filter, switchMap } from 'rxjs/operators';
|
|
3
|
-
import { fetchProfitAndLossForTimeframeProjectView, fetchProfitAndLossProjectView, } from './profitAndLossProjectViewReducer';
|
|
4
|
-
export const fetchProfitAndLossProjectViewEpic = (actions$, state) => actions$.pipe(filter(fetchProfitAndLossProjectView.match), switchMap((action) => {
|
|
5
|
-
const { cacheOverride } = action.payload;
|
|
6
|
-
if (cacheOverride === true) {
|
|
7
|
-
return from([
|
|
8
|
-
fetchProfitAndLossForTimeframeProjectView('month'),
|
|
9
|
-
fetchProfitAndLossForTimeframeProjectView('quarter'),
|
|
10
|
-
fetchProfitAndLossForTimeframeProjectView('year'),
|
|
11
|
-
]);
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
const fetchActions = [];
|
|
15
|
-
const projectFetchState = state.value.profitAndLossProjectViewState.fetchState;
|
|
16
|
-
if (projectFetchState['month'].fetchState !== 'In-Progress' &&
|
|
17
|
-
projectFetchState['month'].fetchState !== 'Completed') {
|
|
18
|
-
fetchActions.push(fetchProfitAndLossForTimeframeProjectView('month'));
|
|
19
|
-
}
|
|
20
|
-
if (projectFetchState['quarter'].fetchState !== 'In-Progress' &&
|
|
21
|
-
projectFetchState['quarter'].fetchState !== 'Completed') {
|
|
22
|
-
fetchActions.push(fetchProfitAndLossForTimeframeProjectView('quarter'));
|
|
23
|
-
}
|
|
24
|
-
if (projectFetchState['year'].fetchState !== 'In-Progress' &&
|
|
25
|
-
projectFetchState['year'].fetchState !== 'Completed') {
|
|
26
|
-
fetchActions.push(fetchProfitAndLossForTimeframeProjectView('year'));
|
|
27
|
-
}
|
|
28
|
-
return from(fetchActions);
|
|
29
|
-
}
|
|
30
|
-
}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
-
import { mapReportPayloadV2ToReportV2 } from '../../commonPayloadTypes/v2/viewAndReportPayloadv2';
|
|
3
|
-
export const initialState = {
|
|
4
|
-
bookCloseDate: undefined,
|
|
5
|
-
fetchState: {
|
|
6
|
-
month: {
|
|
7
|
-
fetchState: 'Not-Started',
|
|
8
|
-
error: undefined,
|
|
9
|
-
},
|
|
10
|
-
quarter: {
|
|
11
|
-
fetchState: 'Not-Started',
|
|
12
|
-
error: undefined,
|
|
13
|
-
},
|
|
14
|
-
year: {
|
|
15
|
-
fetchState: 'Not-Started',
|
|
16
|
-
error: undefined,
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
firstMonthOfFY: 1,
|
|
20
|
-
projectIds: [],
|
|
21
|
-
reportId: 'profit_and_loss_by_projects',
|
|
22
|
-
reportTitle: 'profit_and_loss_by_projects',
|
|
23
|
-
uiState: {
|
|
24
|
-
accountViewMode: 'project',
|
|
25
|
-
nodeCollapseState: {},
|
|
26
|
-
projectsToFilterOut: [],
|
|
27
|
-
scrollPosition: undefined,
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
const profitAndLossProjectView = createSlice({
|
|
31
|
-
name: 'profitAndLossProjectView',
|
|
32
|
-
initialState,
|
|
33
|
-
reducers: {
|
|
34
|
-
fetchProfitAndLossProjectView: {
|
|
35
|
-
prepare(cacheOverride = false) {
|
|
36
|
-
return { payload: { cacheOverride } };
|
|
37
|
-
},
|
|
38
|
-
reducer(
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
40
|
-
_draft,
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
42
|
-
_action) {
|
|
43
|
-
// nothing to do here
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
fetchProfitAndLossForTimeframeProjectView: {
|
|
47
|
-
prepare(timeframe, fetchFullReport = true, cacheOverride = false) {
|
|
48
|
-
return { payload: { timeframe, fetchFullReport, cacheOverride } };
|
|
49
|
-
},
|
|
50
|
-
reducer(draft, action) {
|
|
51
|
-
const timeframe = action.payload.timeframe;
|
|
52
|
-
draft.fetchState[timeframe].fetchState = 'In-Progress';
|
|
53
|
-
draft.fetchState[timeframe].error = undefined;
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
updateProfitAndLossForTimeframeProjectView(draft, action) {
|
|
57
|
-
doUpdateProfitAndLossProjectView(draft, action.payload.timeframe, action.payload.report);
|
|
58
|
-
},
|
|
59
|
-
updateProfitAndLossForTimeframeProjectViewFailure: {
|
|
60
|
-
prepare(error, timeframe) {
|
|
61
|
-
return {
|
|
62
|
-
payload: {
|
|
63
|
-
error,
|
|
64
|
-
timeframe,
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
},
|
|
68
|
-
reducer(draft, action) {
|
|
69
|
-
draft.fetchState[action.payload.timeframe] = {
|
|
70
|
-
fetchState: 'Error',
|
|
71
|
-
error: action.payload.error,
|
|
72
|
-
};
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
updateProjectsToFilterOut(draft, action) {
|
|
76
|
-
draft.uiState.projectsToFilterOut = action.payload.projectsToFilterOut;
|
|
77
|
-
},
|
|
78
|
-
updateProfitAndLossProjectViewUIState(draft, action) {
|
|
79
|
-
const { nodeCollapseState, scrollPosition } = action.payload;
|
|
80
|
-
if (nodeCollapseState != null) {
|
|
81
|
-
draft.uiState.nodeCollapseState = Object.assign({}, draft.uiState.nodeCollapseState, {
|
|
82
|
-
[nodeCollapseState.nodeId]: nodeCollapseState.isCollapsed,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
if (scrollPosition != null) {
|
|
86
|
-
draft.uiState.scrollPosition = scrollPosition;
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
updateProjectViewAccountViewMode(draft, action) {
|
|
90
|
-
draft.uiState.accountViewMode = action.payload.viewMode;
|
|
91
|
-
},
|
|
92
|
-
resetProfitAndLossProjectNodeCollapseState(draft) {
|
|
93
|
-
draft.uiState.nodeCollapseState = {};
|
|
94
|
-
},
|
|
95
|
-
clearProfitAndLossProjectView(draft) {
|
|
96
|
-
Object.assign(draft, initialState);
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
export const { fetchProfitAndLossProjectView, fetchProfitAndLossForTimeframeProjectView, updateProfitAndLossForTimeframeProjectView, updateProfitAndLossForTimeframeProjectViewFailure, updateProjectsToFilterOut, updateProfitAndLossProjectViewUIState, updateProjectViewAccountViewMode, resetProfitAndLossProjectNodeCollapseState, clearProfitAndLossProjectView, } = profitAndLossProjectView.actions;
|
|
101
|
-
export default profitAndLossProjectView.reducer;
|
|
102
|
-
const doUpdateProfitAndLossProjectView = (draft, timeframe, pandLReport) => {
|
|
103
|
-
const report = mapReportPayloadV2ToReportV2(pandLReport.report);
|
|
104
|
-
draft.currency = report.currency;
|
|
105
|
-
draft.dataAvailable = report.dataAvailable;
|
|
106
|
-
draft.firstMonthOfFY = report.firstMonthOfFY;
|
|
107
|
-
draft.bookCloseDate = report.bookCloseDate;
|
|
108
|
-
draft.status = report.status;
|
|
109
|
-
draft.fetchState[timeframe].fetchState = 'Completed';
|
|
110
|
-
if (draft.projectIds.length <= 0) {
|
|
111
|
-
draft.projectIds = pandLReport.report.projects.map((project) => project.zeni_project_id);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { getDifferenceOfBalancesGroupedByPeriod } from '../../commonStateTypes/coaBalance/classBalances/getDifferenceOfBalancesGroupedByPeriod';
|
|
2
|
-
import { getSumOfBalancesByGroupedByPeriod } from '../../commonStateTypes/coaBalance/classBalances/getSumOfBalancesGroupedByPeriod';
|
|
3
|
-
import { getCOABalances } from '../../commonStateTypes/coaBalance/coaBalance';
|
|
4
|
-
import { reduceFetchStateParallelTimeframes } from '../../commonStateTypes/reduceFetchState';
|
|
5
|
-
import { getProjectsByIds } from '../../entity/project/projectSelector';
|
|
6
|
-
import { getSectionProjectViewReport } from '../../entity/sectionProjectView/sectionProjectViewSelector';
|
|
7
|
-
import { ALL_PANDL_REPORT_VIEW_SECTION_IDS, } from '../profitAndLossClassesView/profitAndLossClassesViewSelectorTypes';
|
|
8
|
-
export const profitAndLossProjectIdsInOrder = [
|
|
9
|
-
'income',
|
|
10
|
-
'cogs',
|
|
11
|
-
'grossProfit',
|
|
12
|
-
'expenses',
|
|
13
|
-
'earningsBeforeInterestAndTax',
|
|
14
|
-
'otherIncome',
|
|
15
|
-
'otherExpenses',
|
|
16
|
-
'netOtherIncome',
|
|
17
|
-
'netIncome',
|
|
18
|
-
];
|
|
19
|
-
export const getProfitAndLossProjectView = (filter, accountState, projectState, sectionsState, profitAndLossProjectViewState) => {
|
|
20
|
-
const fetchState = reduceFetchStateParallelTimeframes([
|
|
21
|
-
profitAndLossProjectViewState.fetchState.month,
|
|
22
|
-
profitAndLossProjectViewState.fetchState.quarter,
|
|
23
|
-
profitAndLossProjectViewState.fetchState.year,
|
|
24
|
-
]);
|
|
25
|
-
const reportId = 'profit_and_loss_by_projects';
|
|
26
|
-
const sections = {};
|
|
27
|
-
const calculatedSections = {};
|
|
28
|
-
if (fetchState.fetchState === 'Completed') {
|
|
29
|
-
ALL_PANDL_REPORT_VIEW_SECTION_IDS.forEach((sectionId) => {
|
|
30
|
-
sections[`${sectionId}`] = getSectionProjectViewReport(accountState, projectState, sectionsState, profitAndLossProjectViewState.projectIds, {
|
|
31
|
-
reportId,
|
|
32
|
-
sectionId,
|
|
33
|
-
}, filter);
|
|
34
|
-
});
|
|
35
|
-
const grossProfitBalancesByPeriod = getDifferenceOfBalancesGroupedByPeriod(sections['income'].sectionBalancesTotalByPeriod, sections['cogs'].sectionBalancesTotalByPeriod);
|
|
36
|
-
calculatedSections['grossProfit'] = getCOABalances(grossProfitBalancesByPeriod, filter);
|
|
37
|
-
const ebitBalancesByPeriod = getDifferenceOfBalancesGroupedByPeriod(grossProfitBalancesByPeriod, sections['expenses'].sectionBalancesTotalByPeriod);
|
|
38
|
-
calculatedSections['earningsBeforeInterestAndTax'] = getCOABalances(ebitBalancesByPeriod, filter);
|
|
39
|
-
const netOtherIncomeBalances = getDifferenceOfBalancesGroupedByPeriod(sections['otherIncome'].sectionBalancesTotalByPeriod, sections['otherExpenses'].sectionBalancesTotalByPeriod);
|
|
40
|
-
calculatedSections['netOtherIncome'] = getCOABalances(netOtherIncomeBalances, filter);
|
|
41
|
-
const netIncomeBalances = netOtherIncomeBalances != null
|
|
42
|
-
? getSumOfBalancesByGroupedByPeriod([
|
|
43
|
-
ebitBalancesByPeriod,
|
|
44
|
-
netOtherIncomeBalances,
|
|
45
|
-
])
|
|
46
|
-
: ebitBalancesByPeriod;
|
|
47
|
-
calculatedSections['netIncome'] = getCOABalances(netIncomeBalances, filter);
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
sections,
|
|
51
|
-
calculatedSections,
|
|
52
|
-
reportId: profitAndLossProjectViewState.reportId,
|
|
53
|
-
reportTitle: profitAndLossProjectViewState.reportTitle,
|
|
54
|
-
firstMonthOfFY: profitAndLossProjectViewState.firstMonthOfFY,
|
|
55
|
-
dataAvailable: profitAndLossProjectViewState.dataAvailable,
|
|
56
|
-
bookCloseDate: profitAndLossProjectViewState.bookCloseDate,
|
|
57
|
-
version: profitAndLossProjectViewState.version,
|
|
58
|
-
status: profitAndLossProjectViewState.status,
|
|
59
|
-
fetchState: fetchState.fetchState,
|
|
60
|
-
error: fetchState.error,
|
|
61
|
-
filter,
|
|
62
|
-
uiState: profitAndLossProjectViewState.uiState,
|
|
63
|
-
projects: getProjectsByIds(projectState, profitAndLossProjectViewState.projectIds),
|
|
64
|
-
projectsToFilterOut: profitAndLossProjectViewState.uiState.projectsToFilterOut,
|
|
65
|
-
idsInOrder: profitAndLossProjectIdsInOrder,
|
|
66
|
-
};
|
|
67
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { updateProjects } from '../../entity/project/projectReducer';
|
|
4
|
-
import { updateSectionProjectView } from '../../entity/sectionProjectView/sectionProjectViewReducer';
|
|
5
|
-
import { RootState } from '../../reducer';
|
|
6
|
-
import { ZeniAPI } from '../../zeniAPI';
|
|
7
|
-
import { fetchProfitAndLossForTimeframeProjectView, updateProfitAndLossForTimeframeProjectView, updateProfitAndLossForTimeframeProjectViewFailure } from './profitAndLossProjectViewReducer';
|
|
8
|
-
export type ActionType = ReturnType<typeof fetchProfitAndLossForTimeframeProjectView> | ReturnType<typeof updateProfitAndLossForTimeframeProjectView> | ReturnType<typeof updateProfitAndLossForTimeframeProjectViewFailure> | ReturnType<typeof updateProjects> | ReturnType<typeof updateSectionProjectView>;
|
|
9
|
-
export declare const fetchProfitAndLossForTimeframeProjectViewEpic: (actions$: ActionsObservable<ActionType>, _: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchProfitAndLossForTimeframeProjectViewEpic = 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 sectionProjectViewReducer_1 = require("../../entity/sectionProjectView/sectionProjectViewReducer");
|
|
8
|
-
const responsePayload_1 = require("../../responsePayload");
|
|
9
|
-
const profitAndLossProjectViewReducer_1 = require("./profitAndLossProjectViewReducer");
|
|
10
|
-
const fetchProfitAndLossForTimeframeProjectViewEpic = (actions$, _, zeniAPI) => actions$.pipe((0, operators_1.filter)(profitAndLossProjectViewReducer_1.fetchProfitAndLossForTimeframeProjectView.match), (0, operators_1.mergeMap)((action) => {
|
|
11
|
-
const getTimeSeriesGroup = (timeframe) => {
|
|
12
|
-
switch (timeframe) {
|
|
13
|
-
case 'month':
|
|
14
|
-
return 'months';
|
|
15
|
-
case 'quarter':
|
|
16
|
-
return 'quarters';
|
|
17
|
-
case 'year':
|
|
18
|
-
return 'years';
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
const queryValue = {
|
|
22
|
-
is_full_response: action.payload.fetchFullReport,
|
|
23
|
-
time_series_groups: [getTimeSeriesGroup(action.payload.timeframe)],
|
|
24
|
-
is_group_by_project: true,
|
|
25
|
-
};
|
|
26
|
-
return zeniAPI
|
|
27
|
-
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/profit_and_loss?query=${encodeURIComponent(JSON.stringify(queryValue))}`)
|
|
28
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
29
|
-
if (response.data != null && (0, responsePayload_1.isSuccessResponse)(response)) {
|
|
30
|
-
const actions = [];
|
|
31
|
-
const report = response.data.report;
|
|
32
|
-
const currency = report.currency;
|
|
33
|
-
actions.push((0, projectReducer_1.updateProjects)(report.projects));
|
|
34
|
-
actions.push((0, sectionProjectViewReducer_1.updateSectionProjectView)(action.payload.timeframe, 'cogs', 'profit_and_loss_by_projects', report.cogs, report.accounts, currency));
|
|
35
|
-
actions.push((0, sectionProjectViewReducer_1.updateSectionProjectView)(action.payload.timeframe, 'expenses', 'profit_and_loss_by_projects', report.expenses, report.accounts, currency));
|
|
36
|
-
actions.push((0, sectionProjectViewReducer_1.updateSectionProjectView)(action.payload.timeframe, 'income', 'profit_and_loss_by_projects', report.income, report.accounts, currency));
|
|
37
|
-
actions.push((0, sectionProjectViewReducer_1.updateSectionProjectView)(action.payload.timeframe, 'otherExpenses', 'profit_and_loss_by_projects', report.other_expenses, report.accounts, currency));
|
|
38
|
-
actions.push((0, sectionProjectViewReducer_1.updateSectionProjectView)(action.payload.timeframe, 'otherIncome', 'profit_and_loss_by_projects', report.other_income, report.accounts, currency));
|
|
39
|
-
actions.push((0, profitAndLossProjectViewReducer_1.updateProfitAndLossForTimeframeProjectView)({
|
|
40
|
-
timeframe: action.payload.timeframe,
|
|
41
|
-
report: response.data,
|
|
42
|
-
}));
|
|
43
|
-
return (0, rxjs_1.from)(actions);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
return (0, rxjs_1.of)((0, profitAndLossProjectViewReducer_1.updateProfitAndLossForTimeframeProjectViewFailure)(response.status, action.payload.timeframe));
|
|
47
|
-
}
|
|
48
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, profitAndLossProjectViewReducer_1.updateProfitAndLossForTimeframeProjectViewFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'P&L by Projects REST API call errored out' +
|
|
49
|
-
JSON.stringify(error)), action.payload.timeframe))));
|
|
50
|
-
}));
|
|
51
|
-
exports.fetchProfitAndLossForTimeframeProjectViewEpic = fetchProfitAndLossForTimeframeProjectViewEpic;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { RootState } from '../../reducer';
|
|
4
|
-
import { fetchProfitAndLossForTimeframeProjectView, fetchProfitAndLossProjectView } from './profitAndLossProjectViewReducer';
|
|
5
|
-
export type ActionType = ReturnType<typeof fetchProfitAndLossProjectView> | ReturnType<typeof fetchProfitAndLossForTimeframeProjectView>;
|
|
6
|
-
export declare const fetchProfitAndLossProjectViewEpic: (actions$: ActionsObservable<ActionType>, state: StateObservable<RootState>) => Observable<ActionType>;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchProfitAndLossProjectViewEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const profitAndLossProjectViewReducer_1 = require("./profitAndLossProjectViewReducer");
|
|
7
|
-
const fetchProfitAndLossProjectViewEpic = (actions$, state) => actions$.pipe((0, operators_1.filter)(profitAndLossProjectViewReducer_1.fetchProfitAndLossProjectView.match), (0, operators_1.switchMap)((action) => {
|
|
8
|
-
const { cacheOverride } = action.payload;
|
|
9
|
-
if (cacheOverride === true) {
|
|
10
|
-
return (0, rxjs_1.from)([
|
|
11
|
-
(0, profitAndLossProjectViewReducer_1.fetchProfitAndLossForTimeframeProjectView)('month'),
|
|
12
|
-
(0, profitAndLossProjectViewReducer_1.fetchProfitAndLossForTimeframeProjectView)('quarter'),
|
|
13
|
-
(0, profitAndLossProjectViewReducer_1.fetchProfitAndLossForTimeframeProjectView)('year'),
|
|
14
|
-
]);
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
const fetchActions = [];
|
|
18
|
-
const projectFetchState = state.value.profitAndLossProjectViewState.fetchState;
|
|
19
|
-
if (projectFetchState['month'].fetchState !== 'In-Progress' &&
|
|
20
|
-
projectFetchState['month'].fetchState !== 'Completed') {
|
|
21
|
-
fetchActions.push((0, profitAndLossProjectViewReducer_1.fetchProfitAndLossForTimeframeProjectView)('month'));
|
|
22
|
-
}
|
|
23
|
-
if (projectFetchState['quarter'].fetchState !== 'In-Progress' &&
|
|
24
|
-
projectFetchState['quarter'].fetchState !== 'Completed') {
|
|
25
|
-
fetchActions.push((0, profitAndLossProjectViewReducer_1.fetchProfitAndLossForTimeframeProjectView)('quarter'));
|
|
26
|
-
}
|
|
27
|
-
if (projectFetchState['year'].fetchState !== 'In-Progress' &&
|
|
28
|
-
projectFetchState['year'].fetchState !== 'Completed') {
|
|
29
|
-
fetchActions.push((0, profitAndLossProjectViewReducer_1.fetchProfitAndLossForTimeframeProjectView)('year'));
|
|
30
|
-
}
|
|
31
|
-
return (0, rxjs_1.from)(fetchActions);
|
|
32
|
-
}
|
|
33
|
-
}));
|
|
34
|
-
exports.fetchProfitAndLossProjectViewEpic = fetchProfitAndLossProjectViewEpic;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { AccountCOABalanceGroupedPayloadByAccountId } from '../../commonPayloadTypes/subAccountView/reportBySubAccountPayload';
|
|
2
|
-
import { COABalanceGroupedPayloadV2 } from '../../commonPayloadTypes/v2/coaBalancePayload';
|
|
3
|
-
import { ReportPayloadV2 } from '../../commonPayloadTypes/v2/viewAndReportPayloadv2';
|
|
4
|
-
import { AccountMetadataPayload } from '../../entity/account/accountPayload';
|
|
5
|
-
import { ProjectMetadataPayload } from '../../entity/project/projectPayload';
|
|
6
|
-
import { ZeniReportResponse } from '../../responsePayload';
|
|
7
|
-
export interface ReportByProjectMetadataPayloadV2 extends ReportPayloadV2 {
|
|
8
|
-
accounts: AccountMetadataPayload[];
|
|
9
|
-
projects: ProjectMetadataPayload[];
|
|
10
|
-
}
|
|
11
|
-
export interface ProjectCOABalanceGroupedPayloadV2 extends COABalanceGroupedPayloadV2 {
|
|
12
|
-
accounts: AccountCOABalanceGroupedPayloadByAccountId;
|
|
13
|
-
}
|
|
14
|
-
interface ProjectCOABalanceGroupedPayloadByProjectIdV2 {
|
|
15
|
-
[project_Id: string]: ProjectCOABalanceGroupedPayloadV2;
|
|
16
|
-
}
|
|
17
|
-
export interface SectionByProjectCOABalanceGroupedPayloadV2 extends COABalanceGroupedPayloadV2 {
|
|
18
|
-
projects: ProjectCOABalanceGroupedPayloadByProjectIdV2;
|
|
19
|
-
}
|
|
20
|
-
export interface ProfitAndLossProjectViewPayload extends ReportByProjectMetadataPayloadV2 {
|
|
21
|
-
cogs: SectionByProjectCOABalanceGroupedPayloadV2;
|
|
22
|
-
earnings_before_interest_and_tax: COABalanceGroupedPayloadV2;
|
|
23
|
-
expenses: SectionByProjectCOABalanceGroupedPayloadV2;
|
|
24
|
-
gross_profit: COABalanceGroupedPayloadV2;
|
|
25
|
-
income: SectionByProjectCOABalanceGroupedPayloadV2;
|
|
26
|
-
net_income: COABalanceGroupedPayloadV2;
|
|
27
|
-
net_operating_income: COABalanceGroupedPayloadV2;
|
|
28
|
-
net_other_income: COABalanceGroupedPayloadV2;
|
|
29
|
-
other_expenses: SectionByProjectCOABalanceGroupedPayloadV2;
|
|
30
|
-
other_income: SectionByProjectCOABalanceGroupedPayloadV2;
|
|
31
|
-
}
|
|
32
|
-
export type ProfitAndLossReportProjectViewResponse = ZeniReportResponse<ProfitAndLossProjectViewPayload>;
|
|
33
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { AccountViewMode, ID } from '../../commonStateTypes/common';
|
|
2
|
-
import { ZeniAPIStatus, ZeniReportData } from '../../responsePayload';
|
|
3
|
-
import { ProfitAndLossProjectViewPayload } from './profitAndLossProjectViewPayload';
|
|
4
|
-
import { ProfitAndLossProjectViewState } from './profitAndLossProjectViewState';
|
|
5
|
-
export declare const initialState: ProfitAndLossProjectViewState;
|
|
6
|
-
export declare const fetchProfitAndLossProjectView: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[cacheOverride?: boolean | undefined], {
|
|
7
|
-
cacheOverride: boolean;
|
|
8
|
-
}, "profitAndLossProjectView/fetchProfitAndLossProjectView", never, never>, fetchProfitAndLossForTimeframeProjectView: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[timeframe: "month" | "year" | "quarter", fetchFullReport?: boolean | undefined, cacheOverride?: boolean | undefined], {
|
|
9
|
-
timeframe: "month" | "year" | "quarter";
|
|
10
|
-
fetchFullReport: boolean;
|
|
11
|
-
cacheOverride: boolean;
|
|
12
|
-
}, "profitAndLossProjectView/fetchProfitAndLossForTimeframeProjectView", never, never>, updateProfitAndLossForTimeframeProjectView: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
13
|
-
report: ZeniReportData<ProfitAndLossProjectViewPayload>;
|
|
14
|
-
timeframe: "month" | "quarter" | "year";
|
|
15
|
-
}, "profitAndLossProjectView/updateProfitAndLossForTimeframeProjectView">, updateProfitAndLossForTimeframeProjectViewFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[error: ZeniAPIStatus<Record<string, unknown>>, timeframe: "month" | "year" | "quarter"], {
|
|
16
|
-
error: ZeniAPIStatus<Record<string, unknown>>;
|
|
17
|
-
timeframe: "month" | "year" | "quarter";
|
|
18
|
-
}, "profitAndLossProjectView/updateProfitAndLossForTimeframeProjectViewFailure", never, never>, updateProjectsToFilterOut: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
19
|
-
projectsToFilterOut: ID[];
|
|
20
|
-
}, "profitAndLossProjectView/updateProjectsToFilterOut">, updateProfitAndLossProjectViewUIState: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
21
|
-
nodeCollapseState?: {
|
|
22
|
-
isCollapsed: boolean;
|
|
23
|
-
nodeId: ID;
|
|
24
|
-
};
|
|
25
|
-
scrollPosition?: {
|
|
26
|
-
scrollTop: number;
|
|
27
|
-
scrollLeft?: number;
|
|
28
|
-
};
|
|
29
|
-
}, "profitAndLossProjectView/updateProfitAndLossProjectViewUIState">, updateProjectViewAccountViewMode: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
30
|
-
viewMode: AccountViewMode;
|
|
31
|
-
}, "profitAndLossProjectView/updateProjectViewAccountViewMode">, resetProfitAndLossProjectNodeCollapseState: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"profitAndLossProjectView/resetProfitAndLossProjectNodeCollapseState">, clearProfitAndLossProjectView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"profitAndLossProjectView/clearProfitAndLossProjectView">;
|
|
32
|
-
declare const _default: import("redux").Reducer<ProfitAndLossProjectViewState>;
|
|
33
|
-
export default _default;
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.clearProfitAndLossProjectView = exports.resetProfitAndLossProjectNodeCollapseState = exports.updateProjectViewAccountViewMode = exports.updateProfitAndLossProjectViewUIState = exports.updateProjectsToFilterOut = exports.updateProfitAndLossForTimeframeProjectViewFailure = exports.updateProfitAndLossForTimeframeProjectView = exports.fetchProfitAndLossForTimeframeProjectView = exports.fetchProfitAndLossProjectView = exports.initialState = void 0;
|
|
5
|
-
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
-
const viewAndReportPayloadv2_1 = require("../../commonPayloadTypes/v2/viewAndReportPayloadv2");
|
|
7
|
-
exports.initialState = {
|
|
8
|
-
bookCloseDate: undefined,
|
|
9
|
-
fetchState: {
|
|
10
|
-
month: {
|
|
11
|
-
fetchState: 'Not-Started',
|
|
12
|
-
error: undefined,
|
|
13
|
-
},
|
|
14
|
-
quarter: {
|
|
15
|
-
fetchState: 'Not-Started',
|
|
16
|
-
error: undefined,
|
|
17
|
-
},
|
|
18
|
-
year: {
|
|
19
|
-
fetchState: 'Not-Started',
|
|
20
|
-
error: undefined,
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
firstMonthOfFY: 1,
|
|
24
|
-
projectIds: [],
|
|
25
|
-
reportId: 'profit_and_loss_by_projects',
|
|
26
|
-
reportTitle: 'profit_and_loss_by_projects',
|
|
27
|
-
uiState: {
|
|
28
|
-
accountViewMode: 'project',
|
|
29
|
-
nodeCollapseState: {},
|
|
30
|
-
projectsToFilterOut: [],
|
|
31
|
-
scrollPosition: undefined,
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
const profitAndLossProjectView = (0, toolkit_1.createSlice)({
|
|
35
|
-
name: 'profitAndLossProjectView',
|
|
36
|
-
initialState: exports.initialState,
|
|
37
|
-
reducers: {
|
|
38
|
-
fetchProfitAndLossProjectView: {
|
|
39
|
-
prepare(cacheOverride = false) {
|
|
40
|
-
return { payload: { cacheOverride } };
|
|
41
|
-
},
|
|
42
|
-
reducer(
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
44
|
-
_draft,
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
46
|
-
_action) {
|
|
47
|
-
// nothing to do here
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
fetchProfitAndLossForTimeframeProjectView: {
|
|
51
|
-
prepare(timeframe, fetchFullReport = true, cacheOverride = false) {
|
|
52
|
-
return { payload: { timeframe, fetchFullReport, cacheOverride } };
|
|
53
|
-
},
|
|
54
|
-
reducer(draft, action) {
|
|
55
|
-
const timeframe = action.payload.timeframe;
|
|
56
|
-
draft.fetchState[timeframe].fetchState = 'In-Progress';
|
|
57
|
-
draft.fetchState[timeframe].error = undefined;
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
updateProfitAndLossForTimeframeProjectView(draft, action) {
|
|
61
|
-
doUpdateProfitAndLossProjectView(draft, action.payload.timeframe, action.payload.report);
|
|
62
|
-
},
|
|
63
|
-
updateProfitAndLossForTimeframeProjectViewFailure: {
|
|
64
|
-
prepare(error, timeframe) {
|
|
65
|
-
return {
|
|
66
|
-
payload: {
|
|
67
|
-
error,
|
|
68
|
-
timeframe,
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
reducer(draft, action) {
|
|
73
|
-
draft.fetchState[action.payload.timeframe] = {
|
|
74
|
-
fetchState: 'Error',
|
|
75
|
-
error: action.payload.error,
|
|
76
|
-
};
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
updateProjectsToFilterOut(draft, action) {
|
|
80
|
-
draft.uiState.projectsToFilterOut = action.payload.projectsToFilterOut;
|
|
81
|
-
},
|
|
82
|
-
updateProfitAndLossProjectViewUIState(draft, action) {
|
|
83
|
-
const { nodeCollapseState, scrollPosition } = action.payload;
|
|
84
|
-
if (nodeCollapseState != null) {
|
|
85
|
-
draft.uiState.nodeCollapseState = Object.assign({}, draft.uiState.nodeCollapseState, {
|
|
86
|
-
[nodeCollapseState.nodeId]: nodeCollapseState.isCollapsed,
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
if (scrollPosition != null) {
|
|
90
|
-
draft.uiState.scrollPosition = scrollPosition;
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
updateProjectViewAccountViewMode(draft, action) {
|
|
94
|
-
draft.uiState.accountViewMode = action.payload.viewMode;
|
|
95
|
-
},
|
|
96
|
-
resetProfitAndLossProjectNodeCollapseState(draft) {
|
|
97
|
-
draft.uiState.nodeCollapseState = {};
|
|
98
|
-
},
|
|
99
|
-
clearProfitAndLossProjectView(draft) {
|
|
100
|
-
Object.assign(draft, exports.initialState);
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
_a = profitAndLossProjectView.actions, exports.fetchProfitAndLossProjectView = _a.fetchProfitAndLossProjectView, exports.fetchProfitAndLossForTimeframeProjectView = _a.fetchProfitAndLossForTimeframeProjectView, exports.updateProfitAndLossForTimeframeProjectView = _a.updateProfitAndLossForTimeframeProjectView, exports.updateProfitAndLossForTimeframeProjectViewFailure = _a.updateProfitAndLossForTimeframeProjectViewFailure, exports.updateProjectsToFilterOut = _a.updateProjectsToFilterOut, exports.updateProfitAndLossProjectViewUIState = _a.updateProfitAndLossProjectViewUIState, exports.updateProjectViewAccountViewMode = _a.updateProjectViewAccountViewMode, exports.resetProfitAndLossProjectNodeCollapseState = _a.resetProfitAndLossProjectNodeCollapseState, exports.clearProfitAndLossProjectView = _a.clearProfitAndLossProjectView;
|
|
105
|
-
exports.default = profitAndLossProjectView.reducer;
|
|
106
|
-
const doUpdateProfitAndLossProjectView = (draft, timeframe, pandLReport) => {
|
|
107
|
-
const report = (0, viewAndReportPayloadv2_1.mapReportPayloadV2ToReportV2)(pandLReport.report);
|
|
108
|
-
draft.currency = report.currency;
|
|
109
|
-
draft.dataAvailable = report.dataAvailable;
|
|
110
|
-
draft.firstMonthOfFY = report.firstMonthOfFY;
|
|
111
|
-
draft.bookCloseDate = report.bookCloseDate;
|
|
112
|
-
draft.status = report.status;
|
|
113
|
-
draft.fetchState[timeframe].fetchState = 'Completed';
|
|
114
|
-
if (draft.projectIds.length <= 0) {
|
|
115
|
-
draft.projectIds = pandLReport.report.projects.map((project) => project.zeni_project_id);
|
|
116
|
-
}
|
|
117
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { COABalancesFilterProjectView } from '../../commonStateTypes/coaBalance/coaBalancesFilterProjectView';
|
|
2
|
-
import { AccountState } from '../../entity/account/accountState';
|
|
3
|
-
import { ProjectState } from '../../entity/project/projectReducer';
|
|
4
|
-
import { SectionProjectViewState } from '../../entity/sectionProjectView/sectionProjectViewState';
|
|
5
|
-
import { PandLReportViewCalculatedSectionID, PandLReportViewSectionID } from '../profitAndLossClassesView/profitAndLossClassesViewSelectorTypes';
|
|
6
|
-
import { ProfitAndLossProjectViewReport } from './profitAndLossProjectViewSelectorTypes';
|
|
7
|
-
import { ProfitAndLossProjectViewState } from './profitAndLossProjectViewState';
|
|
8
|
-
export declare const profitAndLossProjectIdsInOrder: (PandLReportViewSectionID | PandLReportViewCalculatedSectionID)[];
|
|
9
|
-
export declare const getProfitAndLossProjectView: (filter: COABalancesFilterProjectView, accountState: AccountState, projectState: ProjectState, sectionsState: SectionProjectViewState, profitAndLossProjectViewState: ProfitAndLossProjectViewState) => ProfitAndLossProjectViewReport;
|