@zeniai/client-epic-state 4.13.18 → 4.13.19
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/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +1 -0
- package/lib/entity/toastNotification/epic/pushToastNotificationEpic.d.ts +1 -1
- package/lib/entity/transaction/payloadTypes/transactionLinePayload.d.ts +3 -1
- package/lib/entity/transaction/payloadTypes/transactionLinePayload.js +6 -0
- package/lib/entity/transaction/payloadTypes/transactionPayload.d.ts +2 -0
- package/lib/entity/transaction/payloadTypes/transactionPayload.js +3 -2
- package/lib/entity/transaction/stateTypes/transactionLine.d.ts +5 -0
- package/lib/entity/transaction/stateTypes/transactionLine.js +9 -1
- package/lib/entity/transaction/stateTypes/transactionType.d.ts +1 -1
- package/lib/entity/transaction/stateTypes/transactionType.js +2 -1
- package/lib/entity/transaction/transactionReducer.d.ts +3 -1
- package/lib/entity/transaction/transactionReducer.js +8 -2
- package/lib/epic.d.ts +7 -1
- package/lib/epic.js +7 -1
- package/lib/index.d.ts +7 -2
- package/lib/index.js +47 -25
- package/lib/view/accountList/fetchAccountListEpic.js +1 -1
- package/lib/view/cardPayment/epic/addCardPaymentSourceEpic.d.ts +1 -1
- package/lib/view/cardPayment/epic/confirmCardSetupIntentEpic.d.ts +1 -1
- package/lib/view/cardPayment/epic/createCardSetupIntentEpic.d.ts +1 -1
- package/lib/view/cardPayment/epic/fetchPaymentSourcesEpic.d.ts +1 -1
- package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.d.ts +2 -1
- package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +8 -2
- package/lib/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.d.ts +2 -1
- package/lib/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.js +5 -3
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +67 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.js +38 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/initializeTransactionCategorizationLocalDataEpic.d.ts +5 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/initializeTransactionCategorizationLocalDataEpic.js +31 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/markTransactionAsNotMiscatgorizedEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/markTransactionAsNotMiscatgorizedEpic.js +56 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/saveTransactionCategorizationEpic.d.ts +5 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/saveTransactionCategorizationEpic.js +32 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/updateTransactionCategorizationEpic.d.ts +6 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/updateTransactionCategorizationEpic.js +164 -0
- package/lib/view/expenseAutomationView/expenseAutomationViewReducer.d.ts +3 -1
- package/lib/view/expenseAutomationView/expenseAutomationViewReducer.js +12 -2
- package/lib/view/expenseAutomationView/expenseAutomationViewSelector.js +14 -7
- package/lib/view/expenseAutomationView/expenseAutomationViewState.d.ts +2 -0
- package/lib/view/expenseAutomationView/helpers/saveTransactionHelper.d.ts +8 -0
- package/lib/view/expenseAutomationView/helpers/saveTransactionHelper.js +165 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +8 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +175 -0
- package/lib/view/expenseAutomationView/payload/transactionCategorizationPayload.d.ts +48 -0
- package/lib/view/expenseAutomationView/payload/transactionCategorizationPayload.js +2 -0
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +100 -2
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +368 -10
- package/lib/view/expenseAutomationView/selectorTypes/expenseAutomationViewSelectorTypes.d.ts +4 -0
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +29 -0
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.js +2 -0
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +4 -0
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +85 -0
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +97 -6
- package/lib/view/expenseAutomationView/types/transactionsViewState.js +15 -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/reviewCompanyView/reviewCompanyViewState.d.ts +1 -1
- package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +1 -1
- package/lib/view/settingsView/epic/saveNotificationSettingsEpic.d.ts +1 -1
- package/lib/view/tagView/epics/createTagEpic.d.ts +1 -1
- package/lib/view/tagView/epics/deleteTagEpic.d.ts +1 -1
- package/lib/view/transactionDetail/epics/saveTransactionHelper.d.ts +8 -0
- package/lib/view/transactionDetail/epics/saveTransactionHelper.js +11 -6
- package/lib/view/transactionDetail/transactionDetailLocalDataHelper.d.ts +10 -0
- package/lib/view/transactionDetail/transactionDetailLocalDataHelper.js +8 -7
- package/package.json +1 -1
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
var _a;
|
|
2
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.clearExpenseAutomationTransactionsView = exports.initialState = void 0;
|
|
7
|
+
exports.clearExpenseAutomationTransactionsView = exports.clearExpenseAutomationTransactionsViewPerTabView = exports.updateSelectedCheckboxTransactionIds = exports.fetchTransactionCategorizationView = exports.fetchTransactionCategorizationSuccess = exports.updateTotalCountForTransactionCategorization = exports.setAllItemsToCategoryClassInLocalDataForCategorization = exports.updateSelectedVendorForTransaction = exports.updateStatusForTransactionNotMiscategorizedUpdate = exports.markTransactionAsNotMiscategorized = exports.updateTransactionCategorizationSaveStatus = exports.updateTransactionCategorization = exports.saveTransactionCategorization = exports.fetchTransactionCategorizationFailure = exports.saveTransactionCategorizationLocalData = exports.initializeTransactionCategorizationViewLocalData = exports.updateTransactionCategorizationUIState = exports.fetchTransactionCategorization = exports.initialState = exports.initialTransactionTabViewState = void 0;
|
|
4
8
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
5
|
-
|
|
9
|
+
const get_1 = __importDefault(require("lodash/get"));
|
|
10
|
+
const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
|
|
11
|
+
const transactionCategorizationLocalDataHelper_1 = require("../helpers/transactionCategorizationLocalDataHelper");
|
|
12
|
+
const vendorTransaction_1 = require("../../../entity/transaction/stateTypes/vendorTransaction");
|
|
13
|
+
exports.initialTransactionTabViewState = {
|
|
6
14
|
saveStatus: {
|
|
7
15
|
fetchState: 'Not-Started',
|
|
8
16
|
error: undefined,
|
|
9
17
|
},
|
|
10
|
-
|
|
18
|
+
refreshStatus: {
|
|
11
19
|
fetchState: 'Not-Started',
|
|
12
20
|
error: undefined,
|
|
13
21
|
},
|
|
14
|
-
|
|
22
|
+
markAsNotMiscategorizedStatus: {
|
|
15
23
|
fetchState: 'Not-Started',
|
|
16
24
|
error: undefined,
|
|
17
25
|
},
|
|
18
26
|
uiState: {
|
|
19
|
-
sortKey: '
|
|
20
|
-
sortOrder: '
|
|
27
|
+
sortKey: 'date',
|
|
28
|
+
sortOrder: 'descending',
|
|
21
29
|
searchString: '',
|
|
22
30
|
nodeCollapseState: {},
|
|
23
31
|
scrollPosition: { scrollTop: 0, scrollLeft: undefined },
|
|
@@ -25,21 +33,371 @@ exports.initialState = {
|
|
|
25
33
|
totalCount: 0,
|
|
26
34
|
limit: 10,
|
|
27
35
|
},
|
|
28
|
-
selectedTab: 'review',
|
|
29
36
|
fetchState: 'Not-Started',
|
|
30
37
|
error: undefined,
|
|
31
38
|
hasValidState() {
|
|
32
39
|
return this.fetchState == 'Completed';
|
|
33
40
|
},
|
|
41
|
+
transactionReviewLocalDataById: {},
|
|
42
|
+
transactionIdsBySelectedPeriod: {},
|
|
43
|
+
selectedCheckBoxTransactionIds: [],
|
|
44
|
+
};
|
|
45
|
+
exports.initialState = {
|
|
46
|
+
review: Object.assign({}, exports.initialTransactionTabViewState),
|
|
47
|
+
autoCategorized: Object.assign({}, exports.initialTransactionTabViewState),
|
|
34
48
|
};
|
|
35
49
|
const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
36
50
|
name: 'expenseAutomationTransactionsView',
|
|
37
51
|
initialState: exports.initialState,
|
|
38
52
|
reducers: {
|
|
39
|
-
|
|
40
|
-
//
|
|
53
|
+
fetchTransactionCategorizationView: {
|
|
54
|
+
prepare(selectedTab, period, cacheOverride = false, keepExistingListItems = false, searchString, // when this is defined the output should go to search result IDs
|
|
55
|
+
pageToken, refreshViewInBackground = false) {
|
|
56
|
+
return {
|
|
57
|
+
payload: {
|
|
58
|
+
selectedTab,
|
|
59
|
+
period,
|
|
60
|
+
searchString,
|
|
61
|
+
keepExistingListItems,
|
|
62
|
+
pageToken,
|
|
63
|
+
cacheOverride,
|
|
64
|
+
refreshViewInBackground,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
reducer() {
|
|
69
|
+
// do nothing
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
fetchTransactionCategorization: {
|
|
73
|
+
reducer(draft, action) {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
const { refreshViewInBackground } = action.payload;
|
|
76
|
+
const selectedTab = action.payload.selectedTab;
|
|
77
|
+
if (refreshViewInBackground === true) {
|
|
78
|
+
draft[selectedTab].refreshStatus = {
|
|
79
|
+
fetchState: 'In-Progress',
|
|
80
|
+
error: undefined,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
if (action.payload.pageToken == null) {
|
|
85
|
+
draft[selectedTab].fetchState = 'In-Progress';
|
|
86
|
+
draft[selectedTab].error = undefined;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Note: Need to reset scroll position whenever a new fetch happens, except when fetching through scroll
|
|
90
|
+
if (action.payload.pageToken == null) {
|
|
91
|
+
// Page Token is null in each fetch except when fetching through scroll
|
|
92
|
+
draft[selectedTab].uiState.scrollPosition = {
|
|
93
|
+
scrollTop: 0,
|
|
94
|
+
scrollLeft: undefined,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
draft[selectedTab].selectedCheckBoxTransactionIds = [];
|
|
98
|
+
draft[selectedTab].uiState.pageToken = (_a = action.payload.pageToken) !== null && _a !== void 0 ? _a : null;
|
|
99
|
+
draft[selectedTab].uiState.searchString =
|
|
100
|
+
(_b = action.payload.searchString) !== null && _b !== void 0 ? _b : '';
|
|
101
|
+
draft[selectedTab].error = undefined;
|
|
102
|
+
},
|
|
103
|
+
prepare(selectedTab, period, cacheOverride = false, keepExistingListItems = false, searchString, // when this is defined the output should go to search result IDs
|
|
104
|
+
pageToken, refreshViewInBackground = false) {
|
|
105
|
+
return {
|
|
106
|
+
payload: {
|
|
107
|
+
selectedTab,
|
|
108
|
+
period,
|
|
109
|
+
searchString,
|
|
110
|
+
keepExistingListItems,
|
|
111
|
+
pageToken,
|
|
112
|
+
cacheOverride,
|
|
113
|
+
refreshViewInBackground,
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
initializeTransactionCategorizationViewLocalData: {
|
|
119
|
+
prepare(selectedTab, transactionIds, selectedPeriod, keepExistingListItems = false, pageToken, totalCount, refreshViewInBackground = false) {
|
|
120
|
+
return {
|
|
121
|
+
payload: {
|
|
122
|
+
selectedTab,
|
|
123
|
+
transactionIds,
|
|
124
|
+
selectedPeriod,
|
|
125
|
+
keepExistingListItems,
|
|
126
|
+
pageToken,
|
|
127
|
+
totalCount,
|
|
128
|
+
refreshViewInBackground,
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
reducer() {
|
|
133
|
+
// do nothing
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
saveTransactionCategorizationLocalData(draft, action) {
|
|
137
|
+
const { keepExistingListItems, transactionIds, transactionLocalData, selectedPeriod, selectedTab, pageToken, totalCount, } = action.payload;
|
|
138
|
+
if (keepExistingListItems === false) {
|
|
139
|
+
draft[selectedTab].transactionIdsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)] = transactionIds;
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
const previousData = draft[selectedTab].transactionIdsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)];
|
|
143
|
+
if (previousData == null) {
|
|
144
|
+
draft[selectedTab].transactionIdsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)] = transactionIds;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
draft[selectedTab].transactionIdsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)] = [...previousData, ...transactionIds];
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
draft[selectedTab].transactionReviewLocalDataById = Object.assign(Object.assign({}, draft[selectedTab].transactionReviewLocalDataById), transactionLocalData);
|
|
151
|
+
draft[selectedTab].selectedCheckBoxTransactionIds = [];
|
|
152
|
+
if (action.payload.refreshViewInBackground === true) {
|
|
153
|
+
draft[selectedTab].refreshStatus = {
|
|
154
|
+
fetchState: 'Completed',
|
|
155
|
+
error: undefined,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
draft[selectedTab].fetchState = 'Completed';
|
|
160
|
+
draft[selectedTab].error = undefined;
|
|
161
|
+
}
|
|
162
|
+
draft[selectedTab].uiState = Object.assign(Object.assign({}, draft[selectedTab].uiState), { pageToken: pageToken !== null && pageToken !== void 0 ? pageToken : null, totalCount });
|
|
163
|
+
},
|
|
164
|
+
updateTransactionCategorizationUIState(draft, action) {
|
|
165
|
+
const selectedTab = action.payload.selectedTab;
|
|
166
|
+
const uiState = action.payload.uiState;
|
|
167
|
+
if (uiState.sortKey != null) {
|
|
168
|
+
draft[selectedTab].uiState.sortKey = uiState.sortKey;
|
|
169
|
+
}
|
|
170
|
+
if (uiState.sortOrder != null) {
|
|
171
|
+
draft[selectedTab].uiState.sortOrder = uiState.sortOrder;
|
|
172
|
+
}
|
|
173
|
+
if (uiState.searchString != null) {
|
|
174
|
+
draft[selectedTab].uiState.searchString = uiState.searchString;
|
|
175
|
+
}
|
|
176
|
+
if (uiState.scrollPosition != null) {
|
|
177
|
+
draft[selectedTab].uiState.scrollPosition = uiState.scrollPosition;
|
|
178
|
+
}
|
|
179
|
+
if (uiState.pageToken != null) {
|
|
180
|
+
draft[selectedTab].uiState.pageToken = uiState.pageToken;
|
|
181
|
+
}
|
|
182
|
+
if (uiState.totalCount != null) {
|
|
183
|
+
draft[selectedTab].uiState.totalCount = uiState.totalCount;
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
saveTransactionCategorization: {
|
|
187
|
+
prepare(selectedTab, transactionIds) {
|
|
188
|
+
return {
|
|
189
|
+
payload: {
|
|
190
|
+
selectedTab,
|
|
191
|
+
transactionIds,
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
},
|
|
195
|
+
reducer() {
|
|
196
|
+
// do nothing
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
updateTransactionCategorization: {
|
|
200
|
+
reducer(draft, action) {
|
|
201
|
+
const selectedTab = action.payload.selectedTab;
|
|
202
|
+
draft[selectedTab].saveStatus = {
|
|
203
|
+
error: undefined,
|
|
204
|
+
fetchState: 'In-Progress',
|
|
205
|
+
};
|
|
206
|
+
},
|
|
207
|
+
prepare(selectedTab, transactionIds, transactionSaveUpdates) {
|
|
208
|
+
return {
|
|
209
|
+
payload: {
|
|
210
|
+
selectedTab,
|
|
211
|
+
transactionIds,
|
|
212
|
+
transactionSaveUpdates,
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
setAllItemsToCategoryClassInLocalDataForCategorization: {
|
|
218
|
+
reducer(draft, action) {
|
|
219
|
+
const { vendorId, selectedAccount, selectedClassBase, transactions, transactionId, lineId, selectedTab, } = action.payload;
|
|
220
|
+
const transactionLocalData = (0, get_1.default)(draft[selectedTab].transactionReviewLocalDataById, transactionId, undefined);
|
|
221
|
+
if (transactionLocalData != null) {
|
|
222
|
+
const newTransactionLocalData = Object.assign(Object.assign({}, transactionLocalData.transactionReviewLocalData), { lineItemById: Object.assign(Object.assign({}, transactionLocalData.transactionReviewLocalData.lineItemById), { [lineId]: Object.assign(Object.assign({}, transactionLocalData.transactionReviewLocalData.lineItemById[lineId]), { account: selectedAccount, class: selectedClassBase }) }) });
|
|
223
|
+
draft[selectedTab].transactionReviewLocalDataById[transactionId] = {
|
|
224
|
+
transactionReviewLocalData: newTransactionLocalData,
|
|
225
|
+
transactionId,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
if (vendorId != null) {
|
|
229
|
+
transactions.forEach((transaction) => {
|
|
230
|
+
const transactionLocalData = (0, get_1.default)(draft[selectedTab].transactionReviewLocalDataById, transaction.id, undefined);
|
|
231
|
+
if (transactionLocalData != null) {
|
|
232
|
+
draft[selectedTab].transactionReviewLocalDataById[transaction.id] = {
|
|
233
|
+
transactionId: transaction.id,
|
|
234
|
+
transactionReviewLocalData: (0, transactionCategorizationLocalDataHelper_1.toSetAllLineItemsToCategoryClass)(draft[selectedTab], transaction, transactionId, lineId, transactionLocalData.transactionReviewLocalData, vendorId, selectedAccount, selectedClassBase),
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
prepare(selectedTab, transactionId, lineId, transactions, vendorId, selectedAccount, selectedClassBase, lineEntity, recommendations) {
|
|
241
|
+
return {
|
|
242
|
+
payload: {
|
|
243
|
+
selectedTab,
|
|
244
|
+
transactionId,
|
|
245
|
+
lineId,
|
|
246
|
+
transactions,
|
|
247
|
+
vendorId,
|
|
248
|
+
lineEntity,
|
|
249
|
+
selectedAccount,
|
|
250
|
+
selectedClassBase,
|
|
251
|
+
recommendations,
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
fetchTransactionCategorizationSuccess(draft, action) {
|
|
257
|
+
const { selectedTab } = action.payload;
|
|
258
|
+
if (action.payload.refreshViewInBackground === true) {
|
|
259
|
+
draft[selectedTab].refreshStatus = {
|
|
260
|
+
fetchState: 'Completed',
|
|
261
|
+
error: undefined,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
draft[selectedTab].fetchState = 'Completed';
|
|
266
|
+
draft[selectedTab].error = undefined;
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
fetchTransactionCategorizationFailure(draft, action) {
|
|
270
|
+
const { selectedTab, selectedPeriod } = action.payload;
|
|
271
|
+
draft[selectedTab].transactionIdsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)] = [];
|
|
272
|
+
draft[selectedTab].fetchState = 'Error';
|
|
273
|
+
draft[selectedTab].error = action.payload.status;
|
|
274
|
+
},
|
|
275
|
+
updateSelectedVendorForTransaction(draft, action) {
|
|
276
|
+
const { transactionId, lineId, updatedVendor, selectedTransaction, selectedTab, } = action.payload;
|
|
277
|
+
const transactionLocalData = (0, get_1.default)(draft[selectedTab].transactionReviewLocalDataById, transactionId, undefined);
|
|
278
|
+
if (transactionLocalData != null) {
|
|
279
|
+
const newTransactionLocalData = Object.assign({}, transactionLocalData.transactionReviewLocalData);
|
|
280
|
+
if (!(0, vendorTransaction_1.isVendorTransaction)(selectedTransaction) &&
|
|
281
|
+
updatedVendor != null) {
|
|
282
|
+
newTransactionLocalData.lineItemById[lineId] = Object.assign(Object.assign({}, transactionLocalData.transactionReviewLocalData.lineItemById[lineId]), { vendor: {
|
|
283
|
+
id: updatedVendor.id,
|
|
284
|
+
name: updatedVendor.name,
|
|
285
|
+
logo: updatedVendor.logo,
|
|
286
|
+
} });
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
newTransactionLocalData.vendorUpdates =
|
|
290
|
+
updatedVendor != null && updatedVendor.id != null
|
|
291
|
+
? {
|
|
292
|
+
id: updatedVendor.id,
|
|
293
|
+
name: updatedVendor.name,
|
|
294
|
+
qboId: updatedVendor.id,
|
|
295
|
+
}
|
|
296
|
+
: undefined;
|
|
297
|
+
newTransactionLocalData.vendor =
|
|
298
|
+
updatedVendor != null && updatedVendor.id != null
|
|
299
|
+
? {
|
|
300
|
+
id: updatedVendor.id,
|
|
301
|
+
name: updatedVendor.name,
|
|
302
|
+
logo: updatedVendor.logo,
|
|
303
|
+
}
|
|
304
|
+
: undefined;
|
|
305
|
+
}
|
|
306
|
+
draft[selectedTab].transactionReviewLocalDataById[transactionId] = {
|
|
307
|
+
transactionReviewLocalData: newTransactionLocalData,
|
|
308
|
+
transactionId,
|
|
309
|
+
};
|
|
310
|
+
const selectedCheckBoxTransactionIds = draft[selectedTab].selectedCheckBoxTransactionIds;
|
|
311
|
+
if (newTransactionLocalData.vendor != null &&
|
|
312
|
+
newTransactionLocalData.vendor.id != null &&
|
|
313
|
+
selectedCheckBoxTransactionIds.length <= transactionCategorizationLocalDataHelper_1.MAX_SELECTION_LIMIT &&
|
|
314
|
+
selectedCheckBoxTransactionIds.includes(transactionId) === false) {
|
|
315
|
+
draft[selectedTab].selectedCheckBoxTransactionIds = [
|
|
316
|
+
...selectedCheckBoxTransactionIds,
|
|
317
|
+
transactionId,
|
|
318
|
+
];
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
updateTransactionCategorizationSaveStatus: {
|
|
323
|
+
reducer(draft, action) {
|
|
324
|
+
const selectedTab = action.payload.selectedTab;
|
|
325
|
+
draft[selectedTab].saveStatus = {
|
|
326
|
+
fetchState: action.payload.fetchState,
|
|
327
|
+
error: action.payload.error,
|
|
328
|
+
};
|
|
329
|
+
},
|
|
330
|
+
prepare(selectedTab, fetchState, error) {
|
|
331
|
+
return {
|
|
332
|
+
payload: {
|
|
333
|
+
selectedTab,
|
|
334
|
+
fetchState,
|
|
335
|
+
error,
|
|
336
|
+
},
|
|
337
|
+
};
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
markTransactionAsNotMiscategorized: {
|
|
341
|
+
reducer(draft, action) {
|
|
342
|
+
const selectedTab = action.payload.selectedTab;
|
|
343
|
+
draft[selectedTab].markAsNotMiscategorizedStatus = {
|
|
344
|
+
fetchState: 'In-Progress',
|
|
345
|
+
error: undefined,
|
|
346
|
+
};
|
|
347
|
+
},
|
|
348
|
+
prepare(selectedTab, transactionsInReview) {
|
|
349
|
+
return {
|
|
350
|
+
payload: {
|
|
351
|
+
selectedTab,
|
|
352
|
+
transactionsInReview,
|
|
353
|
+
},
|
|
354
|
+
};
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
updateStatusForTransactionNotMiscategorizedUpdate: {
|
|
358
|
+
reducer(draft, action) {
|
|
359
|
+
const { selectedTab, selectedPeriod, transactionIds } = action.payload;
|
|
360
|
+
if (action.payload.fetchState === 'Completed') {
|
|
361
|
+
draft[selectedTab].selectedCheckBoxTransactionIds = [];
|
|
362
|
+
const transactionIdsBySelectedPeriod = draft[selectedTab].transactionIdsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)];
|
|
363
|
+
if (transactionIdsBySelectedPeriod != null) {
|
|
364
|
+
draft[selectedTab].transactionIdsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)] = transactionIdsBySelectedPeriod.filter((id) => !transactionIds.includes(id));
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
draft[selectedTab].markAsNotMiscategorizedStatus = {
|
|
368
|
+
fetchState: action.payload.fetchState,
|
|
369
|
+
error: action.payload.error,
|
|
370
|
+
};
|
|
371
|
+
},
|
|
372
|
+
prepare(selectedTab, transactionIds, selectedPeriod, fetchState, error) {
|
|
373
|
+
return {
|
|
374
|
+
payload: {
|
|
375
|
+
selectedPeriod,
|
|
376
|
+
transactionIds,
|
|
377
|
+
selectedTab,
|
|
378
|
+
fetchState,
|
|
379
|
+
error,
|
|
380
|
+
},
|
|
381
|
+
};
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
updateTotalCountForTransactionCategorization(draft, action) {
|
|
385
|
+
const selectedTab = action.payload.selectedTab;
|
|
386
|
+
draft[selectedTab].uiState.totalCount = action.payload.totalCount;
|
|
387
|
+
},
|
|
388
|
+
updateSelectedCheckboxTransactionIds(draft, action) {
|
|
389
|
+
const selectedTab = action.payload.selectedTab;
|
|
390
|
+
const transactionIds = action.payload.transactionIds;
|
|
391
|
+
draft[selectedTab].selectedCheckBoxTransactionIds = [...transactionIds];
|
|
392
|
+
},
|
|
393
|
+
clearExpenseAutomationTransactionsViewPerTabView(draft, action) {
|
|
394
|
+
const selectedTab = action.payload;
|
|
395
|
+
draft[selectedTab] = Object.assign({}, exports.initialTransactionTabViewState);
|
|
396
|
+
},
|
|
397
|
+
clearExpenseAutomationTransactionsView(draft) {
|
|
398
|
+
Object.assign(draft, exports.initialState);
|
|
41
399
|
},
|
|
42
400
|
},
|
|
43
401
|
});
|
|
44
|
-
|
|
402
|
+
_a = expenseAutomationTransactionsView.actions, exports.fetchTransactionCategorization = _a.fetchTransactionCategorization, exports.updateTransactionCategorizationUIState = _a.updateTransactionCategorizationUIState, exports.initializeTransactionCategorizationViewLocalData = _a.initializeTransactionCategorizationViewLocalData, exports.saveTransactionCategorizationLocalData = _a.saveTransactionCategorizationLocalData, exports.fetchTransactionCategorizationFailure = _a.fetchTransactionCategorizationFailure, exports.saveTransactionCategorization = _a.saveTransactionCategorization, exports.updateTransactionCategorization = _a.updateTransactionCategorization, exports.updateTransactionCategorizationSaveStatus = _a.updateTransactionCategorizationSaveStatus, exports.markTransactionAsNotMiscategorized = _a.markTransactionAsNotMiscategorized, exports.updateStatusForTransactionNotMiscategorizedUpdate = _a.updateStatusForTransactionNotMiscategorizedUpdate, exports.updateSelectedVendorForTransaction = _a.updateSelectedVendorForTransaction, exports.setAllItemsToCategoryClassInLocalDataForCategorization = _a.setAllItemsToCategoryClassInLocalDataForCategorization, exports.updateTotalCountForTransactionCategorization = _a.updateTotalCountForTransactionCategorization, exports.fetchTransactionCategorizationSuccess = _a.fetchTransactionCategorizationSuccess, exports.fetchTransactionCategorizationView = _a.fetchTransactionCategorizationView, exports.updateSelectedCheckboxTransactionIds = _a.updateSelectedCheckboxTransactionIds, exports.clearExpenseAutomationTransactionsViewPerTabView = _a.clearExpenseAutomationTransactionsViewPerTabView, exports.clearExpenseAutomationTransactionsView = _a.clearExpenseAutomationTransactionsView;
|
|
45
403
|
exports.default = expenseAutomationTransactionsView.reducer;
|
package/lib/view/expenseAutomationView/selectorTypes/expenseAutomationViewSelectorTypes.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ import { ExpenseAutomationViewType } from '../expenseAutomationViewState';
|
|
|
8
8
|
import { ExpenseAutomationJESchedulesViewSelector } from './jeSchedulesSelectorTypes';
|
|
9
9
|
import { ExpenseAutomationFluxAnalysisViewSelector } from './fluxAnalysisViewSelectorTypes';
|
|
10
10
|
import { ExpenseAutomationMissingReceiptsViewSelector } from './missingReceiptsSelectorTypes';
|
|
11
|
+
import { ExpenseAutomationTransactionViewSelector } from './transactionsViewSelectorTypes';
|
|
12
|
+
import { TransactionsTab } from '../types/transactionsViewState';
|
|
11
13
|
export interface ExpenseAutomationStepDetails {
|
|
12
14
|
step: ExpenseAutomationViewType;
|
|
13
15
|
title: string;
|
|
@@ -20,8 +22,10 @@ export interface ExpenseAutomationStepDetails {
|
|
|
20
22
|
export declare const getAllSteps: (monthEndCloseChecksState: MonthEndCloseChecksState, monthYearId: MonthYearPeriodId, tenantId: ID, auditSummary?: MonthEndAuditSummary | undefined) => ExpenseAutomationStepDetails[];
|
|
21
23
|
export interface ExpenseAutomationViewSelector extends SelectorView {
|
|
22
24
|
currentSelectedView: ExpenseAutomationViewType;
|
|
25
|
+
selectedTransactionCategorizationTab: TransactionsTab;
|
|
23
26
|
selectedPeriod: MonthYearPeriod;
|
|
24
27
|
monthEndCloseChecksView: MonthEndCloseChecksView;
|
|
28
|
+
transactionView: ExpenseAutomationTransactionViewSelector;
|
|
25
29
|
jeSchedules: ExpenseAutomationJESchedulesViewSelector;
|
|
26
30
|
missingReceipts: ExpenseAutomationMissingReceiptsViewSelector;
|
|
27
31
|
fluxAnalysis: ExpenseAutomationFluxAnalysisViewSelector;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { NestedAccountHierarchyForReport } from '../../../commonStateTypes/accountView/nestedAccountID';
|
|
2
|
+
import { NestedClassHierarchyForReport } from '../../../commonStateTypes/classesView/nestedClassID';
|
|
3
|
+
import { ID, FetchStateAndError, CompletionStatusType } from '../../../commonStateTypes/common';
|
|
4
|
+
import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport';
|
|
5
|
+
import { AccountBase } from '../../../entity/account/accountState';
|
|
6
|
+
import { ClassBase } from '../../../entity/class/classState';
|
|
7
|
+
import { SupportedTransaction } from '../../../entity/transaction/transactionState';
|
|
8
|
+
import { UncategorizedAccounts } from '../../accountList/accountListSelector';
|
|
9
|
+
import { TransactionReviewLocalData, TransactionsTab, TransactionsViewUIState } from '../types/transactionsViewState';
|
|
10
|
+
export interface TransactionReviewLocalDataSelectorView {
|
|
11
|
+
transactionId: ID;
|
|
12
|
+
transactionReviewLocalData: TransactionReviewLocalData;
|
|
13
|
+
}
|
|
14
|
+
export interface ExpenseAutomationTransactionViewSelector extends SelectorView {
|
|
15
|
+
uiState: TransactionsViewUIState;
|
|
16
|
+
uncategorizedAccounts: UncategorizedAccounts;
|
|
17
|
+
transactions: SupportedTransaction[];
|
|
18
|
+
accountList: AccountBase[];
|
|
19
|
+
accountsHierarchyList: NestedAccountHierarchyForReport[];
|
|
20
|
+
totalCountByTab: Record<TransactionsTab, number>;
|
|
21
|
+
classList: ClassBase[];
|
|
22
|
+
classHierarchyList: NestedClassHierarchyForReport[];
|
|
23
|
+
selectedCheckBoxTransactionIds: ID[];
|
|
24
|
+
transactionLocalData: TransactionReviewLocalDataSelectorView[];
|
|
25
|
+
markAsNotMiscategorizedStatus: FetchStateAndError;
|
|
26
|
+
refreshStatus: FetchStateAndError;
|
|
27
|
+
saveStatus: FetchStateAndError;
|
|
28
|
+
completionStatus: CompletionStatusType;
|
|
29
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ExpenseAutomationTransactionViewSelector } from '../selectorTypes/transactionsViewSelectorTypes';
|
|
2
|
+
import { RootState } from '../../../reducer';
|
|
3
|
+
import { TransactionsTab } from '../types/transactionsViewState';
|
|
4
|
+
export declare function getExpenseAutomationTransactionView(state: RootState, selectedTab: TransactionsTab): ExpenseAutomationTransactionViewSelector;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getExpenseAutomationTransactionView = void 0;
|
|
7
|
+
const omit_1 = __importDefault(require("lodash/omit"));
|
|
8
|
+
const accountListSelector_1 = require("../../accountList/accountListSelector");
|
|
9
|
+
const classListSelector_1 = require("../../classList/classListSelector");
|
|
10
|
+
const transactionSelector_1 = require("../../../entity/transaction/transactionSelector");
|
|
11
|
+
const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
|
|
12
|
+
const tenantSelector_1 = require("../../../entity/tenant/tenantSelector");
|
|
13
|
+
const reduceFetchState_1 = require("../../../commonStateTypes/reduceFetchState");
|
|
14
|
+
function getExpenseAutomationTransactionView(state, selectedTab) {
|
|
15
|
+
const { accountState, classState, classListState, accountListState, expenseAutomationTransactionsViewState, expenseAutomationViewState, transactionState, } = state;
|
|
16
|
+
const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, } = expenseAutomationTransactionsViewState[selectedTab];
|
|
17
|
+
const uncategorizedIncomeExpense = (0, accountListSelector_1.getUncategorizedAccounts)(accountState, accountListState, 'accountList');
|
|
18
|
+
const accountList = (0, accountListSelector_1.getAccountList)(accountState, accountListState, 'accountList');
|
|
19
|
+
const classList = (0, classListSelector_1.getClassList)(classState, classListState);
|
|
20
|
+
const allClasses = classList.classes.map((classData) => {
|
|
21
|
+
return (0, omit_1.default)(classData, ['accountIds', 'key']);
|
|
22
|
+
});
|
|
23
|
+
const accountsHierarchyList = (0, accountListSelector_1.getNestedAccountListHierarchy)(accountListState, 'accountList');
|
|
24
|
+
const classHierarchyList = (0, classListSelector_1.getNestedClassListHierarchy)(classListState);
|
|
25
|
+
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
|
|
26
|
+
const { selectedPeriodByTenantId } = expenseAutomationViewState;
|
|
27
|
+
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
28
|
+
const monthYearPeriodId = selectedPeriod != null ? (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod) : null;
|
|
29
|
+
const transactionIdsForSelectedPeriod = monthYearPeriodId != null
|
|
30
|
+
? transactionIdsBySelectedPeriod[monthYearPeriodId]
|
|
31
|
+
: null;
|
|
32
|
+
const transactionIds = transactionIdsForSelectedPeriod !== null && transactionIdsForSelectedPeriod !== void 0 ? transactionIdsForSelectedPeriod : [];
|
|
33
|
+
const transactionLocalData = transactionIds
|
|
34
|
+
.map((transactionId) => {
|
|
35
|
+
const transactionData = transactionReviewLocalDataById[transactionId];
|
|
36
|
+
if (transactionData != null) {
|
|
37
|
+
return {
|
|
38
|
+
transactionId,
|
|
39
|
+
transactionReviewLocalData: transactionData.transactionReviewLocalData,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
})
|
|
44
|
+
.filter((transaction) => transaction != null);
|
|
45
|
+
const transactions = (0, transactionSelector_1.getSupportedTransactionsByIds)(transactionState, transactionIds);
|
|
46
|
+
let fetchStatus = {
|
|
47
|
+
fetchState: 'Not-Started',
|
|
48
|
+
error: undefined,
|
|
49
|
+
};
|
|
50
|
+
fetchStatus = (0, reduceFetchState_1.reduceAllFetchState)([
|
|
51
|
+
accountList,
|
|
52
|
+
classList,
|
|
53
|
+
expenseAutomationTransactionsViewState[selectedTab],
|
|
54
|
+
]);
|
|
55
|
+
const totalCountByTab = {
|
|
56
|
+
review: expenseAutomationTransactionsViewState['review'].uiState.totalCount,
|
|
57
|
+
autoCategorized: expenseAutomationTransactionsViewState['autoCategorized'].uiState
|
|
58
|
+
.totalCount,
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
version: 0,
|
|
62
|
+
fetchState: fetchStatus.fetchState,
|
|
63
|
+
error: fetchStatus.error,
|
|
64
|
+
transactions,
|
|
65
|
+
selectedCheckBoxTransactionIds,
|
|
66
|
+
uncategorizedAccounts: uncategorizedIncomeExpense,
|
|
67
|
+
transactionIdsBySelectedPeriod,
|
|
68
|
+
accountList: accountList.accounts,
|
|
69
|
+
classList: allClasses,
|
|
70
|
+
accountsHierarchyList,
|
|
71
|
+
classHierarchyList,
|
|
72
|
+
transactionLocalData,
|
|
73
|
+
uiState,
|
|
74
|
+
refreshStatus,
|
|
75
|
+
saveStatus,
|
|
76
|
+
markAsNotMiscategorizedStatus,
|
|
77
|
+
completionStatus: transactionIdsForSelectedPeriod != null &&
|
|
78
|
+
fetchStatus.fetchState === 'Completed' &&
|
|
79
|
+
transactionIds.length === 0
|
|
80
|
+
? 'complete'
|
|
81
|
+
: 'incomplete',
|
|
82
|
+
totalCountByTab,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
exports.getExpenseAutomationTransactionView = getExpenseAutomationTransactionView;
|