@zeniai/client-epic-state 4.7.98 → 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/spendManagement/billPay/billPayConfig/billPayConfigPayload.d.ts +2 -1
- package/lib/view/spendManagement/billPay/billPayConfig/billPayConfigPayload.js +10 -1
- package/lib/view/spendManagement/billPay/billPayConfig/billPayConfigState.d.ts +6 -0
- package/lib/view/spendManagement/billPay/billPayConfig/billPayConfigState.js +13 -1
- package/lib/view/spendManagement/helpers.d.ts +2 -0
- package/lib/view/spendManagement/helpers.js +12 -1
- package/lib/view/spendManagement/zeniAccounts/transferDetail/transferDetailReducer.js +1 -1
- package/lib/view/spendManagement/zeniAccounts/transferDetail/transferDetailSelector.js +2 -2
- package/lib/view/spendManagement/zeniAccounts/transferDetail/transferDetailState.d.ts +2 -2
- package/lib/view/spendManagement/zeniAccounts/transferDetail/transferMoneyEpic.js +3 -2
- 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,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.clearScheduleDetailView = exports.resetJELinkInLocalData = exports.updatedJELinkWithRecommendedLocalData = exports.updatedSelectedJELinkRowIndex = exports.updateSelectedJEScheduleKey = exports.updateScheduleDetailNewStateLocalData = exports.updateAmountsInScheduleDetail = exports.updatedJELinkInLocalData = exports.updateScheduleDetailsLocalData = exports.initializeScheduleDetailLocalData = exports.saveScheduleDetailsSuccessOrFailure = exports.saveScheduleDetails = exports.updateScheduleDetailsFailure = exports.updateScheduleDetailsSuccess = exports.fetchScheduleDetails = exports.fetchScheduleDetailsPage = exports.createNewSchedules = exports.initialState = exports.initialScheduleDetailsLocalData = void 0;
|
|
5
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
+
const scheduleDetailLocalDataHelper_1 = require("./scheduleDetailLocalDataHelper");
|
|
7
|
+
exports.initialScheduleDetailsLocalData = {
|
|
8
|
+
jeScheduleDetails: [],
|
|
9
|
+
};
|
|
10
|
+
exports.initialState = {
|
|
11
|
+
newScheduleState: exports.initialScheduleDetailsLocalData,
|
|
12
|
+
editScheduleStateById: {},
|
|
13
|
+
saveStatus: {
|
|
14
|
+
fetchState: 'Not-Started',
|
|
15
|
+
error: undefined,
|
|
16
|
+
},
|
|
17
|
+
uiState: {
|
|
18
|
+
sortKey: 'jePostingDate',
|
|
19
|
+
sortOrder: 'descending',
|
|
20
|
+
scrollPosition: 0,
|
|
21
|
+
},
|
|
22
|
+
fetchState: 'Not-Started',
|
|
23
|
+
selectedJEScheduleKey: undefined,
|
|
24
|
+
};
|
|
25
|
+
const scheduleDetailView = (0, toolkit_1.createSlice)({
|
|
26
|
+
name: 'scheduleDetailView',
|
|
27
|
+
initialState: exports.initialState,
|
|
28
|
+
reducers: {
|
|
29
|
+
createNewSchedules: () => {
|
|
30
|
+
// nothing to do here
|
|
31
|
+
},
|
|
32
|
+
fetchScheduleDetailsPage: {
|
|
33
|
+
prepare(tab, selectedJeScheduleDetailId) {
|
|
34
|
+
return {
|
|
35
|
+
payload: { tab, selectedJeScheduleDetailId },
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
reducer() {
|
|
39
|
+
// Do nothing
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
fetchScheduleDetails: {
|
|
43
|
+
prepare(tab, selectedJeScheduleDetailId) {
|
|
44
|
+
return {
|
|
45
|
+
payload: { tab, selectedJeScheduleDetailId },
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
reducer(draft, action) {
|
|
49
|
+
const selectedJeScheduleDetailId = action.payload.selectedJeScheduleDetailId;
|
|
50
|
+
if (selectedJeScheduleDetailId != null) {
|
|
51
|
+
if (draft.editScheduleStateById[selectedJeScheduleDetailId] == null) {
|
|
52
|
+
draft.editScheduleStateById[selectedJeScheduleDetailId] =
|
|
53
|
+
exports.initialScheduleDetailsLocalData;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
draft.newScheduleState = exports.initialScheduleDetailsLocalData;
|
|
58
|
+
}
|
|
59
|
+
draft.fetchState = 'In-Progress';
|
|
60
|
+
draft.error = undefined;
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
updateScheduleDetailsSuccess(draft) {
|
|
64
|
+
draft.fetchState = 'Completed';
|
|
65
|
+
draft.error = undefined;
|
|
66
|
+
},
|
|
67
|
+
updateScheduleDetailsFailure(draft, action) {
|
|
68
|
+
draft.fetchState = 'Error';
|
|
69
|
+
draft.error = action.payload.error;
|
|
70
|
+
},
|
|
71
|
+
// Fire this action to save the latest schedule data in local store in ZENI Platform.
|
|
72
|
+
saveScheduleDetails: {
|
|
73
|
+
prepare(selectedJeScheduleDetailId) {
|
|
74
|
+
return {
|
|
75
|
+
payload: { selectedJeScheduleDetailId },
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
reducer(draft) {
|
|
79
|
+
draft.saveStatus = {
|
|
80
|
+
fetchState: 'In-Progress',
|
|
81
|
+
error: undefined,
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
saveScheduleDetailsSuccessOrFailure: {
|
|
86
|
+
reducer(draft, action) {
|
|
87
|
+
draft.saveStatus = {
|
|
88
|
+
fetchState: action.payload.fetchState,
|
|
89
|
+
error: action.payload.error,
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
prepare(fetchState, error) {
|
|
93
|
+
return {
|
|
94
|
+
payload: {
|
|
95
|
+
fetchState,
|
|
96
|
+
error,
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
updateScheduleDetailsLocalData(draft, action) {
|
|
102
|
+
const { selectedJeScheduleDetailId, localData } = action.payload;
|
|
103
|
+
updateNewOrEditScheduleDetailLocalData(draft, localData, selectedJeScheduleDetailId);
|
|
104
|
+
},
|
|
105
|
+
initializeScheduleDetailLocalData: {
|
|
106
|
+
reducer() {
|
|
107
|
+
//do nothing
|
|
108
|
+
},
|
|
109
|
+
prepare(selectedJEScheduleKey, selectedJeScheduleDetailId) {
|
|
110
|
+
return {
|
|
111
|
+
payload: {
|
|
112
|
+
selectedJEScheduleKey,
|
|
113
|
+
selectedJeScheduleDetailId,
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
updateSelectedJEScheduleKey(draft, action) {
|
|
119
|
+
draft.selectedJEScheduleKey = action.payload.selectedJEScheduleKey;
|
|
120
|
+
},
|
|
121
|
+
updateScheduleDetailNewStateLocalData: {
|
|
122
|
+
prepare(selectedJeScheduleDetailId) {
|
|
123
|
+
return {
|
|
124
|
+
payload: { selectedJeScheduleDetailId },
|
|
125
|
+
};
|
|
126
|
+
},
|
|
127
|
+
reducer(draft, action) {
|
|
128
|
+
// This is a special case - when we save, we need the newSchedule state to move to the
|
|
129
|
+
// edit state
|
|
130
|
+
const selectedJeScheduleDetailId = action.payload.selectedJeScheduleDetailId;
|
|
131
|
+
if (draft.editScheduleStateById[selectedJeScheduleDetailId] == null) {
|
|
132
|
+
draft.editScheduleStateById[selectedJeScheduleDetailId] = Object.assign({}, draft.newScheduleState);
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
updatedSelectedJELinkRowIndex(draft, action) {
|
|
137
|
+
draft.selectedJELinkRowIndex = action.payload.selectedJELinkRowIndex;
|
|
138
|
+
},
|
|
139
|
+
updatedJELinkInLocalData(draft, action) {
|
|
140
|
+
const jeScheduleDetailId = action.payload.jeScheduleDetailId;
|
|
141
|
+
if (draft.editScheduleStateById[jeScheduleDetailId] == null) {
|
|
142
|
+
console.error('Cannot attempt to link a JE for non existing JESchedule Detail');
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
const jeScheduleDetailsLocalData = draft.editScheduleStateById[jeScheduleDetailId].jeScheduleDetails;
|
|
146
|
+
// put the link into the right record
|
|
147
|
+
const jeScheduleLocalDataUpdated = updateJELinkInScheduleDetails(jeScheduleDetailsLocalData, action.payload.rowId, action.payload.jeLink);
|
|
148
|
+
draft.editScheduleStateById[jeScheduleDetailId] = Object.assign(Object.assign({}, draft.editScheduleStateById[jeScheduleDetailId]), { jeScheduleDetails: jeScheduleLocalDataUpdated });
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
updatedJELinkWithRecommendedLocalData(draft, action) {
|
|
152
|
+
const jeScheduleDetailId = action.payload.jeScheduleDetailId;
|
|
153
|
+
if (draft.editScheduleStateById[jeScheduleDetailId] == null) {
|
|
154
|
+
console.error('Cannot attempt to link a JE for non existing JESchedule Detail');
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
const jeScheduleDetailsLocalData = draft.editScheduleStateById[jeScheduleDetailId].jeScheduleDetails;
|
|
158
|
+
// put the link into the right record
|
|
159
|
+
const jeScheduleLocalDataUpdated = updateJELinkInWithRecommendedScheduleDetails(jeScheduleDetailsLocalData, action.payload.rowId);
|
|
160
|
+
draft.editScheduleStateById[jeScheduleDetailId] = Object.assign(Object.assign({}, draft.editScheduleStateById[jeScheduleDetailId]), { jeScheduleDetails: jeScheduleLocalDataUpdated });
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
resetJELinkInLocalData(draft, action) {
|
|
164
|
+
const jeScheduleDetailId = action.payload.jeScheduleDetailId;
|
|
165
|
+
if (draft.editScheduleStateById[jeScheduleDetailId] == null) {
|
|
166
|
+
console.error('Cannot attempt to link a JE for non existing JESchedule Detail');
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
const jeScheduleDetailsLocalData = draft.editScheduleStateById[jeScheduleDetailId].jeScheduleDetails;
|
|
170
|
+
// put the old link into the right record
|
|
171
|
+
const jeScheduleLocalDataUpdated = resetJELinkInScheduleDetails(jeScheduleDetailsLocalData, action.payload.rowId, action.payload.originalScheduledJE);
|
|
172
|
+
draft.editScheduleStateById[jeScheduleDetailId] = Object.assign(Object.assign({}, draft.editScheduleStateById[jeScheduleDetailId]), { jeScheduleDetails: jeScheduleLocalDataUpdated });
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
updateAmountsInScheduleDetail: {
|
|
176
|
+
reducer() {
|
|
177
|
+
//do nothing
|
|
178
|
+
},
|
|
179
|
+
prepare(rowId, jeScheduleDetailId) {
|
|
180
|
+
return {
|
|
181
|
+
payload: {
|
|
182
|
+
rowId,
|
|
183
|
+
jeScheduleDetailId,
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
clearScheduleDetailView(draft) {
|
|
189
|
+
Object.assign(draft, exports.initialState);
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
_a = scheduleDetailView.actions, exports.createNewSchedules = _a.createNewSchedules, exports.fetchScheduleDetailsPage = _a.fetchScheduleDetailsPage, exports.fetchScheduleDetails = _a.fetchScheduleDetails, exports.updateScheduleDetailsSuccess = _a.updateScheduleDetailsSuccess, exports.updateScheduleDetailsFailure = _a.updateScheduleDetailsFailure, exports.saveScheduleDetails = _a.saveScheduleDetails, exports.saveScheduleDetailsSuccessOrFailure = _a.saveScheduleDetailsSuccessOrFailure, exports.initializeScheduleDetailLocalData = _a.initializeScheduleDetailLocalData, exports.updateScheduleDetailsLocalData = _a.updateScheduleDetailsLocalData, exports.updatedJELinkInLocalData = _a.updatedJELinkInLocalData, exports.updateAmountsInScheduleDetail = _a.updateAmountsInScheduleDetail, exports.updateScheduleDetailNewStateLocalData = _a.updateScheduleDetailNewStateLocalData, exports.updateSelectedJEScheduleKey = _a.updateSelectedJEScheduleKey, exports.updatedSelectedJELinkRowIndex = _a.updatedSelectedJELinkRowIndex, exports.updatedJELinkWithRecommendedLocalData = _a.updatedJELinkWithRecommendedLocalData, exports.resetJELinkInLocalData = _a.resetJELinkInLocalData, exports.clearScheduleDetailView = _a.clearScheduleDetailView;
|
|
194
|
+
exports.default = scheduleDetailView.reducer;
|
|
195
|
+
const updateJELinkInScheduleDetails = (jeScheduleDetailsLocalData, rowId, jeLink) => {
|
|
196
|
+
return jeScheduleDetailsLocalData.map((jeScheduleDetail, index) => {
|
|
197
|
+
if (index === rowId) {
|
|
198
|
+
return Object.assign(Object.assign({}, jeScheduleDetail), { jeLink: (0, scheduleDetailLocalDataHelper_1.getThirdPartyIDFromQBOURL)(jeLink),
|
|
199
|
+
// mark this as posted
|
|
200
|
+
postingStatus: 'posted' });
|
|
201
|
+
}
|
|
202
|
+
else
|
|
203
|
+
return jeScheduleDetail;
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
const updateJELinkInWithRecommendedScheduleDetails = (jeScheduleDetailsLocalData, rowId) => {
|
|
207
|
+
return jeScheduleDetailsLocalData.map((jeScheduleDetail, index) => {
|
|
208
|
+
if (index === rowId) {
|
|
209
|
+
return Object.assign(Object.assign({}, jeScheduleDetail), { jeLink: Object.assign(Object.assign({}, jeScheduleDetail.jeLink), { transactionDetailID: jeScheduleDetail.jeLink.recommendedTransactionID }),
|
|
210
|
+
// mark this as posted
|
|
211
|
+
postingStatus: 'posted' });
|
|
212
|
+
}
|
|
213
|
+
else
|
|
214
|
+
return jeScheduleDetail;
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
const resetJELinkInScheduleDetails = (jeScheduleDetailsLocalData, rowId, originalScheduledJE) => {
|
|
218
|
+
const { thirdPartyID, recommendedTransactionID, transactionID } = originalScheduledJE;
|
|
219
|
+
const jeLink = (0, scheduleDetailLocalDataHelper_1.getJETransactionLinkFromThirdPartyId)(thirdPartyID, transactionID, recommendedTransactionID);
|
|
220
|
+
const postingStatus = originalScheduledJE.status.code;
|
|
221
|
+
return jeScheduleDetailsLocalData.map((jeScheduleDetail, index) => {
|
|
222
|
+
if (index === rowId) {
|
|
223
|
+
return Object.assign(Object.assign({}, jeScheduleDetail), { jeLink,
|
|
224
|
+
postingStatus });
|
|
225
|
+
}
|
|
226
|
+
else
|
|
227
|
+
return jeScheduleDetail;
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
const updateNewOrEditScheduleDetailLocalData = (draft, updates, selectedJeScheduleDetailId) => {
|
|
231
|
+
if (selectedJeScheduleDetailId == null) {
|
|
232
|
+
draft.newScheduleState = Object.assign(Object.assign({}, draft.newScheduleState), updates);
|
|
233
|
+
}
|
|
234
|
+
else if (draft.editScheduleStateById[selectedJeScheduleDetailId] != null) {
|
|
235
|
+
draft.editScheduleStateById[selectedJeScheduleDetailId] = Object.assign(Object.assign({}, draft.editScheduleStateById[selectedJeScheduleDetailId]), updates);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RootState } from '../../../reducer';
|
|
2
|
+
import { NestedAccountHeirarchyForReport } from '../../../commonStateTypes/accountView/nestedAccountID';
|
|
3
|
+
import { NestedClassHeirarchyForReport } from '../../../commonStateTypes/classesView/nestedClassID';
|
|
4
|
+
import { AccountBase } from '../../../entity/account/accountState';
|
|
5
|
+
import { ClassBase } from '../../../entity/class/classState';
|
|
6
|
+
import { JEScheduledTransaction } from '../../../entity/jeSchedules/jeSchedulesSelector';
|
|
7
|
+
import { ScheduleDetailUIState, ScheduleDetailsLocalData } from './scheduleDetailState';
|
|
8
|
+
import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport';
|
|
9
|
+
import { FetchStateAndError } from '../../../commonStateTypes/common';
|
|
10
|
+
export interface ScheduleDetailsView extends SelectorView {
|
|
11
|
+
allAccountList: AccountBase[];
|
|
12
|
+
accountListNestedAccountHierarchy: NestedAccountHeirarchyForReport[];
|
|
13
|
+
allClassList: ClassBase[];
|
|
14
|
+
classListNestedAccountHierarchy: NestedClassHeirarchyForReport[];
|
|
15
|
+
uiState: ScheduleDetailUIState;
|
|
16
|
+
saveStatus: FetchStateAndError;
|
|
17
|
+
scheduleDetailsLocalData: ScheduleDetailsLocalData;
|
|
18
|
+
selectedJEScheduleTransaction?: JEScheduledTransaction;
|
|
19
|
+
selectedJELinkRowIndex?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare const getScheduleDetailsView: (state: RootState) => ScheduleDetailsView;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getScheduleDetailsView = void 0;
|
|
4
|
+
const jeSchedulesSelector_1 = require("../../../entity/jeSchedules/jeSchedulesSelector");
|
|
5
|
+
const accountListSelector_1 = require("../../accountList/accountListSelector");
|
|
6
|
+
const classListSelector_1 = require("../../classList/classListSelector");
|
|
7
|
+
const reduceFetchState_1 = require("../../../commonStateTypes/reduceFetchState");
|
|
8
|
+
const scheduleDetailReducer_1 = require("./scheduleDetailReducer");
|
|
9
|
+
const getScheduleDetailsView = (state) => {
|
|
10
|
+
const { accountState, accountListState, classState, classListState, scheduleDetailState, } = state;
|
|
11
|
+
const jeScheduleKey = scheduleDetailState.selectedJEScheduleKey;
|
|
12
|
+
if (jeScheduleKey == null) {
|
|
13
|
+
return {
|
|
14
|
+
uiState: scheduleDetailState.uiState,
|
|
15
|
+
selectedJEScheduleTransaction: undefined,
|
|
16
|
+
allAccountList: [],
|
|
17
|
+
allClassList: [],
|
|
18
|
+
accountListNestedAccountHierarchy: [],
|
|
19
|
+
classListNestedAccountHierarchy: [],
|
|
20
|
+
scheduleDetailsLocalData: {
|
|
21
|
+
jeScheduleDetails: [],
|
|
22
|
+
},
|
|
23
|
+
fetchState: 'Not-Started',
|
|
24
|
+
error: undefined,
|
|
25
|
+
saveStatus: {
|
|
26
|
+
fetchState: 'Not-Started',
|
|
27
|
+
error: undefined,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const jeScheduleTransactionState = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleKey)(jeScheduleKey, state);
|
|
32
|
+
const allAccountList = (0, accountListSelector_1.getAccountList)(accountState, accountListState, 'accountList');
|
|
33
|
+
const allClassList = (0, classListSelector_1.getClassList)(classState, classListState);
|
|
34
|
+
const accountListNestedAccountHierarchy = (0, accountListSelector_1.getNestedAccountListHeirarchy)(accountListState, 'accountList');
|
|
35
|
+
const classListNestedAccountHierarchy = (0, classListSelector_1.getNestedClassListHeirarchy)(classListState);
|
|
36
|
+
const selectedJeScheduleDetailId = jeScheduleTransactionState.jeScheduleId;
|
|
37
|
+
let scheduleDetailsLocalData = Object.assign({}, scheduleDetailReducer_1.initialScheduleDetailsLocalData);
|
|
38
|
+
if (selectedJeScheduleDetailId != null) {
|
|
39
|
+
if (scheduleDetailState.editScheduleStateById[selectedJeScheduleDetailId] !=
|
|
40
|
+
null) {
|
|
41
|
+
scheduleDetailsLocalData =
|
|
42
|
+
scheduleDetailState.editScheduleStateById[selectedJeScheduleDetailId];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
scheduleDetailsLocalData = scheduleDetailState.newScheduleState;
|
|
47
|
+
}
|
|
48
|
+
const fetchState = (0, reduceFetchState_1.reduceAllFetchState)([
|
|
49
|
+
scheduleDetailState,
|
|
50
|
+
allAccountList,
|
|
51
|
+
allClassList,
|
|
52
|
+
]);
|
|
53
|
+
return {
|
|
54
|
+
uiState: scheduleDetailState.uiState,
|
|
55
|
+
selectedJEScheduleTransaction: jeScheduleTransactionState,
|
|
56
|
+
allAccountList: allAccountList.accounts,
|
|
57
|
+
allClassList: allClassList.classes,
|
|
58
|
+
accountListNestedAccountHierarchy,
|
|
59
|
+
classListNestedAccountHierarchy,
|
|
60
|
+
scheduleDetailsLocalData,
|
|
61
|
+
selectedJELinkRowIndex: scheduleDetailState.selectedJELinkRowIndex,
|
|
62
|
+
fetchState: fetchState.fetchState,
|
|
63
|
+
error: fetchState.error,
|
|
64
|
+
saveStatus: scheduleDetailState.saveStatus,
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
exports.getScheduleDetailsView = getScheduleDetailsView;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Amount } from '../../../commonStateTypes/amount';
|
|
2
|
+
import { ID, FetchStateAndError } from '../../../commonStateTypes/common';
|
|
3
|
+
import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
|
|
4
|
+
import { ScheduleDaysOfMonth } from '../../../commonStateTypes/timePeriod';
|
|
5
|
+
import { JEScheduleKey, ScheduleJournalEntryStatusCodeType, SchedulesTypes } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
6
|
+
import { TransactionID } from '../../../entity/transaction/stateTypes/transaction';
|
|
7
|
+
import { ZeniDate } from '../../../zeniDayJS';
|
|
8
|
+
import { ScheduleDetailSortKey } from './scheduleDetailTypes';
|
|
9
|
+
export declare const getScheduleDetailKey: (tab: SchedulesTypes, scheduleId: ID) => `prepaid_expenses-${string}` | `fixed_assets-${string}` | `accured_expenses-${string}` | `deferred_revenue-${string}`;
|
|
10
|
+
export declare type ScheduleListKey = ReturnType<typeof getScheduleDetailKey>;
|
|
11
|
+
export declare type JELinkType = 'recommended' | 'linked' | 'unknown' | 'qbourl';
|
|
12
|
+
export interface JETransactionLink {
|
|
13
|
+
type: JELinkType;
|
|
14
|
+
thirdPartyTransactionId?: ID;
|
|
15
|
+
transactionDetailID?: TransactionID;
|
|
16
|
+
recommendedTransactionID?: TransactionID;
|
|
17
|
+
}
|
|
18
|
+
export interface ScheduleDetailUIState {
|
|
19
|
+
sortKey: ScheduleDetailSortKey;
|
|
20
|
+
sortOrder: SortOrder;
|
|
21
|
+
scrollPosition: number;
|
|
22
|
+
}
|
|
23
|
+
export interface JEScheduleDetailsLocalData {
|
|
24
|
+
postingDate: ZeniDate;
|
|
25
|
+
amount: Amount;
|
|
26
|
+
runningBalance: Amount;
|
|
27
|
+
postingStatus: ScheduleJournalEntryStatusCodeType;
|
|
28
|
+
memo: string;
|
|
29
|
+
jeLink: JETransactionLink;
|
|
30
|
+
}
|
|
31
|
+
export interface ScheduleDetailsLocalData {
|
|
32
|
+
jeScheduleDetails: JEScheduleDetailsLocalData[];
|
|
33
|
+
selectedDate?: ZeniDate;
|
|
34
|
+
selectedMonths?: number;
|
|
35
|
+
selectedAccount?: ID;
|
|
36
|
+
selectedClass?: ID;
|
|
37
|
+
selectedDayOfMonth?: ScheduleDaysOfMonth;
|
|
38
|
+
lastDayOfMonth?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface ScheduleDetailViewState extends FetchStateAndError {
|
|
41
|
+
newScheduleState: ScheduleDetailsLocalData;
|
|
42
|
+
editScheduleStateById: Record<ID, ScheduleDetailsLocalData>;
|
|
43
|
+
saveStatus: FetchStateAndError;
|
|
44
|
+
uiState: ScheduleDetailUIState;
|
|
45
|
+
selectedJEScheduleKey?: JEScheduleKey;
|
|
46
|
+
selectedJELinkRowIndex?: number;
|
|
47
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const ALL_SCHEDULE_DETAIL_SORT_KEYS: readonly ["jePostingDate", "amount", "runningBalance", "postingStatus", "jeLink", "memo"];
|
|
2
|
+
export declare const toScheduleDetailSortKeyType: (v: string) => "amount" | "memo" | "jePostingDate" | "runningBalance" | "postingStatus" | "jeLink";
|
|
3
|
+
export declare type ScheduleDetailSortKey = ReturnType<typeof toScheduleDetailSortKeyType>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toScheduleDetailSortKeyType = exports.ALL_SCHEDULE_DETAIL_SORT_KEYS = void 0;
|
|
4
|
+
const stringToUnion_1 = require("../../../commonStateTypes/stringToUnion");
|
|
5
|
+
exports.ALL_SCHEDULE_DETAIL_SORT_KEYS = [
|
|
6
|
+
'jePostingDate',
|
|
7
|
+
'amount',
|
|
8
|
+
'runningBalance',
|
|
9
|
+
'postingStatus',
|
|
10
|
+
'jeLink',
|
|
11
|
+
'memo',
|
|
12
|
+
];
|
|
13
|
+
const toScheduleDetailSortKeyType = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_SCHEDULE_DETAIL_SORT_KEYS);
|
|
14
|
+
exports.toScheduleDetailSortKeyType = toScheduleDetailSortKeyType;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { fetchDownloadSchedules, updateDownloadScheduleFailure, updateDownloadScheduleSuccess } from '../scheduleListReducer';
|
|
4
|
+
import { RootState } from '../../../../reducer';
|
|
5
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
6
|
+
import { updateJESchedules, updateJESchedulesDetails } from '../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
7
|
+
export declare type ActionType = ReturnType<typeof fetchDownloadSchedules> | ReturnType<typeof updateJESchedules> | ReturnType<typeof updateJESchedulesDetails> | ReturnType<typeof updateDownloadScheduleSuccess> | ReturnType<typeof updateDownloadScheduleFailure>;
|
|
8
|
+
export declare const fetchDownloadSchedulesEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchDownloadSchedulesEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const scheduleListReducer_1 = require("../scheduleListReducer");
|
|
7
|
+
const responsePayload_1 = require("../../../../responsePayload");
|
|
8
|
+
const jeSchedulesReducer_1 = require("../../../../entity/jeSchedules/jeSchedulesReducer");
|
|
9
|
+
const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
|
|
10
|
+
const timeframeTick_1 = require("../../../../commonStateTypes/timeframeTick");
|
|
11
|
+
const scheduleListTypes_1 = require("../scheduleListTypes");
|
|
12
|
+
const fetchDownloadSchedulesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(scheduleListReducer_1.fetchDownloadSchedules.match), (0, operators_1.mergeMap)((action) => {
|
|
13
|
+
const { tab, downloadCategories } = action.payload;
|
|
14
|
+
const scheduleListState = state$.value.scheduleListState;
|
|
15
|
+
// if parameters are provided, use those. else go to localdata
|
|
16
|
+
const timeframe = action.payload.timeframeAndCategory != null
|
|
17
|
+
? action.payload.timeframeAndCategory.selectedTimeframe
|
|
18
|
+
: scheduleListState.scheduleListLocalData.selectedTimeframe;
|
|
19
|
+
const categoryId = action.payload.timeframeAndCategory.selectedCategoryId;
|
|
20
|
+
const timePeriod = (0, timeframeTick_1.toTimePeriod)(timeframe);
|
|
21
|
+
const key = (0, scheduleListTypes_1.getScheduleListKey)(action.payload.tab, categoryId, timeframe);
|
|
22
|
+
const record = scheduleListState.byScheduleListKey[key];
|
|
23
|
+
if (record != null && record.fetchState === 'Completed') {
|
|
24
|
+
return (0, rxjs_1.from)([]);
|
|
25
|
+
}
|
|
26
|
+
const queryParam = {
|
|
27
|
+
start_date: (0, timePeriod_1.toString)(timePeriod.start),
|
|
28
|
+
end_date: (0, timePeriod_1.toString)(timePeriod.end),
|
|
29
|
+
je_schedule_type: tab,
|
|
30
|
+
base_txn_account_ids: downloadCategories,
|
|
31
|
+
sort_by: 'transaction_date',
|
|
32
|
+
sort_order: 'desc',
|
|
33
|
+
filter: 'all',
|
|
34
|
+
};
|
|
35
|
+
return zeniAPI
|
|
36
|
+
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/download?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
37
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
38
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
39
|
+
const updateActions = [
|
|
40
|
+
(0, jeSchedulesReducer_1.updateJESchedules)(response.data.je_schedules),
|
|
41
|
+
(0, jeSchedulesReducer_1.updateJESchedulesDetails)(response.data.je_schedules, response.data.scheduled_journal_entries),
|
|
42
|
+
(0, scheduleListReducer_1.updateDownloadScheduleSuccess)(tab, timeframe, categoryId, response.data.je_schedules),
|
|
43
|
+
];
|
|
44
|
+
return (0, rxjs_1.from)(updateActions);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return (0, rxjs_1.of)((0, scheduleListReducer_1.updateDownloadScheduleFailure)(tab, timeframe, categoryId, response.status));
|
|
48
|
+
}
|
|
49
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, scheduleListReducer_1.updateDownloadScheduleFailure)(tab, timeframe, categoryId, (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Schedule Download REST API call errored out' +
|
|
50
|
+
JSON.stringify(error))))));
|
|
51
|
+
}));
|
|
52
|
+
exports.fetchDownloadSchedulesEpic = fetchDownloadSchedulesEpic;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { fetchScheduleList, updateScheduleListFailure, updateScheduleListSuccess } from '../scheduleListReducer';
|
|
4
|
+
import { RootState } from '../../../../reducer';
|
|
5
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
6
|
+
import { updateJESchedules, updateJESchedulesDetails } from '../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
7
|
+
import { SchedulesTypes } from '../../../../entity/jeSchedules/jeSchedulesTypes';
|
|
8
|
+
import { AccountListState } from '../../../accountList/accountListState';
|
|
9
|
+
import { ID } from '../../../../commonStateTypes/common';
|
|
10
|
+
export declare type ActionType = ReturnType<typeof fetchScheduleList> | ReturnType<typeof updateJESchedules> | ReturnType<typeof updateJESchedulesDetails> | ReturnType<typeof updateScheduleListSuccess> | ReturnType<typeof updateScheduleListFailure>;
|
|
11
|
+
export declare const fetchScheduleListEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
12
|
+
export interface ScheduleListQueryParam {
|
|
13
|
+
start_date: string;
|
|
14
|
+
end_date: string;
|
|
15
|
+
sort_by: string;
|
|
16
|
+
sort_order: string;
|
|
17
|
+
base_txn_account_ids: string[];
|
|
18
|
+
je_schedule_type: string;
|
|
19
|
+
filter: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Based on the tab this will return all IDs
|
|
23
|
+
* @param tab
|
|
24
|
+
* @param accountListState
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
export declare const getAllAccountIdsForTab: (tab: SchedulesTypes, accountListState: AccountListState) => ID[];
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAllAccountIdsForTab = exports.fetchScheduleListEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const scheduleListReducer_1 = require("../scheduleListReducer");
|
|
7
|
+
const responsePayload_1 = require("../../../../responsePayload");
|
|
8
|
+
const jeSchedulesReducer_1 = require("../../../../entity/jeSchedules/jeSchedulesReducer");
|
|
9
|
+
const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
|
|
10
|
+
const timeframeTick_1 = require("../../../../commonStateTypes/timeframeTick");
|
|
11
|
+
const fetchSchedulesAccountEpic_1 = require("./fetchSchedulesAccountEpic");
|
|
12
|
+
const scheduleListTypes_1 = require("../scheduleListTypes");
|
|
13
|
+
const fetchScheduleListEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(scheduleListReducer_1.fetchScheduleList.match), (0, operators_1.mergeMap)((action) => {
|
|
14
|
+
const { tab } = action.payload;
|
|
15
|
+
const { scheduleListState, accountListState } = state$.value;
|
|
16
|
+
// if parameters are provided, use those. else go to localdata
|
|
17
|
+
const timeframe = action.payload.timeframeAndCategory != null
|
|
18
|
+
? action.payload.timeframeAndCategory.selectedTimeframe
|
|
19
|
+
: scheduleListState.scheduleListLocalData.selectedTimeframe;
|
|
20
|
+
const categoryId = action.payload.timeframeAndCategory != null
|
|
21
|
+
? action.payload.timeframeAndCategory.selectedCategoryId
|
|
22
|
+
: scheduleListState.scheduleListLocalData.selectedCategoryID;
|
|
23
|
+
const timePeriod = (0, timeframeTick_1.toTimePeriod)(timeframe);
|
|
24
|
+
const key = (0, scheduleListTypes_1.getScheduleListKey)(action.payload.tab, categoryId, timeframe);
|
|
25
|
+
const draft = scheduleListState.byScheduleListKey[key];
|
|
26
|
+
if (draft != null && draft.fetchState === 'Completed') {
|
|
27
|
+
return (0, rxjs_1.from)([]);
|
|
28
|
+
}
|
|
29
|
+
let categoryIds = [categoryId];
|
|
30
|
+
if (categoryId === 'all') {
|
|
31
|
+
categoryIds = (0, exports.getAllAccountIdsForTab)(scheduleListState.currentTab, accountListState);
|
|
32
|
+
}
|
|
33
|
+
const queryParam = {
|
|
34
|
+
start_date: (0, timePeriod_1.toString)(timePeriod.start),
|
|
35
|
+
end_date: (0, timePeriod_1.toString)(timePeriod.end),
|
|
36
|
+
je_schedule_type: tab,
|
|
37
|
+
base_txn_account_ids: categoryIds,
|
|
38
|
+
// these are hard coded since sorting and filtering are at the client end
|
|
39
|
+
sort_by: 'transaction_date',
|
|
40
|
+
sort_order: 'desc',
|
|
41
|
+
filter: 'all',
|
|
42
|
+
};
|
|
43
|
+
return zeniAPI
|
|
44
|
+
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
45
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
46
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
47
|
+
const updateActions = [];
|
|
48
|
+
updateActions.push((0, jeSchedulesReducer_1.updateJESchedules)(response.data.je_schedules), (0, jeSchedulesReducer_1.updateJESchedulesDetails)(response.data.je_schedules, response.data.scheduled_journal_entries), (0, scheduleListReducer_1.updateScheduleListSuccess)(tab, timeframe, categoryId, response.data.je_schedules));
|
|
49
|
+
return (0, rxjs_1.from)(updateActions);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return (0, rxjs_1.of)((0, scheduleListReducer_1.updateScheduleListFailure)(tab, timeframe, categoryId, response.status));
|
|
53
|
+
}
|
|
54
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, scheduleListReducer_1.updateScheduleListFailure)(tab, timeframe, categoryId, (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Schedule List REST API call errored out' +
|
|
55
|
+
JSON.stringify(error))))));
|
|
56
|
+
}));
|
|
57
|
+
exports.fetchScheduleListEpic = fetchScheduleListEpic;
|
|
58
|
+
/**
|
|
59
|
+
* Based on the tab this will return all IDs
|
|
60
|
+
* @param tab
|
|
61
|
+
* @param accountListState
|
|
62
|
+
* @returns
|
|
63
|
+
*/
|
|
64
|
+
const getAllAccountIdsForTab = (tab, accountListState) => {
|
|
65
|
+
const accountStateForReport = accountListState.byReportId[(0, fetchSchedulesAccountEpic_1.getAccountsTypesForSchedulePayload)(tab).accountListKey];
|
|
66
|
+
let accountIds = accountStateForReport.accountIds;
|
|
67
|
+
if (tab === 'prepaid_expenses') {
|
|
68
|
+
const filteredList = accountStateForReport.accountIdsByLabel['prepaid_expenses'];
|
|
69
|
+
if (filteredList.length > 0) {
|
|
70
|
+
accountIds = filteredList;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return accountIds;
|
|
74
|
+
};
|
|
75
|
+
exports.getAllAccountIdsForTab = getAllAccountIdsForTab;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../../../reducer';
|
|
4
|
+
import { fetchSchedulesAccount } from '../scheduleListReducer';
|
|
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
|
+
export declare type ActionType = ReturnType<typeof fetchSchedulesAccount> | ReturnType<typeof fetchAccountList>;
|
|
10
|
+
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 {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAccountsTypesForSchedulePayload = exports.fetchSchedulesAccountEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const scheduleListReducer_1 = require("../scheduleListReducer");
|
|
7
|
+
const accountListReducer_1 = require("../../../accountList/accountListReducer");
|
|
8
|
+
const fetchSchedulesAccountEpic = (actions$,
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10
|
+
_state$) => actions$.pipe((0, operators_1.filter)(scheduleListReducer_1.fetchSchedulesAccount.match), (0, operators_1.mergeMap)(() => {
|
|
11
|
+
const fetchScheduleListActions = [];
|
|
12
|
+
const scheduleTabIds = ['prepaid_expenses'];
|
|
13
|
+
scheduleTabIds.forEach((scheduleTab) => {
|
|
14
|
+
const accountType = (0, exports.getAccountsTypesForSchedulePayload)(scheduleTab);
|
|
15
|
+
fetchScheduleListActions.push((0, accountListReducer_1.fetchAccountList)(accountType.accountListKey, false, false, false, accountType.allowedAccountList));
|
|
16
|
+
});
|
|
17
|
+
return (0, rxjs_1.from)(fetchScheduleListActions);
|
|
18
|
+
}));
|
|
19
|
+
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;
|