@zeniai/client-epic-state 5.0.0-betaRD1 → 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 -45
- 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,6 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { updateMultipleSubAccountsWithBalances } from '../account/accountReducer';
|
|
4
|
-
import { updateSectionProjectView } from './sectionProjectViewReducer';
|
|
5
|
-
export type ActionType = ReturnType<typeof updateSectionProjectView> | ReturnType<typeof updateMultipleSubAccountsWithBalances>;
|
|
6
|
-
export declare const updateSectionProjectViewEpic: (actions$: ActionsObservable<ActionType>) => Observable<ActionType>;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateSectionProjectViewEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const getNestedAccountIDHierarchyForReport_1 = require("../../commonStateTypes/accountView/getNestedAccountIDHierarchyForReport");
|
|
7
|
-
const accountReducer_1 = require("../account/accountReducer");
|
|
8
|
-
const sectionProjectViewReducer_1 = require("./sectionProjectViewReducer");
|
|
9
|
-
const updateSectionProjectViewEpic = (actions$) => actions$.pipe((0, operators_1.filter)(sectionProjectViewReducer_1.updateSectionProjectView.match), (0, operators_1.mergeMap)((action) => {
|
|
10
|
-
const actions = [];
|
|
11
|
-
const sectionPayload = action.payload.sectionPayload;
|
|
12
|
-
const sectionId = action.payload.sectionId;
|
|
13
|
-
const timeframe = action.payload.timeframe;
|
|
14
|
-
const reportId = action.payload.reportId;
|
|
15
|
-
const currencyPayload = action.payload.currencyPayload;
|
|
16
|
-
const accountsMetadataPayload = action.payload.accountsMetadataPayload;
|
|
17
|
-
const accountMetadataRecordsByID = (0, getNestedAccountIDHierarchyForReport_1.getAllAccountMetadataRecordsByID)(accountsMetadataPayload);
|
|
18
|
-
const accountMetadataWithBalancesPayloads = [];
|
|
19
|
-
if (sectionPayload.projects != null) {
|
|
20
|
-
Object.keys(sectionPayload.projects).forEach((projectId) => {
|
|
21
|
-
const projectAccounts = sectionPayload.projects[projectId].accounts;
|
|
22
|
-
const projectsViewParentID = {
|
|
23
|
-
projectId,
|
|
24
|
-
sectionId,
|
|
25
|
-
};
|
|
26
|
-
getSubAccountsMetadataForProjectAccountList(projectAccounts, accountMetadataRecordsByID, sectionId, projectsViewParentID, accountMetadataWithBalancesPayloads);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
if (accountMetadataWithBalancesPayloads.length > 0) {
|
|
30
|
-
actions.push((0, accountReducer_1.updateMultipleSubAccountsWithBalances)(accountMetadataWithBalancesPayloads, currencyPayload, reportId, timeframe));
|
|
31
|
-
}
|
|
32
|
-
return (0, rxjs_1.from)(actions);
|
|
33
|
-
}));
|
|
34
|
-
exports.updateSectionProjectViewEpic = updateSectionProjectViewEpic;
|
|
35
|
-
const getSubAccountsMetadataForProjectAccountList = (accountListWithBalances, accountMetadataRecordsByID, sectionId, projectsViewParentID, result) => {
|
|
36
|
-
if (accountListWithBalances != null) {
|
|
37
|
-
Object.keys(accountListWithBalances).forEach((eachAccountId) => {
|
|
38
|
-
const accountMetadataRecord = accountMetadataRecordsByID[eachAccountId];
|
|
39
|
-
if (accountMetadataRecord != null) {
|
|
40
|
-
const accountId = accountMetadataRecord.nestedAccountId;
|
|
41
|
-
result.push({
|
|
42
|
-
accountsViewParentID: {
|
|
43
|
-
parentAccountId: (0, getNestedAccountIDHierarchyForReport_1.getParentAccountId)(accountId),
|
|
44
|
-
sectionId,
|
|
45
|
-
},
|
|
46
|
-
accountMetadataPayload: accountMetadataRecord.accountMetadataPayload,
|
|
47
|
-
accountBalancesPayload: accountListWithBalances[eachAccountId],
|
|
48
|
-
projectsViewParentID,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
console.warn(`Account ${eachAccountId} in Section ${sectionId} Project ${projectsViewParentID.projectId} is missing metadata.`);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { COABalanceGroupedByPeriodPayloadV2 } from '../../commonPayloadTypes/v2/coaBalancePayload';
|
|
2
|
-
import { CurrencyPayload } from '../../commonPayloadTypes/v2/viewAndReportPayloadv2';
|
|
3
|
-
import { ID } from '../../commonStateTypes/common';
|
|
4
|
-
import { ReportID } from '../../commonStateTypes/viewAndReport/viewAndReport';
|
|
5
|
-
import { SectionProjectView } from './sectionProjectView';
|
|
6
|
-
export declare const mapProjectCOABalanceGroupedPayloadToSectionProjectView: (timeframe: "month" | "quarter" | "year", projectBalancesPayload: COABalanceGroupedByPeriodPayloadV2, currencyPayload: CurrencyPayload, id: {
|
|
7
|
-
projectId: ID;
|
|
8
|
-
reportId: ReportID;
|
|
9
|
-
sectionId: ID;
|
|
10
|
-
}) => SectionProjectView;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapProjectCOABalanceGroupedPayloadToSectionProjectView = void 0;
|
|
4
|
-
const coaBalancePayload_1 = require("../../commonPayloadTypes/v2/coaBalancePayload");
|
|
5
|
-
const sectionProjectView_1 = require("./sectionProjectView");
|
|
6
|
-
const mapProjectCOABalanceGroupedPayloadToSectionProjectView = (timeframe, projectBalancesPayload, currencyPayload, id) => {
|
|
7
|
-
return {
|
|
8
|
-
key: (0, sectionProjectView_1.getSectionProjectViewKey)(id.sectionId, id.projectId, id.reportId),
|
|
9
|
-
projectId: id.projectId,
|
|
10
|
-
sectionId: id.sectionId,
|
|
11
|
-
balancesByPeriod: (0, coaBalancePayload_1.mapCOABalanceGroupedByPeriodPayloadV2ToCOABalanceGroupedByPeriod)(projectBalancesPayload, currencyPayload, timeframe),
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
exports.mapProjectCOABalanceGroupedPayloadToSectionProjectView = mapProjectCOABalanceGroupedPayloadToSectionProjectView;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { CurrencyPayload } from '../../commonPayloadTypes/v2/viewAndReportPayloadv2';
|
|
2
|
-
import { AccountMetadataPayload } from '../account/accountPayload';
|
|
3
|
-
import { SectionByProjectCOABalanceGroupedPayloadV2 } from '../../view/profitAndLossProjectView/profitAndLossProjectViewPayload';
|
|
4
|
-
import { SectionProjectViewState } from './sectionProjectViewState';
|
|
5
|
-
export declare const initialState: SectionProjectViewState;
|
|
6
|
-
export declare const updateSectionProjectView: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[timeframe: "month" | "year" | "quarter", sectionId: string, reportId: "cash_balance" | "card_balance" | "expense_automation_card" | "operating_expenses" | "operating_expenses_by_classes" | "revenue" | "revenue_by_classes" | "net_burn_or_income" | "net_burn_or_income_story_card" | "net_burn_or_income_by_classes" | "cash_position" | "top_expenses" | "profit_and_loss" | "profit_and_loss_by_classes" | "profit_and_loss_by_projects" | "balance_sheet" | "cash_flow" | "dashboard" | "finance_statement" | "transaction_list_of_account" | "transaction_list_missing_receipt" | "transaction_list_of_account_by_class" | "transaction_detail" | "cash_in_cash_out" | "insights_dashboard" | "company_details" | "class_list" | "account_list" | "account_list_by_type" | "vendor" | "task_card" | "bill_pay" | "reimbursement" | "bill_pay_card" | "reimbursement_card" | "bill_pay_promo_card" | "zeni_accounts" | "zeni_accounts_promo_card" | "zeni_treasury" | "charge_cards" | "other_connection" | "reimbursement_promo_card" | "onboarding" | "operating_expenses_by_vendor" | "operating_expenses_by_vendor_summary" | "vendors_tab" | "accounts_payable_aging" | "accounts_receivable_aging" | "vendor_global_review" | "prepaid_expenses" | "fixed_assets" | "notification" | "rewards_card" | "billing" | "flux_analysis_operating_expense" | "account_reconciliation" | "zeni_credit_promo_card" | "treasury_promo_card" | "excluded_account_reconciliation", sectionPayload: SectionByProjectCOABalanceGroupedPayloadV2, accountsMetadataPayload: AccountMetadataPayload[], currencyPayload: CurrencyPayload], {
|
|
7
|
-
timeframe: "month" | "year" | "quarter";
|
|
8
|
-
reportId: "cash_balance" | "card_balance" | "expense_automation_card" | "operating_expenses" | "operating_expenses_by_classes" | "revenue" | "revenue_by_classes" | "net_burn_or_income" | "net_burn_or_income_story_card" | "net_burn_or_income_by_classes" | "cash_position" | "top_expenses" | "profit_and_loss" | "profit_and_loss_by_classes" | "profit_and_loss_by_projects" | "balance_sheet" | "cash_flow" | "dashboard" | "finance_statement" | "transaction_list_of_account" | "transaction_list_missing_receipt" | "transaction_list_of_account_by_class" | "transaction_detail" | "cash_in_cash_out" | "insights_dashboard" | "company_details" | "class_list" | "account_list" | "account_list_by_type" | "vendor" | "task_card" | "bill_pay" | "reimbursement" | "bill_pay_card" | "reimbursement_card" | "bill_pay_promo_card" | "zeni_accounts" | "zeni_accounts_promo_card" | "zeni_treasury" | "charge_cards" | "other_connection" | "reimbursement_promo_card" | "onboarding" | "operating_expenses_by_vendor" | "operating_expenses_by_vendor_summary" | "vendors_tab" | "accounts_payable_aging" | "accounts_receivable_aging" | "vendor_global_review" | "prepaid_expenses" | "fixed_assets" | "notification" | "rewards_card" | "billing" | "flux_analysis_operating_expense" | "account_reconciliation" | "zeni_credit_promo_card" | "treasury_promo_card" | "excluded_account_reconciliation";
|
|
9
|
-
sectionId: string;
|
|
10
|
-
sectionPayload: SectionByProjectCOABalanceGroupedPayloadV2;
|
|
11
|
-
accountsMetadataPayload: AccountMetadataPayload[];
|
|
12
|
-
currencyPayload: CurrencyPayload;
|
|
13
|
-
}, "sectionProjectView/updateSectionProjectView", never, never>, clearAllSectionsProjectView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"sectionProjectView/clearAllSectionsProjectView">;
|
|
14
|
-
declare const _default: import("redux").Reducer<SectionProjectViewState>;
|
|
15
|
-
export default _default;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.clearAllSectionsProjectView = exports.updateSectionProjectView = exports.initialState = void 0;
|
|
5
|
-
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
-
const coaBalancePayload_1 = require("../../commonPayloadTypes/v2/coaBalancePayload");
|
|
7
|
-
const sectionProjectView_1 = require("./sectionProjectView");
|
|
8
|
-
const sectionProjectViewHelper_1 = require("./sectionProjectViewHelper");
|
|
9
|
-
exports.initialState = {
|
|
10
|
-
sectionsByKey: {},
|
|
11
|
-
};
|
|
12
|
-
const sectionProjectView = (0, toolkit_1.createSlice)({
|
|
13
|
-
name: 'sectionProjectView',
|
|
14
|
-
initialState: exports.initialState,
|
|
15
|
-
reducers: {
|
|
16
|
-
updateSectionProjectView: {
|
|
17
|
-
prepare(timeframe, sectionId, reportId, sectionPayload, accountsMetadataPayload, currencyPayload) {
|
|
18
|
-
return {
|
|
19
|
-
payload: {
|
|
20
|
-
timeframe,
|
|
21
|
-
reportId,
|
|
22
|
-
sectionId,
|
|
23
|
-
sectionPayload,
|
|
24
|
-
accountsMetadataPayload,
|
|
25
|
-
currencyPayload,
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
},
|
|
29
|
-
reducer(draft, action) {
|
|
30
|
-
const { timeframe, sectionPayload, sectionId, reportId, currencyPayload } = action.payload;
|
|
31
|
-
if (sectionPayload.projects != null) {
|
|
32
|
-
Object.keys(sectionPayload.projects).forEach((projectId) => {
|
|
33
|
-
const projectPayload = sectionPayload.projects[projectId];
|
|
34
|
-
updateSectionProject(draft, timeframe, projectPayload, sectionId, projectId, reportId, currencyPayload);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
clearAllSectionsProjectView(draft) {
|
|
40
|
-
Object.assign(draft, exports.initialState);
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
_a = sectionProjectView.actions, exports.updateSectionProjectView = _a.updateSectionProjectView, exports.clearAllSectionsProjectView = _a.clearAllSectionsProjectView;
|
|
45
|
-
exports.default = sectionProjectView.reducer;
|
|
46
|
-
const updateSectionProject = (draft, timeframe, projectPayload, sectionId, projectId, reportId, currencyPayload) => {
|
|
47
|
-
const sectionKey = (0, sectionProjectView_1.getSectionProjectViewKey)(sectionId, projectId, reportId);
|
|
48
|
-
const section = draft.sectionsByKey[sectionKey];
|
|
49
|
-
if (section != null) {
|
|
50
|
-
draft.sectionsByKey[sectionKey].balancesByPeriod = Object.assign({}, draft.sectionsByKey[sectionKey].balancesByPeriod, (0, coaBalancePayload_1.mapCOABalanceGroupedByPeriodPayloadV2ToCOABalanceGroupedByPeriod)(projectPayload, currencyPayload, timeframe));
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
draft.sectionsByKey[sectionKey] =
|
|
54
|
-
(0, sectionProjectViewHelper_1.mapProjectCOABalanceGroupedPayloadToSectionProjectView)(timeframe, projectPayload, currencyPayload, { sectionId, projectId, reportId });
|
|
55
|
-
}
|
|
56
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { COABalancesFilterProjectView } from '../../commonStateTypes/coaBalance/coaBalancesFilterProjectView';
|
|
2
|
-
import { ID } from '../../commonStateTypes/common';
|
|
3
|
-
import { ReportID } from '../../commonStateTypes/viewAndReport/viewAndReport';
|
|
4
|
-
import { AccountState } from '../account/accountState';
|
|
5
|
-
import { ProjectState } from '../project/projectReducer';
|
|
6
|
-
import { SectionProjectViewReport } from './sectionProjectViewSelectorTypes';
|
|
7
|
-
import { SectionProjectViewState } from './sectionProjectViewState';
|
|
8
|
-
export declare const getSectionProjectViewReport: (accountState: AccountState, projectState: ProjectState, sectionState: SectionProjectViewState, projectIds: ID[], id: {
|
|
9
|
-
reportId: ReportID;
|
|
10
|
-
sectionId: ID;
|
|
11
|
-
}, filter: COABalancesFilterProjectView) => SectionProjectViewReport;
|
|
@@ -1,94 +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.getSectionProjectViewReport = void 0;
|
|
7
|
-
const get_1 = __importDefault(require("lodash/get"));
|
|
8
|
-
const coaBalance_1 = require("../../commonStateTypes/coaBalance/coaBalance");
|
|
9
|
-
const getSumOfBalancesGroupedByPeriod_1 = require("../../commonStateTypes/coaBalance/classBalances/getSumOfBalancesGroupedByPeriod");
|
|
10
|
-
const accountPayload_1 = require("../account/accountPayload");
|
|
11
|
-
const accountState_1 = require("../account/accountState");
|
|
12
|
-
const subAccountSelector_1 = require("../account/subAccountSelector");
|
|
13
|
-
const projectSelector_1 = require("../project/projectSelector");
|
|
14
|
-
const getNestedAccountIDHierarchyForSection_1 = require("../sectionAccountsView/getNestedAccountIDHierarchyForSection");
|
|
15
|
-
const sectionProjectView_1 = require("./sectionProjectView");
|
|
16
|
-
const getSectionProjectViewReport = (accountState, projectState, sectionState, projectIds, id, filter) => {
|
|
17
|
-
const projectIdsToShow = projectIds.filter((projectId) => !filter.projectsToFilterOut.includes(projectId));
|
|
18
|
-
const projectReports = [];
|
|
19
|
-
const sectionBalancesTotalByPeriodArray = [];
|
|
20
|
-
const accountsByProject = getAccountsByProject(accountState, id.sectionId, id.reportId);
|
|
21
|
-
projectIdsToShow.forEach((projectId) => {
|
|
22
|
-
const project = (0, projectSelector_1.getProjectById)(projectState, projectId);
|
|
23
|
-
if (project == null) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const projectAccountIds = accountsByProject[projectId] ?? [];
|
|
27
|
-
const accountsMetadata = projectAccountIds
|
|
28
|
-
.map((accountId) => {
|
|
29
|
-
const key = (0, accountState_1.getAccountKey)(id.reportId, accountId, undefined, undefined, { projectId, sectionId: id.sectionId });
|
|
30
|
-
const account = accountState.accountsByKey[key];
|
|
31
|
-
if (account == null) {
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
return (0, accountPayload_1.mapAccountMetadataPayloadToAccountMetadata)({
|
|
35
|
-
account_id: account.accountId,
|
|
36
|
-
account_name: account.accountName,
|
|
37
|
-
account_description: account.accountDescription,
|
|
38
|
-
labels: account.labels,
|
|
39
|
-
is_sub_account: account.accountsViewParentId != null,
|
|
40
|
-
parent_account_id: account.accountsViewParentId?.parentAccountId?.[0] ?? null,
|
|
41
|
-
});
|
|
42
|
-
})
|
|
43
|
-
.filter((metadata) => metadata != null);
|
|
44
|
-
const nestedAccountHierarchy = (0, getNestedAccountIDHierarchyForSection_1.getNestedAccountIDHierarchyForAccounts)(projectAccountIds, accountsMetadata);
|
|
45
|
-
const nestedAccountReports = [];
|
|
46
|
-
nestedAccountHierarchy.forEach((accountIdHierarchy) => {
|
|
47
|
-
const report = (0, subAccountSelector_1.getNestedAccountReportForAccount)(accountState, {
|
|
48
|
-
accountIdHierarchy,
|
|
49
|
-
reportId: id.reportId,
|
|
50
|
-
projectsViewParentId: {
|
|
51
|
-
projectId,
|
|
52
|
-
sectionId: id.sectionId,
|
|
53
|
-
},
|
|
54
|
-
}, filter, nestedAccountHierarchy.length > 1);
|
|
55
|
-
if (report != null) {
|
|
56
|
-
nestedAccountReports.push(report);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
const projectSectionKey = (0, sectionProjectView_1.getSectionProjectViewKey)(id.sectionId, projectId, id.reportId);
|
|
60
|
-
const projectSectionView = (0, get_1.default)(sectionState.sectionsByKey, projectSectionKey, undefined);
|
|
61
|
-
const projectBalancesTotalByPeriod = projectSectionView?.balancesByPeriod ?? {};
|
|
62
|
-
const projectReport = {
|
|
63
|
-
projectId,
|
|
64
|
-
projectName: project.projectName,
|
|
65
|
-
accounts: nestedAccountReports,
|
|
66
|
-
...(0, coaBalance_1.getCOABalances)(projectBalancesTotalByPeriod, filter),
|
|
67
|
-
projectBalancesTotalByPeriod,
|
|
68
|
-
};
|
|
69
|
-
projectReports.push(projectReport);
|
|
70
|
-
sectionBalancesTotalByPeriodArray.push(projectBalancesTotalByPeriod);
|
|
71
|
-
});
|
|
72
|
-
const sectionBalancesTotalByPeriod = (0, getSumOfBalancesGroupedByPeriod_1.getSumOfBalancesByGroupedByPeriod)(sectionBalancesTotalByPeriodArray) ?? {};
|
|
73
|
-
return {
|
|
74
|
-
projects: projectReports,
|
|
75
|
-
...(0, coaBalance_1.getCOABalances)(sectionBalancesTotalByPeriod, filter),
|
|
76
|
-
sectionBalancesTotalByPeriod,
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
exports.getSectionProjectViewReport = getSectionProjectViewReport;
|
|
80
|
-
const getAccountsByProject = (accountState, sectionId, reportId) => {
|
|
81
|
-
const result = {};
|
|
82
|
-
Object.values(accountState.accountsByKey).forEach((account) => {
|
|
83
|
-
if (account.projectsViewParentId != null &&
|
|
84
|
-
account.projectsViewParentId.sectionId === sectionId &&
|
|
85
|
-
account.key.endsWith(reportId)) {
|
|
86
|
-
const projectId = account.projectsViewParentId.projectId;
|
|
87
|
-
if (result[projectId] == null) {
|
|
88
|
-
result[projectId] = [];
|
|
89
|
-
}
|
|
90
|
-
result[projectId].push(account.accountId);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
return result;
|
|
94
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { COABalanceGroupedByPeriod } from '../../commonStateTypes/coaBalance/coaBalance';
|
|
2
|
-
import { COABalancesSlice } from '../../commonStateTypes/coaBalance/coaBalancesFilter';
|
|
3
|
-
import { ID } from '../../commonStateTypes/common';
|
|
4
|
-
import { NestedAccountReport } from '../account/subAccountSelector';
|
|
5
|
-
export interface ProjectReportV2 {
|
|
6
|
-
accounts: NestedAccountReport[];
|
|
7
|
-
projectId: ID;
|
|
8
|
-
projectName: string;
|
|
9
|
-
}
|
|
10
|
-
export interface ProjectReportWithBalances extends ProjectReportV2, COABalancesSlice {
|
|
11
|
-
projectBalancesTotalByPeriod: COABalanceGroupedByPeriod;
|
|
12
|
-
}
|
|
13
|
-
export interface SectionProjectViewReport extends COABalancesSlice {
|
|
14
|
-
projects: ProjectReportWithBalances[];
|
|
15
|
-
sectionBalancesTotalByPeriod: COABalanceGroupedByPeriod;
|
|
16
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { newBalancesFilter } from '../../commonStateTypes/coaBalance/coaBalancesFilter';
|
|
2
|
-
export const newBalancesFilterProjectView = (firstMonthOfFY, timeframe, numberOfPeriods = 8, thisPeriod, orderBy = 'ascending_date', additionalBalances = [], projectsToFilterOut = []) => ({
|
|
3
|
-
...newBalancesFilter(firstMonthOfFY, timeframe, numberOfPeriods, thisPeriod, orderBy, additionalBalances),
|
|
4
|
-
projectsToFilterOut,
|
|
5
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { date } from '../../zeniDayJS';
|
|
2
|
-
export const mapProjectMetadataPayloadToProject = (payload) => ({
|
|
3
|
-
projectId: payload.zeni_project_id,
|
|
4
|
-
projectName: payload.project_name,
|
|
5
|
-
...(payload.status != null ? { status: payload.status } : {}),
|
|
6
|
-
...(payload.start_date != null ? { startDate: date(payload.start_date) } : {}),
|
|
7
|
-
...(payload.parent_customer_accounting_provider_id != null
|
|
8
|
-
? {
|
|
9
|
-
parentCustomerAccountingProviderId: payload.parent_customer_accounting_provider_id,
|
|
10
|
-
}
|
|
11
|
-
: {}),
|
|
12
|
-
...(payload.accounting_provider_project_customer_id != null
|
|
13
|
-
? {
|
|
14
|
-
accountingProviderProjectCustomerId: payload.accounting_provider_project_customer_id,
|
|
15
|
-
}
|
|
16
|
-
: {}),
|
|
17
|
-
...(payload.accounting_provider_project_id != null
|
|
18
|
-
? { accountingProviderProjectId: payload.accounting_provider_project_id }
|
|
19
|
-
: {}),
|
|
20
|
-
...(payload.zeni_parent_customer_id != null
|
|
21
|
-
? { zeniParentCustomerId: payload.zeni_parent_customer_id }
|
|
22
|
-
: {}),
|
|
23
|
-
...(payload.zeni_project_customer_id != null
|
|
24
|
-
? { zeniProjectCustomerId: payload.zeni_project_customer_id }
|
|
25
|
-
: {}),
|
|
26
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
-
import { mapProjectMetadataPayloadToProject, } from './projectPayload';
|
|
3
|
-
export const initialState = {
|
|
4
|
-
projects: {},
|
|
5
|
-
};
|
|
6
|
-
const projectSlice = createSlice({
|
|
7
|
-
name: 'project',
|
|
8
|
-
initialState,
|
|
9
|
-
reducers: {
|
|
10
|
-
updateProjects: {
|
|
11
|
-
reducer(draft, action) {
|
|
12
|
-
action.payload.forEach((projectPayload) => {
|
|
13
|
-
const project = mapProjectMetadataPayloadToProject(projectPayload);
|
|
14
|
-
draft.projects[project.projectId] = project;
|
|
15
|
-
});
|
|
16
|
-
},
|
|
17
|
-
prepare(payload) {
|
|
18
|
-
return { payload };
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
clearAllProjects(draft) {
|
|
22
|
-
Object.assign(draft, initialState);
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
export const { updateProjects, clearAllProjects } = projectSlice.actions;
|
|
27
|
-
export default projectSlice.reducer;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export function getProjectById(projectState, projectId) {
|
|
2
|
-
return projectState.projects[projectId];
|
|
3
|
-
}
|
|
4
|
-
export function getProjectsByIds(projectState, projectIds) {
|
|
5
|
-
return projectIds
|
|
6
|
-
.map((projectId) => getProjectById(projectState, projectId))
|
|
7
|
-
.filter((project) => project != null);
|
|
8
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { from } from 'rxjs';
|
|
2
|
-
import { filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { getAllAccountMetadataRecordsByID, getParentAccountId, } from '../../commonStateTypes/accountView/getNestedAccountIDHierarchyForReport';
|
|
4
|
-
import { updateMultipleSubAccountsWithBalances } from '../account/accountReducer';
|
|
5
|
-
import { updateSectionProjectView } from './sectionProjectViewReducer';
|
|
6
|
-
export const updateSectionProjectViewEpic = (actions$) => actions$.pipe(filter(updateSectionProjectView.match), mergeMap((action) => {
|
|
7
|
-
const actions = [];
|
|
8
|
-
const sectionPayload = action.payload.sectionPayload;
|
|
9
|
-
const sectionId = action.payload.sectionId;
|
|
10
|
-
const timeframe = action.payload.timeframe;
|
|
11
|
-
const reportId = action.payload.reportId;
|
|
12
|
-
const currencyPayload = action.payload.currencyPayload;
|
|
13
|
-
const accountsMetadataPayload = action.payload.accountsMetadataPayload;
|
|
14
|
-
const accountMetadataRecordsByID = getAllAccountMetadataRecordsByID(accountsMetadataPayload);
|
|
15
|
-
const accountMetadataWithBalancesPayloads = [];
|
|
16
|
-
if (sectionPayload.projects != null) {
|
|
17
|
-
Object.keys(sectionPayload.projects).forEach((projectId) => {
|
|
18
|
-
const projectAccounts = sectionPayload.projects[projectId].accounts;
|
|
19
|
-
const projectsViewParentID = {
|
|
20
|
-
projectId,
|
|
21
|
-
sectionId,
|
|
22
|
-
};
|
|
23
|
-
getSubAccountsMetadataForProjectAccountList(projectAccounts, accountMetadataRecordsByID, sectionId, projectsViewParentID, accountMetadataWithBalancesPayloads);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
if (accountMetadataWithBalancesPayloads.length > 0) {
|
|
27
|
-
actions.push(updateMultipleSubAccountsWithBalances(accountMetadataWithBalancesPayloads, currencyPayload, reportId, timeframe));
|
|
28
|
-
}
|
|
29
|
-
return from(actions);
|
|
30
|
-
}));
|
|
31
|
-
const getSubAccountsMetadataForProjectAccountList = (accountListWithBalances, accountMetadataRecordsByID, sectionId, projectsViewParentID, result) => {
|
|
32
|
-
if (accountListWithBalances != null) {
|
|
33
|
-
Object.keys(accountListWithBalances).forEach((eachAccountId) => {
|
|
34
|
-
const accountMetadataRecord = accountMetadataRecordsByID[eachAccountId];
|
|
35
|
-
if (accountMetadataRecord != null) {
|
|
36
|
-
const accountId = accountMetadataRecord.nestedAccountId;
|
|
37
|
-
result.push({
|
|
38
|
-
accountsViewParentID: {
|
|
39
|
-
parentAccountId: getParentAccountId(accountId),
|
|
40
|
-
sectionId,
|
|
41
|
-
},
|
|
42
|
-
accountMetadataPayload: accountMetadataRecord.accountMetadataPayload,
|
|
43
|
-
accountBalancesPayload: accountListWithBalances[eachAccountId],
|
|
44
|
-
projectsViewParentID,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
console.warn(`Account ${eachAccountId} in Section ${sectionId} Project ${projectsViewParentID.projectId} is missing metadata.`);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { mapCOABalanceGroupedByPeriodPayloadV2ToCOABalanceGroupedByPeriod, } from '../../commonPayloadTypes/v2/coaBalancePayload';
|
|
2
|
-
import { getSectionProjectViewKey, } from './sectionProjectView';
|
|
3
|
-
export const mapProjectCOABalanceGroupedPayloadToSectionProjectView = (timeframe, projectBalancesPayload, currencyPayload, id) => {
|
|
4
|
-
return {
|
|
5
|
-
key: getSectionProjectViewKey(id.sectionId, id.projectId, id.reportId),
|
|
6
|
-
projectId: id.projectId,
|
|
7
|
-
sectionId: id.sectionId,
|
|
8
|
-
balancesByPeriod: mapCOABalanceGroupedByPeriodPayloadV2ToCOABalanceGroupedByPeriod(projectBalancesPayload, currencyPayload, timeframe),
|
|
9
|
-
};
|
|
10
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
-
import { mapCOABalanceGroupedByPeriodPayloadV2ToCOABalanceGroupedByPeriod } from '../../commonPayloadTypes/v2/coaBalancePayload';
|
|
3
|
-
import { getSectionProjectViewKey } from './sectionProjectView';
|
|
4
|
-
import { mapProjectCOABalanceGroupedPayloadToSectionProjectView } from './sectionProjectViewHelper';
|
|
5
|
-
export const initialState = {
|
|
6
|
-
sectionsByKey: {},
|
|
7
|
-
};
|
|
8
|
-
const sectionProjectView = createSlice({
|
|
9
|
-
name: 'sectionProjectView',
|
|
10
|
-
initialState,
|
|
11
|
-
reducers: {
|
|
12
|
-
updateSectionProjectView: {
|
|
13
|
-
prepare(timeframe, sectionId, reportId, sectionPayload, accountsMetadataPayload, currencyPayload) {
|
|
14
|
-
return {
|
|
15
|
-
payload: {
|
|
16
|
-
timeframe,
|
|
17
|
-
reportId,
|
|
18
|
-
sectionId,
|
|
19
|
-
sectionPayload,
|
|
20
|
-
accountsMetadataPayload,
|
|
21
|
-
currencyPayload,
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
},
|
|
25
|
-
reducer(draft, action) {
|
|
26
|
-
const { timeframe, sectionPayload, sectionId, reportId, currencyPayload } = action.payload;
|
|
27
|
-
if (sectionPayload.projects != null) {
|
|
28
|
-
Object.keys(sectionPayload.projects).forEach((projectId) => {
|
|
29
|
-
const projectPayload = sectionPayload.projects[projectId];
|
|
30
|
-
updateSectionProject(draft, timeframe, projectPayload, sectionId, projectId, reportId, currencyPayload);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
clearAllSectionsProjectView(draft) {
|
|
36
|
-
Object.assign(draft, initialState);
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
export const { updateSectionProjectView, clearAllSectionsProjectView } = sectionProjectView.actions;
|
|
41
|
-
export default sectionProjectView.reducer;
|
|
42
|
-
const updateSectionProject = (draft, timeframe, projectPayload, sectionId, projectId, reportId, currencyPayload) => {
|
|
43
|
-
const sectionKey = getSectionProjectViewKey(sectionId, projectId, reportId);
|
|
44
|
-
const section = draft.sectionsByKey[sectionKey];
|
|
45
|
-
if (section != null) {
|
|
46
|
-
draft.sectionsByKey[sectionKey].balancesByPeriod = Object.assign({}, draft.sectionsByKey[sectionKey].balancesByPeriod, mapCOABalanceGroupedByPeriodPayloadV2ToCOABalanceGroupedByPeriod(projectPayload, currencyPayload, timeframe));
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
draft.sectionsByKey[sectionKey] =
|
|
50
|
-
mapProjectCOABalanceGroupedPayloadToSectionProjectView(timeframe, projectPayload, currencyPayload, { sectionId, projectId, reportId });
|
|
51
|
-
}
|
|
52
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import recordGet from 'lodash/get';
|
|
2
|
-
import { getCOABalances, } from '../../commonStateTypes/coaBalance/coaBalance';
|
|
3
|
-
import { getSumOfBalancesByGroupedByPeriod } from '../../commonStateTypes/coaBalance/classBalances/getSumOfBalancesGroupedByPeriod';
|
|
4
|
-
import { mapAccountMetadataPayloadToAccountMetadata } from '../account/accountPayload';
|
|
5
|
-
import { getAccountKey } from '../account/accountState';
|
|
6
|
-
import { getNestedAccountReportForAccount, } from '../account/subAccountSelector';
|
|
7
|
-
import { getProjectById } from '../project/projectSelector';
|
|
8
|
-
import { getNestedAccountIDHierarchyForAccounts } from '../sectionAccountsView/getNestedAccountIDHierarchyForSection';
|
|
9
|
-
import { getSectionProjectViewKey } from './sectionProjectView';
|
|
10
|
-
export const getSectionProjectViewReport = (accountState, projectState, sectionState, projectIds, id, filter) => {
|
|
11
|
-
const projectIdsToShow = projectIds.filter((projectId) => !filter.projectsToFilterOut.includes(projectId));
|
|
12
|
-
const projectReports = [];
|
|
13
|
-
const sectionBalancesTotalByPeriodArray = [];
|
|
14
|
-
const accountsByProject = getAccountsByProject(accountState, id.sectionId, id.reportId);
|
|
15
|
-
projectIdsToShow.forEach((projectId) => {
|
|
16
|
-
const project = getProjectById(projectState, projectId);
|
|
17
|
-
if (project == null) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const projectAccountIds = accountsByProject[projectId] ?? [];
|
|
21
|
-
const accountsMetadata = projectAccountIds
|
|
22
|
-
.map((accountId) => {
|
|
23
|
-
const key = getAccountKey(id.reportId, accountId, undefined, undefined, { projectId, sectionId: id.sectionId });
|
|
24
|
-
const account = accountState.accountsByKey[key];
|
|
25
|
-
if (account == null) {
|
|
26
|
-
return undefined;
|
|
27
|
-
}
|
|
28
|
-
return mapAccountMetadataPayloadToAccountMetadata({
|
|
29
|
-
account_id: account.accountId,
|
|
30
|
-
account_name: account.accountName,
|
|
31
|
-
account_description: account.accountDescription,
|
|
32
|
-
labels: account.labels,
|
|
33
|
-
is_sub_account: account.accountsViewParentId != null,
|
|
34
|
-
parent_account_id: account.accountsViewParentId?.parentAccountId?.[0] ?? null,
|
|
35
|
-
});
|
|
36
|
-
})
|
|
37
|
-
.filter((metadata) => metadata != null);
|
|
38
|
-
const nestedAccountHierarchy = getNestedAccountIDHierarchyForAccounts(projectAccountIds, accountsMetadata);
|
|
39
|
-
const nestedAccountReports = [];
|
|
40
|
-
nestedAccountHierarchy.forEach((accountIdHierarchy) => {
|
|
41
|
-
const report = getNestedAccountReportForAccount(accountState, {
|
|
42
|
-
accountIdHierarchy,
|
|
43
|
-
reportId: id.reportId,
|
|
44
|
-
projectsViewParentId: {
|
|
45
|
-
projectId,
|
|
46
|
-
sectionId: id.sectionId,
|
|
47
|
-
},
|
|
48
|
-
}, filter, nestedAccountHierarchy.length > 1);
|
|
49
|
-
if (report != null) {
|
|
50
|
-
nestedAccountReports.push(report);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
const projectSectionKey = getSectionProjectViewKey(id.sectionId, projectId, id.reportId);
|
|
54
|
-
const projectSectionView = recordGet(sectionState.sectionsByKey, projectSectionKey, undefined);
|
|
55
|
-
const projectBalancesTotalByPeriod = projectSectionView?.balancesByPeriod ?? {};
|
|
56
|
-
const projectReport = {
|
|
57
|
-
projectId,
|
|
58
|
-
projectName: project.projectName,
|
|
59
|
-
accounts: nestedAccountReports,
|
|
60
|
-
...getCOABalances(projectBalancesTotalByPeriod, filter),
|
|
61
|
-
projectBalancesTotalByPeriod,
|
|
62
|
-
};
|
|
63
|
-
projectReports.push(projectReport);
|
|
64
|
-
sectionBalancesTotalByPeriodArray.push(projectBalancesTotalByPeriod);
|
|
65
|
-
});
|
|
66
|
-
const sectionBalancesTotalByPeriod = getSumOfBalancesByGroupedByPeriod(sectionBalancesTotalByPeriodArray) ?? {};
|
|
67
|
-
return {
|
|
68
|
-
projects: projectReports,
|
|
69
|
-
...getCOABalances(sectionBalancesTotalByPeriod, filter),
|
|
70
|
-
sectionBalancesTotalByPeriod,
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
const getAccountsByProject = (accountState, sectionId, reportId) => {
|
|
74
|
-
const result = {};
|
|
75
|
-
Object.values(accountState.accountsByKey).forEach((account) => {
|
|
76
|
-
if (account.projectsViewParentId != null &&
|
|
77
|
-
account.projectsViewParentId.sectionId === sectionId &&
|
|
78
|
-
account.key.endsWith(reportId)) {
|
|
79
|
-
const projectId = account.projectsViewParentId.projectId;
|
|
80
|
-
if (result[projectId] == null) {
|
|
81
|
-
result[projectId] = [];
|
|
82
|
-
}
|
|
83
|
-
result[projectId].push(account.accountId);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
return result;
|
|
87
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|