@zeniai/client-epic-state 5.0.52-betaAS1 → 5.0.52
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/SessionManager.d.ts +0 -4
- package/lib/entity/tenant/SessionManager.js +0 -6
- package/lib/entity/tenant/clearAllEpic.d.ts +1 -2
- package/lib/entity/tenant/clearAllEpic.js +0 -2
- 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 -4
- package/lib/esm/commonStateTypes/viewAndReport/viewAndReport.js +0 -1
- package/lib/esm/entity/project/projectPayload.js +0 -12
- package/lib/esm/entity/tenant/SessionManager.js +0 -6
- package/lib/esm/entity/tenant/clearAllEpic.js +0 -2
- 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 -4
- package/lib/esm/index.js +5 -9
- 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 -2
- 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 +7 -11
- package/lib/index.js +27 -40
- package/lib/reducer.d.ts +0 -3
- package/lib/reducer.js +0 -3
- 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 -2
- 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/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/tsconfig.typecheck.tsbuildinfo +0 -1
- 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
|
@@ -4,7 +4,6 @@ import { AccountBase } from '../../entity/account/accountState';
|
|
|
4
4
|
import { ClassBase } from '../../entity/class/classState';
|
|
5
5
|
import { CustomerBase } from '../../entity/customer/customerState';
|
|
6
6
|
import { EntityType } from '../../entity/genericEntity/entity';
|
|
7
|
-
import { ProjectBase } from '../../entity/project/projectState';
|
|
8
7
|
import { Transaction, TransactionID } from '../../entity/transaction/stateTypes/transaction';
|
|
9
8
|
import { VendorBase } from '../../entity/vendor/vendorState';
|
|
10
9
|
import { EntityRecommendationKey } from '../recommendation/recommendationState';
|
|
@@ -53,7 +52,6 @@ export interface TransactionLineUpdates {
|
|
|
53
52
|
class?: ClassBase;
|
|
54
53
|
customer?: CustomerBase;
|
|
55
54
|
lineDescription?: string;
|
|
56
|
-
project?: ProjectBase;
|
|
57
55
|
recommendation?: Recommendation[];
|
|
58
56
|
vendor?: VendorBase;
|
|
59
57
|
}
|
|
@@ -4,7 +4,6 @@ import { AccountBase, RecommendedAccountBase } from '../../entity/account/accoun
|
|
|
4
4
|
import { ClassBase, RecommendedClassBase } from '../../entity/class/classState';
|
|
5
5
|
import { CustomerBase } from '../../entity/customer/customerState';
|
|
6
6
|
import { Entity } from '../../entity/genericEntity/entity';
|
|
7
|
-
import { ProjectBase } from '../../entity/project/projectState';
|
|
8
7
|
import { TransactionID } from '../../entity/transaction/stateTypes/transaction';
|
|
9
8
|
import { BillableStatus, PlatformLineDetailType, ProductOrService, TransactionLineBase } from '../../entity/transaction/stateTypes/transactionLine';
|
|
10
9
|
import { TransactionCategory, TransactionType } from '../../entity/transaction/stateTypes/transactionType';
|
|
@@ -30,7 +29,6 @@ export interface TransactionDetailLineItemData extends TransactionLineBase {
|
|
|
30
29
|
linkedTransactions?: TransactionID[];
|
|
31
30
|
postingType?: TransactionCategory;
|
|
32
31
|
postingTypeName?: string;
|
|
33
|
-
project?: ProjectBase;
|
|
34
32
|
recommendationsWithCOT?: RecommendationWithCOT[];
|
|
35
33
|
recommendedAccount?: RecommendedAccountBase;
|
|
36
34
|
recommendedClass?: RecommendedClassBase;
|
|
@@ -48,24 +48,9 @@ export interface TransactionListByClassPayload {
|
|
|
48
48
|
query: QueryClassMetaDataPayload;
|
|
49
49
|
query_definitions: Record<string, unknown>;
|
|
50
50
|
}
|
|
51
|
-
interface QueryProjectMetaDataPayload {
|
|
52
|
-
account_id: string;
|
|
53
|
-
account_type: string;
|
|
54
|
-
end_date: string;
|
|
55
|
-
group_by: string;
|
|
56
|
-
sort_order: string;
|
|
57
|
-
start_date: string;
|
|
58
|
-
zeni_project_id: string;
|
|
59
|
-
}
|
|
60
|
-
export interface TransactionListByProjectPayload {
|
|
61
|
-
account: TransactionListPayload;
|
|
62
|
-
query: QueryProjectMetaDataPayload;
|
|
63
|
-
query_definitions: Record<string, unknown>;
|
|
64
|
-
}
|
|
65
51
|
export type TransactionListByAccountResponse = ZeniAPIResponse<TransactionListByAccountPayload>;
|
|
66
52
|
export type TransactionListByEntityResponse = ZeniAPIResponse<TransactionListByEntityPayload>;
|
|
67
53
|
export type TransactionListByClassResponse = ZeniAPIResponse<TransactionListByClassPayload>;
|
|
68
|
-
export type TransactionListByProjectResponse = ZeniAPIResponse<TransactionListByProjectPayload>;
|
|
69
54
|
interface TransactionsByCategoryTypePayload {
|
|
70
55
|
query: QueryTransactionByCategoryTypeMetaDataPayload;
|
|
71
56
|
transactions: TransactionPayload[];
|
|
@@ -6,7 +6,7 @@ import { Entity } from '../../entity/genericEntity/entity';
|
|
|
6
6
|
import { TransactionPayload } from '../../entity/transaction/payloadTypes/transactionPayload';
|
|
7
7
|
import { TransactionID } from '../../entity/transaction/stateTypes/transaction';
|
|
8
8
|
import { ZeniAPIStatus } from '../../responsePayload';
|
|
9
|
-
import { TransactionListByAccountPayload, TransactionListByClassPayload, TransactionListByEntityPayload
|
|
9
|
+
import { TransactionListByAccountPayload, TransactionListByClassPayload, TransactionListByEntityPayload } from './transactionListPayload';
|
|
10
10
|
import { TransactionCategoryType, TransactionListState, TransactionListUIState } from './transactionListState';
|
|
11
11
|
export declare const initialState: TransactionListState;
|
|
12
12
|
export declare const parallelFetchAccountTransactionList: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[accountId: string, accountType: "cash_position" | "fixed_assets" | "bank" | "credit_card" | "expenses" | "cogs" | "income" | "cash_in" | "cash_out" | "other_income" | "other_expense" | "accounts_receivable" | "other_current_assets" | "other_assets" | "accounts_payable" | "other_current_liabilities" | "long_term_liabilities" | "equity" | "current_liabilities" | "current_assets", period: TimePeriod, accountName?: string | undefined, cacheOverride?: any, includeSubAccountTransactions?: any], {
|
|
@@ -69,30 +69,7 @@ export declare const parallelFetchAccountTransactionList: import("@reduxjs/toolk
|
|
|
69
69
|
classId: string;
|
|
70
70
|
period: TimePeriod;
|
|
71
71
|
error: ZeniAPIStatus<Record<string, unknown>>;
|
|
72
|
-
}, "transactionList/updateTransactionListByClassFailure", never, never>,
|
|
73
|
-
accountId: string;
|
|
74
|
-
accountType: "cash_position" | "fixed_assets" | "bank" | "credit_card" | "expenses" | "cogs" | "income" | "cash_in" | "cash_out" | "other_income" | "other_expense" | "accounts_receivable" | "other_current_assets" | "other_assets" | "accounts_payable" | "other_current_liabilities" | "long_term_liabilities" | "equity" | "current_liabilities" | "current_assets";
|
|
75
|
-
projectId: string;
|
|
76
|
-
period: TimePeriod;
|
|
77
|
-
cacheOverride: any;
|
|
78
|
-
}, "transactionList/parallelFetchProjectTransactionList", never, never>, fetchProjectTransactionList: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[accountId: string, accountType: "cash_position" | "fixed_assets" | "bank" | "credit_card" | "expenses" | "cogs" | "income" | "cash_in" | "cash_out" | "other_income" | "other_expense" | "accounts_receivable" | "other_current_assets" | "other_assets" | "accounts_payable" | "other_current_liabilities" | "long_term_liabilities" | "equity" | "current_liabilities" | "current_assets", projectId: string, period: TimePeriod, cacheOverride?: any], {
|
|
79
|
-
accountId: string;
|
|
80
|
-
accountType: "cash_position" | "fixed_assets" | "bank" | "credit_card" | "expenses" | "cogs" | "income" | "cash_in" | "cash_out" | "other_income" | "other_expense" | "accounts_receivable" | "other_current_assets" | "other_assets" | "accounts_payable" | "other_current_liabilities" | "long_term_liabilities" | "equity" | "current_liabilities" | "current_assets";
|
|
81
|
-
projectId: string;
|
|
82
|
-
period: TimePeriod;
|
|
83
|
-
cacheOverride: any;
|
|
84
|
-
}, "transactionList/fetchProjectTransactionList", never, never>, updateTransactionListByProject: import("@reduxjs/toolkit").ActionCreatorWithPayload<TransactionListByProjectPayload, "transactionList/updateTransactionListByProject">, updateTransactionListByProjectUIState: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
85
|
-
accountId: ID;
|
|
86
|
-
accountType: AccountType;
|
|
87
|
-
projectId: ID;
|
|
88
|
-
uiState: TransactionListUIState;
|
|
89
|
-
}, "transactionList/updateTransactionListByProjectUIState">, updateTransactionListByProjectFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[accountId: string, accountType: "cash_position" | "fixed_assets" | "bank" | "credit_card" | "expenses" | "cogs" | "income" | "cash_in" | "cash_out" | "other_income" | "other_expense" | "accounts_receivable" | "other_current_assets" | "other_assets" | "accounts_payable" | "other_current_liabilities" | "long_term_liabilities" | "equity" | "current_liabilities" | "current_assets", projectId: string, period: TimePeriod, error: ZeniAPIStatus<Record<string, unknown>>], {
|
|
90
|
-
accountId: string;
|
|
91
|
-
accountType: "cash_position" | "fixed_assets" | "bank" | "credit_card" | "expenses" | "cogs" | "income" | "cash_in" | "cash_out" | "other_income" | "other_expense" | "accounts_receivable" | "other_current_assets" | "other_assets" | "accounts_payable" | "other_current_liabilities" | "long_term_liabilities" | "equity" | "current_liabilities" | "current_assets";
|
|
92
|
-
projectId: string;
|
|
93
|
-
period: TimePeriod;
|
|
94
|
-
error: ZeniAPIStatus<Record<string, unknown>>;
|
|
95
|
-
}, "transactionList/updateTransactionListByProjectFailure", never, never>, parallelFetchTransactionListByCategoryType: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionCategoryType: TransactionCategoryType, period: TimePeriod, cacheOverride?: any, minimumTransactionAmount?: Amount | undefined], {
|
|
72
|
+
}, "transactionList/updateTransactionListByClassFailure", never, never>, parallelFetchTransactionListByCategoryType: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionCategoryType: TransactionCategoryType, period: TimePeriod, cacheOverride?: any, minimumTransactionAmount?: Amount | undefined], {
|
|
96
73
|
transactionCategoryType: TransactionCategoryType;
|
|
97
74
|
period: TimePeriod;
|
|
98
75
|
minimumTransactionAmount: Amount | undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.updateLatestTransactionId = exports.clearTransactionList = exports.updateTransactionListUIStateByCategoryType = exports.updateTransactionsListByCategoryTypeFailure = exports.updateTransactionListByCategoryType = exports.fetchTransactionsListByCategoryType = exports.parallelFetchTransactionListByCategoryType = exports.
|
|
4
|
+
exports.updateLatestTransactionId = exports.clearTransactionList = exports.updateTransactionListUIStateByCategoryType = exports.updateTransactionsListByCategoryTypeFailure = exports.updateTransactionListByCategoryType = exports.fetchTransactionsListByCategoryType = exports.parallelFetchTransactionListByCategoryType = exports.updateTransactionListByClassFailure = exports.updateTransactionListByClassUIState = exports.updateTransactionListByClass = exports.fetchClassTransactionList = exports.parallelFetchClassTransactionList = exports.updateTransactionListByAccountUIState = exports.updateTransactionListByEntityFailure = exports.updateTransactionListByEntity = exports.fetchEntityTransactionList = exports.parallelFetchEntityTransactionList = exports.updateTransactionListByAccountFailure = exports.updateTransactionListByAccount = exports.fetchAccountTransactionList = exports.parallelFetchAccountTransactionList = exports.initialState = void 0;
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
6
|
const timePeriod_1 = require("../../commonStateTypes/timePeriod");
|
|
7
7
|
const accountPayload_1 = require("../../entity/account/accountPayload");
|
|
@@ -41,10 +41,6 @@ exports.initialState = {
|
|
|
41
41
|
transactionListByClassKey: {},
|
|
42
42
|
transactionListUIStateByClassKey: {},
|
|
43
43
|
},
|
|
44
|
-
byProject: {
|
|
45
|
-
transactionListByProjectKey: {},
|
|
46
|
-
transactionListUIStateByProjectKey: {},
|
|
47
|
-
},
|
|
48
44
|
};
|
|
49
45
|
const transactionList = (0, toolkit_1.createSlice)({
|
|
50
46
|
name: 'transactionList',
|
|
@@ -254,64 +250,6 @@ const transactionList = (0, toolkit_1.createSlice)({
|
|
|
254
250
|
return { payload: { accountId, accountType, classId, period, error } };
|
|
255
251
|
},
|
|
256
252
|
},
|
|
257
|
-
// Transaction list by project related reducers
|
|
258
|
-
//
|
|
259
|
-
// Mirrors the by-class set; the only behavioural difference is that the
|
|
260
|
-
// server query param is `zeni_project_id` (post-Ayon's accounting #3984
|
|
261
|
-
// rename) and there's no equivalent of `include_sub_class_transactions`
|
|
262
|
-
// — projects don't have a sub-project hierarchy in this layout yet.
|
|
263
|
-
parallelFetchProjectTransactionList: {
|
|
264
|
-
reducer() {
|
|
265
|
-
// Do nothing..
|
|
266
|
-
},
|
|
267
|
-
prepare(accountId, accountType, projectId, period, cacheOverride = false) {
|
|
268
|
-
return {
|
|
269
|
-
payload: { accountId, accountType, projectId, period, cacheOverride },
|
|
270
|
-
};
|
|
271
|
-
},
|
|
272
|
-
},
|
|
273
|
-
fetchProjectTransactionList: {
|
|
274
|
-
reducer(draft, action) {
|
|
275
|
-
const key = (0, transactionListState_1.getProjectAcTranKey)(action.payload.accountId, action.payload.accountType, action.payload.projectId, action.payload.period);
|
|
276
|
-
if (action.payload.cacheOverride === true ||
|
|
277
|
-
draft.byProject.transactionListByProjectKey[key] == null ||
|
|
278
|
-
(draft.byProject.transactionListByProjectKey[key]?.hasValidState() ===
|
|
279
|
-
false &&
|
|
280
|
-
draft.byProject.transactionListByProjectKey[key]?.fetchState !=
|
|
281
|
-
'In-Progress')) {
|
|
282
|
-
draft.byProject.transactionListByProjectKey[key] = {
|
|
283
|
-
...transactionListState_1.initialProjectTransactionState,
|
|
284
|
-
fetchState: 'In-Progress',
|
|
285
|
-
error: undefined,
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
},
|
|
289
|
-
prepare(accountId, accountType, projectId, period, cacheOverride = false) {
|
|
290
|
-
return {
|
|
291
|
-
payload: { accountId, accountType, projectId, period, cacheOverride },
|
|
292
|
-
};
|
|
293
|
-
},
|
|
294
|
-
},
|
|
295
|
-
updateTransactionListByProject(draft, action) {
|
|
296
|
-
doUpdateTransactionListByProject(draft.byProject.transactionListByProjectKey, action.payload);
|
|
297
|
-
},
|
|
298
|
-
updateTransactionListByProjectUIState(draft, action) {
|
|
299
|
-
const key = (0, transactionListState_1.getProjectAcKey)(action.payload.accountId, action.payload.accountType, action.payload.projectId);
|
|
300
|
-
draft.byProject.transactionListUIStateByProjectKey[key] = Object.assign({}, draft.byProject.transactionListUIStateByProjectKey[key], action.payload.uiState);
|
|
301
|
-
},
|
|
302
|
-
updateTransactionListByProjectFailure: {
|
|
303
|
-
reducer(draft, action) {
|
|
304
|
-
const key = (0, transactionListState_1.getProjectAcTranKey)(action.payload.accountId, action.payload.accountType, action.payload.projectId, action.payload.period);
|
|
305
|
-
draft.byProject.transactionListByProjectKey[key] = {
|
|
306
|
-
...transactionListState_1.initialProjectTransactionState,
|
|
307
|
-
fetchState: 'Error',
|
|
308
|
-
error: action.payload.error,
|
|
309
|
-
};
|
|
310
|
-
},
|
|
311
|
-
prepare(accountId, accountType, projectId, period, error) {
|
|
312
|
-
return { payload: { accountId, accountType, projectId, period, error } };
|
|
313
|
-
},
|
|
314
|
-
},
|
|
315
253
|
parallelFetchTransactionListByCategoryType: {
|
|
316
254
|
reducer() {
|
|
317
255
|
// Do nothing..
|
|
@@ -406,7 +344,7 @@ const transactionList = (0, toolkit_1.createSlice)({
|
|
|
406
344
|
},
|
|
407
345
|
},
|
|
408
346
|
});
|
|
409
|
-
_a = transactionList.actions, exports.parallelFetchAccountTransactionList = _a.parallelFetchAccountTransactionList, exports.fetchAccountTransactionList = _a.fetchAccountTransactionList, exports.updateTransactionListByAccount = _a.updateTransactionListByAccount, exports.updateTransactionListByAccountFailure = _a.updateTransactionListByAccountFailure, exports.parallelFetchEntityTransactionList = _a.parallelFetchEntityTransactionList, exports.fetchEntityTransactionList = _a.fetchEntityTransactionList, exports.updateTransactionListByEntity = _a.updateTransactionListByEntity, exports.updateTransactionListByEntityFailure = _a.updateTransactionListByEntityFailure, exports.updateTransactionListByAccountUIState = _a.updateTransactionListByAccountUIState, exports.parallelFetchClassTransactionList = _a.parallelFetchClassTransactionList, exports.fetchClassTransactionList = _a.fetchClassTransactionList, exports.updateTransactionListByClass = _a.updateTransactionListByClass, exports.updateTransactionListByClassUIState = _a.updateTransactionListByClassUIState, exports.updateTransactionListByClassFailure = _a.updateTransactionListByClassFailure, exports.
|
|
347
|
+
_a = transactionList.actions, exports.parallelFetchAccountTransactionList = _a.parallelFetchAccountTransactionList, exports.fetchAccountTransactionList = _a.fetchAccountTransactionList, exports.updateTransactionListByAccount = _a.updateTransactionListByAccount, exports.updateTransactionListByAccountFailure = _a.updateTransactionListByAccountFailure, exports.parallelFetchEntityTransactionList = _a.parallelFetchEntityTransactionList, exports.fetchEntityTransactionList = _a.fetchEntityTransactionList, exports.updateTransactionListByEntity = _a.updateTransactionListByEntity, exports.updateTransactionListByEntityFailure = _a.updateTransactionListByEntityFailure, exports.updateTransactionListByAccountUIState = _a.updateTransactionListByAccountUIState, exports.parallelFetchClassTransactionList = _a.parallelFetchClassTransactionList, exports.fetchClassTransactionList = _a.fetchClassTransactionList, exports.updateTransactionListByClass = _a.updateTransactionListByClass, exports.updateTransactionListByClassUIState = _a.updateTransactionListByClassUIState, exports.updateTransactionListByClassFailure = _a.updateTransactionListByClassFailure, exports.parallelFetchTransactionListByCategoryType = _a.parallelFetchTransactionListByCategoryType, exports.fetchTransactionsListByCategoryType = _a.fetchTransactionsListByCategoryType, exports.updateTransactionListByCategoryType = _a.updateTransactionListByCategoryType, exports.updateTransactionsListByCategoryTypeFailure = _a.updateTransactionsListByCategoryTypeFailure, exports.updateTransactionListUIStateByCategoryType = _a.updateTransactionListUIStateByCategoryType, exports.clearTransactionList = _a.clearTransactionList, exports.updateLatestTransactionId = _a.updateLatestTransactionId;
|
|
410
348
|
exports.default = transactionList.reducer;
|
|
411
349
|
/**
|
|
412
350
|
* Helper functions
|
|
@@ -456,22 +394,3 @@ function doUpdateTransactionListByClass(draft, payload) {
|
|
|
456
394
|
transactionIDs,
|
|
457
395
|
};
|
|
458
396
|
}
|
|
459
|
-
function doUpdateTransactionListByProject(draft, payload) {
|
|
460
|
-
const transactionIDs = payload.account.transactions.map((transactionPaylod) => transactionPaylod.transaction_id);
|
|
461
|
-
const account = (0, accountPayload_1.mapAccountBasePayloadToAccountBase)(payload.account);
|
|
462
|
-
const projectId = payload.query.zeni_project_id;
|
|
463
|
-
const start = (0, timePeriod_1.toAbsoluteDay)(payload.query.start_date);
|
|
464
|
-
const end = (0, timePeriod_1.toAbsoluteDay)(payload.query.end_date);
|
|
465
|
-
const key = (0, transactionListState_1.getProjectAcTranKey)(account.accountId, account.accountType, projectId, {
|
|
466
|
-
start,
|
|
467
|
-
end,
|
|
468
|
-
});
|
|
469
|
-
draft[key] = {
|
|
470
|
-
...transactionListState_1.initialProjectTransactionState,
|
|
471
|
-
fetchState: 'Completed',
|
|
472
|
-
error: undefined,
|
|
473
|
-
account: account,
|
|
474
|
-
projectId: projectId,
|
|
475
|
-
transactionIDs,
|
|
476
|
-
};
|
|
477
|
-
}
|
|
@@ -45,20 +45,6 @@ export interface TransactionListByClassState {
|
|
|
45
45
|
transactionListUIStateByClassKey: Record<ClassAcKey, TransactionListUIState>;
|
|
46
46
|
}
|
|
47
47
|
export declare const initialClassTransactionState: ClassAccountTransactions;
|
|
48
|
-
export declare const getProjectAcTranKey: (accountId: ID, accountType: AccountType, projectId: ID, period: TimePeriod) => string;
|
|
49
|
-
export type ProjectAcTranKey = ReturnType<typeof getProjectAcTranKey>;
|
|
50
|
-
export declare const getProjectAcKey: (accountId: ID, accountType: AccountType, projectId: ID) => string;
|
|
51
|
-
type ProjectAcKey = ReturnType<typeof getProjectAcKey>;
|
|
52
|
-
export interface ProjectAccountTransactions extends FetchedState {
|
|
53
|
-
transactionIDs: ID[];
|
|
54
|
-
account?: AccountBase;
|
|
55
|
-
projectId?: ID;
|
|
56
|
-
}
|
|
57
|
-
export interface TransactionListByProjectState {
|
|
58
|
-
transactionListByProjectKey: Record<ProjectAcTranKey, ProjectAccountTransactions>;
|
|
59
|
-
transactionListUIStateByProjectKey: Record<ProjectAcKey, TransactionListUIState>;
|
|
60
|
-
}
|
|
61
|
-
export declare const initialProjectTransactionState: ProjectAccountTransactions;
|
|
62
48
|
export type TransactionCategoryType = 'missingReceipts' | 'miscategorizedExpense' | 'miscategorizedIncome' | 'uncategorizedIncome' | 'uncategorizedExpense';
|
|
63
49
|
export declare const getCategoryTypeTranKey: (categoryType: TransactionCategoryType, period: TimePeriod) => string;
|
|
64
50
|
type CategoryTypeTranKey = ReturnType<typeof getCategoryTypeTranKey>;
|
|
@@ -73,7 +59,6 @@ export interface TransactionListState {
|
|
|
73
59
|
byAccount: TransactionListByAccountState;
|
|
74
60
|
byClass: TransactionListByClassState;
|
|
75
61
|
byEntity: TransactionListByEntityState;
|
|
76
|
-
byProject: TransactionListByProjectState;
|
|
77
62
|
byType: Record<TransactionCategoryType, TransactionListByCategoryState>;
|
|
78
63
|
latestTransactionId?: TransactionID;
|
|
79
64
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initialTransactionsStateByCategoryType = exports.getCategoryTypeTranKey = exports.
|
|
3
|
+
exports.initialTransactionsStateByCategoryType = exports.getCategoryTypeTranKey = exports.initialClassTransactionState = exports.getClassAcKey = exports.getClassAcTranKey = exports.initialEntityTransactionState = exports.getEntityTranKey = exports.accountTransactionsInitialState = exports.getAcKey = exports.getAcTranKey = void 0;
|
|
4
4
|
const getAcTranKey = (accountId, accountType, period) => `${accountId}-${accountType}-${period.start.day}_${period.start.month}_${period.start.year}_${period.end.day}_${period.end.month}_${period.end.year}`;
|
|
5
5
|
exports.getAcTranKey = getAcTranKey;
|
|
6
6
|
const getAcKey = (accountId, accountType) => `${accountId}-${accountType}`;
|
|
@@ -38,18 +38,6 @@ exports.initialClassTransactionState = {
|
|
|
38
38
|
return this.fetchState == 'Completed';
|
|
39
39
|
},
|
|
40
40
|
};
|
|
41
|
-
const getProjectAcTranKey = (accountId, accountType, projectId, period) => `${accountId}-${accountType}-${projectId}-${period.start.day}_${period.start.month}_${period.start.year}_${period.end.day}_${period.end.month}_${period.end.year}`;
|
|
42
|
-
exports.getProjectAcTranKey = getProjectAcTranKey;
|
|
43
|
-
const getProjectAcKey = (accountId, accountType, projectId) => `${accountId}-${accountType}-${projectId}`;
|
|
44
|
-
exports.getProjectAcKey = getProjectAcKey;
|
|
45
|
-
exports.initialProjectTransactionState = {
|
|
46
|
-
transactionIDs: [],
|
|
47
|
-
fetchState: 'Not-Started',
|
|
48
|
-
error: undefined,
|
|
49
|
-
hasValidState() {
|
|
50
|
-
return this.fetchState == 'Completed';
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
41
|
const getCategoryTypeTranKey = (categoryType, period) => `${categoryType}_${period.start.day}_${period.start.month}_${period.start.year}_${period.end.day}_${period.end.month}_${period.end.year}`;
|
|
54
42
|
exports.getCategoryTypeTranKey = getCategoryTypeTranKey;
|
|
55
43
|
exports.initialTransactionsStateByCategoryType = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.0.52
|
|
3
|
+
"version": "5.0.52",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -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
|
-
};
|