@zeniai/client-epic-state 5.1.66 → 5.1.68
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/approvalRule/approvalRuleState.d.ts +1 -0
- package/lib/entity/entityApprovalStatus/entityApprovalStatusPayload.d.ts +1 -0
- package/lib/entity/entityApprovalStatus/entityApprovalStatusPayload.js +1 -0
- package/lib/entity/entityApprovalStatus/entityApprovalStatusState.d.ts +1 -0
- package/lib/epic.d.ts +4 -3
- package/lib/epic.js +4 -3
- package/lib/esm/entity/entityApprovalStatus/entityApprovalStatusPayload.js +1 -0
- package/lib/esm/epic.js +4 -3
- package/lib/esm/index.js +2 -2
- package/lib/esm/view/invoicing/createInvoice/createInvoiceReducer.js +15 -1
- package/lib/esm/view/invoicing/createInvoice/createInvoiceSelector.js +5 -1
- package/lib/esm/view/invoicing/createInvoice/epics/fetchCreateInvoiceFormPageEpic.js +50 -0
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewPayload.js +0 -1
- package/lib/esm/view/spendManagement/billPay/billDetailView/billDetailViewSelector.js +76 -37
- package/lib/esm/view/spendManagement/billPay/billList/billListSelector.js +14 -17
- package/lib/esm/view/spendManagement/billPay/editBillView/editBillViewSelector.js +1 -3
- package/lib/esm/view/spendManagement/billPay/editBillView/epics/fetchEditBillDetailPageEpic.js +0 -14
- package/lib/esm/view/spendManagement/helpers.js +14 -0
- package/lib/esm/view/spendManagement/reimbursement/remiDetailView/remiDetailViewSelector.js +42 -17
- package/lib/esm/view/spendManagement/reimbursement/remiListView/remiListSelector.js +14 -17
- package/lib/index.d.ts +2 -2
- package/lib/index.js +12 -11
- package/lib/view/invoicing/createInvoice/createInvoiceReducer.d.ts +5 -1
- package/lib/view/invoicing/createInvoice/createInvoiceReducer.js +16 -2
- package/lib/view/invoicing/createInvoice/createInvoiceSelector.d.ts +1 -0
- package/lib/view/invoicing/createInvoice/createInvoiceSelector.js +5 -1
- package/lib/view/invoicing/createInvoice/epics/fetchCreateInvoiceFormPageEpic.d.ts +15 -0
- package/lib/view/invoicing/createInvoice/epics/fetchCreateInvoiceFormPageEpic.js +54 -0
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewPayload.js +0 -1
- package/lib/view/spendManagement/billPay/billDetailView/billDetailViewSelector.d.ts +3 -0
- package/lib/view/spendManagement/billPay/billDetailView/billDetailViewSelector.js +75 -36
- package/lib/view/spendManagement/billPay/billList/billListSelector.js +13 -16
- package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +1 -3
- package/lib/view/spendManagement/billPay/editBillView/epics/fetchEditBillDetailPageEpic.d.ts +1 -2
- package/lib/view/spendManagement/billPay/editBillView/epics/fetchEditBillDetailPageEpic.js +0 -14
- package/lib/view/spendManagement/helpers.d.ts +5 -1
- package/lib/view/spendManagement/helpers.js +18 -1
- package/lib/view/spendManagement/reimbursement/remiDetailView/remiDetailViewSelector.d.ts +2 -0
- package/lib/view/spendManagement/reimbursement/remiDetailView/remiDetailViewSelector.js +41 -16
- package/lib/view/spendManagement/reimbursement/remiListView/remiListSelector.js +13 -16
- package/package.json +1 -1
|
@@ -14,6 +14,20 @@ const createInvoiceSlice = createSlice({
|
|
|
14
14
|
name: 'invoicingCreateInvoice',
|
|
15
15
|
initialState,
|
|
16
16
|
reducers: {
|
|
17
|
+
/**
|
|
18
|
+
* Trigger-only action for {@link fetchCreateInvoiceFormPageEpic}: fans out to
|
|
19
|
+
* the customer/plan/product/settings fetches, skipping any already cached
|
|
20
|
+
* unless `cacheOverride` is set. Holds no state of its own.
|
|
21
|
+
*/
|
|
22
|
+
fetchCreateInvoiceFormPage: {
|
|
23
|
+
reducer() {
|
|
24
|
+
// No state mutation; fetchCreateInvoiceFormPageEpic fans out to the
|
|
25
|
+
// customer/plan/product/settings fetches in response to this action.
|
|
26
|
+
},
|
|
27
|
+
prepare(payload) {
|
|
28
|
+
return { payload };
|
|
29
|
+
},
|
|
30
|
+
},
|
|
17
31
|
updateInvoicingCreateInvoiceFormDraft(draft, action) {
|
|
18
32
|
draft.formDraft = action.payload;
|
|
19
33
|
},
|
|
@@ -37,5 +51,5 @@ const createInvoiceSlice = createSlice({
|
|
|
37
51
|
},
|
|
38
52
|
},
|
|
39
53
|
});
|
|
40
|
-
export const { createInvoice, createInvoiceSuccess, createInvoiceFailure, resetCreateInvoice, updateInvoicingCreateInvoiceFormDraft, } = createInvoiceSlice.actions;
|
|
54
|
+
export const { createInvoice, createInvoiceSuccess, createInvoiceFailure, fetchCreateInvoiceFormPage, resetCreateInvoice, updateInvoicingCreateInvoiceFormDraft, } = createInvoiceSlice.actions;
|
|
41
55
|
export default createInvoiceSlice.reducer;
|
|
@@ -12,10 +12,14 @@ import { getInvoicingSettings } from '../settingsView/settingsViewSelector';
|
|
|
12
12
|
export const getCreateInvoiceFormView = (state) => {
|
|
13
13
|
const createInvoiceState = state.invoicingCreateInvoiceState;
|
|
14
14
|
const catalogListView = getInvoicingCatalogListView(state);
|
|
15
|
+
const plans = getInvoicingCatalogPrices(catalogListView.plans);
|
|
15
16
|
return {
|
|
16
17
|
customers: getInvoicingCustomerListView(state).customers,
|
|
17
18
|
localData: createInvoiceState.formDraft,
|
|
18
|
-
|
|
19
|
+
planNames: plans
|
|
20
|
+
.map((plan) => plan.name ?? '')
|
|
21
|
+
.filter((name) => name !== ''),
|
|
22
|
+
plans,
|
|
19
23
|
products: getInvoicingCatalogPrices(catalogListView.products),
|
|
20
24
|
savedInvoiceId: createInvoiceState.createdInvoiceId,
|
|
21
25
|
settings: getInvoicingSettings(state),
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { from } from 'rxjs';
|
|
2
|
+
import { filter, mergeMap } from 'rxjs/operators';
|
|
3
|
+
import { fetchInvoicingCatalogPlanList, fetchInvoicingCatalogProductList, } from '../../invoicingCatalogListView/invoicingCatalogListViewReducer';
|
|
4
|
+
import { fetchInvoicingCustomerList } from '../../invoicingCustomerListView/invoicingCustomerListViewReducer';
|
|
5
|
+
import { fetchInvoicingSettings } from '../../settingsView/settingsViewReducer';
|
|
6
|
+
import { fetchCreateInvoiceFormPage } from '../createInvoiceReducer';
|
|
7
|
+
/**
|
|
8
|
+
* Fetch unless the resource is already loaded or in flight — or always when the
|
|
9
|
+
* caller forces a refresh via `cacheOverride` (false on a plain page open, true
|
|
10
|
+
* to force a reload).
|
|
11
|
+
*/
|
|
12
|
+
const shouldFetch = (fetchStateAndError, cacheOverride) => cacheOverride ||
|
|
13
|
+
(fetchStateAndError.fetchState !== 'Completed' &&
|
|
14
|
+
fetchStateAndError.fetchState !== 'In-Progress');
|
|
15
|
+
/**
|
|
16
|
+
* Orchestrates the create-invoice form's option sources: on
|
|
17
|
+
* `fetchCreateInvoiceFormPage`, fans out to the customer, catalog plan, catalog
|
|
18
|
+
* product and settings fetches, skipping any already cached unless
|
|
19
|
+
* `cacheOverride` is set.
|
|
20
|
+
*/
|
|
21
|
+
export const fetchCreateInvoiceFormPageEpic = (actions$, state$) => actions$.pipe(filter(fetchCreateInvoiceFormPage.match), mergeMap((action) => {
|
|
22
|
+
const { cacheOverride } = action.payload;
|
|
23
|
+
const state = state$.value;
|
|
24
|
+
const customerState = state.invoicingCustomerListViewState;
|
|
25
|
+
const catalogState = state.invoicingCatalogListViewState;
|
|
26
|
+
const settingsState = state.invoicingSettingsViewState;
|
|
27
|
+
const pageActions = [];
|
|
28
|
+
if (shouldFetch({ fetchState: customerState.fetchState, error: customerState.error }, cacheOverride)) {
|
|
29
|
+
pageActions.push(fetchInvoicingCustomerList({
|
|
30
|
+
filters: {},
|
|
31
|
+
keepExistingListItems: false,
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
if (shouldFetch({ fetchState: catalogState.fetchState, error: catalogState.error }, cacheOverride)) {
|
|
35
|
+
pageActions.push(fetchInvoicingCatalogPlanList({
|
|
36
|
+
filters: { type: 'plan' },
|
|
37
|
+
keepExistingListItems: false,
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
if (shouldFetch(catalogState.productFetchState, cacheOverride)) {
|
|
41
|
+
pageActions.push(fetchInvoicingCatalogProductList({
|
|
42
|
+
filters: { type: 'addon|charge' },
|
|
43
|
+
keepExistingListItems: false,
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
if (shouldFetch({ fetchState: settingsState.fetchState, error: settingsState.error }, cacheOverride)) {
|
|
47
|
+
pageActions.push(fetchInvoicingSettings());
|
|
48
|
+
}
|
|
49
|
+
return from(pageActions);
|
|
50
|
+
}));
|
package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewPayload.js
CHANGED
|
@@ -9,7 +9,6 @@ export const localDataToSaveInvoicingCouponPayload = (localData, isCreate) => {
|
|
|
9
9
|
discount_type: localData.discountType,
|
|
10
10
|
duration_type: localData.durationType,
|
|
11
11
|
name: localData.name.trim(),
|
|
12
|
-
status: 'active',
|
|
13
12
|
};
|
|
14
13
|
if (isCreate) {
|
|
15
14
|
data.id = localData.couponId.trim();
|
|
@@ -13,7 +13,7 @@ import { getUserByUserId } from '../../../../entity/user/userSelector';
|
|
|
13
13
|
import { getUserRoleByUserId } from '../../../../entity/userRole/userRoleSelector';
|
|
14
14
|
import { getActivityHistory, } from '../../commonHistoryView/commonHistorySelector';
|
|
15
15
|
import { getAllFundingAccounts, } from '../../commonSetup/setupViewSelector';
|
|
16
|
-
import { getLatestApprovalDate, isAwaitingMarkAsPaid } from '../../helpers';
|
|
16
|
+
import { getLatestApprovalDate, isAwaitingMarkAsPaid, isSodAdminFallbackEligibleForStep, isSodExcludedViewerBlocked, } from '../../helpers';
|
|
17
17
|
import { getActivityRealTimeApproval, } from '../../realTimeApprovalView/realTimeApprovalSelector';
|
|
18
18
|
import { getEntityRealTimeApprovalDetailKey } from '../../realTimeApprovalView/realTimeApprovalState';
|
|
19
19
|
import { getBillPaymentSubConfigCodeKey, getInternationalSubConfigCodeKey, getInternationalWireMethodCodeKey, } from '../billPayConfig/billPayConfigPayload';
|
|
@@ -57,7 +57,7 @@ export const getBillActivities = (state, billId, billStageCode) => {
|
|
|
57
57
|
const approvalRules = getApprovalRulesByIds(approvalRuleState, billDetail.approvalRuleIds);
|
|
58
58
|
const entityApprovalStatusByIds = getEntityApprovalStatusByIds(entityApprovalStatusState, billDetail.entityApprovalIds);
|
|
59
59
|
billActivities = entityApprovalStatusByIds.map((entityApprovalStatus) => {
|
|
60
|
-
const { approvalRuleId, entityType, createTime, updateTime, stepsApprovalStatus, areApprovalsSerialized, isAdminFallbackApprover, isRealTimeApprovalEnabled, currentPendingStepIndex, } = entityApprovalStatus;
|
|
60
|
+
const { approvalRuleId, entityType, createTime, updateTime, stepsApprovalStatus, areApprovalsSerialized, isAdminFallbackApprover, isRealTimeApprovalEnabled, currentPendingStepIndex, sodExcludedApproverUserId, } = entityApprovalStatus;
|
|
61
61
|
const approvalRule = approvalRules.find((rule) => rule.approvalRuleId === approvalRuleId);
|
|
62
62
|
return {
|
|
63
63
|
approvalRuleId,
|
|
@@ -69,21 +69,22 @@ export const getBillActivities = (state, billId, billStageCode) => {
|
|
|
69
69
|
isAdminFallbackApprover,
|
|
70
70
|
isRealTimeApprovalEnabled,
|
|
71
71
|
currentPendingStepIndex,
|
|
72
|
+
sodExcludedApproverUserId,
|
|
72
73
|
entityApprovalId: entityApprovalStatus.entityApprovalId,
|
|
73
74
|
stepsWithStatus: stepsApprovalStatus.map((step) => {
|
|
75
|
+
const actorsActivity = step.actorsActivity.map((activity) => ({
|
|
76
|
+
...activity,
|
|
77
|
+
actor: getUserByUserId(userState, activity.userId),
|
|
78
|
+
}));
|
|
74
79
|
return {
|
|
75
80
|
...step,
|
|
76
81
|
actors: step.actors
|
|
77
82
|
.map((actor) => getUserByUserId(userState, actor.userId))
|
|
78
83
|
.filter((user) => user != null),
|
|
79
84
|
nonUserActors: step.actors.filter((actor) => actor.userId == null && actor.type !== 'user'),
|
|
80
|
-
actorsActivity
|
|
81
|
-
return {
|
|
82
|
-
...activity,
|
|
83
|
-
actor: getUserByUserId(userState, activity.userId),
|
|
84
|
-
};
|
|
85
|
-
}),
|
|
85
|
+
actorsActivity,
|
|
86
86
|
isOriginalApprovalStep: step.isOriginalApprovalStep,
|
|
87
|
+
displayPendingApproverAsAdmin: isSodAdminFallbackEligibleForStep(sodExcludedApproverUserId, isAdminFallbackApprover, actorsActivity),
|
|
87
88
|
};
|
|
88
89
|
}),
|
|
89
90
|
};
|
|
@@ -248,7 +249,7 @@ export const checkApproveRejectBtnShow = (billActivities, isUserAdmin, signedInU
|
|
|
248
249
|
let isMarkAsPaidBtnVisible = false;
|
|
249
250
|
let rejectedId = -1;
|
|
250
251
|
const stepsWithStatusData = billActivities[0].stepsWithStatus;
|
|
251
|
-
const { areApprovalsSerialized, isAdminFallbackApprover, currentPendingStepIndex, } = billActivities[0];
|
|
252
|
+
const { areApprovalsSerialized, isAdminFallbackApprover, currentPendingStepIndex, sodExcludedApproverUserId, } = billActivities[0];
|
|
252
253
|
for (const [index, stepWithStatus] of stepsWithStatusData.entries()) {
|
|
253
254
|
if (stepWithStatus.action === 'require_approval') {
|
|
254
255
|
for (const actorActivity of stepWithStatus.actorsActivity) {
|
|
@@ -289,23 +290,42 @@ export const checkApproveRejectBtnShow = (billActivities, isUserAdmin, signedInU
|
|
|
289
290
|
break;
|
|
290
291
|
}
|
|
291
292
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
293
|
+
const sodBlocked = isSodExcludedViewerBlocked(sodExcludedApproverUserId, signedInUser?.userId, pendingStep.actorsActivity);
|
|
294
|
+
if (isAllActivitiesPending) {
|
|
295
|
+
for (const actorActivity of pendingStep.actorsActivity) {
|
|
296
|
+
if (!sodBlocked &&
|
|
297
|
+
actorActivity.actor?.userId === signedInUser?.userId) {
|
|
298
|
+
isApprovalorRejectBtnVisible = true;
|
|
299
|
+
isMarkAsPaidBtnVisible = isLastApprovalStep;
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
297
302
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
actorActivity.
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
303
|
+
}
|
|
304
|
+
if (!isApprovalorRejectBtnVisible) {
|
|
305
|
+
for (const actorActivity of pendingStep.actorsActivity) {
|
|
306
|
+
// admin will be fallback approver if vendor-owner/manager are not assigned any user id
|
|
307
|
+
if (actorActivity.type === 'attribute' &&
|
|
308
|
+
(actorActivity.subType === 'manager' ||
|
|
309
|
+
actorActivity.subType === 'vendor_owner') &&
|
|
310
|
+
actorActivity.userId === null &&
|
|
311
|
+
isAdminFallbackApprover === true &&
|
|
312
|
+
isUserAdmin &&
|
|
313
|
+
signedInUser?.userId != null &&
|
|
314
|
+
signedInUser.userId !== sodExcludedApproverUserId) {
|
|
315
|
+
isApprovalorRejectBtnVisible = true;
|
|
316
|
+
isMarkAsPaidBtnVisible = isLastApprovalStep;
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
307
319
|
}
|
|
308
320
|
}
|
|
321
|
+
if (!isApprovalorRejectBtnVisible &&
|
|
322
|
+
isUserAdmin &&
|
|
323
|
+
signedInUser?.userId != null &&
|
|
324
|
+
signedInUser.userId !== sodExcludedApproverUserId &&
|
|
325
|
+
pendingStep.displayPendingApproverAsAdmin === true) {
|
|
326
|
+
isApprovalorRejectBtnVisible = true;
|
|
327
|
+
isMarkAsPaidBtnVisible = isLastApprovalStep;
|
|
328
|
+
}
|
|
309
329
|
}
|
|
310
330
|
}
|
|
311
331
|
}
|
|
@@ -319,23 +339,42 @@ export const checkApproveRejectBtnShow = (billActivities, isUserAdmin, signedInU
|
|
|
319
339
|
break;
|
|
320
340
|
}
|
|
321
341
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
342
|
+
const sodBlocked = isSodExcludedViewerBlocked(sodExcludedApproverUserId, signedInUser?.userId, stepWithStatus.actorsActivity);
|
|
343
|
+
if (isAllActivitiesPending) {
|
|
344
|
+
for (const actorActivity of stepWithStatus.actorsActivity) {
|
|
345
|
+
if (!sodBlocked &&
|
|
346
|
+
actorActivity.actor?.userId === signedInUser?.userId) {
|
|
347
|
+
isApprovalorRejectBtnVisible = true;
|
|
348
|
+
isMarkAsPaidBtnVisible = true;
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
327
351
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
actorActivity.
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
352
|
+
}
|
|
353
|
+
if (!isApprovalorRejectBtnVisible) {
|
|
354
|
+
for (const actorActivity of stepWithStatus.actorsActivity) {
|
|
355
|
+
// admin will be fallback approver if vendor-owner/manager are not assigned any user id
|
|
356
|
+
if (actorActivity.type === 'attribute' &&
|
|
357
|
+
(actorActivity.subType === 'manager' ||
|
|
358
|
+
actorActivity.subType === 'vendor_owner') &&
|
|
359
|
+
actorActivity.userId === null &&
|
|
360
|
+
isAdminFallbackApprover === true &&
|
|
361
|
+
isUserAdmin &&
|
|
362
|
+
signedInUser?.userId != null &&
|
|
363
|
+
signedInUser.userId !== sodExcludedApproverUserId) {
|
|
364
|
+
isApprovalorRejectBtnVisible = true;
|
|
365
|
+
isMarkAsPaidBtnVisible = true;
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
337
368
|
}
|
|
338
369
|
}
|
|
370
|
+
if (!isApprovalorRejectBtnVisible &&
|
|
371
|
+
isUserAdmin &&
|
|
372
|
+
signedInUser?.userId != null &&
|
|
373
|
+
signedInUser.userId !== sodExcludedApproverUserId &&
|
|
374
|
+
stepWithStatus.displayPendingApproverAsAdmin === true) {
|
|
375
|
+
isApprovalorRejectBtnVisible = true;
|
|
376
|
+
isMarkAsPaidBtnVisible = true;
|
|
377
|
+
}
|
|
339
378
|
}
|
|
340
379
|
if (isApprovalorRejectBtnVisible) {
|
|
341
380
|
break;
|
|
@@ -4,7 +4,7 @@ import orderBy from 'lodash/orderBy';
|
|
|
4
4
|
import { toAttributeTypeStrict, } from '../../../../entity/approvalRule/approvalRuleState';
|
|
5
5
|
import { getUserByUserId } from '../../../../entity/user/userSelector';
|
|
6
6
|
import { dateNow } from '../../../../zeniDayJS';
|
|
7
|
-
import { isAwaitingMarkAsPaid, isBulkProcessing, } from '../../helpers';
|
|
7
|
+
import { isAwaitingMarkAsPaid, isBulkProcessing, isSodAdminFallbackEligibleForStep, } from '../../helpers';
|
|
8
8
|
import { applyAdvancedFiltersOnList, isBillListDownloadable, } from '../../spendManagementFilterHelpers';
|
|
9
9
|
import { getSelectedWithdrawFromAccount } from '../billDetailView/billDetailViewSelector';
|
|
10
10
|
import { getBillPayConfigBotEmail } from '../billPayConfig/billPayConfigSelector';
|
|
@@ -290,7 +290,7 @@ export const getApproversOrRejectors = (billTransaction, entityApprovalStatusSta
|
|
|
290
290
|
};
|
|
291
291
|
if (billTransaction.entityApprovalId !== null) {
|
|
292
292
|
const entityApprovalStatus = entityApprovalStatusState.entityApprovalStatusById[billTransaction.entityApprovalId];
|
|
293
|
-
const { areApprovalsSerialized, isAdminFallbackApprover, currentPendingStepIndex, } = entityApprovalStatus;
|
|
293
|
+
const { areApprovalsSerialized, isAdminFallbackApprover, currentPendingStepIndex, sodExcludedApproverUserId, } = entityApprovalStatus;
|
|
294
294
|
const isBillSerailized = areApprovalsSerialized === true &&
|
|
295
295
|
currentPendingStepIndex != null &&
|
|
296
296
|
currentPendingStepIndex > -1;
|
|
@@ -318,23 +318,20 @@ export const getApproversOrRejectors = (billTransaction, entityApprovalStatusSta
|
|
|
318
318
|
if (isBillSerailized) {
|
|
319
319
|
requireApprovalInfo = [stepsApprovalStatus[currentPendingStepIndex]];
|
|
320
320
|
}
|
|
321
|
-
const pendingActivitiesList = [];
|
|
322
321
|
requireApprovalInfo.forEach((approvalStep) => {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
if (isBillSerailized) {
|
|
326
|
-
pendingActivitiesList.push(...pendingActivities);
|
|
322
|
+
if (approvers.displayPendingApproverAsAdmin === true) {
|
|
323
|
+
return;
|
|
327
324
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
325
|
+
const pendingActivities = approvalStep.actorsActivity.filter((activity) => activity.activity === 'pending');
|
|
326
|
+
const sodDisplayAsAdmin = isSodAdminFallbackEligibleForStep(sodExcludedApproverUserId, isAdminFallbackApprover, approvalStep.actorsActivity);
|
|
327
|
+
const activitiesToShow = isBillSerailized
|
|
328
|
+
? pendingActivities
|
|
329
|
+
: pendingActivities.slice(0, 1);
|
|
330
|
+
if (sodDisplayAsAdmin) {
|
|
331
|
+
approvers.displayPendingApproverAsAdmin = true;
|
|
332
|
+
return;
|
|
334
333
|
}
|
|
335
|
-
|
|
336
|
-
if (pendingActivitiesList.length > 0) {
|
|
337
|
-
pendingActivitiesList.forEach((activity) => {
|
|
334
|
+
activitiesToShow.forEach((activity) => {
|
|
338
335
|
const user = getUserByUserId(userState, activity.userId);
|
|
339
336
|
if (user != null) {
|
|
340
337
|
approvers.users.push(user);
|
|
@@ -346,7 +343,7 @@ export const getApproversOrRejectors = (billTransaction, entityApprovalStatusSta
|
|
|
346
343
|
}
|
|
347
344
|
}
|
|
348
345
|
});
|
|
349
|
-
}
|
|
346
|
+
});
|
|
350
347
|
}
|
|
351
348
|
}
|
|
352
349
|
}
|
|
@@ -29,7 +29,7 @@ import { getDuplicateBills, } from '../billPayReview/billPayReviewSelector';
|
|
|
29
29
|
import { getBillPaySetupApproverView } from '../billPaySetupApproverView/billPaySetupApproverViewSelector';
|
|
30
30
|
import { getPreviousBills, } from '../previousBills/previousBillsSelector';
|
|
31
31
|
export const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, isZeniAccountsEnabled, billId) => {
|
|
32
|
-
const { accountListState, accountState, bankAccountState, billDetailViewState, paymentAccountListState, billTransactionState, billPayConfigState, classListState, classState, editBillDetailViewState, paymentAccountState, vendorState, tenantState, companyState, userState, commonHistoryState, contactState, paymentInstrumentState, recurringBillState, depositAccountListState, depositAccountState,
|
|
32
|
+
const { accountListState, accountState, bankAccountState, billDetailViewState, paymentAccountListState, billTransactionState, billPayConfigState, classListState, classState, editBillDetailViewState, paymentAccountState, vendorState, tenantState, companyState, userState, commonHistoryState, contactState, paymentInstrumentState, recurringBillState, depositAccountListState, depositAccountState, plaidAccountViewState, } = state;
|
|
33
33
|
const transaction = recordGet(billTransactionState.transactionById, billId ?? '', undefined);
|
|
34
34
|
let recommendations = {};
|
|
35
35
|
if (billId != null) {
|
|
@@ -177,7 +177,6 @@ export const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, i
|
|
|
177
177
|
const fetchStateList = [
|
|
178
178
|
sourceBillDetail.fetchStatus,
|
|
179
179
|
accountListState.byReportId.billPayAccountList,
|
|
180
|
-
billPaySetupApproverViewState,
|
|
181
180
|
];
|
|
182
181
|
if (getIsAccountingClassesEnabled(state)) {
|
|
183
182
|
fetchStateList.push(classListState);
|
|
@@ -198,7 +197,6 @@ export const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, i
|
|
|
198
197
|
else {
|
|
199
198
|
const newBillFetchStateList = [
|
|
200
199
|
accountListState.byReportId.billPayAccountList,
|
|
201
|
-
billPaySetupApproverViewState,
|
|
202
200
|
];
|
|
203
201
|
if (getIsAccountingClassesEnabled(state)) {
|
|
204
202
|
newBillFetchStateList.push(classListState);
|
package/lib/esm/view/spendManagement/billPay/editBillView/epics/fetchEditBillDetailPageEpic.js
CHANGED
|
@@ -8,7 +8,6 @@ import { fetchVendorTypeList } from '../../../../vendorTypeList/vendorTypeListRe
|
|
|
8
8
|
import { fetchDepositAccountList } from '../../../zeniAccounts/depositAccountList/depositAccountListReducer';
|
|
9
9
|
import { fetchPaymentAccountList } from '../../../zeniAccounts/paymentAccountList/paymentAccountListReducer';
|
|
10
10
|
import { fetchBillPayConfig } from '../../billPayConfig/billPayConfigReducer';
|
|
11
|
-
import { fetchBillPaySetupApproverView } from '../../billPaySetupApproverView/billPaySetupApproverViewReducer';
|
|
12
11
|
import { fetchBillAndInitializeLocalStore, fetchEditBillDetailPage, updateShowAutofill, } from '../editBillViewReducer';
|
|
13
12
|
export const fetchEditBillDetailPageEpic = (actions$, state$) => actions$.pipe(filter(fetchEditBillDetailPage.match), mergeMap((action) => {
|
|
14
13
|
const { cacheOverride, billId, isShowDeletedBillsEnabled, hasZeniAssistAccess, isInternationalWireEnabled, } = action.payload;
|
|
@@ -38,10 +37,6 @@ export const fetchEditBillDetailPageEpic = (actions$, state$) => actions$.pipe(f
|
|
|
38
37
|
else {
|
|
39
38
|
billDetailActions.push(updateShowAutofill(true));
|
|
40
39
|
}
|
|
41
|
-
// Side-fetch from the edit-bill page bootstrap. The triggering
|
|
42
|
-
// action doesn't carry the V3 flag, so we explicitly target v1
|
|
43
|
-
// here; tenants on v3 re-fetch through their own screen connector.
|
|
44
|
-
billDetailActions.push(fetchBillPaySetupApproverView(true, true, false));
|
|
45
40
|
}
|
|
46
41
|
else {
|
|
47
42
|
if (state.ownerListState.fetchState !== 'In-Progress' &&
|
|
@@ -80,15 +75,6 @@ export const fetchEditBillDetailPageEpic = (actions$, state$) => actions$.pipe(f
|
|
|
80
75
|
if (billId != null) {
|
|
81
76
|
billDetailActions.push(fetchBillAndInitializeLocalStore(billId, false, isShowDeletedBillsEnabled, hasZeniAssistAccess));
|
|
82
77
|
}
|
|
83
|
-
const approvalViewFetchState = state.billPaySetupApproverViewState.fetchState;
|
|
84
|
-
// While opening New Bill Refresh Approval Rules and Payment Accounts
|
|
85
|
-
if (approvalViewFetchState !== 'In-Progress' &&
|
|
86
|
-
approvalViewFetchState !== 'Completed') {
|
|
87
|
-
// Side-fetch from the edit-bill page bootstrap. The triggering
|
|
88
|
-
// action doesn't carry the V3 flag, so we explicitly target v1
|
|
89
|
-
// here; tenants on v3 re-fetch through their own screen connector.
|
|
90
|
-
billDetailActions.push(fetchBillPaySetupApproverView(true, true, false));
|
|
91
|
-
}
|
|
92
78
|
}
|
|
93
79
|
return concat(from(billDetailActions));
|
|
94
80
|
}));
|
|
@@ -5,6 +5,20 @@ import { endDate, isHoliday, startDate, } from '../../commonStateTypes/workingDa
|
|
|
5
5
|
import { VERIFIED_PAYMENT_ACCOUNT_PROVIDER_VERIFICATION_STATUS } from '../../entity/paymentAccount/paymentAccountState';
|
|
6
6
|
import { hasBillPayAccess, hasBillPayAdminLevelAccess, hasReimbursementAccess, hasReimbursementAdminLevelAccess, } from '../../entity/userRole/userRoleType';
|
|
7
7
|
import { date as zeniDate } from '../../zeniDayJS';
|
|
8
|
+
const getUserActorId = (activity) => activity.actor?.userId ?? activity.userId;
|
|
9
|
+
export const isUserActorOnApprovalStep = (userId, stepActorsActivity) => stepActorsActivity.some((activity) => getUserActorId(activity) === userId);
|
|
10
|
+
export const isSodExcludedViewerBlocked = (sodExcludedApproverUserId, signedInUserId, stepActorsActivity = []) => sodExcludedApproverUserId != null &&
|
|
11
|
+
signedInUserId != null &&
|
|
12
|
+
signedInUserId === sodExcludedApproverUserId &&
|
|
13
|
+
isUserActorOnApprovalStep(sodExcludedApproverUserId, stepActorsActivity);
|
|
14
|
+
export const isSodAdminFallbackEligibleForStep = (sodExcludedApproverUserId, isAdminFallbackApprover, stepActorsActivity = []) => {
|
|
15
|
+
if (sodExcludedApproverUserId == null || isAdminFallbackApprover !== true) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
const pendingResolvedApprovers = stepActorsActivity.filter((activity) => activity.activity === 'pending' && getUserActorId(activity) != null);
|
|
19
|
+
return (pendingResolvedApprovers.length > 0 &&
|
|
20
|
+
pendingResolvedApprovers.every((activity) => getUserActorId(activity) === sodExcludedApproverUserId));
|
|
21
|
+
};
|
|
8
22
|
export const getLatestApprovalDate = (allActivities) => {
|
|
9
23
|
let allStepsWithStatus = [];
|
|
10
24
|
let allApprovedActions = [];
|
|
@@ -7,7 +7,7 @@ import { getEntityApprovalStatusByIds } from '../../../../entity/entityApprovalS
|
|
|
7
7
|
import { getUserByUserId } from '../../../../entity/user/userSelector';
|
|
8
8
|
import { getUserRoleByUserId } from '../../../../entity/userRole/userRoleSelector';
|
|
9
9
|
import { getActivityHistory, } from '../../commonHistoryView/commonHistorySelector';
|
|
10
|
-
import { getLatestApprovalDate } from '../../helpers';
|
|
10
|
+
import { getLatestApprovalDate, isSodAdminFallbackEligibleForStep, isSodExcludedViewerBlocked, } from '../../helpers';
|
|
11
11
|
import { getActivityRealTimeApproval, } from '../../realTimeApprovalView/realTimeApprovalSelector';
|
|
12
12
|
import { getReimbursementConfigByKey } from '../reimbursementConfig/reimbursementConfigSelector';
|
|
13
13
|
import { REIMBURSEMENT_PAYMENT_NUMBER_OF_DAYS } from '../reimbursementConfig/reimbursementConfigState';
|
|
@@ -144,7 +144,7 @@ export const getRemiActivities = (state, reimbursementId, billStageCode) => {
|
|
|
144
144
|
const approvalRules = getApprovalRulesByIds(approvalRuleState, remiTransactionDetails.approvalRuleIds);
|
|
145
145
|
const entityApprovalStatusByIds = getEntityApprovalStatusByIds(entityApprovalStatusState, remiTransactionDetails.entityApprovalIds);
|
|
146
146
|
remiActivities = entityApprovalStatusByIds.map((entityApprovalStatus) => {
|
|
147
|
-
const { approvalRuleId, entityType, createTime, updateTime, stepsApprovalStatus, areApprovalsSerialized, isAdminFallbackApprover, currentPendingStepIndex, isRealTimeApprovalEnabled, } = entityApprovalStatus;
|
|
147
|
+
const { approvalRuleId, entityType, createTime, updateTime, stepsApprovalStatus, areApprovalsSerialized, isAdminFallbackApprover, currentPendingStepIndex, isRealTimeApprovalEnabled, sodExcludedApproverUserId, } = entityApprovalStatus;
|
|
148
148
|
const approvalRule = approvalRules.find((rule) => rule.approvalRuleId === approvalRuleId);
|
|
149
149
|
return {
|
|
150
150
|
approvalRuleId,
|
|
@@ -156,21 +156,22 @@ export const getRemiActivities = (state, reimbursementId, billStageCode) => {
|
|
|
156
156
|
isAdminFallbackApprover,
|
|
157
157
|
currentPendingStepIndex,
|
|
158
158
|
isRealTimeApprovalEnabled,
|
|
159
|
+
sodExcludedApproverUserId,
|
|
159
160
|
entityApprovalId: entityApprovalStatus.entityApprovalId,
|
|
160
161
|
stepsWithStatus: stepsApprovalStatus.map((step) => {
|
|
162
|
+
const actorsActivity = step.actorsActivity.map((activity) => ({
|
|
163
|
+
...activity,
|
|
164
|
+
actor: getUserByUserId(userState, activity.userId),
|
|
165
|
+
}));
|
|
161
166
|
return {
|
|
162
167
|
...step,
|
|
163
168
|
actors: step.actors
|
|
164
169
|
.map((actor) => getUserByUserId(userState, actor.userId))
|
|
165
170
|
.filter((user) => user != null),
|
|
166
171
|
nonUserActors: step.actors.filter((actor) => actor.userId == null && actor.type !== 'user'),
|
|
167
|
-
actorsActivity
|
|
168
|
-
return {
|
|
169
|
-
...activity,
|
|
170
|
-
actor: getUserByUserId(userState, activity.userId),
|
|
171
|
-
};
|
|
172
|
-
}),
|
|
172
|
+
actorsActivity,
|
|
173
173
|
isOriginalApprovalStep: step.isOriginalApprovalStep,
|
|
174
|
+
displayPendingApproverAsAdmin: isSodAdminFallbackEligibleForStep(sodExcludedApproverUserId, isAdminFallbackApprover, actorsActivity),
|
|
174
175
|
};
|
|
175
176
|
}),
|
|
176
177
|
};
|
|
@@ -183,7 +184,7 @@ export const checkApproveRejectBtnShow = (remiActivities, isUserAdmin, signedInU
|
|
|
183
184
|
let isApprovalorRejectBtnVisible = false;
|
|
184
185
|
let rejectedId = -1;
|
|
185
186
|
const stepsWithStatusData = remiActivities[0].stepsWithStatus;
|
|
186
|
-
const { areApprovalsSerialized, isAdminFallbackApprover, currentPendingStepIndex, } = remiActivities[0];
|
|
187
|
+
const { areApprovalsSerialized, isAdminFallbackApprover, currentPendingStepIndex, sodExcludedApproverUserId, } = remiActivities[0];
|
|
187
188
|
for (const [index, stepWithStatus] of stepsWithStatusData.entries()) {
|
|
188
189
|
if (stepWithStatus.action === 'require_approval') {
|
|
189
190
|
for (const actorActivity of stepWithStatus.actorsActivity) {
|
|
@@ -219,27 +220,39 @@ export const checkApproveRejectBtnShow = (remiActivities, isUserAdmin, signedInU
|
|
|
219
220
|
break;
|
|
220
221
|
}
|
|
221
222
|
}
|
|
223
|
+
const sodBlocked = isSodExcludedViewerBlocked(sodExcludedApproverUserId, signedInUser?.userId, pendingStep.actorsActivity);
|
|
222
224
|
for (const actorActivity of pendingStep.actorsActivity) {
|
|
223
|
-
if (
|
|
225
|
+
if (!sodBlocked &&
|
|
226
|
+
actorActivity.actor?.userId === signedInUser?.userId &&
|
|
224
227
|
isAllActivitiesPending) {
|
|
225
228
|
isApprovalorRejectBtnVisible = true;
|
|
226
229
|
}
|
|
227
230
|
else if (actorActivity.subType === 'admin' &&
|
|
228
231
|
isUserAdmin &&
|
|
229
|
-
isAllActivitiesPending
|
|
232
|
+
isAllActivitiesPending &&
|
|
233
|
+
signedInUser?.userId != null &&
|
|
234
|
+
signedInUser.userId !== sodExcludedApproverUserId) {
|
|
230
235
|
isApprovalorRejectBtnVisible = true;
|
|
231
236
|
}
|
|
232
|
-
// admin will be fallback approver if vendor-owner/manager are not assigned any user id
|
|
233
237
|
else if (actorActivity.type === 'attribute' &&
|
|
234
238
|
(actorActivity.subType === 'manager' ||
|
|
235
239
|
actorActivity.subType === 'vendor_owner' ||
|
|
236
240
|
actorActivity.subType === 'manager_of_manager') &&
|
|
237
241
|
actorActivity.userId === null &&
|
|
238
242
|
isAdminFallbackApprover === true &&
|
|
239
|
-
isUserAdmin
|
|
243
|
+
isUserAdmin &&
|
|
244
|
+
signedInUser?.userId != null &&
|
|
245
|
+
signedInUser.userId !== sodExcludedApproverUserId) {
|
|
240
246
|
isApprovalorRejectBtnVisible = true;
|
|
241
247
|
}
|
|
242
248
|
}
|
|
249
|
+
if (!isApprovalorRejectBtnVisible &&
|
|
250
|
+
isUserAdmin &&
|
|
251
|
+
signedInUser?.userId != null &&
|
|
252
|
+
signedInUser.userId !== sodExcludedApproverUserId &&
|
|
253
|
+
pendingStep.displayPendingApproverAsAdmin === true) {
|
|
254
|
+
isApprovalorRejectBtnVisible = true;
|
|
255
|
+
}
|
|
243
256
|
}
|
|
244
257
|
}
|
|
245
258
|
}
|
|
@@ -253,27 +266,39 @@ export const checkApproveRejectBtnShow = (remiActivities, isUserAdmin, signedInU
|
|
|
253
266
|
break;
|
|
254
267
|
}
|
|
255
268
|
}
|
|
269
|
+
const sodBlocked = isSodExcludedViewerBlocked(sodExcludedApproverUserId, signedInUser?.userId, stepWithStatus.actorsActivity);
|
|
256
270
|
for (const actorActivity of stepWithStatus.actorsActivity) {
|
|
257
|
-
if (
|
|
271
|
+
if (!sodBlocked &&
|
|
272
|
+
actorActivity.actor?.userId === signedInUser?.userId &&
|
|
258
273
|
isAllActivitiesPending) {
|
|
259
274
|
isApprovalorRejectBtnVisible = true;
|
|
260
275
|
}
|
|
261
276
|
else if (actorActivity.subType === 'admin' &&
|
|
262
277
|
isUserAdmin &&
|
|
263
|
-
isAllActivitiesPending
|
|
278
|
+
isAllActivitiesPending &&
|
|
279
|
+
signedInUser?.userId != null &&
|
|
280
|
+
signedInUser.userId !== sodExcludedApproverUserId) {
|
|
264
281
|
isApprovalorRejectBtnVisible = true;
|
|
265
282
|
}
|
|
266
|
-
// admin will be fallback approver if vendor-owner/manager are not assigned any user id
|
|
267
283
|
else if (actorActivity.type === 'attribute' &&
|
|
268
284
|
(actorActivity.subType === 'manager' ||
|
|
269
285
|
actorActivity.subType === 'vendor_owner' ||
|
|
270
286
|
actorActivity.subType === 'manager_of_manager') &&
|
|
271
287
|
actorActivity.userId === null &&
|
|
272
288
|
isAdminFallbackApprover === true &&
|
|
273
|
-
isUserAdmin
|
|
289
|
+
isUserAdmin &&
|
|
290
|
+
signedInUser?.userId != null &&
|
|
291
|
+
signedInUser.userId !== sodExcludedApproverUserId) {
|
|
274
292
|
isApprovalorRejectBtnVisible = true;
|
|
275
293
|
}
|
|
276
294
|
}
|
|
295
|
+
if (!isApprovalorRejectBtnVisible &&
|
|
296
|
+
isUserAdmin &&
|
|
297
|
+
signedInUser?.userId != null &&
|
|
298
|
+
signedInUser.userId !== sodExcludedApproverUserId &&
|
|
299
|
+
stepWithStatus.displayPendingApproverAsAdmin === true) {
|
|
300
|
+
isApprovalorRejectBtnVisible = true;
|
|
301
|
+
}
|
|
277
302
|
}
|
|
278
303
|
if (isApprovalorRejectBtnVisible) {
|
|
279
304
|
break;
|
|
@@ -7,7 +7,7 @@ import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
|
|
|
7
7
|
import { getUserByUserId, getUsersByUserIds, } from '../../../../entity/user/userSelector';
|
|
8
8
|
import { hasAdminLevelAccess, hasReimbursementUserAccess, } from '../../../../entity/userRole/userRoleType';
|
|
9
9
|
import { dateNow } from '../../../../zeniDayJS';
|
|
10
|
-
import { isBulkProcessing } from '../../helpers';
|
|
10
|
+
import { isBulkProcessing, isSodAdminFallbackEligibleForStep, } from '../../helpers';
|
|
11
11
|
import { getReimbursementConfigBotEmail } from '../../reimbursement/reimbursementConfig/reimbursementConfigSelector';
|
|
12
12
|
import { applyAdvancedFiltersOnList, isRemiListDownloadable, } from '../../spendManagementFilterHelpers';
|
|
13
13
|
import { ALL_REMI_TABS, getRemiListKey, } from './remiListState';
|
|
@@ -209,7 +209,7 @@ export const getApproversOrRejectors = (reimbursement, entityApprovalStatusState
|
|
|
209
209
|
};
|
|
210
210
|
if (reimbursement.entityApprovalId !== null) {
|
|
211
211
|
const entityApprovalStatus = entityApprovalStatusState.entityApprovalStatusById[reimbursement.entityApprovalId];
|
|
212
|
-
const { areApprovalsSerialized, isAdminFallbackApprover, currentPendingStepIndex, } = entityApprovalStatus;
|
|
212
|
+
const { areApprovalsSerialized, isAdminFallbackApprover, currentPendingStepIndex, sodExcludedApproverUserId, } = entityApprovalStatus;
|
|
213
213
|
const isReimbursementSerailized = areApprovalsSerialized === true &&
|
|
214
214
|
currentPendingStepIndex != null &&
|
|
215
215
|
currentPendingStepIndex > -1;
|
|
@@ -237,23 +237,20 @@ export const getApproversOrRejectors = (reimbursement, entityApprovalStatusState
|
|
|
237
237
|
if (isReimbursementSerailized) {
|
|
238
238
|
requireApprovalInfo = [stepsApprovalStatus[currentPendingStepIndex]];
|
|
239
239
|
}
|
|
240
|
-
const pendingActivitiesList = [];
|
|
241
240
|
requireApprovalInfo.forEach((approvalStep) => {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
if (isReimbursementSerailized) {
|
|
245
|
-
pendingActivitiesList.push(...pendingActivities);
|
|
241
|
+
if (approvers.displayPendingApproverAsAdmin === true) {
|
|
242
|
+
return;
|
|
246
243
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
244
|
+
const pendingActivities = approvalStep.actorsActivity.filter((activity) => activity.activity === 'pending');
|
|
245
|
+
const sodDisplayAsAdmin = isSodAdminFallbackEligibleForStep(sodExcludedApproverUserId, isAdminFallbackApprover, approvalStep.actorsActivity);
|
|
246
|
+
const activitiesToShow = isReimbursementSerailized
|
|
247
|
+
? pendingActivities
|
|
248
|
+
: pendingActivities.slice(0, 1);
|
|
249
|
+
if (sodDisplayAsAdmin) {
|
|
250
|
+
approvers.displayPendingApproverAsAdmin = true;
|
|
251
|
+
return;
|
|
253
252
|
}
|
|
254
|
-
|
|
255
|
-
if (pendingActivitiesList.length > 0) {
|
|
256
|
-
pendingActivitiesList.forEach((activity) => {
|
|
253
|
+
activitiesToShow.forEach((activity) => {
|
|
257
254
|
const user = getUserByUserId(userState, activity.userId);
|
|
258
255
|
if (user != null) {
|
|
259
256
|
approvers.users.push(user);
|
|
@@ -265,7 +262,7 @@ export const getApproversOrRejectors = (reimbursement, entityApprovalStatusState
|
|
|
265
262
|
}
|
|
266
263
|
}
|
|
267
264
|
});
|
|
268
|
-
}
|
|
265
|
+
});
|
|
269
266
|
}
|
|
270
267
|
}
|
|
271
268
|
}
|