@zeniai/client-epic-state 5.1.91 → 5.1.92-betaRD0
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/aiCfo/aiCfoState.d.ts +2 -2
- package/lib/entity/jeSchedules/jeScheduleHelper.d.ts +2 -0
- package/lib/entity/jeSchedules/jeScheduleHelper.js +7 -0
- package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +66 -1
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +135 -0
- package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +4 -2
- package/lib/entity/jeSchedules/jeSchedulesReducer.js +24 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +11 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.js +34 -3
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +79 -1
- package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +24 -1
- package/lib/entity/jeSchedules/jeSchedulesTypes.js +88 -1
- package/lib/entity/snackbar/snackbarApiError.d.ts +8 -0
- package/lib/entity/snackbar/snackbarApiError.js +15 -0
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +1 -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 +8 -1
- package/lib/epic.js +8 -1
- package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +6 -0
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +135 -1
- package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +24 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +32 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +78 -0
- package/lib/esm/entity/snackbar/snackbarApiError.js +11 -0
- package/lib/esm/entity/snackbar/snackbarTypes.js +1 -0
- package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
- package/lib/esm/epic.js +8 -1
- package/lib/esm/index.js +13 -7
- package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +41 -5
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +81 -0
- 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/oneTimeAccrualActionsEpic.js +129 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +92 -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/payload/jeSchedulesPayload.js +55 -0
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +268 -29
- package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +1 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +106 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +286 -22
- package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +5 -6
- package/lib/esm/view/invoicing/createCreditNote/createCreditNoteEpic.js +2 -0
- package/lib/esm/view/invoicing/createInvoice/createInvoiceEpic.js +2 -0
- package/lib/esm/view/invoicing/discountAction/discountActionEpic.js +6 -3
- package/lib/esm/view/invoicing/dunningAction/dunningActionEpic.js +6 -3
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +5 -4
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +3 -0
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +2 -0
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +2 -0
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +2 -0
- package/lib/esm/view/invoicing/invoiceAction/invoiceActionEpic.js +7 -3
- package/lib/esm/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.js +2 -0
- package/lib/esm/view/invoicing/invoicingQboView/epics/startInvoicingQboBackfillEpic.js +2 -0
- package/lib/esm/view/invoicing/issueCreditNote/issueCreditNoteEpic.js +2 -0
- package/lib/esm/view/invoicing/recordPayment/recordPaymentEpic.js +3 -0
- package/lib/esm/view/invoicing/settingsView/settingsViewEpics.js +6 -3
- package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +52 -0
- package/lib/esm/view/invoicing/subscriptionAction/subscriptionActionEpic.js +6 -3
- package/lib/esm/view/vendorTabView/vendorTabViewReducer.js +1 -1
- package/lib/index.d.ts +18 -14
- package/lib/index.js +92 -49
- package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +3 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +38 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +85 -0
- 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/oneTimeAccrualActionsEpic.d.ts +12 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +136 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.d.ts +65 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +96 -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/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +72 -3
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.js +58 -1
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +79 -11
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +270 -29
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -1
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +2 -2
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +42 -0
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +2 -0
- package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +34 -8
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +21 -0
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +112 -0
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +31 -1
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +294 -21
- package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +81 -8
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -8
- package/lib/view/invoicing/createCreditNote/createCreditNoteEpic.js +2 -0
- package/lib/view/invoicing/createInvoice/createInvoiceEpic.js +2 -0
- package/lib/view/invoicing/discountAction/discountActionEpic.js +5 -2
- package/lib/view/invoicing/dunningAction/dunningActionEpic.js +5 -2
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +5 -4
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +3 -0
- package/lib/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +2 -0
- package/lib/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +2 -0
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +2 -0
- package/lib/view/invoicing/invoiceAction/invoiceActionEpic.js +6 -2
- package/lib/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.js +2 -0
- package/lib/view/invoicing/invoicingQboView/epics/startInvoicingQboBackfillEpic.js +2 -0
- package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewReducer.d.ts +1 -1
- package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewState.d.ts +1 -1
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteEpic.js +2 -0
- package/lib/view/invoicing/recordPayment/recordPaymentEpic.js +3 -0
- package/lib/view/invoicing/settingsView/settingsViewEpics.js +5 -2
- package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +41 -1
- package/lib/view/invoicing/settingsView/settingsViewSelector.js +55 -1
- package/lib/view/invoicing/subscriptionAction/subscriptionActionEpic.js +5 -2
- package/package.json +1 -1
|
@@ -3,7 +3,9 @@ import orderBy from 'lodash/orderBy';
|
|
|
3
3
|
import { reduceAnyFetchState } from '../../../commonStateTypes/reduceFetchState';
|
|
4
4
|
import { LAST_SCHEDULE_DAY_OF_MONTH, toMonthYearPeriodId, } from '../../../commonStateTypes/timePeriod';
|
|
5
5
|
import { getAccountIdsForTypes } from '../../../entity/account/accountSelector';
|
|
6
|
-
import {
|
|
6
|
+
import { generateJEOneTimeAccrualKey } from '../../../entity/jeSchedules/jeScheduleHelper';
|
|
7
|
+
import { getJEAccruedScheduleByJEScheduleKey, getJEOneTimeAccrualByKey, getJEScheduledTransactionByJEScheduleTransactionKey, } from '../../../entity/jeSchedules/jeSchedulesSelector';
|
|
8
|
+
import { ALL_SCHEDULES_TYPES, } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
7
9
|
import { getCurrentTenant } from '../../../entity/tenant/tenantSelector';
|
|
8
10
|
import { getAccountIdsForLabel, getAccountList, getNestedAccountListHierarchy, getUncategorizedAccounts, } from '../../accountList/accountListSelector';
|
|
9
11
|
import { getClassList, getNestedClassListHierarchy, } from '../../classList/classListSelector';
|
|
@@ -11,8 +13,126 @@ import { getAccountsTypesForScheduleDetails } from '../../scheduleView/scheduleD
|
|
|
11
13
|
import { filterNestedAccountHierarchyById } from '../../scheduleView/scheduleDetailView/scheduleDetailSelector';
|
|
12
14
|
import { getAccountLabelForScheduleType, getAccountsTypesForScheduleList, } from '../../scheduleView/scheduleListView/scheduleListHelper';
|
|
13
15
|
import { getAllSteps } from '../selectorTypes/expenseAutomationViewSelectorTypes';
|
|
16
|
+
import { ALL_JE_PAGE_TABS, getJESchedulePeriodTabKey, } from '../types/jeSchedulesViewState';
|
|
14
17
|
import { getJEAccountSettingsView } from './jeAccountSettingsViewSelector';
|
|
18
|
+
import { getNewScheduleView } from './jeNewScheduleViewSelector';
|
|
19
|
+
// Matches the AI-automation user addresses webc's schedule list row already
|
|
20
|
+
// checks (JEScheduleReadOnlyListRow/JEScheduleDraftListRow "Method" column,
|
|
21
|
+
// strings.ts aiBotEmail/botEmail) to determine whether a schedule was
|
|
22
|
+
// created by the AI accountant vs. a human.
|
|
23
|
+
const AI_BOT_EMAIL = 'ai@zeni.ai';
|
|
24
|
+
const BOT_EMAIL = 'bot@zeni.ai';
|
|
25
|
+
// A one-time accrual has no jeScheduleType of its own — it is not a JE schedule. It is still an
|
|
26
|
+
// accrued expense, so it counts and filters under that type on the page's type tabs.
|
|
27
|
+
const ONE_TIME_ACCRUAL_SCHEDULE_TYPE = 'accrued_expenses';
|
|
28
|
+
// Which of the two list buckets an accrual belongs in. `draft` still needs a human to post it;
|
|
29
|
+
// everything else is already on the books or in a transient claim.
|
|
30
|
+
const ONE_TIME_ACCRUAL_REVIEW_STATUSES = [
|
|
31
|
+
'draft',
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* `posting_blocked` is written by the posting Cron when a JE fails to post. It is an internal
|
|
35
|
+
* failure state with no human action attached, so it is dropped here rather than hidden at render
|
|
36
|
+
* time — filtering in the view would leave the group counts and KPI totals counting rows nobody
|
|
37
|
+
* can see. The expense-automation endpoint applies no status filter on the close-period path, so
|
|
38
|
+
* these rows do arrive.
|
|
39
|
+
*/
|
|
40
|
+
export function isRenderableOneTimeAccrual(accrual) {
|
|
41
|
+
return accrual.accrualStatus !== 'posting_blocked';
|
|
42
|
+
}
|
|
43
|
+
export function getJEScheduleRowType(schedule) {
|
|
44
|
+
return isOneTimeAccrualRow(schedule)
|
|
45
|
+
? ONE_TIME_ACCRUAL_SCHEDULE_TYPE
|
|
46
|
+
: schedule.jeScheduleType;
|
|
47
|
+
}
|
|
48
|
+
export function isPendingReviewRow(schedule) {
|
|
49
|
+
return isOneTimeAccrualRow(schedule)
|
|
50
|
+
? ONE_TIME_ACCRUAL_REVIEW_STATUSES.includes(schedule.accrualStatus)
|
|
51
|
+
: schedule.status.code === 'draft';
|
|
52
|
+
}
|
|
53
|
+
// Belongs on the Existing Schedules tab. For an accrual the endpoint has already filtered to
|
|
54
|
+
// posted, so this only has to agree with that rather than re-derive it.
|
|
55
|
+
export function isExistingTabRow(schedule) {
|
|
56
|
+
return isOneTimeAccrualRow(schedule)
|
|
57
|
+
? schedule.accrualStatus === 'posted'
|
|
58
|
+
: schedule.status.code === 'ongoing';
|
|
59
|
+
}
|
|
60
|
+
// Exported (rather than kept as a closure inside the selector) so it can be
|
|
61
|
+
// unit-tested directly — confidenceScore is a separate, more narrowly
|
|
62
|
+
// populated field that can be null on a schedule the bot user created,
|
|
63
|
+
// which previously caused these schedules to display as "AI Accountant" in
|
|
64
|
+
// the list but count under "Manual" in the KPI summary.
|
|
65
|
+
export const isAiAccountantSchedule = (schedule) => {
|
|
66
|
+
// A one-time accrual records who made it as `origin`, which is authoritative — no email
|
|
67
|
+
// sniffing needed, and the JE bot is often absent from the user entity entirely.
|
|
68
|
+
if (isOneTimeAccrualRow(schedule)) {
|
|
69
|
+
return schedule.origin === 'agent';
|
|
70
|
+
}
|
|
71
|
+
return (schedule.createdByUser?.email === AI_BOT_EMAIL ||
|
|
72
|
+
schedule.createdByUser?.email === BOT_EMAIL);
|
|
73
|
+
};
|
|
74
|
+
// Accrued schedules are structurally distinct — no baseTransaction, carrying recurringAmount and
|
|
75
|
+
// memo in its place — so anything reading baseTransaction has to branch on this first.
|
|
76
|
+
//
|
|
77
|
+
// Discriminates on jeAccruedScheduleKey, which only JEAccruedSchedule carries. jeScheduleType
|
|
78
|
+
// cannot be used: it is a data field present on BOTH row shapes, so an accrued-typed row that
|
|
79
|
+
// arrived through the prepaid/fixed DTO (failed_je_postings, legacy fetches) would be
|
|
80
|
+
// misclassified and then crash on recurringAmount / jeAccruedScheduleKey.
|
|
81
|
+
export function isAccruedScheduleRow(schedule) {
|
|
82
|
+
return 'jeAccruedScheduleKey' in schedule;
|
|
83
|
+
}
|
|
84
|
+
// Same structural approach as isAccruedScheduleRow, and for the same reason: jeOneTimeAccrualKey
|
|
85
|
+
// exists only on this shape. Note the two guards are NOT interchangeable — a one-time accrual is
|
|
86
|
+
// not an accrued *schedule*, and routing it into the accrued branch would read recurringAmount,
|
|
87
|
+
// render postedCount/lifecycleTotal as a lifecycle and startDate–endDate as a period, none of
|
|
88
|
+
// which it has.
|
|
89
|
+
export function isOneTimeAccrualRow(schedule) {
|
|
90
|
+
return 'jeOneTimeAccrualKey' in schedule;
|
|
91
|
+
}
|
|
92
|
+
function getScheduleAmount(schedule) {
|
|
93
|
+
if (isOneTimeAccrualRow(schedule)) {
|
|
94
|
+
return schedule.estimatedAmount.amount;
|
|
95
|
+
}
|
|
96
|
+
if (isAccruedScheduleRow(schedule)) {
|
|
97
|
+
return schedule.recurringAmount.amount;
|
|
98
|
+
}
|
|
99
|
+
return schedule.baseTransaction.amount.amount;
|
|
100
|
+
}
|
|
101
|
+
// A one-time accrual shares almost no sortable field with a schedule, so it gets its own accessor
|
|
102
|
+
// rather than a guard on each of the dozen cases below. Keys with no meaning for a single-month
|
|
103
|
+
// accrual -- amortizationPeriod, remainingMonths, runningBalance, jePostingDate, scheduleCategory --
|
|
104
|
+
// deliberately fall through to undefined, which sorts them together at one end.
|
|
105
|
+
function getOneTimeAccrualSortValue(accrual, sortKey) {
|
|
106
|
+
switch (sortKey) {
|
|
107
|
+
case 'vendor':
|
|
108
|
+
return accrual.vendorName.toLowerCase();
|
|
109
|
+
case 'category':
|
|
110
|
+
return accrual.jeDebitAccountName?.toLowerCase();
|
|
111
|
+
case 'class':
|
|
112
|
+
return accrual.jeDebitAccountingClassName?.toLowerCase();
|
|
113
|
+
case 'depCategory':
|
|
114
|
+
return accrual.jeCreditAccountName?.toLowerCase();
|
|
115
|
+
case 'type':
|
|
116
|
+
return ONE_TIME_ACCRUAL_SCHEDULE_TYPE;
|
|
117
|
+
case 'totalAmount':
|
|
118
|
+
return accrual.estimatedAmount.amount;
|
|
119
|
+
case 'transactionDate':
|
|
120
|
+
return accrual.postingDate?.valueOf();
|
|
121
|
+
case 'memo':
|
|
122
|
+
return accrual.memo.toLowerCase();
|
|
123
|
+
case 'startMonth':
|
|
124
|
+
return accrual.serviceMonth;
|
|
125
|
+
default:
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
15
129
|
function getJEScheduleSortAccessor(sortKey) {
|
|
130
|
+
const scheduleAccessor = getScheduleRowSortAccessor(sortKey);
|
|
131
|
+
return (schedule) => isOneTimeAccrualRow(schedule)
|
|
132
|
+
? getOneTimeAccrualSortValue(schedule, sortKey)
|
|
133
|
+
: scheduleAccessor(schedule);
|
|
134
|
+
}
|
|
135
|
+
function getScheduleRowSortAccessor(sortKey) {
|
|
16
136
|
switch (sortKey) {
|
|
17
137
|
case 'vendor':
|
|
18
138
|
return (s) => s.vendor.name?.toLowerCase();
|
|
@@ -23,7 +143,9 @@ function getJEScheduleSortAccessor(sortKey) {
|
|
|
23
143
|
case 'depCategory':
|
|
24
144
|
return (s) => s.jeCredit.account?.accountName?.toLowerCase();
|
|
25
145
|
case 'scheduleCategory':
|
|
26
|
-
return (s) => s
|
|
146
|
+
return (s) => isAccruedScheduleRow(s)
|
|
147
|
+
? undefined
|
|
148
|
+
: s.baseTransaction.account?.accountName?.toLowerCase();
|
|
27
149
|
case 'startMonth':
|
|
28
150
|
return (s) => s.startDate?.valueOf();
|
|
29
151
|
case 'type':
|
|
@@ -51,11 +173,13 @@ function getJEScheduleSortAccessor(sortKey) {
|
|
|
51
173
|
return s.balanceAsOfToday?.amount ?? null;
|
|
52
174
|
};
|
|
53
175
|
case 'totalAmount':
|
|
54
|
-
return (s) => s
|
|
176
|
+
return (s) => getScheduleAmount(s);
|
|
55
177
|
case 'transactionDate':
|
|
56
|
-
return (s) => s.
|
|
178
|
+
return (s) => s.createTime?.valueOf();
|
|
57
179
|
case 'memo':
|
|
58
|
-
return (s) => s
|
|
180
|
+
return (s) => isAccruedScheduleRow(s)
|
|
181
|
+
? s.memo.toLowerCase()
|
|
182
|
+
: s.baseTransaction.memo?.toLowerCase();
|
|
59
183
|
default:
|
|
60
184
|
return (s) => s.startDate?.valueOf();
|
|
61
185
|
}
|
|
@@ -67,9 +191,15 @@ function sortJEScheduledTransactions(transactions, sortKey, sortOrder) {
|
|
|
67
191
|
export function getExpenseAutomationJESchedulesView(state) {
|
|
68
192
|
const jeScheduledTransaction = [];
|
|
69
193
|
const failedJeScheduledTransaction = [];
|
|
194
|
+
const accruedSchedules = [];
|
|
195
|
+
const oneTimeAccruals = [];
|
|
70
196
|
const { accountState, accountListState, classState, classListState, expenseAutomationJESchedulesViewState, expenseAutomationViewState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
|
|
71
|
-
const {
|
|
197
|
+
const { jeScheduleTransactionKeysByPeriodAndTab, jeScheduleAccruedKeysByPeriodAndTab, jeScheduleOneTimeAccrualKeysByPeriodAndTab, failedJeScheduleTransactionKeysByPeriodAndTab, jeScheduleLocalDataById, postStatusById, ignoreStatusById, uiState, error, fetchState, refreshStatus, newSchedule, } = expenseAutomationJESchedulesViewState;
|
|
72
198
|
const accountSettingsView = getJEAccountSettingsView(state);
|
|
199
|
+
const newScheduleView = newSchedule.selectedDetailScheduleType === 'fixed_assets' ||
|
|
200
|
+
newSchedule.selectedDetailScheduleType === 'prepaid_expenses'
|
|
201
|
+
? getNewScheduleView(state, newSchedule.selectedDetailScheduleType)
|
|
202
|
+
: undefined;
|
|
73
203
|
const currentTenant = getCurrentTenant(state);
|
|
74
204
|
const { selectedPeriodByTenantId } = expenseAutomationViewState;
|
|
75
205
|
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
@@ -97,27 +227,48 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
97
227
|
const filteredDepAccountListNestedAccountHierarchy = filterNestedAccountHierarchyById(depAccountListNestedAccountHierarchy, filteredDepAccounts.map((account) => account.accountId));
|
|
98
228
|
const classListNestedAccountHierarchy = getNestedClassListHierarchy(classListState);
|
|
99
229
|
const monthYearPeriodId = selectedPeriod != null ? toMonthYearPeriodId(selectedPeriod) : null;
|
|
100
|
-
const
|
|
101
|
-
?
|
|
102
|
-
: null;
|
|
103
|
-
const failedJeScheduleTransactionKeysForSelectedPeriod = monthYearPeriodId != null
|
|
104
|
-
? failedJeScheduleTransactionKeysByPeriod[monthYearPeriodId]
|
|
230
|
+
const selectedPeriodTabKey = monthYearPeriodId != null
|
|
231
|
+
? getJESchedulePeriodTabKey(uiState.selectedPageTab, monthYearPeriodId)
|
|
105
232
|
: null;
|
|
106
|
-
const
|
|
107
|
-
|
|
233
|
+
const jeScheduleTransactionKeysForSelectedTab = selectedPeriodTabKey != null
|
|
234
|
+
? jeScheduleTransactionKeysByPeriodAndTab[selectedPeriodTabKey]
|
|
235
|
+
: undefined;
|
|
236
|
+
const failedJeScheduleTransactionKeysForSelectedTab = selectedPeriodTabKey != null
|
|
237
|
+
? failedJeScheduleTransactionKeysByPeriodAndTab[selectedPeriodTabKey]
|
|
238
|
+
: undefined;
|
|
239
|
+
// Distinguishes "this tab has never been fetched for this period" from "fetched and genuinely
|
|
240
|
+
// empty". Without it the page cannot tell a first visit from a real empty state, and renders an
|
|
241
|
+
// empty table where it should render a skeleton.
|
|
242
|
+
const hasLoadedForSelectedTab = jeScheduleTransactionKeysForSelectedTab != null;
|
|
243
|
+
const jeScheduleTransactionKeys = jeScheduleTransactionKeysForSelectedTab ?? [];
|
|
244
|
+
const failedJeScheduleTransactionKeys = failedJeScheduleTransactionKeysForSelectedTab ?? [];
|
|
245
|
+
const jeScheduleAccruedKeys = (selectedPeriodTabKey != null
|
|
246
|
+
? jeScheduleAccruedKeysByPeriodAndTab[selectedPeriodTabKey]
|
|
247
|
+
: undefined) ?? [];
|
|
248
|
+
const jeScheduleOneTimeAccrualKeys = (selectedPeriodTabKey != null
|
|
249
|
+
? jeScheduleOneTimeAccrualKeysByPeriodAndTab[selectedPeriodTabKey]
|
|
250
|
+
: undefined) ?? [];
|
|
251
|
+
jeScheduleOneTimeAccrualKeys.forEach((jeOneTimeAccrualKey) => {
|
|
252
|
+
const accrual = getJEOneTimeAccrualByKey(jeOneTimeAccrualKey, state.jeSchedulesState);
|
|
253
|
+
if (accrual != null && isRenderableOneTimeAccrual(accrual)) {
|
|
254
|
+
oneTimeAccruals.push(accrual);
|
|
255
|
+
}
|
|
256
|
+
});
|
|
108
257
|
jeScheduleTransactionKeys.forEach((jeScheduleKey) => {
|
|
109
258
|
const jeScheduleDetails = getJEScheduledTransactionByJEScheduleTransactionKey(jeScheduleKey, state);
|
|
110
259
|
jeScheduledTransaction.push(jeScheduleDetails);
|
|
111
260
|
});
|
|
261
|
+
jeScheduleAccruedKeys.forEach((jeAccruedScheduleKey) => {
|
|
262
|
+
const accruedScheduleDetails = getJEAccruedScheduleByJEScheduleKey(jeAccruedScheduleKey, state);
|
|
263
|
+
if (accruedScheduleDetails != null) {
|
|
264
|
+
accruedSchedules.push(accruedScheduleDetails);
|
|
265
|
+
}
|
|
266
|
+
});
|
|
112
267
|
failedJeScheduleTransactionKeys.forEach((jeScheduleKey) => {
|
|
113
268
|
const jeScheduleDetails = getJEScheduledTransactionByJEScheduleTransactionKey(jeScheduleKey, state);
|
|
114
269
|
failedJeScheduledTransaction.push(jeScheduleDetails);
|
|
115
270
|
});
|
|
116
|
-
const { sortKey, sortOrder } = uiState;
|
|
117
|
-
const draftSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'draft'), sortKey, sortOrder);
|
|
118
|
-
const ongoingSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'ongoing'), sortKey, sortOrder);
|
|
119
|
-
const completedSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'completed' ||
|
|
120
|
-
schedule.status.code === 'marked_as_completed'), sortKey, sortOrder);
|
|
271
|
+
const { sortKey, sortOrder, selectedJETypeFilter } = uiState;
|
|
121
272
|
const unsortedResolveSchedules = [];
|
|
122
273
|
failedJeScheduledTransaction.forEach((schedule) => {
|
|
123
274
|
schedule.scheduledJournalEntry.forEach((journalEntry) => {
|
|
@@ -129,10 +280,87 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
129
280
|
});
|
|
130
281
|
const resolveSchedules = sortJEScheduledTransactions(unsortedResolveSchedules, sortKey, sortOrder);
|
|
131
282
|
const validResolveForPending = unsortedResolveSchedules.filter((r) => jeScheduleLocalDataById[r.scheduledJournalEntry.scheduledJournalEntryID] != null);
|
|
283
|
+
const matchesTypeFilter = (schedule) => selectedJETypeFilter == null ||
|
|
284
|
+
getJEScheduleRowType(schedule) === selectedJETypeFilter;
|
|
285
|
+
const isCreatedStatus = (schedule) => {
|
|
286
|
+
// An accrual is "created" once it is not review work: posted, reversing, reversed, or in a
|
|
287
|
+
// transient posting claim.
|
|
288
|
+
if (isOneTimeAccrualRow(schedule)) {
|
|
289
|
+
return !isPendingReviewRow(schedule);
|
|
290
|
+
}
|
|
291
|
+
return (schedule.status.code === 'ongoing' ||
|
|
292
|
+
schedule.status.code === 'completed' ||
|
|
293
|
+
schedule.status.code === 'marked_as_completed');
|
|
294
|
+
};
|
|
295
|
+
const allScheduleRows = [
|
|
296
|
+
...jeScheduledTransaction,
|
|
297
|
+
...accruedSchedules,
|
|
298
|
+
...oneTimeAccruals,
|
|
299
|
+
];
|
|
132
300
|
const pendingReviewSchedules = sortJEScheduledTransactions([
|
|
133
|
-
...
|
|
301
|
+
...allScheduleRows.filter((schedule) => isPendingReviewRow(schedule) && matchesTypeFilter(schedule)),
|
|
134
302
|
...validResolveForPending,
|
|
135
303
|
], sortKey, sortOrder);
|
|
304
|
+
const createdSchedules = sortJEScheduledTransactions(allScheduleRows.filter((schedule) => isCreatedStatus(schedule) && matchesTypeFilter(schedule)), sortKey, sortOrder);
|
|
305
|
+
// KPI summary — derived from unfiltered schedules so counts are always accurate
|
|
306
|
+
const allSchedules = allScheduleRows;
|
|
307
|
+
const sumAmount = (schedules) => schedules.reduce((total, schedule) => total + (getScheduleAmount(schedule) ?? 0), 0);
|
|
308
|
+
const pendingReviewTotal = sumAmount(pendingReviewSchedules);
|
|
309
|
+
const createdTotal = sumAmount(createdSchedules);
|
|
310
|
+
const aiAccountantSchedules = allSchedules.filter(isAiAccountantSchedule);
|
|
311
|
+
const manualSchedules = allSchedules.filter((schedule) => !isAiAccountantSchedule(schedule));
|
|
312
|
+
const pendingUnfiltered = allSchedules.filter((schedule) => isPendingReviewRow(schedule));
|
|
313
|
+
const kpiSummary = {
|
|
314
|
+
aiAccountant: {
|
|
315
|
+
count: aiAccountantSchedules.length,
|
|
316
|
+
amount: sumAmount(aiAccountantSchedules),
|
|
317
|
+
},
|
|
318
|
+
manual: {
|
|
319
|
+
count: manualSchedules.length,
|
|
320
|
+
amount: sumAmount(manualSchedules),
|
|
321
|
+
},
|
|
322
|
+
needsReview: {
|
|
323
|
+
count: pendingUnfiltered.length,
|
|
324
|
+
amount: sumAmount(pendingUnfiltered),
|
|
325
|
+
},
|
|
326
|
+
total: {
|
|
327
|
+
count: allSchedules.length,
|
|
328
|
+
amount: sumAmount(allSchedules),
|
|
329
|
+
},
|
|
330
|
+
};
|
|
331
|
+
// Each tab's badge counts from that tab's own bucket. A tab that has not been fetched yet
|
|
332
|
+
// reports undefined rather than 0, so the UI can hide the badge instead of asserting "none".
|
|
333
|
+
const scheduleCountsByTab = {};
|
|
334
|
+
ALL_JE_PAGE_TABS.forEach((pageTab) => {
|
|
335
|
+
const periodTabKey = monthYearPeriodId != null
|
|
336
|
+
? getJESchedulePeriodTabKey(pageTab, monthYearPeriodId)
|
|
337
|
+
: null;
|
|
338
|
+
const transactionKeys = periodTabKey != null
|
|
339
|
+
? jeScheduleTransactionKeysByPeriodAndTab[periodTabKey]
|
|
340
|
+
: undefined;
|
|
341
|
+
if (transactionKeys == null) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
const accruedKeys = (periodTabKey != null
|
|
345
|
+
? jeScheduleAccruedKeysByPeriodAndTab[periodTabKey]
|
|
346
|
+
: undefined) ?? [];
|
|
347
|
+
const oneTimeAccrualKeys = (periodTabKey != null
|
|
348
|
+
? jeScheduleOneTimeAccrualKeysByPeriodAndTab[periodTabKey]
|
|
349
|
+
: undefined) ?? [];
|
|
350
|
+
const rowsForTab = [
|
|
351
|
+
...transactionKeys.map((transactionKey) => getJEScheduledTransactionByJEScheduleTransactionKey(transactionKey, state)),
|
|
352
|
+
...accruedKeys
|
|
353
|
+
.map((accruedKey) => getJEAccruedScheduleByJEScheduleKey(accruedKey, state))
|
|
354
|
+
.filter((accruedRow) => accruedRow != null),
|
|
355
|
+
...oneTimeAccrualKeys
|
|
356
|
+
.map((accrualKey) => getJEOneTimeAccrualByKey(accrualKey, state.jeSchedulesState))
|
|
357
|
+
.filter((accrualRow) => accrualRow != null && isRenderableOneTimeAccrual(accrualRow)),
|
|
358
|
+
];
|
|
359
|
+
scheduleCountsByTab[pageTab] =
|
|
360
|
+
pageTab === 'existing_schedules'
|
|
361
|
+
? rowsForTab.filter((row) => isExistingTabRow(row)).length
|
|
362
|
+
: rowsForTab.filter((row) => isPendingReviewRow(row) || isCreatedStatus(row)).length;
|
|
363
|
+
});
|
|
136
364
|
const allSteps = monthYearPeriodId != null
|
|
137
365
|
? getAllSteps(monthEndCloseChecksState, monthYearPeriodId, currentTenant.tenantId)
|
|
138
366
|
: [];
|
|
@@ -145,6 +373,20 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
145
373
|
{ fetchState, error },
|
|
146
374
|
monthEndFetchState,
|
|
147
375
|
]);
|
|
376
|
+
const countByType = (schedules) => {
|
|
377
|
+
const counts = ALL_SCHEDULES_TYPES.reduce((acc, type) => ({ ...acc, [type]: 0 }), {});
|
|
378
|
+
schedules.forEach((schedule) => {
|
|
379
|
+
const scheduleType = getJEScheduleRowType(schedule);
|
|
380
|
+
if (scheduleType != null) {
|
|
381
|
+
counts[scheduleType] += 1;
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
return counts;
|
|
385
|
+
};
|
|
386
|
+
const jeScheduleTypeCounts = {
|
|
387
|
+
active: countByType(allSchedules.filter((schedule) => isPendingReviewRow(schedule) || isCreatedStatus(schedule))),
|
|
388
|
+
ongoing: countByType(allSchedules.filter((schedule) => isExistingTabRow(schedule))),
|
|
389
|
+
};
|
|
148
390
|
return {
|
|
149
391
|
uncategorizedAccounts,
|
|
150
392
|
allDepreciationAccountList: filteredDepAccounts,
|
|
@@ -153,12 +395,17 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
153
395
|
allAccountList: filteredAccounts,
|
|
154
396
|
accountListNestedAccountHierarchy,
|
|
155
397
|
allClassList: allClasses,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
398
|
+
createdSchedules,
|
|
399
|
+
createdTotal,
|
|
400
|
+
hasLoadedForSelectedTab,
|
|
401
|
+
jeScheduleTypeCounts,
|
|
402
|
+
scheduleCountsByTab,
|
|
403
|
+
kpiSummary,
|
|
159
404
|
pendingReviewSchedules,
|
|
405
|
+
pendingReviewTotal,
|
|
160
406
|
resolveSchedules: resolveSchedules,
|
|
161
407
|
accountSettingsView,
|
|
408
|
+
newScheduleView,
|
|
162
409
|
postStatusById: postStatusById,
|
|
163
410
|
ignoreStatusById: ignoreStatusById,
|
|
164
411
|
fetchState: reducedFetchStatus.fetchState,
|
|
@@ -169,3 +416,20 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
169
416
|
completionStatus,
|
|
170
417
|
};
|
|
171
418
|
}
|
|
419
|
+
/**
|
|
420
|
+
* One accrual plus the status of its promote / ignore request, for the detail screen.
|
|
421
|
+
*
|
|
422
|
+
* The accruals gateway has no GET-by-id, so the accrual is read from whatever the list already
|
|
423
|
+
* wrote to the store — a deep link that has not fetched the list yet resolves to undefined, and
|
|
424
|
+
* the screen renders its not-found state.
|
|
425
|
+
*/
|
|
426
|
+
export function getExpenseAutomationJEOneTimeAccrualDetailView(state, accrualId) {
|
|
427
|
+
return {
|
|
428
|
+
accrual: getJEOneTimeAccrualByKey(generateJEOneTimeAccrualKey(accrualId), state.jeSchedulesState),
|
|
429
|
+
actionFetchState: state.expenseAutomationJESchedulesViewState
|
|
430
|
+
.oneTimeAccrualActionStatusById[accrualId] ?? {
|
|
431
|
+
fetchState: 'Not-Started',
|
|
432
|
+
error: undefined,
|
|
433
|
+
},
|
|
434
|
+
};
|
|
435
|
+
}
|
|
@@ -16,9 +16,8 @@ const JE_SCHEDULE_SORT_KEYS = [
|
|
|
16
16
|
'memo',
|
|
17
17
|
];
|
|
18
18
|
export const toJEScheduleSortKey = (v) => stringToUnion(v, JE_SCHEDULE_SORT_KEYS);
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export const toJEScheduleMainTab = (v) => stringToUnion(v, JE_SCHEDULE_MAIN_TABS);
|
|
19
|
+
const JE_PAGE_TABS = ['schedules', 'existing_schedules'];
|
|
20
|
+
export const toJEPageTab = (v) => stringToUnion(v, JE_PAGE_TABS);
|
|
21
|
+
export const ALL_JE_PAGE_TABS = JE_PAGE_TABS;
|
|
22
|
+
export const getJESchedulePeriodTabKey = (selectedPageTab, monthYearPeriodId) => `${selectedPageTab}_${monthYearPeriodId}`;
|
|
23
|
+
export const MIN_NEW_SCHEDULE_SEARCH_LENGTH = 2;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { from } from 'rxjs';
|
|
2
2
|
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
3
|
import { updateInvoicingCreditNotes } from '../../../entity/invoicing/creditNote/creditNoteReducer';
|
|
4
|
+
import { apiErrorSnackbarVariables } from '../../../entity/snackbar/snackbarApiError';
|
|
4
5
|
import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
5
6
|
import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
|
|
6
7
|
import { localDataToCreateCreditNotePayload, } from './createCreditNotePayload';
|
|
@@ -29,6 +30,7 @@ export const createCreditNoteEpic = (actions$, state$, zeniAPI) => actions$.pipe
|
|
|
29
30
|
messageSection: 'invoicing_credit_note_saved',
|
|
30
31
|
messageText: 'failed',
|
|
31
32
|
type: 'error',
|
|
33
|
+
variables: apiErrorSnackbarVariables(response.status),
|
|
32
34
|
}),
|
|
33
35
|
]);
|
|
34
36
|
}), catchError((error) => from([
|
|
@@ -3,6 +3,7 @@ import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
|
3
3
|
import { updateAddresses } from '../../../entity/address/addressReducer';
|
|
4
4
|
import { extractInvoicingInvoiceAddresses } from '../../../entity/invoicing/invoice/invoicePayload';
|
|
5
5
|
import { updateInvoices } from '../../../entity/invoicing/invoice/invoiceReducer';
|
|
6
|
+
import { apiErrorSnackbarVariables } from '../../../entity/snackbar/snackbarApiError';
|
|
6
7
|
import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
7
8
|
import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
|
|
8
9
|
import { addInvoiceToList } from '../invoiceList/invoiceListReducer';
|
|
@@ -36,6 +37,7 @@ export const createInvoiceEpic = (actions$, _state$, zeniAPI) => actions$.pipe(f
|
|
|
36
37
|
messageSection: 'invoicing_invoice_saved',
|
|
37
38
|
messageText: 'failed',
|
|
38
39
|
type: 'error',
|
|
40
|
+
variables: apiErrorSnackbarVariables(response.status),
|
|
39
41
|
}),
|
|
40
42
|
]);
|
|
41
43
|
}), catchError((error) => from([
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { from } from 'rxjs';
|
|
2
2
|
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
3
|
import { updateInvoicingCoupons } from '../../../entity/invoicing/coupon/couponReducer';
|
|
4
|
+
import { apiErrorSnackbarVariables } from '../../../entity/snackbar/snackbarApiError';
|
|
4
5
|
import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
5
|
-
import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
|
|
6
|
+
import { createZeniAPIStatus, isSuccessResponse, } from '../../../responsePayload';
|
|
6
7
|
import { runInvoicingDiscountAction, runInvoicingDiscountActionFailure, runInvoicingDiscountActionSuccess, } from './discountActionReducer';
|
|
7
8
|
/** Snackbar copy per action kind; unlisted kinds run without one. */
|
|
8
9
|
const SNACKBAR_SECTION_BY_KIND = {
|
|
@@ -14,13 +15,15 @@ export const runInvoicingDiscountActionEpic = (actions$, _state$, zeniAPI) => ac
|
|
|
14
15
|
const { action: kind, id } = action.payload;
|
|
15
16
|
const requestBody = { action: kind };
|
|
16
17
|
const snackbarSection = SNACKBAR_SECTION_BY_KIND[kind];
|
|
17
|
-
|
|
18
|
+
/** `status` surfaces the platform's error text; omit it to keep the generic copy. */
|
|
19
|
+
const snackbar = (messageText, status) => snackbarSection == null
|
|
18
20
|
? []
|
|
19
21
|
: [
|
|
20
22
|
openSnackbar({
|
|
21
23
|
messageSection: snackbarSection,
|
|
22
24
|
messageText,
|
|
23
25
|
type: messageText === 'success' ? 'success' : 'error',
|
|
26
|
+
variables: apiErrorSnackbarVariables(status),
|
|
24
27
|
}),
|
|
25
28
|
];
|
|
26
29
|
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/discounts/${encodeURIComponent(id)}/actions`;
|
|
@@ -39,7 +42,7 @@ export const runInvoicingDiscountActionEpic = (actions$, _state$, zeniAPI) => ac
|
|
|
39
42
|
error: response.status,
|
|
40
43
|
id,
|
|
41
44
|
}),
|
|
42
|
-
...snackbar('failed'),
|
|
45
|
+
...snackbar('failed', response.status),
|
|
43
46
|
]);
|
|
44
47
|
}), catchError((error) => from([
|
|
45
48
|
runInvoicingDiscountActionFailure({
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { from } from 'rxjs';
|
|
2
2
|
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
3
|
import { updateInvoicingDunningCases } from '../../../entity/invoicing/dunningCase/dunningCaseReducer';
|
|
4
|
+
import { apiErrorSnackbarVariables } from '../../../entity/snackbar/snackbarApiError';
|
|
4
5
|
import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
5
|
-
import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
|
|
6
|
+
import { createZeniAPIStatus, isSuccessResponse, } from '../../../responsePayload';
|
|
6
7
|
import { runInvoicingDunningAction, runInvoicingDunningActionFailure, runInvoicingDunningActionSuccess, } from './dunningActionReducer';
|
|
7
8
|
/**
|
|
8
9
|
* Snackbar copy is per action kind; anything not listed here runs without one.
|
|
@@ -15,13 +16,15 @@ const SNACKBAR_SECTION_BY_KIND = {
|
|
|
15
16
|
export const runInvoicingDunningActionEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(runInvoicingDunningAction.match), mergeMap((action) => {
|
|
16
17
|
const { action: kind, body, id } = action.payload;
|
|
17
18
|
const snackbarSection = SNACKBAR_SECTION_BY_KIND[kind];
|
|
18
|
-
|
|
19
|
+
/** `status` surfaces the platform's error text; omit it to keep the generic copy. */
|
|
20
|
+
const snackbar = (messageText, status) => snackbarSection == null
|
|
19
21
|
? []
|
|
20
22
|
: [
|
|
21
23
|
openSnackbar({
|
|
22
24
|
messageSection: snackbarSection,
|
|
23
25
|
messageText,
|
|
24
26
|
type: messageText === 'success' ? 'success' : 'error',
|
|
27
|
+
variables: apiErrorSnackbarVariables(status),
|
|
25
28
|
}),
|
|
26
29
|
];
|
|
27
30
|
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/dunning/${encodeURIComponent(id)}/${kind}`;
|
|
@@ -40,7 +43,7 @@ export const runInvoicingDunningActionEpic = (actions$, _state$, zeniAPI) => act
|
|
|
40
43
|
error: response.status,
|
|
41
44
|
id,
|
|
42
45
|
}),
|
|
43
|
-
...snackbar('failed'),
|
|
46
|
+
...snackbar('failed', response.status),
|
|
44
47
|
]);
|
|
45
48
|
}), catchError((error) => from([
|
|
46
49
|
runInvoicingDunningActionFailure({
|
|
@@ -80,6 +80,8 @@ const buildSubFamilyPayload = (localData, subFamily, clearEmptyValues) => {
|
|
|
80
80
|
}
|
|
81
81
|
return payload;
|
|
82
82
|
};
|
|
83
|
+
/** `unit` is the item's unit of measure, not a currency; `CURRENCY_CODE` above prices sub-families. */
|
|
84
|
+
const DEFAULT_CATALOG_ITEM_UNIT = 'USD';
|
|
83
85
|
/**
|
|
84
86
|
* Build the parent catalog-item request body from the form draft. Creates omit
|
|
85
87
|
* both parent and sub-family IDs; edits retain returned sub-family IDs.
|
|
@@ -101,10 +103,9 @@ export const localDataToSaveInvoicingCatalogItemPayload = (localData, isCreate)
|
|
|
101
103
|
if (description != null) {
|
|
102
104
|
itemPayload.description = description;
|
|
103
105
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
106
|
+
// The form no longer collects a unit; an item that already has one keeps it.
|
|
107
|
+
itemPayload.unit =
|
|
108
|
+
trimOrUndefined(localData.unit) ?? DEFAULT_CATALOG_ITEM_UNIT;
|
|
108
109
|
if (localData.itemApplicability === 'restricted' &&
|
|
109
110
|
localData.applicableItems.length > 0) {
|
|
110
111
|
itemPayload.applicable_items = localData.applicableItems;
|
package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js
CHANGED
|
@@ -2,6 +2,7 @@ import { forkJoin, from } from 'rxjs';
|
|
|
2
2
|
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
3
|
import { mergeInvoicingPlanSubFamily, updateInvoicingPlans, } from '../../../entity/invoicing/plan/planReducer';
|
|
4
4
|
import { updateInvoicingProducts } from '../../../entity/invoicing/product/productReducer';
|
|
5
|
+
import { apiErrorSnackbarVariables } from '../../../entity/snackbar/snackbarApiError';
|
|
5
6
|
import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
6
7
|
import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
|
|
7
8
|
import { addInvoicingCatalogItem } from '../invoicingCatalogListView/invoicingCatalogListViewReducer';
|
|
@@ -45,6 +46,7 @@ export const saveInvoicingCatalogItemEpic = (actions$, state$, zeniAPI) => actio
|
|
|
45
46
|
messageSection: 'invoicing_catalog_item_saved',
|
|
46
47
|
messageText: 'failed',
|
|
47
48
|
type: 'error',
|
|
49
|
+
variables: apiErrorSnackbarVariables(failedProductResponse.status),
|
|
48
50
|
}),
|
|
49
51
|
]);
|
|
50
52
|
}
|
|
@@ -94,6 +96,7 @@ export const saveInvoicingCatalogItemEpic = (actions$, state$, zeniAPI) => actio
|
|
|
94
96
|
messageSection: 'invoicing_catalog_item_saved',
|
|
95
97
|
messageText: 'failed',
|
|
96
98
|
type: 'error',
|
|
99
|
+
variables: apiErrorSnackbarVariables(response.status),
|
|
97
100
|
}),
|
|
98
101
|
]);
|
|
99
102
|
}), catchError((error) => from([
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { from } from 'rxjs';
|
|
2
2
|
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
3
|
import { updateInvoicingCoupons } from '../../../entity/invoicing/coupon/couponReducer';
|
|
4
|
+
import { apiErrorSnackbarVariables } from '../../../entity/snackbar/snackbarApiError';
|
|
4
5
|
import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
5
6
|
import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
|
|
6
7
|
import { addInvoicingCouponToList } from '../couponView/couponViewReducer';
|
|
@@ -57,6 +58,7 @@ export const saveInvoicingCouponEpic = (actions$, state$, zeniAPI) => actions$.p
|
|
|
57
58
|
messageSection: 'invoicing_coupon_saved',
|
|
58
59
|
messageText: 'failed',
|
|
59
60
|
type: 'error',
|
|
61
|
+
variables: apiErrorSnackbarVariables(response.status),
|
|
60
62
|
}),
|
|
61
63
|
]);
|
|
62
64
|
}), catchError((error) => from([
|
|
@@ -3,6 +3,7 @@ import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
|
3
3
|
import { updateAddresses } from '../../../entity/address/addressReducer';
|
|
4
4
|
import { extractInvoicingCustomerAddresses } from '../../../entity/invoicing/invoicingCustomer/invoicingCustomerPayload';
|
|
5
5
|
import { updateInvoicingCustomers } from '../../../entity/invoicing/invoicingCustomer/invoicingCustomerReducer';
|
|
6
|
+
import { apiErrorSnackbarVariables } from '../../../entity/snackbar/snackbarApiError';
|
|
6
7
|
import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
7
8
|
import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
|
|
8
9
|
import { resetNewAddressDataInLocalStore } from '../../addressView/addressViewReducer';
|
|
@@ -59,6 +60,7 @@ export const saveInvoicingCustomerEpic = (actions$, state$, zeniAPI) => actions$
|
|
|
59
60
|
messageSection: 'invoicing_customer_saved',
|
|
60
61
|
messageText: 'failed',
|
|
61
62
|
type: 'error',
|
|
63
|
+
variables: apiErrorSnackbarVariables(response.status),
|
|
62
64
|
}),
|
|
63
65
|
]);
|
|
64
66
|
}), catchError((error) => from([
|
package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js
CHANGED
|
@@ -3,6 +3,7 @@ import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
|
3
3
|
import { updateAddresses } from '../../../entity/address/addressReducer';
|
|
4
4
|
import { extractInvoicingSubscriptionAddresses } from '../../../entity/invoicing/invoicingSubscription/invoicingSubscriptionPayload';
|
|
5
5
|
import { updateInvoicingSubscriptions } from '../../../entity/invoicing/invoicingSubscription/invoicingSubscriptionReducer';
|
|
6
|
+
import { apiErrorSnackbarVariables } from '../../../entity/snackbar/snackbarApiError';
|
|
6
7
|
import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
7
8
|
import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
|
|
8
9
|
import { resetNewAddressDataInLocalStore } from '../../addressView/addressViewReducer';
|
|
@@ -45,6 +46,7 @@ export const saveInvoicingSubscriptionEpic = (actions$, state$, zeniAPI) => acti
|
|
|
45
46
|
messageSection: 'invoicing_subscription_saved',
|
|
46
47
|
messageText: 'failed',
|
|
47
48
|
type: 'error',
|
|
49
|
+
variables: apiErrorSnackbarVariables(response.status),
|
|
48
50
|
}),
|
|
49
51
|
];
|
|
50
52
|
}
|