@zeniai/client-epic-state 4.7.99 → 4.8.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/statusPayload.d.ts +4 -0
- package/lib/commonStateTypes/fiscalYearHelpers/formatZeniDateFY.d.ts +3 -0
- package/lib/commonStateTypes/fiscalYearHelpers/formatZeniDateFY.js +4 -1
- package/lib/commonStateTypes/timePeriod.d.ts +9 -2
- package/lib/commonStateTypes/timePeriod.js +12 -1
- package/lib/commonStateTypes/viewAndReport/viewAndReport.d.ts +1 -1
- package/lib/commonStateTypes/viewAndReport/viewAndReport.js +1 -0
- package/lib/entity/account/accountPayload.d.ts +1 -1
- package/lib/entity/account/accountSelector.d.ts +3 -3
- package/lib/entity/account/accountState.d.ts +4 -4
- package/lib/entity/account/accountState.js +1 -0
- package/lib/entity/account/pickAndMergeForecastAccountReport.d.ts +1 -1
- package/lib/entity/accountGroup/accountGroupSelector.d.ts +22 -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 +2 -2
- package/lib/entity/depositAccountTransaction/depositAccountTransaction.d.ts +1 -1
- package/lib/entity/forecast/forecastState.d.ts +1 -1
- package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +55 -0
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +142 -0
- package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +11 -0
- package/lib/entity/jeSchedules/jeSchedulesReducer.js +91 -0
- package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +58 -0
- package/lib/entity/jeSchedules/jeSchedulesSelector.js +74 -0
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +61 -0
- package/lib/entity/jeSchedules/jeSchedulesState.js +2 -0
- package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +10 -0
- package/lib/entity/jeSchedules/jeSchedulesTypes.js +25 -0
- package/lib/entity/jeSchedules/updateJESchedulesEpic.d.ts +10 -0
- package/lib/entity/jeSchedules/updateJESchedulesEpic.js +65 -0
- 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/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +2 -0
- package/lib/entity/tenant/clearAllEpic.d.ts +3 -1
- package/lib/entity/tenant/clearAllEpic.js +4 -0
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +12 -0
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +37 -0
- package/lib/entity/transaction/payloadTypes/transactionPayload.d.ts +3 -3
- package/lib/entity/transaction/payloadTypes/transactionPayload.js +1 -1
- package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +11 -0
- package/lib/entity/transaction/stateTypes/scheduleTransaction.js +2 -0
- package/lib/entity/transaction/stateTypes/transaction.d.ts +10 -7
- package/lib/entity/transaction/stateTypes/transactionType.d.ts +4 -0
- package/lib/entity/transaction/stateTypes/transactionType.js +11 -3
- package/lib/entity/transaction/transactionReducer.d.ts +7 -0
- package/lib/entity/transaction/transactionReducer.js +39 -3
- package/lib/entity/transaction/transactionSelector.d.ts +6 -0
- package/lib/entity/transaction/transactionSelector.js +19 -0
- package/lib/entity/transaction/transactionState.d.ts +3 -0
- package/lib/epic.d.ts +77 -67
- package/lib/epic.js +11 -1
- package/lib/index.d.ts +19 -6
- package/lib/index.js +58 -17
- package/lib/reducer.d.ts +9 -0
- package/lib/reducer.js +9 -0
- package/lib/view/accountList/accountListReducer.js +2 -0
- package/lib/view/accountList/accountListSelector.d.ts +16 -1
- package/lib/view/accountList/accountListSelector.js +33 -4
- package/lib/view/accountList/accountListState.d.ts +1 -1
- package/lib/view/accountMappingView/accountTypeRecommendation/accountTypeRecommendationPayload.d.ts +1 -1
- package/lib/view/billPayCard/billPayCardSelector.d.ts +1 -1
- package/lib/view/cardBalance/cardBalanceSelector.d.ts +2 -2
- package/lib/view/cashBalance/cashBalanceSelector.d.ts +2 -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/globalMerchantView/globalMerchantViewReducer.d.ts +2 -2
- package/lib/view/people/changeZeniPersonRolesEpic.d.ts +1 -1
- package/lib/view/people/deletePersonEpic.d.ts +1 -1
- package/lib/view/people/invitePeopleEpic.d.ts +1 -1
- package/lib/view/people/inviteZeniPeopleEpic.d.ts +1 -1
- package/lib/view/people/resendInviteEpic.d.ts +1 -1
- package/lib/view/reimbursementCard/reimbursementCardSelector.d.ts +1 -1
- package/lib/view/reviewCompanyView/reviewCompanyViewState.d.ts +2 -2
- package/lib/view/reviewCompanyView/reviewCompanyViewState.js +1 -0
- package/lib/view/scheduleView/scheduleDetailView/epics/createNewSchedulesEpic.d.ts +6 -0
- package/lib/view/scheduleView/scheduleDetailView/epics/createNewSchedulesEpic.js +28 -0
- package/lib/view/scheduleView/scheduleDetailView/epics/fetchScheduleDetailsEpic.d.ts +8 -0
- package/lib/view/scheduleView/scheduleDetailView/epics/fetchScheduleDetailsEpic.js +51 -0
- package/lib/view/scheduleView/scheduleDetailView/epics/fetchScheduleDetailsPageEpic.d.ts +7 -0
- package/lib/view/scheduleView/scheduleDetailView/epics/fetchScheduleDetailsPageEpic.js +16 -0
- package/lib/view/scheduleView/scheduleDetailView/epics/initializeScheduleDetailLocalDataEpic.d.ts +6 -0
- package/lib/view/scheduleView/scheduleDetailView/epics/initializeScheduleDetailLocalDataEpic.js +32 -0
- package/lib/view/scheduleView/scheduleDetailView/epics/saveScheduleDetailsEpic.d.ts +11 -0
- package/lib/view/scheduleView/scheduleDetailView/epics/saveScheduleDetailsEpic.js +102 -0
- package/lib/view/scheduleView/scheduleDetailView/epics/updateAmountsInScheduleDetailEpic.d.ts +6 -0
- package/lib/view/scheduleView/scheduleDetailView/epics/updateAmountsInScheduleDetailEpic.js +29 -0
- package/lib/view/scheduleView/scheduleDetailView/scheduleDetailLocalDataHelper.d.ts +18 -0
- package/lib/view/scheduleView/scheduleDetailView/scheduleDetailLocalDataHelper.js +185 -0
- package/lib/view/scheduleView/scheduleDetailView/scheduleDetailPayload.d.ts +58 -0
- package/lib/view/scheduleView/scheduleDetailView/scheduleDetailPayload.js +118 -0
- package/lib/view/scheduleView/scheduleDetailView/scheduleDetailReducer.d.ts +50 -0
- package/lib/view/scheduleView/scheduleDetailView/scheduleDetailReducer.js +237 -0
- package/lib/view/scheduleView/scheduleDetailView/scheduleDetailSelector.d.ts +21 -0
- package/lib/view/scheduleView/scheduleDetailView/scheduleDetailSelector.js +67 -0
- package/lib/view/scheduleView/scheduleDetailView/scheduleDetailState.d.ts +47 -0
- package/lib/view/scheduleView/scheduleDetailView/scheduleDetailState.js +5 -0
- package/lib/view/scheduleView/scheduleDetailView/scheduleDetailTypes.d.ts +3 -0
- package/lib/view/scheduleView/scheduleDetailView/scheduleDetailTypes.js +14 -0
- package/lib/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.d.ts +8 -0
- package/lib/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +52 -0
- package/lib/view/scheduleView/scheduleListView/epics/fetchScheduleListEpic.d.ts +27 -0
- package/lib/view/scheduleView/scheduleListView/epics/fetchScheduleListEpic.js +75 -0
- package/lib/view/scheduleView/scheduleListView/epics/fetchSchedulesAccountEpic.d.ts +19 -0
- package/lib/view/scheduleView/scheduleListView/epics/fetchSchedulesAccountEpic.js +37 -0
- package/lib/view/scheduleView/scheduleListView/scheduleListHelper.d.ts +70 -0
- package/lib/view/scheduleView/scheduleListView/scheduleListHelper.js +187 -0
- package/lib/view/scheduleView/scheduleListView/scheduleListPayload.d.ts +7 -0
- package/lib/view/scheduleView/scheduleListView/scheduleListPayload.js +2 -0
- package/lib/view/scheduleView/scheduleListView/scheduleListReducer.d.ts +55 -0
- package/lib/view/scheduleView/scheduleListView/scheduleListReducer.js +228 -0
- package/lib/view/scheduleView/scheduleListView/scheduleListSelector.d.ts +38 -0
- package/lib/view/scheduleView/scheduleListView/scheduleListSelector.js +193 -0
- package/lib/view/scheduleView/scheduleListView/scheduleListState.d.ts +29 -0
- package/lib/view/scheduleView/scheduleListView/scheduleListState.js +2 -0
- package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +22 -0
- package/lib/view/scheduleView/scheduleListView/scheduleListTypes.js +39 -0
- package/lib/view/tasksCard/tasksCardSelector.d.ts +1 -1
- package/lib/view/topEx/topExSelector.d.ts +1 -1
- package/lib/view/transactionDetail/epics/initializeTransactionDetailLocalDataEpic.js +2 -5
- package/lib/view/transactionDetail/epics/saveTransactionDetailEpic.js +2 -1
- package/lib/view/transactionDetail/epics/transactionDetailEpic.js +3 -2
- package/lib/view/transactionDetail/epics/updateTransactionDetailEpic.js +2 -1
- package/lib/view/transactionDetail/transactionDetailSelector.js +3 -2
- package/lib/view/transactionDetail/transactionDetailState.d.ts +1 -1
- package/lib/view/transactionDetail/transactionDetailState.js +3 -16
- package/lib/view/transactionList/transactionListByAccountSelector.js +2 -1
- package/lib/view/transactionList/transactionListByCategoryTypeSelector.js +2 -1
- package/lib/view/transactionList/transactionListByClassSelector.js +2 -1
- package/lib/view/transactionList/transactionListByEntitySelector.js +2 -1
- package/lib/view/vendorList/vendorListSelector.d.ts +3 -0
- package/lib/view/vendorList/vendorListSelector.js +11 -1
- package/lib/view/vendorReviewView/vendorGlobalReviewView/vendorGlobalReviewViewState.d.ts +2 -2
- package/lib/zeniDayJS.d.ts +1 -0
- package/lib/zeniDayJS.js +7 -1
- package/package.json +1 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { NestedAccountHeirarchyForReport } from '../../../commonStateTypes/accountView/nestedAccountID';
|
|
2
|
+
import { Amount } from '../../../commonStateTypes/amount';
|
|
3
|
+
import { COABalance, COABalanceGroupedByPeriod } from '../../../commonStateTypes/coaBalance/coaBalance';
|
|
4
|
+
import { TimeframeTickWithMetaData } from '../../../commonStateTypes/timeframeTick';
|
|
5
|
+
import { AccountBase } from '../../../entity/account/accountState';
|
|
6
|
+
import { JEScheduledTransaction, ScheduledJournalEntry } from '../../../entity/jeSchedules/jeSchedulesSelector';
|
|
7
|
+
import { SchedulesTypes } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
8
|
+
import { JEScheduledTransactionWithBalance } from './scheduleListSelector';
|
|
9
|
+
export declare type TimeframeTickBalances = Record<string, COABalance[]>;
|
|
10
|
+
export interface ScheduleTotalType {
|
|
11
|
+
totalAmount: Amount;
|
|
12
|
+
totalRunningBalances: Amount;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* This helper function calculates Total Amount and Total Running balances
|
|
16
|
+
* for all the JE transactions which can be used to display the totals on the Schedule List page.
|
|
17
|
+
* @param jeTransactions
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export declare const getCalculatedScheduleTotals: (jeTransactions: JEScheduledTransaction[]) => ScheduleTotalType;
|
|
21
|
+
export declare const getAccountListKeyForSchedulesTab: (scheduleTab: SchedulesTypes) => "accountList" | "prepaidExpenseAccountList";
|
|
22
|
+
export declare const getAllAccountBase: () => AccountBase;
|
|
23
|
+
export declare const getAllAccountNested: () => NestedAccountHeirarchyForReport;
|
|
24
|
+
/**
|
|
25
|
+
* This helper function is to get all possible timeframe
|
|
26
|
+
* Logic --> Timeframe Range is startDate = (currentDate to 3 months back )and endDate = (currentDate to 9 months ahead)
|
|
27
|
+
* @param sortedJETransactionView
|
|
28
|
+
* @param startMonth
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
export declare const getAllTimeframeTicks: (sortedJETransactionView: JEScheduledTransaction[], startMonth: number) => TimeframeTickWithMetaData[];
|
|
32
|
+
/**
|
|
33
|
+
* This is a helper function to map totalBalanceTimeframeTicks to COABalance
|
|
34
|
+
* @param totalBalanceTimeframeTicks
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
export declare const mapTotalBalanceTimeframeTickToCOAGroupedBalance: (totalBalanceTimeframeTicks: TimeframeTickBalances) => COABalance[];
|
|
38
|
+
/**
|
|
39
|
+
* This function setting default values in the totalBalanceTimeframeTicks using allTimeframeTicks
|
|
40
|
+
* e.g {'Feb 2023' : [], 'Mar 2023' : [], 'Apr 2023' : [], 'Jun 2023' : [], 'Jun 2023' : [], 'Jul 2023' : []}
|
|
41
|
+
*
|
|
42
|
+
* @param allTimeframeTicks
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
export declare const setDefaultTotalBalanceTimeframeTicks: (allTimeframeTicks: TimeframeTickWithMetaData[]) => TimeframeTickBalances;
|
|
46
|
+
/**
|
|
47
|
+
* This function returns an COABalanceGroupedByPeriod (months, weeks, years, quarters) with an array of COABalances
|
|
48
|
+
* in which we loop over the totalBalanceTimeframeTicks which is a record of <Labels(mm yy), Balances>- {'Feb 2023' : [20, 30, 40]}
|
|
49
|
+
* e.g - { months : { balance, startDate, endDate, type}}
|
|
50
|
+
* @param allTimeframeTickBalances
|
|
51
|
+
* @param allTimeframeTicks
|
|
52
|
+
* @param timeframe
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
export declare const calculateTotalBalanceTimeframeTick: (allTimeframeTickBalances: JEScheduledTransactionWithBalance[], allTimeframeTicks: TimeframeTickWithMetaData[], timeframe: 'months') => COABalanceGroupedByPeriod;
|
|
56
|
+
/**
|
|
57
|
+
* This is a helper function just to map COABalance for every ScheduledJournalEntry
|
|
58
|
+
* @param scheduleJournal
|
|
59
|
+
* @param currencyCode
|
|
60
|
+
* @param currencySymbol
|
|
61
|
+
* @param timeframe
|
|
62
|
+
* @returns
|
|
63
|
+
*/
|
|
64
|
+
export declare const mapScheduleJournalToCOABalance: (scheduleJournal: ScheduledJournalEntry, currencyCode: string, currencySymbol: string, timeframe: 'month') => COABalance;
|
|
65
|
+
/**
|
|
66
|
+
* This function helps us in finding COABalanceGroupedByPeriod for months
|
|
67
|
+
* @param jeSchedule
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
export declare const calculateCOABalanceGroupedByPeriod: (jeSchedule: JEScheduledTransaction) => COABalanceGroupedByPeriod;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateCOABalanceGroupedByPeriod = exports.mapScheduleJournalToCOABalance = exports.calculateTotalBalanceTimeframeTick = exports.setDefaultTotalBalanceTimeframeTicks = exports.mapTotalBalanceTimeframeTickToCOAGroupedBalance = exports.getAllTimeframeTicks = exports.getAllAccountNested = exports.getAllAccountBase = exports.getAccountListKeyForSchedulesTab = exports.getCalculatedScheduleTotals = void 0;
|
|
4
|
+
const amount_1 = require("../../../commonStateTypes/amount");
|
|
5
|
+
const formatZeniDateFY_1 = require("../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY");
|
|
6
|
+
const getFYMonths_1 = require("../../../commonStateTypes/fiscalYearHelpers/getFYMonths");
|
|
7
|
+
const zeniDayJS_1 = require("../../../zeniDayJS");
|
|
8
|
+
/**
|
|
9
|
+
* This helper function calculates Total Amount and Total Running balances
|
|
10
|
+
* for all the JE transactions which can be used to display the totals on the Schedule List page.
|
|
11
|
+
* @param jeTransactions
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
const getCalculatedScheduleTotals = (jeTransactions) => {
|
|
15
|
+
if (jeTransactions.length == 0) {
|
|
16
|
+
return {
|
|
17
|
+
totalAmount: (0, amount_1.toAmount)(0, '', ''),
|
|
18
|
+
totalRunningBalances: (0, amount_1.toAmount)(0, '', ''),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const totalAmountSum = jeTransactions.reduce((sum, schedule) => {
|
|
22
|
+
return sum + schedule.baseTransaction.amount.amount;
|
|
23
|
+
}, 0);
|
|
24
|
+
const totalRunningBalanceSum = jeTransactions.reduce((sum, schedule) => {
|
|
25
|
+
return (sum +
|
|
26
|
+
(schedule.balanceAsOfToday != null ? schedule.balanceAsOfToday.amount : 0));
|
|
27
|
+
}, 0);
|
|
28
|
+
return {
|
|
29
|
+
totalAmount: Object.assign(Object.assign({}, jeTransactions[0].baseTransaction.amount), { amount: totalAmountSum }),
|
|
30
|
+
totalRunningBalances: Object.assign(Object.assign({}, jeTransactions[0].baseTransaction.amount), { amount: totalRunningBalanceSum }),
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
exports.getCalculatedScheduleTotals = getCalculatedScheduleTotals;
|
|
34
|
+
const getAccountListKeyForSchedulesTab = (scheduleTab) => {
|
|
35
|
+
switch (scheduleTab) {
|
|
36
|
+
case 'prepaid_expenses':
|
|
37
|
+
return 'prepaidExpenseAccountList';
|
|
38
|
+
case 'accured_expenses':
|
|
39
|
+
case 'deferred_revenue':
|
|
40
|
+
case 'fixed_assets':
|
|
41
|
+
return 'accountList';
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.getAccountListKeyForSchedulesTab = getAccountListKeyForSchedulesTab;
|
|
45
|
+
const getAllAccountBase = () => ({
|
|
46
|
+
accountDescription: 'All',
|
|
47
|
+
accountId: 'all',
|
|
48
|
+
qboId: 'all',
|
|
49
|
+
accountName: 'All',
|
|
50
|
+
labels: [],
|
|
51
|
+
});
|
|
52
|
+
exports.getAllAccountBase = getAllAccountBase;
|
|
53
|
+
const getAllAccountNested = () => ({
|
|
54
|
+
accountId: ['all'],
|
|
55
|
+
accountName: 'All',
|
|
56
|
+
qboId: 'all',
|
|
57
|
+
children: [],
|
|
58
|
+
hasSiblings: false,
|
|
59
|
+
});
|
|
60
|
+
exports.getAllAccountNested = getAllAccountNested;
|
|
61
|
+
/**
|
|
62
|
+
* This helper function is to get all possible timeframe
|
|
63
|
+
* Logic --> Timeframe Range is startDate = (currentDate to 3 months back )and endDate = (currentDate to 9 months ahead)
|
|
64
|
+
* @param sortedJETransactionView
|
|
65
|
+
* @param startMonth
|
|
66
|
+
* @returns
|
|
67
|
+
*/
|
|
68
|
+
const getAllTimeframeTicks = (sortedJETransactionView, startMonth) => {
|
|
69
|
+
const tickLabel = [];
|
|
70
|
+
if (sortedJETransactionView.length > 0) {
|
|
71
|
+
const jeTransaction = sortedJETransactionView[0];
|
|
72
|
+
const { currencySymbol } = jeTransaction;
|
|
73
|
+
const start = (0, zeniDayJS_1.dateNow)().startOf('month').subtract(startMonth, 'month');
|
|
74
|
+
let months = 0;
|
|
75
|
+
while (months < getFYMonths_1.NUM_OF_MONTHS_IN_YEAR) {
|
|
76
|
+
tickLabel.push({
|
|
77
|
+
startDate: start.add(months, 'month'),
|
|
78
|
+
endDate: start.add(months, 'month').endOf('month'),
|
|
79
|
+
currencySymbol: currencySymbol,
|
|
80
|
+
balanceType: 'default',
|
|
81
|
+
});
|
|
82
|
+
months++;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return tickLabel;
|
|
86
|
+
};
|
|
87
|
+
exports.getAllTimeframeTicks = getAllTimeframeTicks;
|
|
88
|
+
/**
|
|
89
|
+
* This is a helper function to map totalBalanceTimeframeTicks to COABalance
|
|
90
|
+
* @param totalBalanceTimeframeTicks
|
|
91
|
+
* @returns
|
|
92
|
+
*/
|
|
93
|
+
const mapTotalBalanceTimeframeTickToCOAGroupedBalance = (totalBalanceTimeframeTicks) => {
|
|
94
|
+
const coaBalanceTotalByTimeframe = [];
|
|
95
|
+
Object.keys(totalBalanceTimeframeTicks).map((timeframeLabel) => {
|
|
96
|
+
const coaBalance = totalBalanceTimeframeTicks[timeframeLabel];
|
|
97
|
+
if (coaBalance.length > 0) {
|
|
98
|
+
const totalCOABalance = Object.assign(Object.assign({}, coaBalance[0]), { balance: Object.assign(Object.assign({}, coaBalance[0].balance), { amount: 0 }) });
|
|
99
|
+
const calculatedCOABalance = coaBalance.reduce((prev, curr) => {
|
|
100
|
+
return Object.assign(Object.assign({}, curr), { balance: (0, amount_1.toAmount)(prev.balance.amount + curr.balance.amount, curr.balance.currencyCode, curr.balance.currencySymbol) });
|
|
101
|
+
}, totalCOABalance);
|
|
102
|
+
coaBalanceTotalByTimeframe.push(calculatedCOABalance);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
return coaBalanceTotalByTimeframe;
|
|
106
|
+
};
|
|
107
|
+
exports.mapTotalBalanceTimeframeTickToCOAGroupedBalance = mapTotalBalanceTimeframeTickToCOAGroupedBalance;
|
|
108
|
+
/**
|
|
109
|
+
* This function setting default values in the totalBalanceTimeframeTicks using allTimeframeTicks
|
|
110
|
+
* e.g {'Feb 2023' : [], 'Mar 2023' : [], 'Apr 2023' : [], 'Jun 2023' : [], 'Jun 2023' : [], 'Jul 2023' : []}
|
|
111
|
+
*
|
|
112
|
+
* @param allTimeframeTicks
|
|
113
|
+
* @returns
|
|
114
|
+
*/
|
|
115
|
+
const setDefaultTotalBalanceTimeframeTicks = (allTimeframeTicks) => {
|
|
116
|
+
const totalBalanceTimeframeTicks = {};
|
|
117
|
+
allTimeframeTicks.map((timeframe) => {
|
|
118
|
+
totalBalanceTimeframeTicks[timeframe.startDate.format(formatZeniDateFY_1.MONTH_YEAR_FORMAT)] =
|
|
119
|
+
[];
|
|
120
|
+
});
|
|
121
|
+
return totalBalanceTimeframeTicks;
|
|
122
|
+
};
|
|
123
|
+
exports.setDefaultTotalBalanceTimeframeTicks = setDefaultTotalBalanceTimeframeTicks;
|
|
124
|
+
/**
|
|
125
|
+
* This function returns an COABalanceGroupedByPeriod (months, weeks, years, quarters) with an array of COABalances
|
|
126
|
+
* in which we loop over the totalBalanceTimeframeTicks which is a record of <Labels(mm yy), Balances>- {'Feb 2023' : [20, 30, 40]}
|
|
127
|
+
* e.g - { months : { balance, startDate, endDate, type}}
|
|
128
|
+
* @param allTimeframeTickBalances
|
|
129
|
+
* @param allTimeframeTicks
|
|
130
|
+
* @param timeframe
|
|
131
|
+
* @returns
|
|
132
|
+
*/
|
|
133
|
+
const calculateTotalBalanceTimeframeTick = (allTimeframeTickBalances, allTimeframeTicks, timeframe) => {
|
|
134
|
+
const totalBalanceTimeframeTicks = (0, exports.setDefaultTotalBalanceTimeframeTicks)(allTimeframeTicks);
|
|
135
|
+
allTimeframeTickBalances.forEach((jeScheduleKey) => {
|
|
136
|
+
const coaBalanceByPeriodByTimeframe = jeScheduleKey.coaBalanceByPeriod[timeframe];
|
|
137
|
+
if (coaBalanceByPeriodByTimeframe != null) {
|
|
138
|
+
coaBalanceByPeriodByTimeframe.map((coaBalancePeriod) => {
|
|
139
|
+
if (coaBalancePeriod.label != null &&
|
|
140
|
+
totalBalanceTimeframeTicks[coaBalancePeriod.label] != null) {
|
|
141
|
+
totalBalanceTimeframeTicks[coaBalancePeriod.label].push(coaBalancePeriod);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
const coaBalanceGrouped = (0, exports.mapTotalBalanceTimeframeTickToCOAGroupedBalance)(totalBalanceTimeframeTicks);
|
|
147
|
+
return {
|
|
148
|
+
months: coaBalanceGrouped,
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
exports.calculateTotalBalanceTimeframeTick = calculateTotalBalanceTimeframeTick;
|
|
152
|
+
/**
|
|
153
|
+
* This is a helper function just to map COABalance for every ScheduledJournalEntry
|
|
154
|
+
* @param scheduleJournal
|
|
155
|
+
* @param currencyCode
|
|
156
|
+
* @param currencySymbol
|
|
157
|
+
* @param timeframe
|
|
158
|
+
* @returns
|
|
159
|
+
*/
|
|
160
|
+
const mapScheduleJournalToCOABalance = (scheduleJournal, currencyCode, currencySymbol, timeframe) => {
|
|
161
|
+
var _a, _b, _c, _d, _e, _f;
|
|
162
|
+
const startDate = scheduleJournal.expectedPostDate.startOf('month');
|
|
163
|
+
const endDate = scheduleJournal.expectedPostDate.endOf('month');
|
|
164
|
+
const label = startDate.format(formatZeniDateFY_1.MONTH_YEAR_FORMAT);
|
|
165
|
+
return {
|
|
166
|
+
balance: (0, amount_1.toAmount)((_b = (_a = scheduleJournal.amount) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0, (_d = (_c = scheduleJournal.amount) === null || _c === void 0 ? void 0 : _c.currencyCode) !== null && _d !== void 0 ? _d : currencyCode, (_f = (_e = scheduleJournal.amount) === null || _e === void 0 ? void 0 : _e.currencySymbol) !== null && _f !== void 0 ? _f : currencySymbol),
|
|
167
|
+
balanceTimeFrame: timeframe,
|
|
168
|
+
type: 'default',
|
|
169
|
+
startDate,
|
|
170
|
+
endDate,
|
|
171
|
+
label,
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
exports.mapScheduleJournalToCOABalance = mapScheduleJournalToCOABalance;
|
|
175
|
+
/**
|
|
176
|
+
* This function helps us in finding COABalanceGroupedByPeriod for months
|
|
177
|
+
* @param jeSchedule
|
|
178
|
+
* @returns
|
|
179
|
+
*/
|
|
180
|
+
const calculateCOABalanceGroupedByPeriod = (jeSchedule) => {
|
|
181
|
+
const scheduleJournalEntry = jeSchedule.scheduledJournalEntry;
|
|
182
|
+
const { currencyCode, currencySymbol } = jeSchedule;
|
|
183
|
+
return {
|
|
184
|
+
months: scheduleJournalEntry.map((scheduleJournal) => (0, exports.mapScheduleJournalToCOABalance)(scheduleJournal, currencyCode, currencySymbol, 'month')),
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
exports.calculateCOABalanceGroupedByPeriod = calculateCOABalanceGroupedByPeriod;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { JEScheduledTransactionPayload, ScheduledJournalEntryPayload } from '../../../entity/jeSchedules/jeSchedulesPayload';
|
|
2
|
+
import { ZeniAPIResponse } from '../../../responsePayload';
|
|
3
|
+
export interface ScheduleListPayload {
|
|
4
|
+
je_schedules: JEScheduledTransactionPayload[];
|
|
5
|
+
scheduled_journal_entries?: ScheduledJournalEntryPayload[];
|
|
6
|
+
}
|
|
7
|
+
export declare type FetchScheduleListResponse = ZeniAPIResponse<ScheduleListPayload>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ScheduleListLocalData, ScheduleListViewState, ScheduleWithListStatus, ScheduleListUIState } from './scheduleListState';
|
|
2
|
+
import { FetchState, ID } from '../../../commonStateTypes/common';
|
|
3
|
+
import { TimeframeTick } from '../../../commonStateTypes/timeframeTick';
|
|
4
|
+
import { ZeniAPIStatus } from '../../../responsePayload';
|
|
5
|
+
import { JEScheduledTransactionPayload } from '../../../entity/jeSchedules/jeSchedulesPayload';
|
|
6
|
+
export declare const initialState: ScheduleListViewState;
|
|
7
|
+
export declare const scheduleListInitialState: ScheduleWithListStatus;
|
|
8
|
+
export declare const fetchDownloadSchedules: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[tab: "prepaid_expenses" | "fixed_assets" | "accured_expenses" | "deferred_revenue", timeframeAndCategory: {
|
|
9
|
+
selectedTimeframe: TimeframeTick;
|
|
10
|
+
selectedCategoryId: ID;
|
|
11
|
+
}, downloadCategories: string[], cacheOverride?: any], {
|
|
12
|
+
timeframeAndCategory: {
|
|
13
|
+
selectedTimeframe: TimeframeTick;
|
|
14
|
+
selectedCategoryId: ID;
|
|
15
|
+
};
|
|
16
|
+
tab: "prepaid_expenses" | "fixed_assets" | "accured_expenses" | "deferred_revenue";
|
|
17
|
+
cacheOverride: any;
|
|
18
|
+
downloadCategories: string[];
|
|
19
|
+
}, string, never, never>, fetchScheduleList: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[tab: "prepaid_expenses" | "fixed_assets" | "accured_expenses" | "deferred_revenue", timeframeAndCategory?: {
|
|
20
|
+
selectedTimeframe: TimeframeTick;
|
|
21
|
+
selectedCategoryId: ID;
|
|
22
|
+
} | undefined, cacheOverride?: any], {
|
|
23
|
+
timeframeAndCategory: {
|
|
24
|
+
selectedTimeframe: TimeframeTick;
|
|
25
|
+
selectedCategoryId: ID;
|
|
26
|
+
} | undefined;
|
|
27
|
+
tab: "prepaid_expenses" | "fixed_assets" | "accured_expenses" | "deferred_revenue";
|
|
28
|
+
cacheOverride: any;
|
|
29
|
+
}, string, never, never>, fetchSchedulesAccount: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[tab: "prepaid_expenses" | "fixed_assets" | "accured_expenses" | "deferred_revenue"], {
|
|
30
|
+
tab: "prepaid_expenses" | "fixed_assets" | "accured_expenses" | "deferred_revenue";
|
|
31
|
+
}, string, never, never>, updateScheduleListSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[tab: "prepaid_expenses" | "fixed_assets" | "accured_expenses" | "deferred_revenue", selectedTimeframe: TimeframeTick, selectedCategoryId: string, scheduleList: JEScheduledTransactionPayload[]], {
|
|
32
|
+
tab: "prepaid_expenses" | "fixed_assets" | "accured_expenses" | "deferred_revenue";
|
|
33
|
+
selectedTimeframe: TimeframeTick;
|
|
34
|
+
selectedCategoryId: string;
|
|
35
|
+
scheduleList: JEScheduledTransactionPayload[];
|
|
36
|
+
}, string, never, never>, updateScheduleListFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[tab: "prepaid_expenses" | "fixed_assets" | "accured_expenses" | "deferred_revenue", selectedTimeframe: TimeframeTick, selectedCategoryId: string, error: ZeniAPIStatus<Record<string, unknown>>], {
|
|
37
|
+
selectedCategoryId: string;
|
|
38
|
+
selectedTimeframe: TimeframeTick;
|
|
39
|
+
tab: "prepaid_expenses" | "fixed_assets" | "accured_expenses" | "deferred_revenue";
|
|
40
|
+
error: ZeniAPIStatus<Record<string, unknown>>;
|
|
41
|
+
}, string, never, never>, updateDownloadScheduleFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[tab: "prepaid_expenses" | "fixed_assets" | "accured_expenses" | "deferred_revenue", selectedTimeframe: TimeframeTick, selectedCategoryId: string, error: ZeniAPIStatus<Record<string, unknown>>], {
|
|
42
|
+
selectedCategoryId: string;
|
|
43
|
+
selectedTimeframe: TimeframeTick;
|
|
44
|
+
tab: "prepaid_expenses" | "fixed_assets" | "accured_expenses" | "deferred_revenue";
|
|
45
|
+
error: ZeniAPIStatus<Record<string, unknown>>;
|
|
46
|
+
}, string, never, never>, updateDownloadScheduleSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[tab: "prepaid_expenses" | "fixed_assets" | "accured_expenses" | "deferred_revenue", selectedTimeframe: TimeframeTick, selectedCategoryId: string, scheduleList: JEScheduledTransactionPayload[]], {
|
|
47
|
+
tab: "prepaid_expenses" | "fixed_assets" | "accured_expenses" | "deferred_revenue";
|
|
48
|
+
selectedTimeframe: TimeframeTick;
|
|
49
|
+
selectedCategoryId: string;
|
|
50
|
+
scheduleList: JEScheduledTransactionPayload[];
|
|
51
|
+
}, string, never, never>, updateScheduleListTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<"prepaid_expenses" | "fixed_assets" | "accured_expenses" | "deferred_revenue", string>, updateScheduleListSubTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<"all" | "new" | "completed" | "ongoing", string>, updateScheduleListUIState: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
52
|
+
uiState: Partial<ScheduleListUIState>;
|
|
53
|
+
}, string>, updateScheduleListLocalData: import("@reduxjs/toolkit").ActionCreatorWithPayload<ScheduleListLocalData, string>, updateScheduleListSearchText: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>, updateScheduleListDownloadState: import("@reduxjs/toolkit").ActionCreatorWithPayload<FetchState, string>, clearScheduleList: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
54
|
+
declare const _default: import("@reduxjs/toolkit").Reducer<ScheduleListViewState, import("@reduxjs/toolkit").AnyAction>;
|
|
55
|
+
export default _default;
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.clearScheduleList = exports.updateScheduleListDownloadState = exports.updateScheduleListSearchText = exports.updateScheduleListLocalData = exports.updateScheduleListUIState = exports.updateScheduleListSubTab = exports.updateScheduleListTab = exports.updateDownloadScheduleSuccess = exports.updateDownloadScheduleFailure = exports.updateScheduleListFailure = exports.updateScheduleListSuccess = exports.fetchSchedulesAccount = exports.fetchScheduleList = exports.fetchDownloadSchedules = exports.scheduleListInitialState = exports.initialState = void 0;
|
|
5
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
+
const zeniDayJS_1 = require("../../../zeniDayJS");
|
|
7
|
+
const transactionIDPayload_1 = require("../../../entity/transaction/payloadTypes/transactionIDPayload");
|
|
8
|
+
const scheduleListTypes_1 = require("./scheduleListTypes");
|
|
9
|
+
const transactionDetailState_1 = require("../../transactionDetail/transactionDetailState");
|
|
10
|
+
exports.initialState = {
|
|
11
|
+
byScheduleListKey: {},
|
|
12
|
+
currentTab: 'prepaid_expenses',
|
|
13
|
+
currentSubTab: 'all',
|
|
14
|
+
searchText: '',
|
|
15
|
+
scheduleListLocalData: {
|
|
16
|
+
selectedCategoryID: 'all',
|
|
17
|
+
selectedTimeframe: {
|
|
18
|
+
startDate: (0, zeniDayJS_1.dateNow)().subtract(1, 'year'),
|
|
19
|
+
endDate: (0, zeniDayJS_1.dateNow)(),
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
selectedCategoryId: 'all',
|
|
23
|
+
selectedTimeframe: {
|
|
24
|
+
startDate: (0, zeniDayJS_1.dateNow)().subtract(1, 'year'),
|
|
25
|
+
endDate: (0, zeniDayJS_1.dateNow)(),
|
|
26
|
+
},
|
|
27
|
+
downloadState: {
|
|
28
|
+
fetchState: 'Not-Started',
|
|
29
|
+
error: undefined,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
exports.scheduleListInitialState = {
|
|
33
|
+
fetchState: 'Not-Started',
|
|
34
|
+
error: undefined,
|
|
35
|
+
jeScheduleTransactionKeys: [],
|
|
36
|
+
uiState: {
|
|
37
|
+
sortKey: 'transactionDate',
|
|
38
|
+
sortOrder: 'descending',
|
|
39
|
+
scrollYOffset: 0,
|
|
40
|
+
},
|
|
41
|
+
hasValidState() {
|
|
42
|
+
return this.fetchState === 'Completed';
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
const scheduleListView = (0, toolkit_1.createSlice)({
|
|
46
|
+
name: 'scheduleListView',
|
|
47
|
+
initialState: exports.initialState,
|
|
48
|
+
reducers: {
|
|
49
|
+
fetchDownloadSchedules: {
|
|
50
|
+
reducer(draft, action) {
|
|
51
|
+
const selectedTimeframe = action.payload.timeframeAndCategory.selectedTimeframe;
|
|
52
|
+
const selectedCategoryID = action.payload.timeframeAndCategory.selectedCategoryId;
|
|
53
|
+
draft.scheduleListLocalData = {
|
|
54
|
+
selectedTimeframe,
|
|
55
|
+
selectedCategoryID: selectedCategoryID,
|
|
56
|
+
};
|
|
57
|
+
const key = (0, scheduleListTypes_1.getScheduleListKey)(action.payload.tab, selectedCategoryID, selectedTimeframe);
|
|
58
|
+
const record = draft.byScheduleListKey[key];
|
|
59
|
+
if (record == null) {
|
|
60
|
+
draft.byScheduleListKey[key] = Object.assign({}, exports.scheduleListInitialState);
|
|
61
|
+
draft.downloadState = {
|
|
62
|
+
fetchState: 'In-Progress',
|
|
63
|
+
error: undefined,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
draft.selectedCategoryId = selectedCategoryID;
|
|
68
|
+
draft.selectedTimeframe = selectedTimeframe;
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
prepare(tab, timeframeAndCategory, downloadCategories, cacheOverride = false) {
|
|
72
|
+
return {
|
|
73
|
+
payload: {
|
|
74
|
+
timeframeAndCategory,
|
|
75
|
+
tab,
|
|
76
|
+
cacheOverride,
|
|
77
|
+
downloadCategories,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
fetchSchedulesAccount: {
|
|
83
|
+
reducer() {
|
|
84
|
+
//do nothing
|
|
85
|
+
},
|
|
86
|
+
prepare(tab) {
|
|
87
|
+
return {
|
|
88
|
+
payload: { tab },
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
fetchScheduleList: {
|
|
93
|
+
reducer(draft, action) {
|
|
94
|
+
const selectedTimeframe = action.payload.timeframeAndCategory != null
|
|
95
|
+
? action.payload.timeframeAndCategory.selectedTimeframe
|
|
96
|
+
: draft.scheduleListLocalData.selectedTimeframe;
|
|
97
|
+
const selectedCategoryID = action.payload.timeframeAndCategory != null
|
|
98
|
+
? action.payload.timeframeAndCategory.selectedCategoryId
|
|
99
|
+
: draft.scheduleListLocalData.selectedCategoryID;
|
|
100
|
+
const key = (0, scheduleListTypes_1.getScheduleListKey)(action.payload.tab, selectedCategoryID, selectedTimeframe);
|
|
101
|
+
const record = draft.byScheduleListKey[key];
|
|
102
|
+
if (record == null) {
|
|
103
|
+
draft.byScheduleListKey[key] = Object.assign(Object.assign({}, exports.scheduleListInitialState), { fetchState: 'In-Progress' });
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
// if the record is found, then set the selected ID and timeframe.
|
|
107
|
+
draft.scheduleListLocalData = {
|
|
108
|
+
selectedTimeframe,
|
|
109
|
+
selectedCategoryID,
|
|
110
|
+
};
|
|
111
|
+
draft.selectedCategoryId = selectedCategoryID;
|
|
112
|
+
draft.selectedTimeframe = selectedTimeframe;
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
prepare(tab, timeframeAndCategory, cacheOverride = false) {
|
|
116
|
+
return {
|
|
117
|
+
payload: {
|
|
118
|
+
timeframeAndCategory,
|
|
119
|
+
tab,
|
|
120
|
+
cacheOverride,
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
updateScheduleListSuccess: {
|
|
126
|
+
reducer(draft, action) {
|
|
127
|
+
doUpdateScheduleList(draft, action.payload.scheduleList, action.payload.tab, action.payload.selectedTimeframe, action.payload.selectedCategoryId);
|
|
128
|
+
},
|
|
129
|
+
prepare(tab, selectedTimeframe, selectedCategoryId, scheduleList) {
|
|
130
|
+
return {
|
|
131
|
+
payload: { tab, selectedTimeframe, selectedCategoryId, scheduleList },
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
updateScheduleListFailure: {
|
|
136
|
+
reducer(draft, action) {
|
|
137
|
+
const key = (0, scheduleListTypes_1.getScheduleListKey)(action.payload.tab, action.payload.selectedCategoryId, action.payload.selectedTimeframe);
|
|
138
|
+
draft.byScheduleListKey[key] = Object.assign(Object.assign({}, exports.scheduleListInitialState), { fetchState: 'Error', error: action.payload.error });
|
|
139
|
+
draft.selectedCategoryId = action.payload.selectedCategoryId;
|
|
140
|
+
draft.selectedTimeframe = action.payload.selectedTimeframe;
|
|
141
|
+
},
|
|
142
|
+
prepare(tab, selectedTimeframe, selectedCategoryId, error) {
|
|
143
|
+
return { payload: { selectedCategoryId, selectedTimeframe, tab, error } };
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
updateDownloadScheduleSuccess: {
|
|
147
|
+
reducer(draft, action) {
|
|
148
|
+
doUpdateScheduleList(draft, action.payload.scheduleList, action.payload.tab, action.payload.selectedTimeframe, action.payload.selectedCategoryId);
|
|
149
|
+
},
|
|
150
|
+
prepare(tab, selectedTimeframe, selectedCategoryId, scheduleList) {
|
|
151
|
+
return {
|
|
152
|
+
payload: { tab, selectedTimeframe, selectedCategoryId, scheduleList },
|
|
153
|
+
};
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
updateDownloadScheduleFailure: {
|
|
157
|
+
reducer(draft, action) {
|
|
158
|
+
const key = (0, scheduleListTypes_1.getScheduleListKey)(action.payload.tab, action.payload.selectedCategoryId, action.payload.selectedTimeframe);
|
|
159
|
+
draft.byScheduleListKey[key] = Object.assign(Object.assign({}, exports.scheduleListInitialState), { error: action.payload.error });
|
|
160
|
+
draft.selectedCategoryId = action.payload.selectedCategoryId;
|
|
161
|
+
draft.selectedTimeframe = action.payload.selectedTimeframe;
|
|
162
|
+
draft.downloadState = {
|
|
163
|
+
fetchState: 'Error',
|
|
164
|
+
error: action.payload.error,
|
|
165
|
+
};
|
|
166
|
+
},
|
|
167
|
+
prepare(tab, selectedTimeframe, selectedCategoryId, error) {
|
|
168
|
+
return { payload: { selectedCategoryId, selectedTimeframe, tab, error } };
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
updateScheduleListTab(draft, action) {
|
|
172
|
+
draft.currentTab = action.payload;
|
|
173
|
+
},
|
|
174
|
+
updateScheduleListSearchText(draft, action) {
|
|
175
|
+
draft.searchText = action.payload;
|
|
176
|
+
},
|
|
177
|
+
updateScheduleListSubTab(draft, action) {
|
|
178
|
+
draft.currentSubTab = action.payload;
|
|
179
|
+
},
|
|
180
|
+
updateScheduleListUIState(draft, action) {
|
|
181
|
+
const tab = draft.currentTab;
|
|
182
|
+
const key = (0, scheduleListTypes_1.getScheduleListKey)(tab, draft.selectedCategoryId, draft.selectedTimeframe);
|
|
183
|
+
if (draft.byScheduleListKey[key] != null) {
|
|
184
|
+
if (action.payload.uiState.sortKey != null) {
|
|
185
|
+
draft.byScheduleListKey[key].uiState.sortKey =
|
|
186
|
+
action.payload.uiState.sortKey;
|
|
187
|
+
}
|
|
188
|
+
if (action.payload.uiState.sortOrder != null) {
|
|
189
|
+
draft.byScheduleListKey[key].uiState.sortOrder =
|
|
190
|
+
action.payload.uiState.sortOrder;
|
|
191
|
+
}
|
|
192
|
+
if (action.payload.uiState.scrollYOffset != null) {
|
|
193
|
+
draft.byScheduleListKey[key].uiState.scrollYOffset =
|
|
194
|
+
action.payload.uiState.scrollYOffset;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
updateScheduleListLocalData(draft, action) {
|
|
199
|
+
draft.scheduleListLocalData = action.payload;
|
|
200
|
+
},
|
|
201
|
+
updateScheduleListDownloadState(draft, action) {
|
|
202
|
+
draft.downloadState = { fetchState: action.payload, error: undefined };
|
|
203
|
+
},
|
|
204
|
+
clearScheduleList(draft) {
|
|
205
|
+
Object.assign(draft, exports.initialState);
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
_a = scheduleListView.actions, exports.fetchDownloadSchedules = _a.fetchDownloadSchedules, exports.fetchScheduleList = _a.fetchScheduleList, exports.fetchSchedulesAccount = _a.fetchSchedulesAccount, exports.updateScheduleListSuccess = _a.updateScheduleListSuccess, exports.updateScheduleListFailure = _a.updateScheduleListFailure, exports.updateDownloadScheduleFailure = _a.updateDownloadScheduleFailure, exports.updateDownloadScheduleSuccess = _a.updateDownloadScheduleSuccess, exports.updateScheduleListTab = _a.updateScheduleListTab, exports.updateScheduleListSubTab = _a.updateScheduleListSubTab, exports.updateScheduleListUIState = _a.updateScheduleListUIState, exports.updateScheduleListLocalData = _a.updateScheduleListLocalData, exports.updateScheduleListSearchText = _a.updateScheduleListSearchText, exports.updateScheduleListDownloadState = _a.updateScheduleListDownloadState, exports.clearScheduleList = _a.clearScheduleList;
|
|
210
|
+
exports.default = scheduleListView.reducer;
|
|
211
|
+
/**
|
|
212
|
+
* Helper functions
|
|
213
|
+
*/
|
|
214
|
+
function doUpdateScheduleList(draft, payload, tab, selectedTimeframe, selectedCategoryId) {
|
|
215
|
+
const jeScheduleTransactionKeys = payload.map((schedules) => {
|
|
216
|
+
const transactionID = (0, transactionIDPayload_1.toTransactionID)(schedules.base_transaction);
|
|
217
|
+
return (0, transactionDetailState_1.getTransactionDetailKey)(transactionID);
|
|
218
|
+
});
|
|
219
|
+
draft.selectedCategoryId = selectedCategoryId;
|
|
220
|
+
draft.selectedTimeframe = selectedTimeframe;
|
|
221
|
+
const key = (0, scheduleListTypes_1.getScheduleListKey)(tab, selectedCategoryId, selectedTimeframe);
|
|
222
|
+
const record = draft.byScheduleListKey[key];
|
|
223
|
+
draft.byScheduleListKey[key] = Object.assign(Object.assign({}, record), { fetchState: 'Completed', error: undefined, jeScheduleTransactionKeys });
|
|
224
|
+
draft.downloadState = {
|
|
225
|
+
fetchState: 'Completed',
|
|
226
|
+
error: undefined,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { FetchState, FetchStateAndError, ID } from '../../../commonStateTypes/common';
|
|
2
|
+
import { EntityOrder } from '../../../commonStateTypes/selectorTypes/selectorTypes';
|
|
3
|
+
import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport';
|
|
4
|
+
import { RootState } from '../../../reducer';
|
|
5
|
+
import { ScheduleListLocalData, ScheduleListUIState } from './scheduleListState';
|
|
6
|
+
import { NestedAccountHeirarchyForReport } from '../../../commonStateTypes/accountView/nestedAccountID';
|
|
7
|
+
import { TimeframeTick, TimeframeTickWithMetaData } from '../../../commonStateTypes/timeframeTick';
|
|
8
|
+
import { AccountBase } from '../../../entity/account/accountState';
|
|
9
|
+
import { JEScheduledTransaction } from '../../../entity/jeSchedules/jeSchedulesSelector';
|
|
10
|
+
import { SchedulesTypes } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
11
|
+
import { ScheduleSubTabType } from './scheduleListTypes';
|
|
12
|
+
import { Amount } from '../../../commonStateTypes/amount';
|
|
13
|
+
import { COABalanceGroupedByPeriod } from '../../../commonStateTypes/coaBalance/coaBalance';
|
|
14
|
+
export interface JEScheduledTransactionWithBalance extends JEScheduledTransaction {
|
|
15
|
+
coaBalanceByPeriod: COABalanceGroupedByPeriod;
|
|
16
|
+
}
|
|
17
|
+
export interface ScheduleListReport extends SelectorView {
|
|
18
|
+
allSubTabs: ScheduleSubTabType[];
|
|
19
|
+
currentTab: SchedulesTypes;
|
|
20
|
+
currentSubTab: ScheduleSubTabType;
|
|
21
|
+
downloadUIState: FetchStateAndError;
|
|
22
|
+
jeScheduleOrder: EntityOrder;
|
|
23
|
+
jeScheduledTransactions: JEScheduledTransactionWithBalance[];
|
|
24
|
+
searchText: string;
|
|
25
|
+
scheduleListAccounts: AccountBase[];
|
|
26
|
+
scheduleListNestedAccountHierarchy: NestedAccountHeirarchyForReport[];
|
|
27
|
+
uiState: ScheduleListUIState;
|
|
28
|
+
selectedCategoryID: ID;
|
|
29
|
+
selectedTimeframe: TimeframeTick;
|
|
30
|
+
scheduleListLocalData: ScheduleListLocalData;
|
|
31
|
+
allTimeframeTicks: TimeframeTickWithMetaData[];
|
|
32
|
+
totalBalanceTimeframeTicks: COABalanceGroupedByPeriod;
|
|
33
|
+
totalAmount: Amount;
|
|
34
|
+
totalRunningBalances: Amount;
|
|
35
|
+
selectedScheduledId?: ID;
|
|
36
|
+
}
|
|
37
|
+
export declare const getScheduleListReport: (state: RootState) => ScheduleListReport;
|
|
38
|
+
export declare const getFetchStateForScheduleAccountList: (state: RootState, scheduleTab: SchedulesTypes) => FetchState;
|