@zeniai/client-epic-state 5.1.69 → 5.1.70-betaRD1
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 +2 -0
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +2 -0
- package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +4 -0
- package/lib/entity/jeSchedules/jeSchedulesSelector.js +11 -1
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +2 -0
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +2 -0
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
- package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +2 -0
- package/lib/epic.d.ts +5 -1
- package/lib/epic.js +5 -1
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +2 -0
- package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +11 -1
- package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
- package/lib/esm/epic.js +5 -1
- package/lib/esm/index.js +14 -11
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +15 -2
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +21 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +110 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +73 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +22 -0
- package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +140 -0
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +126 -6
- package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +1 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +70 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +78 -11
- package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +3 -6
- package/lib/esm/view/invoicing/couponView/couponViewEpics.js +0 -3
- package/lib/esm/view/invoicing/couponView/couponViewReducer.js +7 -1
- package/lib/esm/view/invoicing/couponView/couponViewSelector.js +27 -14
- package/lib/esm/view/invoicing/invoiceList/fetchInvoiceListEpic.js +7 -5
- package/lib/esm/view/invoicing/invoiceList/fetchInvoiceListPageEpic.js +2 -1
- package/lib/esm/view/invoicing/invoiceList/invoiceListReducer.js +62 -36
- package/lib/esm/view/invoicing/invoiceList/invoiceListSelector.js +19 -15
- package/lib/esm/view/invoicing/invoiceList/invoiceListState.js +10 -0
- package/lib/esm/view/invoicing/invoicingCreditNoteListView/epics/fetchInvoicingCreditNoteListEpic.js +0 -3
- package/lib/esm/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewReducer.js +7 -1
- package/lib/esm/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewSelector.js +23 -13
- package/lib/esm/view/invoicing/invoicingCustomerDetailView/fetchInvoicingCustomerDetailPageEpic.js +3 -2
- package/lib/esm/view/invoicing/invoicingCustomerDetailView/invoicingCustomerDetailViewSelector.js +1 -1
- package/lib/esm/view/invoicing/invoicingCustomerListView/epics/fetchInvoicingCustomerListEpic.js +0 -3
- package/lib/esm/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewReducer.js +7 -1
- package/lib/esm/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewSelector.js +25 -12
- package/lib/esm/view/invoicing/invoicingDunningCaseListView/epics/fetchInvoicingDunningCaseListEpic.js +0 -3
- package/lib/esm/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewReducer.js +7 -1
- package/lib/esm/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewSelector.js +23 -13
- package/lib/esm/view/invoicing/invoicingSubscriptionListView/epics/fetchInvoicingSubscriptionListEpic.js +0 -3
- package/lib/esm/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewReducer.js +7 -1
- package/lib/esm/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewSelector.js +22 -12
- package/lib/esm/view/invoicing/invoicingTransactionListView/epics/fetchInvoicingTransactionListEpic.js +7 -5
- package/lib/esm/view/invoicing/invoicingTransactionListView/epics/fetchInvoicingTransactionListPageEpic.js +2 -1
- package/lib/esm/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewReducer.js +56 -25
- package/lib/esm/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewSelector.js +15 -11
- package/lib/esm/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewState.js +10 -0
- package/lib/index.d.ts +16 -13
- package/lib/index.js +73 -48
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +14 -1
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +25 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts +45 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +114 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +77 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +6 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +26 -0
- package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.d.ts +36 -0
- package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +145 -0
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +1 -0
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +38 -8
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +128 -7
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +25 -0
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +2 -0
- package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +29 -4
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +10 -0
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +75 -0
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +1 -0
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +80 -11
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +52 -6
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +5 -8
- package/lib/view/invoicing/couponView/couponViewEpics.js +0 -3
- package/lib/view/invoicing/couponView/couponViewReducer.d.ts +1 -1
- package/lib/view/invoicing/couponView/couponViewReducer.js +8 -2
- package/lib/view/invoicing/couponView/couponViewSelector.d.ts +1 -0
- package/lib/view/invoicing/couponView/couponViewSelector.js +27 -14
- package/lib/view/invoicing/couponView/couponViewState.d.ts +2 -1
- package/lib/view/invoicing/invoiceList/fetchInvoiceListEpic.d.ts +1 -1
- package/lib/view/invoicing/invoiceList/fetchInvoiceListEpic.js +7 -5
- package/lib/view/invoicing/invoiceList/fetchInvoiceListPageEpic.js +2 -1
- package/lib/view/invoicing/invoiceList/invoiceListReducer.d.ts +5 -4
- package/lib/view/invoicing/invoiceList/invoiceListReducer.js +63 -37
- package/lib/view/invoicing/invoiceList/invoiceListSelector.d.ts +1 -0
- package/lib/view/invoicing/invoiceList/invoiceListSelector.js +19 -15
- package/lib/view/invoicing/invoiceList/invoiceListState.d.ts +20 -7
- package/lib/view/invoicing/invoiceList/invoiceListState.js +13 -1
- package/lib/view/invoicing/invoicingCreditNoteListView/epics/fetchInvoicingCreditNoteListEpic.js +0 -3
- package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewReducer.d.ts +1 -1
- package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewReducer.js +8 -2
- package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewSelector.d.ts +1 -0
- package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewSelector.js +23 -13
- package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewState.d.ts +2 -1
- package/lib/view/invoicing/invoicingCustomerDetailView/fetchInvoicingCustomerDetailPageEpic.js +3 -2
- package/lib/view/invoicing/invoicingCustomerDetailView/invoicingCustomerDetailViewSelector.js +1 -1
- package/lib/view/invoicing/invoicingCustomerListView/epics/fetchInvoicingCustomerListEpic.js +0 -3
- package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewReducer.d.ts +1 -1
- package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewReducer.js +8 -2
- package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewSelector.d.ts +1 -0
- package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewSelector.js +25 -12
- package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewState.d.ts +2 -1
- package/lib/view/invoicing/invoicingDunningCaseListView/epics/fetchInvoicingDunningCaseListEpic.js +0 -3
- package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewReducer.d.ts +1 -1
- package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewReducer.js +8 -2
- package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewSelector.d.ts +1 -0
- package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewSelector.js +23 -13
- package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewState.d.ts +2 -1
- package/lib/view/invoicing/invoicingSubscriptionListView/epics/fetchInvoicingSubscriptionListEpic.js +0 -3
- package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewReducer.d.ts +1 -1
- package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewReducer.js +8 -2
- package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewSelector.d.ts +1 -0
- package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewSelector.js +22 -12
- package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewState.d.ts +3 -1
- package/lib/view/invoicing/invoicingTransactionListView/epics/fetchInvoicingTransactionListEpic.d.ts +1 -1
- package/lib/view/invoicing/invoicingTransactionListView/epics/fetchInvoicingTransactionListEpic.js +7 -5
- package/lib/view/invoicing/invoicingTransactionListView/epics/fetchInvoicingTransactionListPageEpic.js +2 -1
- package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewReducer.d.ts +1 -1
- package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewReducer.js +57 -26
- package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewSelector.d.ts +1 -0
- package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewSelector.js +15 -11
- package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewState.d.ts +18 -4
- package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewState.js +13 -1
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ 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;
|
|
6
7
|
exports.getExpenseAutomationJESchedulesView = getExpenseAutomationJESchedulesView;
|
|
7
8
|
const omit_1 = __importDefault(require("lodash/omit"));
|
|
8
9
|
const orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
@@ -10,6 +11,7 @@ const reduceFetchState_1 = require("../../../commonStateTypes/reduceFetchState")
|
|
|
10
11
|
const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
|
|
11
12
|
const accountSelector_1 = require("../../../entity/account/accountSelector");
|
|
12
13
|
const jeSchedulesSelector_1 = require("../../../entity/jeSchedules/jeSchedulesSelector");
|
|
14
|
+
const jeSchedulesTypes_1 = require("../../../entity/jeSchedules/jeSchedulesTypes");
|
|
13
15
|
const tenantSelector_1 = require("../../../entity/tenant/tenantSelector");
|
|
14
16
|
const accountListSelector_1 = require("../../accountList/accountListSelector");
|
|
15
17
|
const classListSelector_1 = require("../../classList/classListSelector");
|
|
@@ -18,6 +20,21 @@ const scheduleDetailSelector_1 = require("../../scheduleView/scheduleDetailView/
|
|
|
18
20
|
const scheduleListHelper_1 = require("../../scheduleView/scheduleListView/scheduleListHelper");
|
|
19
21
|
const expenseAutomationViewSelectorTypes_1 = require("../selectorTypes/expenseAutomationViewSelectorTypes");
|
|
20
22
|
const jeAccountSettingsViewSelector_1 = require("./jeAccountSettingsViewSelector");
|
|
23
|
+
const jeNewScheduleViewSelector_1 = require("./jeNewScheduleViewSelector");
|
|
24
|
+
// Matches the AI-automation user addresses webc's schedule list row already
|
|
25
|
+
// checks (JEScheduleReadOnlyListRow/JEScheduleDraftListRow "Method" column,
|
|
26
|
+
// strings.ts aiBotEmail/botEmail) to determine whether a schedule was
|
|
27
|
+
// created by the AI accountant vs. a human.
|
|
28
|
+
const AI_BOT_EMAIL = 'ai@zeni.ai';
|
|
29
|
+
const BOT_EMAIL = 'bot@zeni.ai';
|
|
30
|
+
// Exported (rather than kept as a closure inside the selector) so it can be
|
|
31
|
+
// unit-tested directly — confidenceScore is a separate, more narrowly
|
|
32
|
+
// populated field that can be null on a schedule the bot user created,
|
|
33
|
+
// which previously caused these schedules to display as "AI Accountant" in
|
|
34
|
+
// the list but count under "Manual" in the KPI summary.
|
|
35
|
+
const isAiAccountantSchedule = (schedule) => schedule.createdByUser?.email === AI_BOT_EMAIL ||
|
|
36
|
+
schedule.createdByUser?.email === BOT_EMAIL;
|
|
37
|
+
exports.isAiAccountantSchedule = isAiAccountantSchedule;
|
|
21
38
|
function getJEScheduleSortAccessor(sortKey) {
|
|
22
39
|
switch (sortKey) {
|
|
23
40
|
case 'vendor':
|
|
@@ -59,7 +76,7 @@ function getJEScheduleSortAccessor(sortKey) {
|
|
|
59
76
|
case 'totalAmount':
|
|
60
77
|
return (s) => s.baseTransaction.amount.amount;
|
|
61
78
|
case 'transactionDate':
|
|
62
|
-
return (s) => s.
|
|
79
|
+
return (s) => s.createTime?.valueOf();
|
|
63
80
|
case 'memo':
|
|
64
81
|
return (s) => s.baseTransaction.memo?.toLowerCase();
|
|
65
82
|
default:
|
|
@@ -74,8 +91,12 @@ function getExpenseAutomationJESchedulesView(state) {
|
|
|
74
91
|
const jeScheduledTransaction = [];
|
|
75
92
|
const failedJeScheduledTransaction = [];
|
|
76
93
|
const { accountState, accountListState, classState, classListState, expenseAutomationJESchedulesViewState, expenseAutomationViewState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
|
|
77
|
-
const { jeScheduleTransactionKeysByPeriod, failedJeScheduleTransactionKeysByPeriod, jeScheduleLocalDataById, postStatusById, ignoreStatusById, uiState, error, fetchState, refreshStatus, } = expenseAutomationJESchedulesViewState;
|
|
94
|
+
const { jeScheduleTransactionKeysByPeriod, failedJeScheduleTransactionKeysByPeriod, jeScheduleLocalDataById, postStatusById, ignoreStatusById, uiState, error, fetchState, refreshStatus, newSchedule, } = expenseAutomationJESchedulesViewState;
|
|
78
95
|
const accountSettingsView = (0, jeAccountSettingsViewSelector_1.getJEAccountSettingsView)(state);
|
|
96
|
+
const newScheduleView = newSchedule.selectedDetailScheduleType === 'fixed_assets' ||
|
|
97
|
+
newSchedule.selectedDetailScheduleType === 'prepaid_expenses'
|
|
98
|
+
? (0, jeNewScheduleViewSelector_1.getNewScheduleView)(state, newSchedule.selectedDetailScheduleType)
|
|
99
|
+
: undefined;
|
|
79
100
|
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
|
|
80
101
|
const { selectedPeriodByTenantId } = expenseAutomationViewState;
|
|
81
102
|
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
@@ -119,11 +140,7 @@ function getExpenseAutomationJESchedulesView(state) {
|
|
|
119
140
|
const jeScheduleDetails = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleTransactionKey)(jeScheduleKey, state);
|
|
120
141
|
failedJeScheduledTransaction.push(jeScheduleDetails);
|
|
121
142
|
});
|
|
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);
|
|
143
|
+
const { sortKey, sortOrder, selectedJETypeFilter } = uiState;
|
|
127
144
|
const unsortedResolveSchedules = [];
|
|
128
145
|
failedJeScheduledTransaction.forEach((schedule) => {
|
|
129
146
|
schedule.scheduledJournalEntry.forEach((journalEntry) => {
|
|
@@ -136,9 +153,42 @@ function getExpenseAutomationJESchedulesView(state) {
|
|
|
136
153
|
const resolveSchedules = sortJEScheduledTransactions(unsortedResolveSchedules, sortKey, sortOrder);
|
|
137
154
|
const validResolveForPending = unsortedResolveSchedules.filter((r) => jeScheduleLocalDataById[r.scheduledJournalEntry.scheduledJournalEntryID] != null);
|
|
138
155
|
const pendingReviewSchedules = sortJEScheduledTransactions([
|
|
139
|
-
...jeScheduledTransaction.filter((schedule) => schedule.status.code === 'draft'
|
|
156
|
+
...jeScheduledTransaction.filter((schedule) => schedule.status.code === 'draft' &&
|
|
157
|
+
(selectedJETypeFilter == null ||
|
|
158
|
+
schedule.jeScheduleType === selectedJETypeFilter)),
|
|
140
159
|
...validResolveForPending,
|
|
141
160
|
], sortKey, sortOrder);
|
|
161
|
+
const createdSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => (schedule.status.code === 'ongoing' ||
|
|
162
|
+
schedule.status.code === 'completed' ||
|
|
163
|
+
schedule.status.code === 'marked_as_completed') &&
|
|
164
|
+
(selectedJETypeFilter == null ||
|
|
165
|
+
schedule.jeScheduleType === selectedJETypeFilter)), sortKey, sortOrder);
|
|
166
|
+
// KPI summary — derived from unfiltered schedules so counts are always accurate
|
|
167
|
+
const allSchedules = jeScheduledTransaction;
|
|
168
|
+
const sumAmount = (schedules) => schedules.reduce((total, schedule) => total + (schedule.baseTransaction.amount.amount ?? 0), 0);
|
|
169
|
+
const pendingReviewTotal = sumAmount(pendingReviewSchedules);
|
|
170
|
+
const createdTotal = sumAmount(createdSchedules);
|
|
171
|
+
const aiAccountantSchedules = allSchedules.filter(exports.isAiAccountantSchedule);
|
|
172
|
+
const manualSchedules = allSchedules.filter((schedule) => !(0, exports.isAiAccountantSchedule)(schedule));
|
|
173
|
+
const pendingUnfiltered = allSchedules.filter((schedule) => schedule.status.code === 'draft');
|
|
174
|
+
const kpiSummary = {
|
|
175
|
+
aiAccountant: {
|
|
176
|
+
count: aiAccountantSchedules.length,
|
|
177
|
+
amount: sumAmount(aiAccountantSchedules),
|
|
178
|
+
},
|
|
179
|
+
manual: {
|
|
180
|
+
count: manualSchedules.length,
|
|
181
|
+
amount: sumAmount(manualSchedules),
|
|
182
|
+
},
|
|
183
|
+
needsReview: {
|
|
184
|
+
count: pendingUnfiltered.length,
|
|
185
|
+
amount: sumAmount(pendingUnfiltered),
|
|
186
|
+
},
|
|
187
|
+
total: {
|
|
188
|
+
count: allSchedules.length,
|
|
189
|
+
amount: sumAmount(allSchedules),
|
|
190
|
+
},
|
|
191
|
+
};
|
|
142
192
|
const allSteps = monthYearPeriodId != null
|
|
143
193
|
? (0, expenseAutomationViewSelectorTypes_1.getAllSteps)(monthEndCloseChecksState, monthYearPeriodId, currentTenant.tenantId)
|
|
144
194
|
: [];
|
|
@@ -151,6 +201,22 @@ function getExpenseAutomationJESchedulesView(state) {
|
|
|
151
201
|
{ fetchState, error },
|
|
152
202
|
monthEndFetchState,
|
|
153
203
|
]);
|
|
204
|
+
const countByType = (schedules) => {
|
|
205
|
+
const counts = jeSchedulesTypes_1.ALL_SCHEDULES_TYPES.reduce((acc, type) => ({ ...acc, [type]: 0 }), {});
|
|
206
|
+
schedules.forEach((schedule) => {
|
|
207
|
+
if (schedule.jeScheduleType != null) {
|
|
208
|
+
counts[schedule.jeScheduleType] += 1;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
return counts;
|
|
212
|
+
};
|
|
213
|
+
const jeScheduleTypeCounts = {
|
|
214
|
+
active: countByType(allSchedules.filter((schedule) => schedule.status.code === 'draft' ||
|
|
215
|
+
schedule.status.code === 'ongoing' ||
|
|
216
|
+
schedule.status.code === 'completed' ||
|
|
217
|
+
schedule.status.code === 'marked_as_completed')),
|
|
218
|
+
ongoing: countByType(allSchedules.filter((schedule) => schedule.status.code === 'ongoing')),
|
|
219
|
+
};
|
|
154
220
|
return {
|
|
155
221
|
uncategorizedAccounts,
|
|
156
222
|
allDepreciationAccountList: filteredDepAccounts,
|
|
@@ -159,12 +225,15 @@ function getExpenseAutomationJESchedulesView(state) {
|
|
|
159
225
|
allAccountList: filteredAccounts,
|
|
160
226
|
accountListNestedAccountHierarchy,
|
|
161
227
|
allClassList: allClasses,
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
228
|
+
createdSchedules,
|
|
229
|
+
createdTotal,
|
|
230
|
+
jeScheduleTypeCounts,
|
|
231
|
+
kpiSummary,
|
|
165
232
|
pendingReviewSchedules,
|
|
233
|
+
pendingReviewTotal,
|
|
166
234
|
resolveSchedules: resolveSchedules,
|
|
167
235
|
accountSettingsView,
|
|
236
|
+
newScheduleView,
|
|
168
237
|
postStatusById: postStatusById,
|
|
169
238
|
ignoreStatusById: ignoreStatusById,
|
|
170
239
|
fetchState: reducedFetchStatus.fetchState,
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
import { NestedAccountHierarchyForReport } from '../../../commonStateTypes/accountView/nestedAccountID';
|
|
2
|
+
import { Amount } from '../../../commonStateTypes/amount';
|
|
2
3
|
import { FetchStateAndError, FetchedState, ID } from '../../../commonStateTypes/common';
|
|
3
4
|
import { Recommendation } from '../../../commonStateTypes/recommendationBase';
|
|
4
5
|
import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
|
|
5
|
-
import { MonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
|
|
6
|
+
import { MonthYearPeriodId, ScheduleDaysOfMonth } from '../../../commonStateTypes/timePeriod';
|
|
6
7
|
import { AccountBase } from '../../../entity/account/accountState';
|
|
7
|
-
import { JEScheduleTransactionKey, ScheduleTypes } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
8
|
+
import { JEScheduleTransactionKey, ScheduleJournalEntryStatusCodeType, ScheduleTransactionID, ScheduleTypes } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
8
9
|
import { VendorBase } from '../../../entity/vendor/vendorState';
|
|
9
|
-
|
|
10
|
+
import { ZeniDate } from '../../../zeniDayJS';
|
|
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";
|
|
10
13
|
export type JEScheduleSortKey = ReturnType<typeof toJEScheduleSortKey>;
|
|
11
|
-
export declare const
|
|
12
|
-
export type
|
|
14
|
+
export declare const toJEPageTab: (v: string) => "schedules" | "existing_schedules";
|
|
15
|
+
export type JEPageTab = ReturnType<typeof toJEPageTab>;
|
|
13
16
|
export interface JESchedulesViewUIState {
|
|
17
|
+
createdGroupCollapsed: boolean;
|
|
18
|
+
pendingGroupCollapsed: boolean;
|
|
14
19
|
scrollPosition: {
|
|
15
20
|
scrollTop: number;
|
|
16
21
|
scrollLeft?: number;
|
|
17
22
|
} | undefined;
|
|
18
23
|
searchString: string;
|
|
19
|
-
|
|
24
|
+
selectedJETypeFilter: ScheduleTypes | null;
|
|
25
|
+
selectedPageTab: JEPageTab;
|
|
20
26
|
sortKey: JEScheduleSortKey;
|
|
21
27
|
sortOrder: SortOrder;
|
|
22
28
|
totalCount: number;
|
|
@@ -37,10 +43,50 @@ export interface JESchedulesViewState extends FetchedState {
|
|
|
37
43
|
ignoreStatusById: Record<JEScheduleTransactionKey, FetchStateAndError>;
|
|
38
44
|
jeScheduleLocalDataById: Record<ID, JEScheduleLocalData>;
|
|
39
45
|
jeScheduleTransactionKeysByPeriod: Record<MonthYearPeriodId, JEScheduleTransactionKey[]>;
|
|
46
|
+
newSchedule: NewJeScheduleState;
|
|
40
47
|
postStatusById: Record<ID, FetchStateAndError>;
|
|
41
48
|
refreshStatus: FetchStateAndError;
|
|
42
49
|
uiState: JESchedulesViewUIState;
|
|
43
50
|
}
|
|
51
|
+
export interface NewJeDetailLocalData {
|
|
52
|
+
amount: Amount;
|
|
53
|
+
jeLink: JETransactionLink;
|
|
54
|
+
memo: string;
|
|
55
|
+
postingDate: ZeniDate;
|
|
56
|
+
postingStatus: ScheduleJournalEntryStatusCodeType;
|
|
57
|
+
runningBalance: Amount;
|
|
58
|
+
}
|
|
59
|
+
export interface NewScheduleLocalData {
|
|
60
|
+
jeScheduleDetails: NewJeDetailLocalData[];
|
|
61
|
+
scheduleType: ScheduleTypes;
|
|
62
|
+
lastDayOfMonth?: boolean;
|
|
63
|
+
selectedAccount?: ID;
|
|
64
|
+
selectedBaseTransactionId?: ScheduleTransactionID;
|
|
65
|
+
selectedClass?: ID;
|
|
66
|
+
selectedDate?: ZeniDate;
|
|
67
|
+
selectedDayOfMonth?: ScheduleDaysOfMonth;
|
|
68
|
+
selectedJEScheduleKey?: JEScheduleTransactionKey;
|
|
69
|
+
selectedMonths?: number;
|
|
70
|
+
selectedVendor?: VendorBase;
|
|
71
|
+
}
|
|
72
|
+
export interface NewScheduleLocalDataFixedAssets extends NewScheduleLocalData {
|
|
73
|
+
assetId?: string;
|
|
74
|
+
selectedAccumulatedDepreciationCategory?: ID;
|
|
75
|
+
}
|
|
76
|
+
export interface SearchTransactionsState extends FetchStateAndError {
|
|
77
|
+
searchResults: JEScheduleTransactionKey[];
|
|
78
|
+
searchString?: string;
|
|
79
|
+
}
|
|
80
|
+
export declare const MIN_NEW_SCHEDULE_SEARCH_LENGTH = 2;
|
|
81
|
+
export interface NewJeScheduleState extends FetchStateAndError {
|
|
82
|
+
newScheduleState: {
|
|
83
|
+
fixed_assets: NewScheduleLocalDataFixedAssets;
|
|
84
|
+
prepaid_expenses: NewScheduleLocalData;
|
|
85
|
+
};
|
|
86
|
+
saveStatus: FetchStateAndError;
|
|
87
|
+
searchTransactions: SearchTransactionsState;
|
|
88
|
+
selectedDetailScheduleType?: ScheduleTypes;
|
|
89
|
+
}
|
|
44
90
|
export interface AccountSettingsLocalData {
|
|
45
91
|
previousAccruedExpensesAccount: AccountBase[];
|
|
46
92
|
previousFixedAssetsAccount: AccountBase[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MIN_NEW_SCHEDULE_SEARCH_LENGTH = exports.toJEPageTab = exports.toJEScheduleSortKey = void 0;
|
|
4
4
|
const stringToUnion_1 = require("../../../commonStateTypes/stringToUnion");
|
|
5
5
|
const JE_SCHEDULE_SORT_KEYS = [
|
|
6
6
|
'vendor',
|
|
@@ -20,10 +20,7 @@ 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
|
-
|
|
27
|
-
];
|
|
28
|
-
const toJEScheduleMainTab = (v) => (0, stringToUnion_1.stringToUnion)(v, JE_SCHEDULE_MAIN_TABS);
|
|
29
|
-
exports.toJEScheduleMainTab = toJEScheduleMainTab;
|
|
23
|
+
const JE_PAGE_TABS = ['schedules', 'existing_schedules'];
|
|
24
|
+
const toJEPageTab = (v) => (0, stringToUnion_1.stringToUnion)(v, JE_PAGE_TABS);
|
|
25
|
+
exports.toJEPageTab = toJEPageTab;
|
|
26
|
+
exports.MIN_NEW_SCHEDULE_SEARCH_LENGTH = 2;
|
|
@@ -16,9 +16,6 @@ const shouldFetch = (fetchStateAndError, cacheOverride) => cacheOverride ||
|
|
|
16
16
|
fetchStateAndError.fetchState !== 'In-Progress');
|
|
17
17
|
const buildQuery = (filters, cursor, sort) => {
|
|
18
18
|
const params = new URLSearchParams();
|
|
19
|
-
if (filters.status != null && filters.status.length > 0) {
|
|
20
|
-
params.set('status', filters.status);
|
|
21
|
-
}
|
|
22
19
|
if (filters.search != null && filters.search.length > 0) {
|
|
23
20
|
params.set('search', filters.search);
|
|
24
21
|
}
|
|
@@ -27,7 +27,7 @@ export declare const fetchInvoicingCouponList: import("@reduxjs/toolkit").Action
|
|
|
27
27
|
ids: ID[];
|
|
28
28
|
keepExistingListItems: boolean;
|
|
29
29
|
nextCursor: string | null;
|
|
30
|
-
}, "invoicingCouponView/updateInvoicingCouponList">, updateInvoicingCouponListFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingCouponView/updateInvoicingCouponListFailure">, fetchInvoicingCouponCounts: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingCouponView/fetchInvoicingCouponCounts">, updateInvoicingCouponCounts: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingListCounts, "invoicingCouponView/updateInvoicingCouponCounts">, updateInvoicingCouponCountsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingCouponView/updateInvoicingCouponCountsFailure">, updateInvoicingCouponFilters: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingCouponFilters, "invoicingCouponView/updateInvoicingCouponFilters">, addInvoicingCouponToList: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
30
|
+
}, "invoicingCouponView/updateInvoicingCouponList">, updateInvoicingCouponListFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingCouponView/updateInvoicingCouponListFailure">, fetchInvoicingCouponCounts: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingCouponView/fetchInvoicingCouponCounts">, updateInvoicingCouponCounts: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingListCounts, "invoicingCouponView/updateInvoicingCouponCounts">, updateInvoicingCouponCountsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingCouponView/updateInvoicingCouponCountsFailure">, updateInvoicingCouponFilters: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingCouponFilters, "invoicingCouponView/updateInvoicingCouponFilters">, setInvoicingCouponActiveTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<"active" | "inactive" | "all", "invoicingCouponView/setInvoicingCouponActiveTab">, addInvoicingCouponToList: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
31
31
|
id: ID;
|
|
32
32
|
status?: InvoicingCouponStatus;
|
|
33
33
|
}, "invoicingCouponView/addInvoicingCouponToList">, clearInvoicingCouponView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingCouponView/clearInvoicingCouponView">;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.clearInvoicingCouponView = exports.addInvoicingCouponToList = exports.updateInvoicingCouponFilters = exports.updateInvoicingCouponCountsFailure = exports.updateInvoicingCouponCounts = exports.fetchInvoicingCouponCounts = exports.updateInvoicingCouponListFailure = exports.updateInvoicingCouponList = exports.fetchInvoicingCouponListPage = exports.fetchInvoicingCouponList = exports.initialState = void 0;
|
|
4
|
+
exports.clearInvoicingCouponView = exports.addInvoicingCouponToList = exports.setInvoicingCouponActiveTab = exports.updateInvoicingCouponFilters = exports.updateInvoicingCouponCountsFailure = exports.updateInvoicingCouponCounts = exports.fetchInvoicingCouponCounts = exports.updateInvoicingCouponListFailure = exports.updateInvoicingCouponList = exports.fetchInvoicingCouponListPage = exports.fetchInvoicingCouponList = exports.initialState = void 0;
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
6
|
// The discounts-list tabs look up counts by tab id ('active' / 'inactive'),
|
|
7
7
|
// while a coupon's status is 'active' | 'expired' | 'archived'. Collapse the
|
|
@@ -13,6 +13,7 @@ function couponStatusToTabCountKey(status) {
|
|
|
13
13
|
exports.initialState = {
|
|
14
14
|
fetchState: 'Not-Started',
|
|
15
15
|
error: undefined,
|
|
16
|
+
activeTab: 'all',
|
|
16
17
|
ids: [],
|
|
17
18
|
nextCursor: null,
|
|
18
19
|
filters: {},
|
|
@@ -91,6 +92,11 @@ const couponView = (0, toolkit_1.createSlice)({
|
|
|
91
92
|
updateInvoicingCouponFilters(draft, action) {
|
|
92
93
|
draft.filters = action.payload;
|
|
93
94
|
},
|
|
95
|
+
// Select a status tab. The list API ignores `status` (returns all statuses),
|
|
96
|
+
// so the selector filters rows to this tab client-side — no refetch needed.
|
|
97
|
+
setInvoicingCouponActiveTab(draft, action) {
|
|
98
|
+
draft.activeTab = action.payload;
|
|
99
|
+
},
|
|
94
100
|
// Reflect a newly created coupon in the cached discounts list + tab counts
|
|
95
101
|
// so the list page shows it without refetching from the server. Edits keep
|
|
96
102
|
// the same id/counts, so only creates dispatch this.
|
|
@@ -109,5 +115,5 @@ const couponView = (0, toolkit_1.createSlice)({
|
|
|
109
115
|
},
|
|
110
116
|
},
|
|
111
117
|
});
|
|
112
|
-
_a = couponView.actions, exports.fetchInvoicingCouponList = _a.fetchInvoicingCouponList, exports.fetchInvoicingCouponListPage = _a.fetchInvoicingCouponListPage, exports.updateInvoicingCouponList = _a.updateInvoicingCouponList, exports.updateInvoicingCouponListFailure = _a.updateInvoicingCouponListFailure, exports.fetchInvoicingCouponCounts = _a.fetchInvoicingCouponCounts, exports.updateInvoicingCouponCounts = _a.updateInvoicingCouponCounts, exports.updateInvoicingCouponCountsFailure = _a.updateInvoicingCouponCountsFailure, exports.updateInvoicingCouponFilters = _a.updateInvoicingCouponFilters, exports.addInvoicingCouponToList = _a.addInvoicingCouponToList, exports.clearInvoicingCouponView = _a.clearInvoicingCouponView;
|
|
118
|
+
_a = couponView.actions, exports.fetchInvoicingCouponList = _a.fetchInvoicingCouponList, exports.fetchInvoicingCouponListPage = _a.fetchInvoicingCouponListPage, exports.updateInvoicingCouponList = _a.updateInvoicingCouponList, exports.updateInvoicingCouponListFailure = _a.updateInvoicingCouponListFailure, exports.fetchInvoicingCouponCounts = _a.fetchInvoicingCouponCounts, exports.updateInvoicingCouponCounts = _a.updateInvoicingCouponCounts, exports.updateInvoicingCouponCountsFailure = _a.updateInvoicingCouponCountsFailure, exports.updateInvoicingCouponFilters = _a.updateInvoicingCouponFilters, exports.setInvoicingCouponActiveTab = _a.setInvoicingCouponActiveTab, exports.addInvoicingCouponToList = _a.addInvoicingCouponToList, exports.clearInvoicingCouponView = _a.clearInvoicingCouponView;
|
|
113
119
|
exports.default = couponView.reducer;
|
|
@@ -12,6 +12,7 @@ export declare const getInvoicingCouponListHasMore: (state: RootState) => boolea
|
|
|
12
12
|
export declare const getInvoicingCouponListFilters: (state: RootState) => InvoicingCouponFilters;
|
|
13
13
|
export declare const getInvoicingCouponCounts: (state: RootState) => InvoicingListCounts;
|
|
14
14
|
export interface InvoicingCouponListView extends SelectorView {
|
|
15
|
+
activeTab: InvoicingCouponTabId;
|
|
15
16
|
columns: InvoicingCouponColumnConfig[];
|
|
16
17
|
count: InvoicingListCounts;
|
|
17
18
|
countsFetchState: FetchStateAndError;
|
|
@@ -26,18 +26,31 @@ exports.getInvoicingCouponCounts = getInvoicingCouponCounts;
|
|
|
26
26
|
* array (and the wrapping view object) keep referential identity until the
|
|
27
27
|
* coupon entity slice or the list-view slice actually change.
|
|
28
28
|
*/
|
|
29
|
-
exports.getInvoicingCouponListView = (0, toolkit_1.createSelector)((state) => state.invoicingCouponState, (state) => state.invoicingCouponViewState, (couponState, listViewState) =>
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
exports.getInvoicingCouponListView = (0, toolkit_1.createSelector)((state) => state.invoicingCouponState, (state) => state.invoicingCouponViewState, (couponState, listViewState) => {
|
|
30
|
+
const { activeTab } = listViewState;
|
|
31
|
+
const allCoupons = listViewState.ids
|
|
32
32
|
.map((id) => couponState.couponByID[id])
|
|
33
|
-
.filter((item) => item != null)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
.filter((item) => item != null);
|
|
34
|
+
// The list API ignores `status`, so it returns every status; filter to the
|
|
35
|
+
// active tab client-side. 'all' shows everything, 'active' shows only active
|
|
36
|
+
// coupons, and 'inactive' shows every non-active status (undefined included).
|
|
37
|
+
const coupons = activeTab === 'all'
|
|
38
|
+
? allCoupons
|
|
39
|
+
: allCoupons.filter((coupon) => activeTab === 'active'
|
|
40
|
+
? coupon.status === 'active'
|
|
41
|
+
: coupon.status !== 'active');
|
|
42
|
+
return {
|
|
43
|
+
activeTab,
|
|
44
|
+
columns: couponViewState_1.INVOICING_COUPON_COLUMNS,
|
|
45
|
+
coupons,
|
|
46
|
+
count: listViewState.counts,
|
|
47
|
+
countsFetchState: listViewState.countsFetchState,
|
|
48
|
+
filters: listViewState.filters,
|
|
49
|
+
nextCursor: listViewState.nextCursor,
|
|
50
|
+
tabIds: couponViewState_1.INVOICING_COUPON_TABS,
|
|
51
|
+
fetchState: listViewState.fetchState,
|
|
52
|
+
error: listViewState.error,
|
|
53
|
+
sort: listViewState.sort,
|
|
54
|
+
version: 1.0,
|
|
55
|
+
};
|
|
56
|
+
});
|
|
@@ -3,7 +3,6 @@ import { InvoicingListCounts } from '../../../entity/invoicing/invoicingCommonPa
|
|
|
3
3
|
import { InvoicingListSort } from '../invoicingApiHelper';
|
|
4
4
|
export interface InvoicingCouponFilters {
|
|
5
5
|
search?: string;
|
|
6
|
-
status?: string;
|
|
7
6
|
}
|
|
8
7
|
export declare const ALL_INVOICING_COUPON_SORT_KEYS: readonly ["coupon_id", "name", "discount", "duration", "created", "valid_till", "apply_on", "status", "redemptions"];
|
|
9
8
|
export declare const toInvoicingCouponSortKey: (v: string) => "status" | "name" | "redemptions" | "created" | "coupon_id" | "discount" | "duration" | "valid_till" | "apply_on";
|
|
@@ -31,6 +30,8 @@ export type InvoicingCouponTabId = ReturnType<typeof toInvoicingCouponTabId>;
|
|
|
31
30
|
*/
|
|
32
31
|
export declare const INVOICING_COUPON_TABS: InvoicingCouponTabId[];
|
|
33
32
|
export interface InvoicingCouponViewState extends FetchedState {
|
|
33
|
+
/** Selected status tab (CES-owned so it persists across page revisits). */
|
|
34
|
+
activeTab: InvoicingCouponTabId;
|
|
34
35
|
counts: InvoicingListCounts;
|
|
35
36
|
countsFetchState: FetchStateAndError;
|
|
36
37
|
filters: InvoicingCouponFilters;
|
|
@@ -6,4 +6,4 @@ import { RootState } from '../../../reducer';
|
|
|
6
6
|
import { ZeniAPI } from '../../../zeniAPI';
|
|
7
7
|
import { fetchInvoiceList, updateInvoiceList, updateInvoiceListFailure, updateInvoiceListFilters } from './invoiceListReducer';
|
|
8
8
|
export type ActionType = ReturnType<typeof fetchInvoiceList> | ReturnType<typeof updateInvoiceList> | ReturnType<typeof updateInvoiceListFailure> | ReturnType<typeof updateInvoiceListFilters> | ReturnType<typeof updateAddresses> | ReturnType<typeof updateInvoices>;
|
|
9
|
-
export declare const fetchInvoiceListEpic: (actions$: ActionsObservable<ActionType>,
|
|
9
|
+
export declare const fetchInvoiceListEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -9,10 +9,10 @@ const invoiceReducer_1 = require("../../../entity/invoicing/invoice/invoiceReduc
|
|
|
9
9
|
const responsePayload_1 = require("../../../responsePayload");
|
|
10
10
|
const invoicingApiHelper_1 = require("../invoicingApiHelper");
|
|
11
11
|
const invoiceListReducer_1 = require("./invoiceListReducer");
|
|
12
|
-
const buildInvoiceListQuery = (filters, cursor, sort) => {
|
|
12
|
+
const buildInvoiceListQuery = (filters, status, cursor, sort) => {
|
|
13
13
|
const params = new URLSearchParams();
|
|
14
|
-
if (
|
|
15
|
-
params.set('status',
|
|
14
|
+
if (status != null && status.length > 0) {
|
|
15
|
+
params.set('status', status);
|
|
16
16
|
}
|
|
17
17
|
if (filters.customerId != null) {
|
|
18
18
|
params.set('customer_id', filters.customerId);
|
|
@@ -36,9 +36,11 @@ const buildInvoiceListQuery = (filters, cursor, sort) => {
|
|
|
36
36
|
(0, invoicingApiHelper_1.applyListSortParams)(params, sort);
|
|
37
37
|
return params;
|
|
38
38
|
};
|
|
39
|
-
const fetchInvoiceListEpic = (actions$,
|
|
39
|
+
const fetchInvoiceListEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(invoiceListReducer_1.fetchInvoiceList.match), (0, operators_1.switchMap)((action) => {
|
|
40
40
|
const { filters, cursor, keepExistingListItems, sort } = action.payload;
|
|
41
|
-
const
|
|
41
|
+
const { activeTab } = state$.value.invoicingInvoiceListState;
|
|
42
|
+
const status = activeTab !== 'all' ? activeTab : undefined;
|
|
43
|
+
const apiUrl = (0, invoicingApiHelper_1.withQuery)(`${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/invoices`, buildInvoiceListQuery(filters, status, cursor, sort));
|
|
42
44
|
return zeniAPI.getJSON(apiUrl).pipe((0, operators_1.switchMap)((response) => {
|
|
43
45
|
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
44
46
|
const items = response.data?.items ?? [];
|
|
@@ -19,8 +19,9 @@ const shouldFetch = (fetchStateAndError, cacheOverride) => cacheOverride ||
|
|
|
19
19
|
const fetchInvoiceListPageEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(invoiceListReducer_1.fetchInvoiceListPage.match), (0, operators_1.mergeMap)((action) => {
|
|
20
20
|
const { cacheOverride, filters, sort } = action.payload;
|
|
21
21
|
const state = state$.value.invoicingInvoiceListState;
|
|
22
|
+
const activeTabState = state.invoiceByTab[state.activeTab];
|
|
22
23
|
const pageActions = [];
|
|
23
|
-
if (shouldFetch({ fetchState:
|
|
24
|
+
if (shouldFetch({ fetchState: activeTabState.fetchState, error: activeTabState.error }, cacheOverride)) {
|
|
24
25
|
pageActions.push((0, invoiceListReducer_1.fetchInvoiceList)({ filters, sort }));
|
|
25
26
|
}
|
|
26
27
|
if (shouldFetch(state.countsFetchState, cacheOverride)) {
|
|
@@ -6,9 +6,10 @@ import { ZeniAPIStatus } from '../../../responsePayload';
|
|
|
6
6
|
import { InvoicingListSort } from '../invoicingApiHelper';
|
|
7
7
|
import { InvoiceListFilters, InvoiceListState } from './invoiceListState';
|
|
8
8
|
/**
|
|
9
|
-
* Whether two invoice-list queries
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Whether two invoice-list queries share the same base (tab-independent) query.
|
|
10
|
+
* The status tab is server-side per-tab, so it is excluded here — when the base
|
|
11
|
+
* query changes (search / customer / subscription / dates / sort) every per-tab
|
|
12
|
+
* cache is stale and the reducer resets them all.
|
|
12
13
|
*/
|
|
13
14
|
export declare const sameInvoiceListQuery: (a: {
|
|
14
15
|
filters: InvoiceListFilters;
|
|
@@ -40,7 +41,7 @@ export declare const fetchInvoiceList: import("@reduxjs/toolkit").ActionCreatorW
|
|
|
40
41
|
invoices: InvoicingInvoicePayload[];
|
|
41
42
|
keepExistingListItems: boolean;
|
|
42
43
|
nextCursor: string | null;
|
|
43
|
-
}, "invoicingInvoiceList/updateInvoiceList">, updateInvoiceListFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingInvoiceList/updateInvoiceListFailure">, fetchInvoiceCounts: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingInvoiceList/fetchInvoiceCounts">, updateInvoiceCounts: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingListCounts, "invoicingInvoiceList/updateInvoiceCounts">, updateInvoiceCountsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingInvoiceList/updateInvoiceCountsFailure">, fetchInvoiceKPIs: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingInvoiceList/fetchInvoiceKPIs">, updateInvoiceKPIs: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingInvoiceKPIs, "invoicingInvoiceList/updateInvoiceKPIs">, updateInvoiceKPIsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingInvoiceList/updateInvoiceKPIsFailure">, updateInvoiceListFilters: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoiceListFilters, "invoicingInvoiceList/updateInvoiceListFilters">, addInvoiceToList: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
44
|
+
}, "invoicingInvoiceList/updateInvoiceList">, updateInvoiceListFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingInvoiceList/updateInvoiceListFailure">, fetchInvoiceCounts: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingInvoiceList/fetchInvoiceCounts">, updateInvoiceCounts: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingListCounts, "invoicingInvoiceList/updateInvoiceCounts">, updateInvoiceCountsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingInvoiceList/updateInvoiceCountsFailure">, fetchInvoiceKPIs: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingInvoiceList/fetchInvoiceKPIs">, updateInvoiceKPIs: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingInvoiceKPIs, "invoicingInvoiceList/updateInvoiceKPIs">, updateInvoiceKPIsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingInvoiceList/updateInvoiceKPIsFailure">, updateInvoiceListFilters: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoiceListFilters, "invoicingInvoiceList/updateInvoiceListFilters">, setInvoiceActiveTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<"paid" | "voided" | "partially_paid" | "payment_due" | "not_paid" | "all", "invoicingInvoiceList/setInvoiceActiveTab">, addInvoiceToList: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
44
45
|
id: ID;
|
|
45
46
|
status: InvoicingInvoiceStatus;
|
|
46
47
|
}, "invoicingInvoiceList/addInvoiceToList">, clearInvoiceList: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingInvoiceList/clearInvoiceList">;
|