@zeniai/client-epic-state 4.8.3 → 4.8.4
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/entity/account/accountSelector.d.ts +3 -1
- package/lib/entity/account/accountSelector.js +27 -1
- package/lib/view/scheduleView/scheduleDetailView/epics/fetchScheduleDetailsEpic.js +2 -1
- package/lib/view/scheduleView/scheduleDetailView/epics/fetchScheduleDetailsPageEpic.js +2 -1
- package/lib/view/scheduleView/scheduleDetailView/scheduleDetailLocalDataHelper.d.ts +8 -1
- package/lib/view/scheduleView/scheduleDetailView/scheduleDetailLocalDataHelper.js +15 -1
- package/lib/view/scheduleView/scheduleDetailView/scheduleDetailSelector.js +9 -3
- package/lib/view/scheduleView/scheduleListView/epics/fetchScheduleListEpic.d.ts +1 -1
- package/lib/view/scheduleView/scheduleListView/epics/fetchScheduleListEpic.js +9 -6
- package/lib/view/scheduleView/scheduleListView/epics/fetchSchedulesAccountEpic.d.ts +0 -12
- package/lib/view/scheduleView/scheduleListView/epics/fetchSchedulesAccountEpic.js +3 -20
- package/lib/view/scheduleView/scheduleListView/scheduleListHelper.d.ts +13 -1
- package/lib/view/scheduleView/scheduleListView/scheduleListHelper.js +21 -1
- package/lib/view/scheduleView/scheduleListView/scheduleListSelector.js +7 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="url-parse" />
|
|
2
|
-
import { AccountBase, AccountState } from './accountState';
|
|
2
|
+
import { Account, AccountBase, AccountState, AccountType } from './accountState';
|
|
3
3
|
import { ID } from '../../commonStateTypes/common';
|
|
4
4
|
import { EntityOrder } from '../../commonStateTypes/selectorTypes/selectorTypes';
|
|
5
5
|
import { ReportIDPlusForecastID } from '../../commonStateTypes/viewAndReport/viewAndReport';
|
|
@@ -108,3 +108,5 @@ export declare const getAccountsOrdered: (filter: COABalancesFilter, accountStat
|
|
|
108
108
|
accountsViewParentId: AccountsViewParentID | undefined;
|
|
109
109
|
labels: ("prepaid_expenses" | "uncategorized_income" | "uncategorized_expense")[];
|
|
110
110
|
}[];
|
|
111
|
+
export declare const getAccountsByType: (accountState: AccountState, accountTypes: AccountType[]) => Partial<Record<AccountType, Account[]>>;
|
|
112
|
+
export declare const getAccountIdsForTypes: (accountState: AccountState, accountTypes: AccountType[]) => ID[];
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAccountsOrdered = exports.getAccountWithBalance = exports.getAccount = exports.getAccountBase = void 0;
|
|
6
|
+
exports.getAccountIdsForTypes = exports.getAccountsByType = exports.getAccountsOrdered = exports.getAccountWithBalance = exports.getAccount = exports.getAccountBase = void 0;
|
|
7
|
+
const flatMap_1 = __importDefault(require("lodash/flatMap"));
|
|
4
8
|
const accountState_1 = require("./accountState");
|
|
5
9
|
const coaBalance_1 = require("../../commonStateTypes/coaBalance/coaBalance");
|
|
6
10
|
const sortBalancesByFreeRangeTotal_1 = require("../../commonStateTypes/coaBalance/sortBalancesByFreeRangeTotal");
|
|
@@ -142,3 +146,25 @@ const getAccountsOrdered = (filter, accountState, id, orderBy, order = 'last_bal
|
|
|
142
146
|
}
|
|
143
147
|
});
|
|
144
148
|
exports.getAccountsOrdered = getAccountsOrdered;
|
|
149
|
+
const getAccountsByType = (accountState, accountTypes) => {
|
|
150
|
+
const accountsByType = {};
|
|
151
|
+
accountTypes.forEach((accountType) => {
|
|
152
|
+
accountsByType[accountType] = Object.values(accountState.accountsByKey).filter((account) => account.accountType === accountType);
|
|
153
|
+
});
|
|
154
|
+
return accountsByType;
|
|
155
|
+
};
|
|
156
|
+
exports.getAccountsByType = getAccountsByType;
|
|
157
|
+
const getAccountIdsForTypes = (accountState, accountTypes) => {
|
|
158
|
+
const allAccountsByType = (0, exports.getAccountsByType)(accountState, accountTypes);
|
|
159
|
+
let allAccountIdsForTypes = [];
|
|
160
|
+
accountTypes.forEach((accountType) => {
|
|
161
|
+
if (allAccountsByType[accountType] != null) {
|
|
162
|
+
allAccountIdsForTypes = [
|
|
163
|
+
...allAccountIdsForTypes,
|
|
164
|
+
...(0, flatMap_1.default)(allAccountsByType[accountType], (value) => value.accountId),
|
|
165
|
+
];
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
return allAccountIdsForTypes;
|
|
169
|
+
};
|
|
170
|
+
exports.getAccountIdsForTypes = getAccountIdsForTypes;
|
|
@@ -9,11 +9,12 @@ const scheduleDetailReducer_1 = require("../scheduleDetailReducer");
|
|
|
9
9
|
const transactionType_1 = require("../../../../entity/transaction/stateTypes/transactionType");
|
|
10
10
|
const transactionDetailState_1 = require("../../../transactionDetail/transactionDetailState");
|
|
11
11
|
const fetchScheduleDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(scheduleDetailReducer_1.fetchScheduleDetails.match), (0, operators_1.mergeMap)((action) => {
|
|
12
|
+
var _a;
|
|
12
13
|
const updateActions = [];
|
|
13
14
|
const { tab, selectedJeScheduleDetailId } = action.payload;
|
|
14
15
|
const { scheduleDetailState } = state$.value;
|
|
15
16
|
if (selectedJeScheduleDetailId != null) {
|
|
16
|
-
if (scheduleDetailState.editScheduleStateById[selectedJeScheduleDetailId]
|
|
17
|
+
if (((_a = scheduleDetailState.editScheduleStateById[selectedJeScheduleDetailId]) === null || _a === void 0 ? void 0 : _a.jeScheduleDetails.length) > 0 &&
|
|
17
18
|
scheduleDetailState.selectedJEScheduleKey != null) {
|
|
18
19
|
updateActions.push((0, scheduleDetailReducer_1.initializeScheduleDetailLocalData)(scheduleDetailState.selectedJEScheduleKey, selectedJeScheduleDetailId));
|
|
19
20
|
updateActions.push((0, scheduleDetailReducer_1.updateScheduleDetailsSuccess)());
|
|
@@ -6,9 +6,10 @@ const operators_1 = require("rxjs/operators");
|
|
|
6
6
|
const accountListReducer_1 = require("../../../accountList/accountListReducer");
|
|
7
7
|
const classListReducer_1 = require("../../../classList/classListReducer");
|
|
8
8
|
const scheduleDetailReducer_1 = require("../scheduleDetailReducer");
|
|
9
|
+
const scheduleDetailLocalDataHelper_1 = require("../scheduleDetailLocalDataHelper");
|
|
9
10
|
const fetchScheduleDetailsPageEpic = (actions$) => actions$.pipe((0, operators_1.filter)(scheduleDetailReducer_1.fetchScheduleDetailsPage.match), (0, operators_1.mergeMap)((action) => {
|
|
10
11
|
const scheduleDetailsActions = [];
|
|
11
|
-
scheduleDetailsActions.push((0, accountListReducer_1.fetchAccountList)('
|
|
12
|
+
scheduleDetailsActions.push((0, accountListReducer_1.fetchAccountList)('prepaidExpenseAccountList', true, false, false, false, (0, scheduleDetailLocalDataHelper_1.getAccountsTypesForScheduleDetails)('prepaid_expenses')));
|
|
12
13
|
scheduleDetailsActions.push((0, classListReducer_1.fetchClassList)());
|
|
13
14
|
scheduleDetailsActions.push((0, scheduleDetailReducer_1.fetchScheduleDetails)(action.payload.tab, action.payload.selectedJeScheduleDetailId));
|
|
14
15
|
return (0, rxjs_1.concat)((0, rxjs_1.from)(scheduleDetailsActions));
|
|
@@ -3,8 +3,9 @@ import { JEScheduledTransaction, ScheduledJournalEntry } from '../../../entity/j
|
|
|
3
3
|
import { JEScheduleDetailsLocalData, JETransactionLink, ScheduleDetailsLocalData } from './scheduleDetailState';
|
|
4
4
|
import ZeniUrl from '../../../zeniUrl';
|
|
5
5
|
import { ZeniDate } from '../../../zeniDayJS';
|
|
6
|
-
import { ScheduleJournalEntryStatusCodeType } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
6
|
+
import { ScheduleJournalEntryStatusCodeType, SchedulesTypes } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
7
7
|
import { TransactionID } from '../../../entity/transaction/stateTypes/transaction';
|
|
8
|
+
import { AccountType } from '../../../entity/account/accountState';
|
|
8
9
|
export declare const DUMMY_TRANSACTION_ID = "dummyid";
|
|
9
10
|
export declare const getPostingDateAndStatusForIndex: (schedulePostingMonth: number, schedulePostingYear: number, postingDay?: 2 | 1 | 22 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 27 | 28 | undefined) => {
|
|
10
11
|
postingDate: ZeniDate;
|
|
@@ -16,3 +17,9 @@ export declare const updateAmountsInScheduleDetails: (jeSchedulesLocalData: JESc
|
|
|
16
17
|
export declare const getQBOUrlForLink: (qboAppUrl: string, jeLink?: JETransactionLink | undefined) => ZeniUrl | undefined;
|
|
17
18
|
export declare const getThirdPartyIDFromQBOURL: (jeLinkURL: ZeniUrl) => JETransactionLink;
|
|
18
19
|
export declare const getJETransactionLinkFromThirdPartyId: (thirdPartyID?: string | undefined, transactionId?: string | undefined, recommendedTransactionID?: TransactionID | undefined) => JETransactionLink;
|
|
20
|
+
/**
|
|
21
|
+
* Function to get type of accounts to fetch for a given tab
|
|
22
|
+
* @param scheduleType
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
export declare const getAccountsTypesForScheduleDetails: (scheduleType: SchedulesTypes) => AccountType[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getJETransactionLinkFromThirdPartyId = exports.getThirdPartyIDFromQBOURL = exports.getQBOUrlForLink = exports.updateAmountsInScheduleDetails = exports.getInitializedJEScheduleDetailsLocalData = exports.createNewSchedulesHelper = exports.getPostingDateAndStatusForIndex = exports.DUMMY_TRANSACTION_ID = void 0;
|
|
3
|
+
exports.getAccountsTypesForScheduleDetails = exports.getJETransactionLinkFromThirdPartyId = exports.getThirdPartyIDFromQBOURL = exports.getQBOUrlForLink = exports.updateAmountsInScheduleDetails = exports.getInitializedJEScheduleDetailsLocalData = exports.createNewSchedulesHelper = exports.getPostingDateAndStatusForIndex = exports.DUMMY_TRANSACTION_ID = void 0;
|
|
4
4
|
const amount_1 = require("../../../commonStateTypes/amount");
|
|
5
5
|
const zeniUrl_1 = require("../../../zeniUrl");
|
|
6
6
|
const zeniDayJS_1 = require("../../../zeniDayJS");
|
|
@@ -183,3 +183,17 @@ const getJETransactionLinkFromThirdPartyId = (thirdPartyID, transactionId, recom
|
|
|
183
183
|
};
|
|
184
184
|
};
|
|
185
185
|
exports.getJETransactionLinkFromThirdPartyId = getJETransactionLinkFromThirdPartyId;
|
|
186
|
+
/**
|
|
187
|
+
* Function to get type of accounts to fetch for a given tab
|
|
188
|
+
* @param scheduleType
|
|
189
|
+
* @returns
|
|
190
|
+
*/
|
|
191
|
+
const getAccountsTypesForScheduleDetails = (scheduleType) => {
|
|
192
|
+
switch (scheduleType) {
|
|
193
|
+
case 'prepaid_expenses':
|
|
194
|
+
return ['cogs', 'expenses', 'other_expense'];
|
|
195
|
+
default:
|
|
196
|
+
return [];
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
exports.getAccountsTypesForScheduleDetails = getAccountsTypesForScheduleDetails;
|
|
@@ -6,6 +6,8 @@ const accountListSelector_1 = require("../../accountList/accountListSelector");
|
|
|
6
6
|
const classListSelector_1 = require("../../classList/classListSelector");
|
|
7
7
|
const reduceFetchState_1 = require("../../../commonStateTypes/reduceFetchState");
|
|
8
8
|
const scheduleDetailReducer_1 = require("./scheduleDetailReducer");
|
|
9
|
+
const accountSelector_1 = require("../../../entity/account/accountSelector");
|
|
10
|
+
const scheduleDetailLocalDataHelper_1 = require("./scheduleDetailLocalDataHelper");
|
|
9
11
|
const getScheduleDetailsView = (state) => {
|
|
10
12
|
const { accountState, accountListState, classState, classListState, scheduleDetailState, } = state;
|
|
11
13
|
const jeScheduleKey = scheduleDetailState.selectedJEScheduleKey;
|
|
@@ -29,9 +31,13 @@ const getScheduleDetailsView = (state) => {
|
|
|
29
31
|
};
|
|
30
32
|
}
|
|
31
33
|
const jeScheduleTransactionState = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleKey)(jeScheduleKey, state);
|
|
32
|
-
const
|
|
34
|
+
const scheduleDetailAccountTypes = (0, scheduleDetailLocalDataHelper_1.getAccountsTypesForScheduleDetails)('prepaid_expenses');
|
|
35
|
+
const scheduleDetailAccountIds = (0, accountSelector_1.getAccountIdsForTypes)(accountState, scheduleDetailAccountTypes);
|
|
36
|
+
const allAccountList = (0, accountListSelector_1.getAccountList)(accountState, accountListState, 'prepaidExpenseAccountList');
|
|
37
|
+
const filteredAccounts = allAccountList.accounts.filter((account) => scheduleDetailAccountIds.includes(account.accountId));
|
|
33
38
|
const allClassList = (0, classListSelector_1.getClassList)(classState, classListState);
|
|
34
|
-
const accountListNestedAccountHierarchy = (0, accountListSelector_1.getNestedAccountListHeirarchy)(accountListState, '
|
|
39
|
+
const accountListNestedAccountHierarchy = (0, accountListSelector_1.getNestedAccountListHeirarchy)(accountListState, 'prepaidExpenseAccountList').filter((account) => account.accountId[0] != null &&
|
|
40
|
+
scheduleDetailAccountIds.includes(account.accountId[0]));
|
|
35
41
|
const classListNestedAccountHierarchy = (0, classListSelector_1.getNestedClassListHeirarchy)(classListState);
|
|
36
42
|
const selectedJeScheduleDetailId = jeScheduleTransactionState.jeScheduleId;
|
|
37
43
|
let scheduleDetailsLocalData = Object.assign({}, scheduleDetailReducer_1.initialScheduleDetailsLocalData);
|
|
@@ -53,7 +59,7 @@ const getScheduleDetailsView = (state) => {
|
|
|
53
59
|
return {
|
|
54
60
|
uiState: scheduleDetailState.uiState,
|
|
55
61
|
selectedJEScheduleTransaction: jeScheduleTransactionState,
|
|
56
|
-
allAccountList:
|
|
62
|
+
allAccountList: filteredAccounts,
|
|
57
63
|
allClassList: allClassList.classes,
|
|
58
64
|
accountListNestedAccountHierarchy,
|
|
59
65
|
classListNestedAccountHierarchy,
|
|
@@ -24,4 +24,4 @@ export interface ScheduleListQueryParam {
|
|
|
24
24
|
* @param accountListState
|
|
25
25
|
* @returns
|
|
26
26
|
*/
|
|
27
|
-
export declare const getAllAccountIdsForTab: (tab: SchedulesTypes, accountListState: AccountListState) => ID[];
|
|
27
|
+
export declare const getAllAccountIdsForTab: (tab: SchedulesTypes, accountListState: AccountListState, filterAccountIds: ID[]) => ID[];
|
|
@@ -8,11 +8,12 @@ const responsePayload_1 = require("../../../../responsePayload");
|
|
|
8
8
|
const jeSchedulesReducer_1 = require("../../../../entity/jeSchedules/jeSchedulesReducer");
|
|
9
9
|
const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
|
|
10
10
|
const timeframeTick_1 = require("../../../../commonStateTypes/timeframeTick");
|
|
11
|
-
const
|
|
11
|
+
const scheduleListHelper_1 = require("../scheduleListHelper");
|
|
12
12
|
const scheduleListTypes_1 = require("../scheduleListTypes");
|
|
13
|
+
const accountSelector_1 = require("../../../../entity/account/accountSelector");
|
|
13
14
|
const fetchScheduleListEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(scheduleListReducer_1.fetchScheduleList.match), (0, operators_1.mergeMap)((action) => {
|
|
14
15
|
const { tab } = action.payload;
|
|
15
|
-
const { scheduleListState, accountListState } = state$.value;
|
|
16
|
+
const { scheduleListState, accountState, accountListState } = state$.value;
|
|
16
17
|
// if parameters are provided, use those. else go to localdata
|
|
17
18
|
const timeframe = action.payload.timeframeAndCategory != null
|
|
18
19
|
? action.payload.timeframeAndCategory.selectedTimeframe
|
|
@@ -26,9 +27,11 @@ const fetchScheduleListEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, o
|
|
|
26
27
|
if (draft != null && draft.fetchState === 'Completed') {
|
|
27
28
|
return (0, rxjs_1.from)([]);
|
|
28
29
|
}
|
|
30
|
+
const scheduleListCurrentTabAccountTypes = (0, scheduleListHelper_1.getAccountsTypesForSchedulePayload)(scheduleListState.currentTab).allowedAccountList;
|
|
31
|
+
const scheduleListCurrentTabAccountIds = (0, accountSelector_1.getAccountIdsForTypes)(accountState, scheduleListCurrentTabAccountTypes);
|
|
29
32
|
let categoryIds = [categoryId];
|
|
30
33
|
if (categoryId === 'all') {
|
|
31
|
-
categoryIds = (0, exports.getAllAccountIdsForTab)(scheduleListState.currentTab, accountListState);
|
|
34
|
+
categoryIds = (0, exports.getAllAccountIdsForTab)(scheduleListState.currentTab, accountListState, scheduleListCurrentTabAccountIds);
|
|
32
35
|
}
|
|
33
36
|
const queryParam = {
|
|
34
37
|
start_date: (0, timePeriod_1.toString)(timePeriod.start),
|
|
@@ -61,9 +64,9 @@ exports.fetchScheduleListEpic = fetchScheduleListEpic;
|
|
|
61
64
|
* @param accountListState
|
|
62
65
|
* @returns
|
|
63
66
|
*/
|
|
64
|
-
const getAllAccountIdsForTab = (tab, accountListState) => {
|
|
65
|
-
const accountStateForReport = accountListState.byReportId[(0,
|
|
66
|
-
let accountIds = accountStateForReport.accountIds;
|
|
67
|
+
const getAllAccountIdsForTab = (tab, accountListState, filterAccountIds) => {
|
|
68
|
+
const accountStateForReport = accountListState.byReportId[(0, scheduleListHelper_1.getAccountsTypesForSchedulePayload)(tab).accountListKey];
|
|
69
|
+
let accountIds = accountStateForReport.accountIds.filter((accountId) => filterAccountIds.includes(accountId));
|
|
67
70
|
if (tab === 'prepaid_expenses') {
|
|
68
71
|
const filteredList = accountStateForReport.accountIdsByLabel['prepaid_expenses'];
|
|
69
72
|
if (filteredList.length > 0) {
|
|
@@ -3,17 +3,5 @@ import { Observable } from 'rxjs';
|
|
|
3
3
|
import { RootState } from '../../../../reducer';
|
|
4
4
|
import { fetchSchedulesAccount } from '../scheduleListReducer';
|
|
5
5
|
import { fetchAccountList } from '../../../accountList/accountListReducer';
|
|
6
|
-
import { AccountListKeyType } from '../../../accountList/accountListState';
|
|
7
|
-
import { AccountType } from '../../../../entity/account/accountState';
|
|
8
|
-
import { SchedulesTypes } from '../../../../entity/jeSchedules/jeSchedulesTypes';
|
|
9
6
|
export declare type ActionType = ReturnType<typeof fetchSchedulesAccount> | ReturnType<typeof fetchAccountList>;
|
|
10
7
|
export declare const fetchSchedulesAccountEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>) => Observable<ActionType>;
|
|
11
|
-
declare type AccountListTypesPayload = {
|
|
12
|
-
accountListKey: AccountListKeyType;
|
|
13
|
-
allowedAccountList: AccountType[];
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Helper functions
|
|
17
|
-
*/
|
|
18
|
-
export declare const getAccountsTypesForSchedulePayload: (scheduleType: SchedulesTypes) => AccountListTypesPayload;
|
|
19
|
-
export {};
|
|
@@ -1,37 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.fetchSchedulesAccountEpic = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
6
|
const scheduleListReducer_1 = require("../scheduleListReducer");
|
|
7
7
|
const accountListReducer_1 = require("../../../accountList/accountListReducer");
|
|
8
|
+
const scheduleListHelper_1 = require("../scheduleListHelper");
|
|
8
9
|
const fetchSchedulesAccountEpic = (actions$,
|
|
9
10
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10
11
|
_state$) => actions$.pipe((0, operators_1.filter)(scheduleListReducer_1.fetchSchedulesAccount.match), (0, operators_1.mergeMap)(() => {
|
|
11
12
|
const fetchScheduleListActions = [];
|
|
12
13
|
const scheduleTabIds = ['prepaid_expenses'];
|
|
13
14
|
scheduleTabIds.forEach((scheduleTab) => {
|
|
14
|
-
const accountType = (0,
|
|
15
|
+
const accountType = (0, scheduleListHelper_1.getAccountsTypesForSchedulePayload)(scheduleTab);
|
|
15
16
|
fetchScheduleListActions.push((0, accountListReducer_1.fetchAccountList)(accountType.accountListKey, false, false, false, false, accountType.allowedAccountList));
|
|
16
17
|
});
|
|
17
18
|
return (0, rxjs_1.from)(fetchScheduleListActions);
|
|
18
19
|
}));
|
|
19
20
|
exports.fetchSchedulesAccountEpic = fetchSchedulesAccountEpic;
|
|
20
|
-
/**
|
|
21
|
-
* Helper functions
|
|
22
|
-
*/
|
|
23
|
-
const getAccountsTypesForSchedulePayload = (scheduleType) => {
|
|
24
|
-
switch (scheduleType) {
|
|
25
|
-
case 'prepaid_expenses':
|
|
26
|
-
return {
|
|
27
|
-
accountListKey: 'prepaidExpenseAccountList',
|
|
28
|
-
allowedAccountList: ['other_current_assets'],
|
|
29
|
-
};
|
|
30
|
-
default:
|
|
31
|
-
return {
|
|
32
|
-
accountListKey: 'accountList',
|
|
33
|
-
allowedAccountList: [],
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
exports.getAccountsTypesForSchedulePayload = getAccountsTypesForSchedulePayload;
|
|
@@ -2,9 +2,10 @@ import { NestedAccountHeirarchyForReport } from '../../../commonStateTypes/accou
|
|
|
2
2
|
import { Amount } from '../../../commonStateTypes/amount';
|
|
3
3
|
import { COABalance, COABalanceGroupedByPeriod } from '../../../commonStateTypes/coaBalance/coaBalance';
|
|
4
4
|
import { TimeframeTickWithMetaData } from '../../../commonStateTypes/timeframeTick';
|
|
5
|
-
import { AccountBase } from '../../../entity/account/accountState';
|
|
5
|
+
import { AccountBase, AccountType } from '../../../entity/account/accountState';
|
|
6
6
|
import { JEScheduledTransaction, ScheduledJournalEntry } from '../../../entity/jeSchedules/jeSchedulesSelector';
|
|
7
7
|
import { SchedulesTypes } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
8
|
+
import { AccountListKeyType } from '../../accountList/accountListState';
|
|
8
9
|
import { JEScheduledTransactionWithBalance } from './scheduleListSelector';
|
|
9
10
|
export declare type TimeframeTickBalances = Record<string, COABalance[]>;
|
|
10
11
|
export interface ScheduleTotalType {
|
|
@@ -74,3 +75,14 @@ export declare const calculateCOABalanceGroupedByPeriod: (jeSchedule: JESchedule
|
|
|
74
75
|
* @returns
|
|
75
76
|
*/
|
|
76
77
|
export declare const getDurationOfMonthOutTotalMonth: (jeSchedule: JEScheduledTransaction) => number;
|
|
78
|
+
declare type AccountListTypesPayload = {
|
|
79
|
+
accountListKey: AccountListKeyType;
|
|
80
|
+
allowedAccountList: AccountType[];
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Function to get accountListKey and allowedAccountList for a given tab
|
|
84
|
+
* @param scheduleType
|
|
85
|
+
* @returns
|
|
86
|
+
*/
|
|
87
|
+
export declare const getAccountsTypesForSchedulePayload: (scheduleType: SchedulesTypes) => AccountListTypesPayload;
|
|
88
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDurationOfMonthOutTotalMonth = exports.calculateCOABalanceGroupedByPeriod = exports.mapScheduleJournalToCOABalance = exports.calculateTotalBalanceTimeframeTick = exports.setDefaultTotalBalanceTimeframeTicks = exports.mapTotalBalanceTimeframeTickToCOAGroupedBalance = exports.getAllTimeframeTicks = exports.getAllAccountNested = exports.getAllAccountBase = exports.getAccountListKeyForSchedulesTab = exports.getCalculatedScheduleTotals = void 0;
|
|
3
|
+
exports.getAccountsTypesForSchedulePayload = exports.getDurationOfMonthOutTotalMonth = exports.calculateCOABalanceGroupedByPeriod = exports.mapScheduleJournalToCOABalance = exports.calculateTotalBalanceTimeframeTick = exports.setDefaultTotalBalanceTimeframeTicks = exports.mapTotalBalanceTimeframeTickToCOAGroupedBalance = exports.getAllTimeframeTicks = exports.getAllAccountNested = exports.getAllAccountBase = exports.getAccountListKeyForSchedulesTab = exports.getCalculatedScheduleTotals = void 0;
|
|
4
4
|
const amount_1 = require("../../../commonStateTypes/amount");
|
|
5
5
|
const formatZeniDateFY_1 = require("../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY");
|
|
6
6
|
const getFYMonths_1 = require("../../../commonStateTypes/fiscalYearHelpers/getFYMonths");
|
|
@@ -202,3 +202,23 @@ const getDurationOfMonthOutTotalMonth = (jeSchedule) => {
|
|
|
202
202
|
return totalDurationCompleted;
|
|
203
203
|
};
|
|
204
204
|
exports.getDurationOfMonthOutTotalMonth = getDurationOfMonthOutTotalMonth;
|
|
205
|
+
/**
|
|
206
|
+
* Function to get accountListKey and allowedAccountList for a given tab
|
|
207
|
+
* @param scheduleType
|
|
208
|
+
* @returns
|
|
209
|
+
*/
|
|
210
|
+
const getAccountsTypesForSchedulePayload = (scheduleType) => {
|
|
211
|
+
switch (scheduleType) {
|
|
212
|
+
case 'prepaid_expenses':
|
|
213
|
+
return {
|
|
214
|
+
accountListKey: 'prepaidExpenseAccountList',
|
|
215
|
+
allowedAccountList: ['other_current_assets'],
|
|
216
|
+
};
|
|
217
|
+
default:
|
|
218
|
+
return {
|
|
219
|
+
accountListKey: 'accountList',
|
|
220
|
+
allowedAccountList: [],
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
exports.getAccountsTypesForSchedulePayload = getAccountsTypesForSchedulePayload;
|
|
@@ -12,6 +12,8 @@ const scheduleListReducer_1 = require("./scheduleListReducer");
|
|
|
12
12
|
const scheduleListTypes_1 = require("./scheduleListTypes");
|
|
13
13
|
const amount_1 = require("../../../commonStateTypes/amount");
|
|
14
14
|
const scheduleListHelper_1 = require("./scheduleListHelper");
|
|
15
|
+
const scheduleListHelper_2 = require("./scheduleListHelper");
|
|
16
|
+
const accountSelector_1 = require("../../../entity/account/accountSelector");
|
|
15
17
|
const sortedJETransactionsView = (jeTransactions, sortKey, sortOrder) => {
|
|
16
18
|
return (0, orderBy_1.default)(jeTransactions, (jeTransaction) => {
|
|
17
19
|
var _a;
|
|
@@ -69,12 +71,15 @@ const getScheduleListReport = (state) => {
|
|
|
69
71
|
const allScheduleAccounts = (0, accountListSelector_1.getAccountList)(accountState, accountListState, (0, scheduleListHelper_1.getAccountListKeyForSchedulesTab)(scheduleListState.currentTab));
|
|
70
72
|
let allNestedAccounts = (0, accountListSelector_1.getNestedAccountListHeirarchy)(accountListState, (0, scheduleListHelper_1.getAccountListKeyForSchedulesTab)(scheduleListState.currentTab));
|
|
71
73
|
let allAccounts = allScheduleAccounts.accounts;
|
|
74
|
+
const scheduleListCurrentTabAccountTypes = (0, scheduleListHelper_2.getAccountsTypesForSchedulePayload)(scheduleListState.currentTab).allowedAccountList;
|
|
75
|
+
const scheduleListCurrentTabAccountIds = (0, accountSelector_1.getAccountIdsForTypes)(accountState, scheduleListCurrentTabAccountTypes);
|
|
72
76
|
if (scheduleListState.currentTab === 'prepaid_expenses') {
|
|
73
77
|
const filteredList = (0, accountListSelector_1.getFilteredNestedAndAccountListsForLabel)(accountState, accountListState, (0, scheduleListHelper_1.getAccountListKeyForSchedulesTab)(scheduleListState.currentTab), 'prepaid_expenses');
|
|
74
78
|
// Use this list only if there is some account in it.
|
|
75
79
|
if (filteredList.accountList.length > 0) {
|
|
76
|
-
allAccounts = filteredList.accountList;
|
|
77
|
-
allNestedAccounts = filteredList.nestedAccountList
|
|
80
|
+
allAccounts = filteredList.accountList.filter((account) => scheduleListCurrentTabAccountIds.includes(account.accountId));
|
|
81
|
+
allNestedAccounts = filteredList.nestedAccountList.filter((account) => account.accountId[0] != null &&
|
|
82
|
+
scheduleListCurrentTabAccountIds.includes(account.accountId[0]));
|
|
78
83
|
}
|
|
79
84
|
}
|
|
80
85
|
if (scheduleListRecord == null) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.4",
|
|
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
|
"types": "lib/index.d.ts",
|