@zeniai/client-epic-state 5.1.72-betaRD1 → 5.1.73
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/jeSchedules/jeSchedulesPayload.d.ts +0 -2
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +0 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +0 -4
- package/lib/entity/jeSchedules/jeSchedulesSelector.js +1 -11
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +0 -2
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +0 -2
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -2
- package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +0 -2
- package/lib/epic.d.ts +1 -5
- package/lib/epic.js +1 -5
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +0 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +1 -11
- package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -2
- package/lib/esm/epic.js +1 -5
- package/lib/esm/index.js +4 -10
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +3 -23
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +8 -133
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +15 -110
- package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +6 -3
- package/lib/index.d.ts +7 -11
- package/lib/index.js +48 -70
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +1 -21
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +1 -7
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +9 -40
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +8 -134
- package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +7 -31
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +1 -4
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +14 -112
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +6 -53
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -5
- package/package.json +1 -1
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +0 -21
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +0 -110
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +0 -73
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +0 -22
- package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +0 -140
- package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +0 -1
- package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +0 -70
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +0 -8
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +0 -25
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts +0 -45
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +0 -114
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +0 -8
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +0 -77
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +0 -6
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +0 -26
- package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.d.ts +0 -36
- package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +0 -145
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +0 -25
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +0 -2
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +0 -10
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +0 -75
|
@@ -3,8 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isAiAccountantSchedule = void 0;
|
|
7
|
-
exports.isAccruedScheduleRow = isAccruedScheduleRow;
|
|
8
6
|
exports.getExpenseAutomationJESchedulesView = getExpenseAutomationJESchedulesView;
|
|
9
7
|
const omit_1 = __importDefault(require("lodash/omit"));
|
|
10
8
|
const orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
@@ -12,7 +10,6 @@ const reduceFetchState_1 = require("../../../commonStateTypes/reduceFetchState")
|
|
|
12
10
|
const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
|
|
13
11
|
const accountSelector_1 = require("../../../entity/account/accountSelector");
|
|
14
12
|
const jeSchedulesSelector_1 = require("../../../entity/jeSchedules/jeSchedulesSelector");
|
|
15
|
-
const jeSchedulesTypes_1 = require("../../../entity/jeSchedules/jeSchedulesTypes");
|
|
16
13
|
const tenantSelector_1 = require("../../../entity/tenant/tenantSelector");
|
|
17
14
|
const accountListSelector_1 = require("../../accountList/accountListSelector");
|
|
18
15
|
const classListSelector_1 = require("../../classList/classListSelector");
|
|
@@ -21,32 +18,6 @@ const scheduleDetailSelector_1 = require("../../scheduleView/scheduleDetailView/
|
|
|
21
18
|
const scheduleListHelper_1 = require("../../scheduleView/scheduleListView/scheduleListHelper");
|
|
22
19
|
const expenseAutomationViewSelectorTypes_1 = require("../selectorTypes/expenseAutomationViewSelectorTypes");
|
|
23
20
|
const jeAccountSettingsViewSelector_1 = require("./jeAccountSettingsViewSelector");
|
|
24
|
-
const jeNewScheduleViewSelector_1 = require("./jeNewScheduleViewSelector");
|
|
25
|
-
// Matches the AI-automation user addresses webc's schedule list row already
|
|
26
|
-
// checks (JEScheduleReadOnlyListRow/JEScheduleDraftListRow "Method" column,
|
|
27
|
-
// strings.ts aiBotEmail/botEmail) to determine whether a schedule was
|
|
28
|
-
// created by the AI accountant vs. a human.
|
|
29
|
-
const AI_BOT_EMAIL = 'ai@zeni.ai';
|
|
30
|
-
const BOT_EMAIL = 'bot@zeni.ai';
|
|
31
|
-
// Exported (rather than kept as a closure inside the selector) so it can be
|
|
32
|
-
// unit-tested directly — confidenceScore is a separate, more narrowly
|
|
33
|
-
// populated field that can be null on a schedule the bot user created,
|
|
34
|
-
// which previously caused these schedules to display as "AI Accountant" in
|
|
35
|
-
// the list but count under "Manual" in the KPI summary.
|
|
36
|
-
const isAiAccountantSchedule = (schedule) => schedule.createdByUser?.email === AI_BOT_EMAIL ||
|
|
37
|
-
schedule.createdByUser?.email === BOT_EMAIL;
|
|
38
|
-
exports.isAiAccountantSchedule = isAiAccountantSchedule;
|
|
39
|
-
// Accrued schedules are structurally distinct — no baseTransaction, carrying recurringAmount and
|
|
40
|
-
// memo in its place — so anything reading baseTransaction has to branch on this first.
|
|
41
|
-
function isAccruedScheduleRow(schedule) {
|
|
42
|
-
return schedule.jeScheduleType === 'accrued_expenses';
|
|
43
|
-
}
|
|
44
|
-
function getScheduleAmount(schedule) {
|
|
45
|
-
if (isAccruedScheduleRow(schedule)) {
|
|
46
|
-
return schedule.recurringAmount.amount;
|
|
47
|
-
}
|
|
48
|
-
return schedule.baseTransaction.amount.amount;
|
|
49
|
-
}
|
|
50
21
|
function getJEScheduleSortAccessor(sortKey) {
|
|
51
22
|
switch (sortKey) {
|
|
52
23
|
case 'vendor':
|
|
@@ -58,9 +29,7 @@ function getJEScheduleSortAccessor(sortKey) {
|
|
|
58
29
|
case 'depCategory':
|
|
59
30
|
return (s) => s.jeCredit.account?.accountName?.toLowerCase();
|
|
60
31
|
case 'scheduleCategory':
|
|
61
|
-
return (s) =>
|
|
62
|
-
? undefined
|
|
63
|
-
: s.baseTransaction.account?.accountName?.toLowerCase();
|
|
32
|
+
return (s) => s.baseTransaction.account?.accountName?.toLowerCase();
|
|
64
33
|
case 'startMonth':
|
|
65
34
|
return (s) => s.startDate?.valueOf();
|
|
66
35
|
case 'type':
|
|
@@ -88,13 +57,11 @@ function getJEScheduleSortAccessor(sortKey) {
|
|
|
88
57
|
return s.balanceAsOfToday?.amount ?? null;
|
|
89
58
|
};
|
|
90
59
|
case 'totalAmount':
|
|
91
|
-
return (s) =>
|
|
60
|
+
return (s) => s.baseTransaction.amount.amount;
|
|
92
61
|
case 'transactionDate':
|
|
93
|
-
return (s) => s.
|
|
62
|
+
return (s) => s.baseTransaction.date.valueOf();
|
|
94
63
|
case 'memo':
|
|
95
|
-
return (s) =>
|
|
96
|
-
? s.memo.toLowerCase()
|
|
97
|
-
: s.baseTransaction.memo?.toLowerCase();
|
|
64
|
+
return (s) => s.baseTransaction.memo?.toLowerCase();
|
|
98
65
|
default:
|
|
99
66
|
return (s) => s.startDate?.valueOf();
|
|
100
67
|
}
|
|
@@ -106,14 +73,9 @@ function sortJEScheduledTransactions(transactions, sortKey, sortOrder) {
|
|
|
106
73
|
function getExpenseAutomationJESchedulesView(state) {
|
|
107
74
|
const jeScheduledTransaction = [];
|
|
108
75
|
const failedJeScheduledTransaction = [];
|
|
109
|
-
const accruedSchedules = [];
|
|
110
76
|
const { accountState, accountListState, classState, classListState, expenseAutomationJESchedulesViewState, expenseAutomationViewState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
|
|
111
|
-
const { jeScheduleTransactionKeysByPeriod,
|
|
77
|
+
const { jeScheduleTransactionKeysByPeriod, failedJeScheduleTransactionKeysByPeriod, jeScheduleLocalDataById, postStatusById, ignoreStatusById, uiState, error, fetchState, refreshStatus, } = expenseAutomationJESchedulesViewState;
|
|
112
78
|
const accountSettingsView = (0, jeAccountSettingsViewSelector_1.getJEAccountSettingsView)(state);
|
|
113
|
-
const newScheduleView = newSchedule.selectedDetailScheduleType === 'fixed_assets' ||
|
|
114
|
-
newSchedule.selectedDetailScheduleType === 'prepaid_expenses'
|
|
115
|
-
? (0, jeNewScheduleViewSelector_1.getNewScheduleView)(state, newSchedule.selectedDetailScheduleType)
|
|
116
|
-
: undefined;
|
|
117
79
|
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
|
|
118
80
|
const { selectedPeriodByTenantId } = expenseAutomationViewState;
|
|
119
81
|
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
@@ -149,24 +111,19 @@ function getExpenseAutomationJESchedulesView(state) {
|
|
|
149
111
|
: null;
|
|
150
112
|
const jeScheduleTransactionKeys = jeScheduleTransactionKeysForSelectedPeriod ?? [];
|
|
151
113
|
const failedJeScheduleTransactionKeys = failedJeScheduleTransactionKeysForSelectedPeriod ?? [];
|
|
152
|
-
const jeScheduleAccruedKeys = (monthYearPeriodId != null
|
|
153
|
-
? jeScheduleAccruedKeysByPeriod[monthYearPeriodId]
|
|
154
|
-
: null) ?? [];
|
|
155
114
|
jeScheduleTransactionKeys.forEach((jeScheduleKey) => {
|
|
156
115
|
const jeScheduleDetails = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleTransactionKey)(jeScheduleKey, state);
|
|
157
116
|
jeScheduledTransaction.push(jeScheduleDetails);
|
|
158
117
|
});
|
|
159
|
-
jeScheduleAccruedKeys.forEach((jeAccruedScheduleKey) => {
|
|
160
|
-
const accruedScheduleDetails = (0, jeSchedulesSelector_1.getJEAccruedScheduleByJEScheduleKey)(jeAccruedScheduleKey, state);
|
|
161
|
-
if (accruedScheduleDetails != null) {
|
|
162
|
-
accruedSchedules.push(accruedScheduleDetails);
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
118
|
failedJeScheduleTransactionKeys.forEach((jeScheduleKey) => {
|
|
166
119
|
const jeScheduleDetails = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleTransactionKey)(jeScheduleKey, state);
|
|
167
120
|
failedJeScheduledTransaction.push(jeScheduleDetails);
|
|
168
121
|
});
|
|
169
|
-
const { sortKey, sortOrder
|
|
122
|
+
const { sortKey, sortOrder } = uiState;
|
|
123
|
+
const draftSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'draft'), sortKey, sortOrder);
|
|
124
|
+
const ongoingSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'ongoing'), sortKey, sortOrder);
|
|
125
|
+
const completedSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'completed' ||
|
|
126
|
+
schedule.status.code === 'marked_as_completed'), sortKey, sortOrder);
|
|
170
127
|
const unsortedResolveSchedules = [];
|
|
171
128
|
failedJeScheduledTransaction.forEach((schedule) => {
|
|
172
129
|
schedule.scheduledJournalEntry.forEach((journalEntry) => {
|
|
@@ -178,46 +135,10 @@ function getExpenseAutomationJESchedulesView(state) {
|
|
|
178
135
|
});
|
|
179
136
|
const resolveSchedules = sortJEScheduledTransactions(unsortedResolveSchedules, sortKey, sortOrder);
|
|
180
137
|
const validResolveForPending = unsortedResolveSchedules.filter((r) => jeScheduleLocalDataById[r.scheduledJournalEntry.scheduledJournalEntryID] != null);
|
|
181
|
-
const matchesTypeFilter = (schedule) => selectedJETypeFilter == null ||
|
|
182
|
-
schedule.jeScheduleType === selectedJETypeFilter;
|
|
183
|
-
const isCreatedStatus = (schedule) => schedule.status.code === 'ongoing' ||
|
|
184
|
-
schedule.status.code === 'completed' ||
|
|
185
|
-
schedule.status.code === 'marked_as_completed';
|
|
186
|
-
const allScheduleRows = [
|
|
187
|
-
...jeScheduledTransaction,
|
|
188
|
-
...accruedSchedules,
|
|
189
|
-
];
|
|
190
138
|
const pendingReviewSchedules = sortJEScheduledTransactions([
|
|
191
|
-
...
|
|
139
|
+
...jeScheduledTransaction.filter((schedule) => schedule.status.code === 'draft'),
|
|
192
140
|
...validResolveForPending,
|
|
193
141
|
], sortKey, sortOrder);
|
|
194
|
-
const createdSchedules = sortJEScheduledTransactions(allScheduleRows.filter((schedule) => isCreatedStatus(schedule) && matchesTypeFilter(schedule)), sortKey, sortOrder);
|
|
195
|
-
// KPI summary — derived from unfiltered schedules so counts are always accurate
|
|
196
|
-
const allSchedules = allScheduleRows;
|
|
197
|
-
const sumAmount = (schedules) => schedules.reduce((total, schedule) => total + (getScheduleAmount(schedule) ?? 0), 0);
|
|
198
|
-
const pendingReviewTotal = sumAmount(pendingReviewSchedules);
|
|
199
|
-
const createdTotal = sumAmount(createdSchedules);
|
|
200
|
-
const aiAccountantSchedules = allSchedules.filter(exports.isAiAccountantSchedule);
|
|
201
|
-
const manualSchedules = allSchedules.filter((schedule) => !(0, exports.isAiAccountantSchedule)(schedule));
|
|
202
|
-
const pendingUnfiltered = allSchedules.filter((schedule) => schedule.status.code === 'draft');
|
|
203
|
-
const kpiSummary = {
|
|
204
|
-
aiAccountant: {
|
|
205
|
-
count: aiAccountantSchedules.length,
|
|
206
|
-
amount: sumAmount(aiAccountantSchedules),
|
|
207
|
-
},
|
|
208
|
-
manual: {
|
|
209
|
-
count: manualSchedules.length,
|
|
210
|
-
amount: sumAmount(manualSchedules),
|
|
211
|
-
},
|
|
212
|
-
needsReview: {
|
|
213
|
-
count: pendingUnfiltered.length,
|
|
214
|
-
amount: sumAmount(pendingUnfiltered),
|
|
215
|
-
},
|
|
216
|
-
total: {
|
|
217
|
-
count: allSchedules.length,
|
|
218
|
-
amount: sumAmount(allSchedules),
|
|
219
|
-
},
|
|
220
|
-
};
|
|
221
142
|
const allSteps = monthYearPeriodId != null
|
|
222
143
|
? (0, expenseAutomationViewSelectorTypes_1.getAllSteps)(monthEndCloseChecksState, monthYearPeriodId, currentTenant.tenantId)
|
|
223
144
|
: [];
|
|
@@ -230,22 +151,6 @@ function getExpenseAutomationJESchedulesView(state) {
|
|
|
230
151
|
{ fetchState, error },
|
|
231
152
|
monthEndFetchState,
|
|
232
153
|
]);
|
|
233
|
-
const countByType = (schedules) => {
|
|
234
|
-
const counts = jeSchedulesTypes_1.ALL_SCHEDULES_TYPES.reduce((acc, type) => ({ ...acc, [type]: 0 }), {});
|
|
235
|
-
schedules.forEach((schedule) => {
|
|
236
|
-
if (schedule.jeScheduleType != null) {
|
|
237
|
-
counts[schedule.jeScheduleType] += 1;
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
return counts;
|
|
241
|
-
};
|
|
242
|
-
const jeScheduleTypeCounts = {
|
|
243
|
-
active: countByType(allSchedules.filter((schedule) => schedule.status.code === 'draft' ||
|
|
244
|
-
schedule.status.code === 'ongoing' ||
|
|
245
|
-
schedule.status.code === 'completed' ||
|
|
246
|
-
schedule.status.code === 'marked_as_completed')),
|
|
247
|
-
ongoing: countByType(allSchedules.filter((schedule) => schedule.status.code === 'ongoing')),
|
|
248
|
-
};
|
|
249
154
|
return {
|
|
250
155
|
uncategorizedAccounts,
|
|
251
156
|
allDepreciationAccountList: filteredDepAccounts,
|
|
@@ -254,15 +159,12 @@ function getExpenseAutomationJESchedulesView(state) {
|
|
|
254
159
|
allAccountList: filteredAccounts,
|
|
255
160
|
accountListNestedAccountHierarchy,
|
|
256
161
|
allClassList: allClasses,
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
kpiSummary,
|
|
162
|
+
completedSchedules,
|
|
163
|
+
draftSchedules,
|
|
164
|
+
ongoingSchedules,
|
|
261
165
|
pendingReviewSchedules,
|
|
262
|
-
pendingReviewTotal,
|
|
263
166
|
resolveSchedules: resolveSchedules,
|
|
264
167
|
accountSettingsView,
|
|
265
|
-
newScheduleView,
|
|
266
168
|
postStatusById: postStatusById,
|
|
267
169
|
ignoreStatusById: ignoreStatusById,
|
|
268
170
|
fetchState: reducedFetchStatus.fetchState,
|
|
@@ -1,28 +1,22 @@
|
|
|
1
1
|
import { NestedAccountHierarchyForReport } from '../../../commonStateTypes/accountView/nestedAccountID';
|
|
2
|
-
import { Amount } from '../../../commonStateTypes/amount';
|
|
3
2
|
import { FetchStateAndError, FetchedState, ID } from '../../../commonStateTypes/common';
|
|
4
3
|
import { Recommendation } from '../../../commonStateTypes/recommendationBase';
|
|
5
4
|
import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
|
|
6
|
-
import { MonthYearPeriodId
|
|
5
|
+
import { MonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
|
|
7
6
|
import { AccountBase } from '../../../entity/account/accountState';
|
|
8
|
-
import {
|
|
7
|
+
import { JEScheduleTransactionKey, ScheduleTypes } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
9
8
|
import { VendorBase } from '../../../entity/vendor/vendorState';
|
|
10
|
-
|
|
11
|
-
import { JETransactionLink } from '../../scheduleView/scheduleDetailView/scheduleDetailState';
|
|
12
|
-
export declare const toJEScheduleSortKey: (v: string) => "vendor" | "type" | "category" | "class" | "memo" | "transactionDate" | "totalAmount" | "runningBalance" | "jePostingDate" | "depCategory" | "scheduleCategory" | "startMonth" | "amortizationPeriod" | "remainingMonths";
|
|
9
|
+
export declare const toJEScheduleSortKey: (v: string) => "vendor" | "type" | "category" | "class" | "memo" | "transactionDate" | "totalAmount" | "runningBalance" | "depCategory" | "scheduleCategory" | "startMonth" | "amortizationPeriod" | "jePostingDate" | "remainingMonths";
|
|
13
10
|
export type JEScheduleSortKey = ReturnType<typeof toJEScheduleSortKey>;
|
|
14
|
-
export declare const
|
|
15
|
-
export type
|
|
11
|
+
export declare const toJEScheduleMainTab: (v: string) => "completed" | "pending_review" | "ongoing";
|
|
12
|
+
export type JEScheduleMainTab = ReturnType<typeof toJEScheduleMainTab>;
|
|
16
13
|
export interface JESchedulesViewUIState {
|
|
17
|
-
createdGroupCollapsed: boolean;
|
|
18
|
-
pendingGroupCollapsed: boolean;
|
|
19
14
|
scrollPosition: {
|
|
20
15
|
scrollTop: number;
|
|
21
16
|
scrollLeft?: number;
|
|
22
17
|
} | undefined;
|
|
23
18
|
searchString: string;
|
|
24
|
-
|
|
25
|
-
selectedPageTab: JEPageTab;
|
|
19
|
+
selectedMainTab: JEScheduleMainTab;
|
|
26
20
|
sortKey: JEScheduleSortKey;
|
|
27
21
|
sortOrder: SortOrder;
|
|
28
22
|
totalCount: number;
|
|
@@ -41,53 +35,12 @@ export interface JESchedulesViewState extends FetchedState {
|
|
|
41
35
|
accountSettings: AccountSettingsState;
|
|
42
36
|
failedJeScheduleTransactionKeysByPeriod: Record<MonthYearPeriodId, JEScheduleTransactionKey[]>;
|
|
43
37
|
ignoreStatusById: Record<JEScheduleTransactionKey, FetchStateAndError>;
|
|
44
|
-
jeScheduleAccruedKeysByPeriod: Record<MonthYearPeriodId, JEScheduleKey[]>;
|
|
45
38
|
jeScheduleLocalDataById: Record<ID, JEScheduleLocalData>;
|
|
46
39
|
jeScheduleTransactionKeysByPeriod: Record<MonthYearPeriodId, JEScheduleTransactionKey[]>;
|
|
47
|
-
newSchedule: NewJeScheduleState;
|
|
48
40
|
postStatusById: Record<ID, FetchStateAndError>;
|
|
49
41
|
refreshStatus: FetchStateAndError;
|
|
50
42
|
uiState: JESchedulesViewUIState;
|
|
51
43
|
}
|
|
52
|
-
export interface NewJeDetailLocalData {
|
|
53
|
-
amount: Amount;
|
|
54
|
-
jeLink: JETransactionLink;
|
|
55
|
-
memo: string;
|
|
56
|
-
postingDate: ZeniDate;
|
|
57
|
-
postingStatus: ScheduleJournalEntryStatusCodeType;
|
|
58
|
-
runningBalance: Amount;
|
|
59
|
-
}
|
|
60
|
-
export interface NewScheduleLocalData {
|
|
61
|
-
jeScheduleDetails: NewJeDetailLocalData[];
|
|
62
|
-
scheduleType: ScheduleTypes;
|
|
63
|
-
lastDayOfMonth?: boolean;
|
|
64
|
-
selectedAccount?: ID;
|
|
65
|
-
selectedBaseTransactionId?: ScheduleTransactionID;
|
|
66
|
-
selectedClass?: ID;
|
|
67
|
-
selectedDate?: ZeniDate;
|
|
68
|
-
selectedDayOfMonth?: ScheduleDaysOfMonth;
|
|
69
|
-
selectedJEScheduleKey?: JEScheduleTransactionKey;
|
|
70
|
-
selectedMonths?: number;
|
|
71
|
-
selectedVendor?: VendorBase;
|
|
72
|
-
}
|
|
73
|
-
export interface NewScheduleLocalDataFixedAssets extends NewScheduleLocalData {
|
|
74
|
-
assetId?: string;
|
|
75
|
-
selectedAccumulatedDepreciationCategory?: ID;
|
|
76
|
-
}
|
|
77
|
-
export interface SearchTransactionsState extends FetchStateAndError {
|
|
78
|
-
searchResults: JEScheduleTransactionKey[];
|
|
79
|
-
searchString?: string;
|
|
80
|
-
}
|
|
81
|
-
export declare const MIN_NEW_SCHEDULE_SEARCH_LENGTH = 2;
|
|
82
|
-
export interface NewJeScheduleState extends FetchStateAndError {
|
|
83
|
-
newScheduleState: {
|
|
84
|
-
fixed_assets: NewScheduleLocalDataFixedAssets;
|
|
85
|
-
prepaid_expenses: NewScheduleLocalData;
|
|
86
|
-
};
|
|
87
|
-
saveStatus: FetchStateAndError;
|
|
88
|
-
searchTransactions: SearchTransactionsState;
|
|
89
|
-
selectedDetailScheduleType?: ScheduleTypes;
|
|
90
|
-
}
|
|
91
44
|
export interface AccountSettingsLocalData {
|
|
92
45
|
previousAccruedExpensesAccount: AccountBase[];
|
|
93
46
|
previousFixedAssetsAccount: AccountBase[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.toJEScheduleMainTab = exports.toJEScheduleSortKey = void 0;
|
|
4
4
|
const stringToUnion_1 = require("../../../commonStateTypes/stringToUnion");
|
|
5
5
|
const JE_SCHEDULE_SORT_KEYS = [
|
|
6
6
|
'vendor',
|
|
@@ -20,7 +20,10 @@ const JE_SCHEDULE_SORT_KEYS = [
|
|
|
20
20
|
];
|
|
21
21
|
const toJEScheduleSortKey = (v) => (0, stringToUnion_1.stringToUnion)(v, JE_SCHEDULE_SORT_KEYS);
|
|
22
22
|
exports.toJEScheduleSortKey = toJEScheduleSortKey;
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const JE_SCHEDULE_MAIN_TABS = [
|
|
24
|
+
'pending_review',
|
|
25
|
+
'ongoing',
|
|
26
|
+
'completed',
|
|
27
|
+
];
|
|
28
|
+
const toJEScheduleMainTab = (v) => (0, stringToUnion_1.stringToUnion)(v, JE_SCHEDULE_MAIN_TABS);
|
|
29
|
+
exports.toJEScheduleMainTab = toJEScheduleMainTab;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.73",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|
package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { from } from 'rxjs';
|
|
2
|
-
import { filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { fetchAccountList } from '../../../../accountList/accountListReducer';
|
|
4
|
-
import { fetchClassList } from '../../../../classList/classListReducer';
|
|
5
|
-
import { getAccountsTypesForScheduleEpics } from '../../../../scheduleView/scheduleListView/scheduleListHelper';
|
|
6
|
-
import { clearSearchTransactionsForNewSchedule, initializeNewSchedule, resetNewScheduleLocalData, } from '../../../reducers/jeSchedulesViewReducer';
|
|
7
|
-
export const initializeNewScheduleEpic = (actions$, state$) => actions$.pipe(filter(initializeNewSchedule.match), mergeMap((action) => {
|
|
8
|
-
const newScheduleActions = [];
|
|
9
|
-
const accountType = getAccountsTypesForScheduleEpics();
|
|
10
|
-
const { accountListState, classListState } = state$.value;
|
|
11
|
-
if (accountListState.byReportId[accountType.accountListKey]?.fetchState ===
|
|
12
|
-
'Not-Started') {
|
|
13
|
-
newScheduleActions.push(fetchAccountList(accountType.accountListKey, true, false, false, false, accountType.allowedAccountList));
|
|
14
|
-
}
|
|
15
|
-
if (classListState.fetchState === 'Not-Started') {
|
|
16
|
-
newScheduleActions.push(fetchClassList());
|
|
17
|
-
}
|
|
18
|
-
newScheduleActions.push(resetNewScheduleLocalData({ scheduleType: action.payload.scheduleType }));
|
|
19
|
-
newScheduleActions.push(clearSearchTransactionsForNewSchedule());
|
|
20
|
-
return from(newScheduleActions);
|
|
21
|
-
}));
|
package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { from } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { updateJESchedules, updateJESchedulesDetails, } from '../../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
4
|
-
import { getJEScheduleTransactionKey } from '../../../../../entity/jeSchedules/jeSchedulesTypes';
|
|
5
|
-
import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
|
|
6
|
-
import { getScheduleTransactionById } from '../../../../../entity/transaction/transactionSelector';
|
|
7
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
8
|
-
import { prepareNewSchedulePayload, } from '../../../helpers/newScheduleLocalDataHelper';
|
|
9
|
-
import { resetNewScheduleLocalData, saveNewSchedule, saveNewScheduleFailure, saveNewScheduleSuccess, } from '../../../reducers/jeSchedulesViewReducer';
|
|
10
|
-
const FAILURE_REASON_MESSAGES = {
|
|
11
|
-
missing_third_party_id: 'This transaction is missing a QuickBooks reference and cannot be scheduled.',
|
|
12
|
-
missing_vendor: 'Select a vendor before saving this schedule.',
|
|
13
|
-
};
|
|
14
|
-
export const saveNewScheduleEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(saveNewSchedule.match), mergeMap((action) => {
|
|
15
|
-
const { scheduleType } = action.payload;
|
|
16
|
-
const state = state$.value;
|
|
17
|
-
const localData = state.expenseAutomationJESchedulesViewState.newSchedule
|
|
18
|
-
.newScheduleState[scheduleType];
|
|
19
|
-
const { selectedBaseTransactionId } = localData;
|
|
20
|
-
const transaction = selectedBaseTransactionId != null
|
|
21
|
-
? getScheduleTransactionById(state.transactionState, getJEScheduleTransactionKey(selectedBaseTransactionId))
|
|
22
|
-
: undefined;
|
|
23
|
-
if (transaction == null) {
|
|
24
|
-
return from([
|
|
25
|
-
saveNewScheduleFailure({
|
|
26
|
-
status: createZeniAPIStatus('Unexpected Error', 'No base transaction selected for this schedule.'),
|
|
27
|
-
}),
|
|
28
|
-
openSnackbar({
|
|
29
|
-
messageSection: 'create_schedule',
|
|
30
|
-
messageText: 'failed',
|
|
31
|
-
type: 'error',
|
|
32
|
-
variables: [
|
|
33
|
-
{
|
|
34
|
-
variableName: '_api-error_',
|
|
35
|
-
variableValue: 'No base transaction selected.',
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
}),
|
|
39
|
-
]);
|
|
40
|
-
}
|
|
41
|
-
const result = prepareNewSchedulePayload(transaction, localData, scheduleType);
|
|
42
|
-
if (!result.ok) {
|
|
43
|
-
const message = FAILURE_REASON_MESSAGES[result.reason];
|
|
44
|
-
return from([
|
|
45
|
-
saveNewScheduleFailure({
|
|
46
|
-
status: createZeniAPIStatus('Unexpected Error', message),
|
|
47
|
-
}),
|
|
48
|
-
openSnackbar({
|
|
49
|
-
messageSection: 'create_schedule',
|
|
50
|
-
messageText: 'failed',
|
|
51
|
-
type: 'error',
|
|
52
|
-
variables: [{ variableName: '_api-error_', variableValue: message }],
|
|
53
|
-
}),
|
|
54
|
-
]);
|
|
55
|
-
}
|
|
56
|
-
const vendorName = localData.selectedVendor?.name ?? transaction.vendorName ?? '';
|
|
57
|
-
const queryParam = {
|
|
58
|
-
je_schedule_type: scheduleType,
|
|
59
|
-
};
|
|
60
|
-
const payload = { ...result.payload };
|
|
61
|
-
return zeniAPI
|
|
62
|
-
.postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(queryParam))}`, payload)
|
|
63
|
-
.pipe(mergeMap((response) => {
|
|
64
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
65
|
-
return from([
|
|
66
|
-
updateJESchedules(response.data.je_schedules),
|
|
67
|
-
updateJESchedulesDetails(response.data.je_schedules, response.data.scheduled_journal_entries),
|
|
68
|
-
resetNewScheduleLocalData({ scheduleType }),
|
|
69
|
-
saveNewScheduleSuccess(),
|
|
70
|
-
openSnackbar({
|
|
71
|
-
messageSection: 'create_schedule',
|
|
72
|
-
messageText: 'success',
|
|
73
|
-
type: 'success',
|
|
74
|
-
variables: [
|
|
75
|
-
{ variableName: '_vendor_name_', variableValue: vendorName },
|
|
76
|
-
],
|
|
77
|
-
}),
|
|
78
|
-
]);
|
|
79
|
-
}
|
|
80
|
-
return from([
|
|
81
|
-
saveNewScheduleFailure({ status: response.status }),
|
|
82
|
-
openSnackbar({
|
|
83
|
-
messageSection: 'create_schedule',
|
|
84
|
-
messageText: 'failed',
|
|
85
|
-
type: 'error',
|
|
86
|
-
variables: [
|
|
87
|
-
{
|
|
88
|
-
variableName: '_api-error_',
|
|
89
|
-
variableValue: response.status.message,
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
}),
|
|
93
|
-
]);
|
|
94
|
-
}), catchError((error) => from([
|
|
95
|
-
openSnackbar({
|
|
96
|
-
messageSection: 'create_schedule',
|
|
97
|
-
messageText: 'failed',
|
|
98
|
-
type: 'error',
|
|
99
|
-
variables: [
|
|
100
|
-
{
|
|
101
|
-
variableName: '_api-error_',
|
|
102
|
-
variableValue: JSON.stringify(error),
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
}),
|
|
106
|
-
saveNewScheduleFailure({
|
|
107
|
-
status: createZeniAPIStatus('Unexpected Error', `Save New Schedule REST API call errored out ${JSON.stringify(error)}`),
|
|
108
|
-
}),
|
|
109
|
-
])));
|
|
110
|
-
}));
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { EMPTY, from, merge, of } from 'rxjs';
|
|
2
|
-
import { catchError, debounceTime, filter, mergeMap, switchMap, } from 'rxjs/operators';
|
|
3
|
-
import { getJEScheduleTransactionKey } from '../../../../../entity/jeSchedules/jeSchedulesTypes';
|
|
4
|
-
import { toTransactionType } from '../../../../../entity/transaction/stateTypes/transactionType';
|
|
5
|
-
import { updateScheduleTransactions } from '../../../../../entity/transaction/transactionReducer';
|
|
6
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
7
|
-
import { searchTransactionsForNewSchedule, searchTransactionsForNewScheduleFailure, searchTransactionsForNewScheduleSuccess, } from '../../../reducers/jeSchedulesViewReducer';
|
|
8
|
-
import { MIN_NEW_SCHEDULE_SEARCH_LENGTH } from '../../../types/jeSchedulesViewState';
|
|
9
|
-
/** Dropdown-sized result set — no pagination for Base Transaction search. */
|
|
10
|
-
const NEW_SCHEDULE_SEARCH_PAGE_SIZE = 10;
|
|
11
|
-
/** Fallback when the backend sends a null currency for a search result. */
|
|
12
|
-
const DEFAULT_CURRENCY_CODE = 'USD';
|
|
13
|
-
const DEFAULT_CURRENCY_SYMBOL = '$';
|
|
14
|
-
export const searchTransactionsForNewScheduleEpic = (actions$, _state$, zeniAPI) => {
|
|
15
|
-
const searchActions$ = actions$.pipe(filter(searchTransactionsForNewSchedule.match));
|
|
16
|
-
/** No API for empty or 1-char queries; immediate merge so switchMap cancels any in-flight HTTP. */
|
|
17
|
-
const newSearchTooShortOrClear$ = searchActions$.pipe(filter((action) => action.payload.query.trim().length < MIN_NEW_SCHEDULE_SEARCH_LENGTH));
|
|
18
|
-
const newSearchDebounced$ = searchActions$.pipe(filter((action) => action.payload.query.trim().length >= MIN_NEW_SCHEDULE_SEARCH_LENGTH), debounceTime(300));
|
|
19
|
-
return merge(newSearchTooShortOrClear$, newSearchDebounced$).pipe(switchMap((action) => {
|
|
20
|
-
const query = action.payload.query.trim();
|
|
21
|
-
if (query.length < MIN_NEW_SCHEDULE_SEARCH_LENGTH) {
|
|
22
|
-
return EMPTY;
|
|
23
|
-
}
|
|
24
|
-
const queryParam = {
|
|
25
|
-
page_size: NEW_SCHEDULE_SEARCH_PAGE_SIZE,
|
|
26
|
-
search_text: query,
|
|
27
|
-
je_schedule_type: action.payload.scheduleType,
|
|
28
|
-
};
|
|
29
|
-
return zeniAPI
|
|
30
|
-
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/base_transaction_search?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
31
|
-
.pipe(mergeMap((response) => {
|
|
32
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
33
|
-
const { transactions } = response.data;
|
|
34
|
-
const transactionsPerCurrency = {};
|
|
35
|
-
transactions.forEach((transaction) => {
|
|
36
|
-
const { currency_code, currency_symbol } = transaction;
|
|
37
|
-
const currencyCode = currency_code ?? DEFAULT_CURRENCY_CODE;
|
|
38
|
-
const existing = transactionsPerCurrency[currencyCode];
|
|
39
|
-
transactionsPerCurrency[currencyCode] =
|
|
40
|
-
existing != null
|
|
41
|
-
? {
|
|
42
|
-
currencySymbol: existing.currencySymbol,
|
|
43
|
-
transactions: [...existing.transactions, transaction],
|
|
44
|
-
}
|
|
45
|
-
: {
|
|
46
|
-
currencySymbol: currency_code == null
|
|
47
|
-
? DEFAULT_CURRENCY_SYMBOL
|
|
48
|
-
: currency_symbol,
|
|
49
|
-
transactions: [transaction],
|
|
50
|
-
};
|
|
51
|
-
});
|
|
52
|
-
const actionsOut = Object.keys(transactionsPerCurrency).map((currencyCode) => {
|
|
53
|
-
const perCurrency = transactionsPerCurrency[currencyCode];
|
|
54
|
-
return updateScheduleTransactions(perCurrency.transactions, currencyCode, perCurrency.currencySymbol, 'merge');
|
|
55
|
-
});
|
|
56
|
-
actionsOut.push(searchTransactionsForNewScheduleSuccess({
|
|
57
|
-
searchResults: transactions.map((transaction) => getJEScheduleTransactionKey({
|
|
58
|
-
id: transaction.transaction_id,
|
|
59
|
-
type: toTransactionType(transaction.transaction_type),
|
|
60
|
-
lineId: transaction.line_id,
|
|
61
|
-
})),
|
|
62
|
-
}));
|
|
63
|
-
return from(actionsOut);
|
|
64
|
-
}
|
|
65
|
-
return of(searchTransactionsForNewScheduleFailure({
|
|
66
|
-
status: response.status,
|
|
67
|
-
}));
|
|
68
|
-
}), catchError((error) => of(searchTransactionsForNewScheduleFailure({
|
|
69
|
-
status: createZeniAPIStatus('Unexpected Error', 'Search transactions for new schedule errored: ' +
|
|
70
|
-
JSON.stringify(error)),
|
|
71
|
-
}))));
|
|
72
|
-
}));
|
|
73
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { EMPTY, of } from 'rxjs';
|
|
2
|
-
import { filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { convertToPeriod, toAbsoluteDay, } from '../../../../commonStateTypes/timePeriod';
|
|
4
|
-
import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
|
|
5
|
-
import { fetchJeSchedulesPage, updateJESchedulesUIState, } from '../../reducers/jeSchedulesViewReducer';
|
|
6
|
-
export const switchJESchedulesTabEpic = (actions$, state$) => actions$.pipe(filter(updateJESchedulesUIState.match), filter((action) => action.payload.selectedPageTab != null), mergeMap(() => {
|
|
7
|
-
const state = state$.value;
|
|
8
|
-
const { fetchState, refreshStatus } = state.expenseAutomationJESchedulesViewState;
|
|
9
|
-
if (fetchState === 'In-Progress' ||
|
|
10
|
-
refreshStatus.fetchState === 'In-Progress') {
|
|
11
|
-
return EMPTY;
|
|
12
|
-
}
|
|
13
|
-
const currentTenant = getCurrentTenant(state);
|
|
14
|
-
const selectedPeriod = state.expenseAutomationViewState.selectedPeriodByTenantId[currentTenant.tenantId];
|
|
15
|
-
const period = convertToPeriod(selectedPeriod);
|
|
16
|
-
const timePeriodStart = toAbsoluteDay(period.start);
|
|
17
|
-
const timePeriodEnd = toAbsoluteDay(period.end);
|
|
18
|
-
if (timePeriodStart == null || timePeriodEnd == null) {
|
|
19
|
-
return EMPTY;
|
|
20
|
-
}
|
|
21
|
-
return of(fetchJeSchedulesPage({ start: timePeriodStart, end: timePeriodEnd }, true));
|
|
22
|
-
}));
|