@zeniai/client-epic-state 5.3.6-betaGS2 → 5.3.6-betaGS4
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/jeScheduleApprovalRule/jeScheduleApprovalRulePayload.d.ts +8 -7
- package/lib/entity/jeScheduleApprovalRule/jeScheduleApprovalRulePayload.js +10 -8
- package/lib/entity/jeScheduleApprovalRule/jeScheduleApprovalRuleState.d.ts +5 -1
- package/lib/entity/jeScheduleApprovalRule/jeScheduleApprovalRuleTypes.d.ts +2 -0
- package/lib/entity/jeScheduleApprovalRule/jeScheduleApprovalRuleTypes.js +2 -1
- package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +2 -4
- package/lib/entity/jeSchedules/jeSchedulesSelector.js +16 -13
- package/lib/esm/entity/jeScheduleApprovalRule/jeScheduleApprovalRulePayload.js +10 -8
- package/lib/esm/entity/jeScheduleApprovalRule/jeScheduleApprovalRuleTypes.js +1 -0
- package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +15 -12
- package/lib/esm/index.js +2 -2
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +9 -2
- package/lib/esm/view/scheduleView/scheduleDetailView/epics/fetchScheduleDetailsEpic.js +2 -0
- package/lib/esm/view/settings/jeScheduleApprovalRules/epic/deleteJEScheduleApprovalRuleEpic.js +23 -5
- package/lib/esm/view/settings/jeScheduleApprovalRules/epic/fetchJEScheduleApprovalRulesEpic.js +5 -2
- package/lib/esm/view/settings/jeScheduleApprovalRules/epic/fetchJEScheduleApproversEpic.js +5 -2
- package/lib/esm/view/settings/jeScheduleApprovalRules/epic/jeScheduleApprovalActionEpic.js +29 -6
- package/lib/esm/view/settings/jeScheduleApprovalRules/epic/reorderJEScheduleApprovalRulesEpic.js +7 -3
- package/lib/esm/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalDraftEpic.js +14 -9
- package/lib/esm/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalRuleEpic.js +22 -5
- package/lib/esm/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewPayload.js +9 -6
- package/lib/esm/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewReducer.js +19 -10
- package/lib/esm/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewSelector.js +7 -11
- package/lib/esm/view/settingsView/settingsViewHelpers.js +3 -2
- package/lib/index.d.ts +2 -2
- package/lib/index.js +28 -27
- package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +9 -2
- package/lib/view/scheduleView/scheduleDetailView/epics/fetchScheduleDetailsEpic.js +2 -0
- package/lib/view/settings/jeScheduleApprovalRules/epic/deleteJEScheduleApprovalRuleEpic.d.ts +2 -1
- package/lib/view/settings/jeScheduleApprovalRules/epic/deleteJEScheduleApprovalRuleEpic.js +21 -3
- package/lib/view/settings/jeScheduleApprovalRules/epic/fetchJEScheduleApprovalRulesEpic.d.ts +2 -1
- package/lib/view/settings/jeScheduleApprovalRules/epic/fetchJEScheduleApprovalRulesEpic.js +4 -1
- package/lib/view/settings/jeScheduleApprovalRules/epic/fetchJEScheduleApproversEpic.d.ts +2 -1
- package/lib/view/settings/jeScheduleApprovalRules/epic/fetchJEScheduleApproversEpic.js +4 -1
- package/lib/view/settings/jeScheduleApprovalRules/epic/jeScheduleApprovalActionEpic.d.ts +4 -1
- package/lib/view/settings/jeScheduleApprovalRules/epic/jeScheduleApprovalActionEpic.js +27 -4
- package/lib/view/settings/jeScheduleApprovalRules/epic/reorderJEScheduleApprovalRulesEpic.d.ts +2 -1
- package/lib/view/settings/jeScheduleApprovalRules/epic/reorderJEScheduleApprovalRulesEpic.js +6 -2
- package/lib/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalDraftEpic.d.ts +3 -2
- package/lib/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalDraftEpic.js +14 -9
- package/lib/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalRuleEpic.d.ts +2 -1
- package/lib/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalRuleEpic.js +20 -3
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewPayload.d.ts +11 -3
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewPayload.js +9 -6
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewReducer.d.ts +5 -3
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewReducer.js +19 -10
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewSelector.js +7 -14
- package/lib/view/settingsView/settingsViewHelpers.d.ts +1 -1
- package/lib/view/settingsView/settingsViewHelpers.js +3 -2
- package/lib/view/taskManager/taskListView/taskListReducer.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ID } from '../../commonStateTypes/common';
|
|
2
2
|
import { ZeniAPIResponse, ZeniAPIStatus } from '../../responsePayload';
|
|
3
3
|
import { JEScheduleApprovalAPIStatus, JEScheduleApprovalInfo, JEScheduleApprovalRuleFormData, JEScheduleApprovalRuleState, JEScheduleApprovalStepState, JEScheduleApprover, JEScheduleApproverRole } from './jeScheduleApprovalRuleState';
|
|
4
|
-
import { JEScheduleType } from './jeScheduleApprovalRuleTypes';
|
|
4
|
+
import { JEApprovalEntriesSource, JEScheduleType } from './jeScheduleApprovalRuleTypes';
|
|
5
5
|
export interface JEScheduleApprovalUserActorPayload {
|
|
6
6
|
id: ID;
|
|
7
7
|
type: 'user';
|
|
@@ -39,8 +39,8 @@ export interface JEScheduleApprovalRulesListPayload {
|
|
|
39
39
|
export interface JEScheduleApprovalRuleSavePayload extends JEScheduleApprovalRulesListPayload {
|
|
40
40
|
rule: JEScheduleApprovalRulePayload;
|
|
41
41
|
}
|
|
42
|
-
/** Body for POST / PUT `/1.0/je-schedules/approval-rules[/<id>]
|
|
43
|
-
export
|
|
42
|
+
/** Body for POST / PUT `/1.0/je-schedules/approval-rules[/<id>]`; a type alias so it satisfies the `Record<string, unknown>` body param. */
|
|
43
|
+
export type JEScheduleApprovalRuleRequestBody = {
|
|
44
44
|
description: string | null;
|
|
45
45
|
is_applicable_on_pending_approval_entity: boolean;
|
|
46
46
|
is_separation_of_duty_enabled: boolean;
|
|
@@ -48,8 +48,7 @@ export interface JEScheduleApprovalRuleRequestBody {
|
|
|
48
48
|
name: string;
|
|
49
49
|
schedule_types: JEScheduleType[];
|
|
50
50
|
step: JEScheduleApprovalStepPayload;
|
|
51
|
-
|
|
52
|
-
}
|
|
51
|
+
};
|
|
53
52
|
export interface JEScheduleApproverPayload {
|
|
54
53
|
email: string;
|
|
55
54
|
first_name: string;
|
|
@@ -74,6 +73,8 @@ export interface JEScheduleApprovalInfoPayload {
|
|
|
74
73
|
approver_roles: string[];
|
|
75
74
|
approver_user_ids: ID[];
|
|
76
75
|
can_approve: boolean;
|
|
76
|
+
entries_source: JEApprovalEntriesSource;
|
|
77
|
+
entries_version: number;
|
|
77
78
|
matched_rule_ids: ID[];
|
|
78
79
|
matched_rule_name: string | null;
|
|
79
80
|
matched_rule_owner: string | null;
|
|
@@ -96,5 +97,5 @@ export declare const toJEScheduleApprovalRulePayload: (formData: JEScheduleAppro
|
|
|
96
97
|
export declare const toJEScheduleApprover: (payload: JEScheduleApproverPayload) => JEScheduleApprover;
|
|
97
98
|
export declare const toJEScheduleApproverRole: (payload: JEScheduleApproverRolePayload) => JEScheduleApproverRole;
|
|
98
99
|
export declare const toJEScheduleApprovalInfo: (payload: JEScheduleApprovalInfoPayload | null | undefined) => JEScheduleApprovalInfo | undefined;
|
|
99
|
-
/** Wraps an API status with a typed `kind` and a user-facing message for 403 /
|
|
100
|
-
export declare const toJEScheduleApprovalAPIStatus: (status: ZeniAPIStatus) => JEScheduleApprovalAPIStatus;
|
|
100
|
+
/** Wraps an API status with a typed `kind` and a user-facing message for 403 / 404; a 404 on the action endpoint means the schedule, not the rules, is gone. */
|
|
101
|
+
export declare const toJEScheduleApprovalAPIStatus: (status: ZeniAPIStatus, context?: "rules" | "action") => JEScheduleApprovalAPIStatus;
|
|
@@ -106,6 +106,8 @@ const toJEScheduleApprovalInfo = (payload) => {
|
|
|
106
106
|
return {
|
|
107
107
|
requiresApproval: payload.requires_approval,
|
|
108
108
|
canApprove: payload.can_approve,
|
|
109
|
+
entriesSource: payload.entries_source,
|
|
110
|
+
entriesVersion: payload.entries_version,
|
|
109
111
|
approverLabels: payload.approver_labels,
|
|
110
112
|
approverRoles: payload.approver_roles,
|
|
111
113
|
approverUserIds: payload.approver_user_ids,
|
|
@@ -139,18 +141,18 @@ const toJEApprovalErrorKind = (code) => {
|
|
|
139
141
|
};
|
|
140
142
|
const USER_FACING_MESSAGES = {
|
|
141
143
|
forbidden: 'You are not allowed to perform this action.',
|
|
142
|
-
conflict:
|
|
144
|
+
conflict: undefined, // already-claimed and stale-draft both arrive with a user-facing message
|
|
143
145
|
validation: undefined, // backend's status.message is already user-facing
|
|
144
146
|
not_found: 'JE schedule approval rules are not available for this account.',
|
|
145
147
|
unknown: undefined,
|
|
146
148
|
};
|
|
147
|
-
|
|
148
|
-
|
|
149
|
+
const SCHEDULE_NOT_FOUND_MESSAGE = 'This schedule no longer exists.';
|
|
150
|
+
/** Wraps an API status with a typed `kind` and a user-facing message for 403 / 404; a 404 on the action endpoint means the schedule, not the rules, is gone. */
|
|
151
|
+
const toJEScheduleApprovalAPIStatus = (status, context = 'rules') => {
|
|
149
152
|
const kind = toJEApprovalErrorKind(status.code);
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
kind
|
|
153
|
-
|
|
154
|
-
};
|
|
153
|
+
const message = kind === 'not_found' && context === 'action'
|
|
154
|
+
? status.message || SCHEDULE_NOT_FOUND_MESSAGE
|
|
155
|
+
: (USER_FACING_MESSAGES[kind] ?? status.message);
|
|
156
|
+
return { ...status, kind, message };
|
|
155
157
|
};
|
|
156
158
|
exports.toJEScheduleApprovalAPIStatus = toJEScheduleApprovalAPIStatus;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ID } from '../../commonStateTypes/common';
|
|
2
2
|
import { ZeniAPIStatus } from '../../responsePayload';
|
|
3
3
|
import { ZeniDate } from '../../zeniDayJS';
|
|
4
|
-
import { JEApprovalErrorKind, JEApprovalOwner, JEApprovalRoleSubType, JEApprovalStepAction, JEScheduleType } from './jeScheduleApprovalRuleTypes';
|
|
4
|
+
import { JEApprovalEntriesSource, JEApprovalErrorKind, JEApprovalOwner, JEApprovalRoleSubType, JEApprovalStepAction, JEScheduleType } from './jeScheduleApprovalRuleTypes';
|
|
5
5
|
/** A user eligible to approve JE schedules, as `/je-schedules/approvers` reports them. */
|
|
6
6
|
export interface JEScheduleApprover {
|
|
7
7
|
email: string;
|
|
@@ -71,6 +71,10 @@ export interface JEScheduleApprovalInfo {
|
|
|
71
71
|
approverRoles: string[];
|
|
72
72
|
approverUserIds: ID[];
|
|
73
73
|
canApprove: boolean;
|
|
74
|
+
/** 'parked' when the detail read served the rows saved while held; 'live' otherwise. */
|
|
75
|
+
entriesSource: JEApprovalEntriesSource;
|
|
76
|
+
/** Echoed back on approve; the server answers 409 when the draft was re-parked since. */
|
|
77
|
+
entriesVersion: number;
|
|
74
78
|
matchedRuleIds: ID[];
|
|
75
79
|
message: string;
|
|
76
80
|
requiresApproval: boolean;
|
|
@@ -28,5 +28,7 @@ export declare const JE_SCHEDULE_TYPE_LABELS: Record<JEScheduleType, string>;
|
|
|
28
28
|
* 403 = viewer may not edit (or touched the other owner's rule / is not an
|
|
29
29
|
* eligible approver / SoD); 409 = someone else already approved.
|
|
30
30
|
*/
|
|
31
|
+
export declare const JE_APPROVAL_ENTRIES_SOURCES: readonly ["parked", "live"];
|
|
32
|
+
export type JEApprovalEntriesSource = (typeof JE_APPROVAL_ENTRIES_SOURCES)[number];
|
|
31
33
|
export declare const JE_APPROVAL_ERROR_KINDS: readonly ["forbidden", "conflict", "validation", "not_found", "unknown"];
|
|
32
34
|
export type JEApprovalErrorKind = (typeof JE_APPROVAL_ERROR_KINDS)[number];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JE_APPROVAL_ERROR_KINDS = exports.JE_SCHEDULE_TYPE_LABELS = exports.JE_LEVEL_LABELS = exports.JE_LEVEL_CONTROLLER = exports.JE_LEVEL_REVIEWER = exports.JE_LEVEL_PREPARER = exports.JE_APPROVAL_ACTIONS = exports.toJEApprovalRoleSubTypeStrict = exports.toJEApprovalRoleSubType = exports.JE_APPROVAL_ROLE_SUB_TYPES = exports.JE_APPROVAL_CUSTOMER_ROLE_SUB_TYPES = exports.JE_APPROVAL_ZENI_ROLE_SUB_TYPES = exports.toJEApprovalStepAction = exports.JE_APPROVAL_STEP_ACTIONS = exports.toJEApprovalOwnerStrict = exports.toJEApprovalOwner = exports.JE_APPROVAL_OWNERS = exports.toJEScheduleTypeStrict = exports.toJEScheduleType = exports.JE_SCHEDULE_TYPES = void 0;
|
|
3
|
+
exports.JE_APPROVAL_ERROR_KINDS = exports.JE_APPROVAL_ENTRIES_SOURCES = exports.JE_SCHEDULE_TYPE_LABELS = exports.JE_LEVEL_LABELS = exports.JE_LEVEL_CONTROLLER = exports.JE_LEVEL_REVIEWER = exports.JE_LEVEL_PREPARER = exports.JE_APPROVAL_ACTIONS = exports.toJEApprovalRoleSubTypeStrict = exports.toJEApprovalRoleSubType = exports.JE_APPROVAL_ROLE_SUB_TYPES = exports.JE_APPROVAL_CUSTOMER_ROLE_SUB_TYPES = exports.JE_APPROVAL_ZENI_ROLE_SUB_TYPES = exports.toJEApprovalStepAction = exports.JE_APPROVAL_STEP_ACTIONS = exports.toJEApprovalOwnerStrict = exports.toJEApprovalOwner = exports.JE_APPROVAL_OWNERS = exports.toJEScheduleTypeStrict = exports.toJEScheduleType = exports.JE_SCHEDULE_TYPES = void 0;
|
|
4
4
|
const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
|
|
5
5
|
exports.JE_SCHEDULE_TYPES = [
|
|
6
6
|
'prepaid_expenses',
|
|
@@ -58,6 +58,7 @@ exports.JE_SCHEDULE_TYPE_LABELS = {
|
|
|
58
58
|
* 403 = viewer may not edit (or touched the other owner's rule / is not an
|
|
59
59
|
* eligible approver / SoD); 409 = someone else already approved.
|
|
60
60
|
*/
|
|
61
|
+
exports.JE_APPROVAL_ENTRIES_SOURCES = ['parked', 'live'];
|
|
61
62
|
exports.JE_APPROVAL_ERROR_KINDS = [
|
|
62
63
|
'forbidden',
|
|
63
64
|
'conflict',
|
|
@@ -85,10 +85,8 @@ export interface JEOneTimeAccrual extends JEOneTimeAccrualState {
|
|
|
85
85
|
export declare const getJEOneTimeAccrualByKey: (jeOneTimeAccrualKey: JEOneTimeAccrualKey, jeSchedulesState: JESchedulesState) => JEOneTimeAccrual | undefined;
|
|
86
86
|
export declare const getJEAccruedScheduleByJEScheduleKey: (JEScheduleKey: JEScheduleKey, state: RootState) => JEAccruedSchedule | undefined;
|
|
87
87
|
export declare const getJEScheduledTransactionByJEScheduleTransactionKey: (jeScheduleTransactionKey: JEScheduleTransactionKey, state: RootState) => JEScheduledTransaction;
|
|
88
|
-
/**
|
|
89
|
-
|
|
90
|
-
* scans both maps. ponytail: O(n) scan; index by schedule id if lists grow.
|
|
91
|
-
*/
|
|
88
|
+
/** Schedules are keyed by transaction / accrued key, not schedule id, so this re-indexes both maps by schedule id. */
|
|
89
|
+
export declare const getApprovalInfoByScheduleId: (jeSchedulesState: JESchedulesState) => Record<ID, JEScheduleApprovalInfo>;
|
|
92
90
|
export declare const getScheduleApprovalInfo: (jeSchedulesState: JESchedulesState, jeScheduleId: ID) => JEScheduleApprovalInfo | undefined;
|
|
93
91
|
/** One-time accruals are keyed by accrual id, so this is a direct lookup, unlike the schedule scan. */
|
|
94
92
|
export declare const getOneTimeAccrualApprovalInfo: (jeSchedulesState: JESchedulesState, accrualId: ID) => JEScheduleApprovalInfo | undefined;
|
|
@@ -3,7 +3,8 @@ 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.getOneTimeAccrualApprovalInfo = exports.getScheduleApprovalInfo = exports.getJEScheduledTransactionByJEScheduleTransactionKey = exports.getJEAccruedScheduleByJEScheduleKey = exports.getJEOneTimeAccrualByKey = void 0;
|
|
6
|
+
exports.getOneTimeAccrualApprovalInfo = exports.getScheduleApprovalInfo = exports.getApprovalInfoByScheduleId = exports.getJEScheduledTransactionByJEScheduleTransactionKey = exports.getJEAccruedScheduleByJEScheduleKey = exports.getJEOneTimeAccrualByKey = void 0;
|
|
7
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
7
8
|
const get_1 = __importDefault(require("lodash/get"));
|
|
8
9
|
const amount_1 = require("../../commonStateTypes/amount");
|
|
9
10
|
const accountSelector_1 = require("../account/accountSelector");
|
|
@@ -177,18 +178,20 @@ const getJEScheduledTransactionByJEScheduleTransactionKey = (jeScheduleTransacti
|
|
|
177
178
|
};
|
|
178
179
|
};
|
|
179
180
|
exports.getJEScheduledTransactionByJEScheduleTransactionKey = getJEScheduledTransactionByJEScheduleTransactionKey;
|
|
180
|
-
/**
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
181
|
+
/** Schedules are keyed by transaction / accrued key, not schedule id, so this re-indexes both maps by schedule id. */
|
|
182
|
+
exports.getApprovalInfoByScheduleId = (0, toolkit_1.createSelector)((jeSchedulesState) => jeSchedulesState.schedulesByTransactionKey, (jeSchedulesState) => jeSchedulesState.schedulesByAccruedJEScheduleKey, (schedulesByTransactionKey, schedulesByAccruedJEScheduleKey) => {
|
|
183
|
+
const byScheduleId = {};
|
|
184
|
+
[
|
|
185
|
+
...Object.values(schedulesByTransactionKey),
|
|
186
|
+
...Object.values(schedulesByAccruedJEScheduleKey),
|
|
187
|
+
].forEach((schedule) => {
|
|
188
|
+
if (schedule.jeScheduleId != null && schedule.approvalInfo != null) {
|
|
189
|
+
byScheduleId[schedule.jeScheduleId] = schedule.approvalInfo;
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
return byScheduleId;
|
|
193
|
+
});
|
|
194
|
+
const getScheduleApprovalInfo = (jeSchedulesState, jeScheduleId) => (0, get_1.default)((0, exports.getApprovalInfoByScheduleId)(jeSchedulesState), jeScheduleId, undefined);
|
|
192
195
|
exports.getScheduleApprovalInfo = getScheduleApprovalInfo;
|
|
193
196
|
/** One-time accruals are keyed by accrual id, so this is a direct lookup, unlike the schedule scan. */
|
|
194
197
|
const getOneTimeAccrualApprovalInfo = (jeSchedulesState, accrualId) => (0, get_1.default)(jeSchedulesState.oneTimeAccrualsByKey, (0, jeScheduleHelper_1.generateJEOneTimeAccrualKey)(accrualId), undefined)?.approvalInfo;
|
|
@@ -97,6 +97,8 @@ export const toJEScheduleApprovalInfo = (payload) => {
|
|
|
97
97
|
return {
|
|
98
98
|
requiresApproval: payload.requires_approval,
|
|
99
99
|
canApprove: payload.can_approve,
|
|
100
|
+
entriesSource: payload.entries_source,
|
|
101
|
+
entriesVersion: payload.entries_version,
|
|
100
102
|
approverLabels: payload.approver_labels,
|
|
101
103
|
approverRoles: payload.approver_roles,
|
|
102
104
|
approverUserIds: payload.approver_user_ids,
|
|
@@ -129,17 +131,17 @@ const toJEApprovalErrorKind = (code) => {
|
|
|
129
131
|
};
|
|
130
132
|
const USER_FACING_MESSAGES = {
|
|
131
133
|
forbidden: 'You are not allowed to perform this action.',
|
|
132
|
-
conflict:
|
|
134
|
+
conflict: undefined, // already-claimed and stale-draft both arrive with a user-facing message
|
|
133
135
|
validation: undefined, // backend's status.message is already user-facing
|
|
134
136
|
not_found: 'JE schedule approval rules are not available for this account.',
|
|
135
137
|
unknown: undefined,
|
|
136
138
|
};
|
|
137
|
-
|
|
138
|
-
|
|
139
|
+
const SCHEDULE_NOT_FOUND_MESSAGE = 'This schedule no longer exists.';
|
|
140
|
+
/** Wraps an API status with a typed `kind` and a user-facing message for 403 / 404; a 404 on the action endpoint means the schedule, not the rules, is gone. */
|
|
141
|
+
export const toJEScheduleApprovalAPIStatus = (status, context = 'rules') => {
|
|
139
142
|
const kind = toJEApprovalErrorKind(status.code);
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
kind
|
|
143
|
-
|
|
144
|
-
};
|
|
143
|
+
const message = kind === 'not_found' && context === 'action'
|
|
144
|
+
? status.message || SCHEDULE_NOT_FOUND_MESSAGE
|
|
145
|
+
: (USER_FACING_MESSAGES[kind] ?? status.message);
|
|
146
|
+
return { ...status, kind, message };
|
|
145
147
|
};
|
|
@@ -48,6 +48,7 @@ export const JE_SCHEDULE_TYPE_LABELS = {
|
|
|
48
48
|
* 403 = viewer may not edit (or touched the other owner's rule / is not an
|
|
49
49
|
* eligible approver / SoD); 409 = someone else already approved.
|
|
50
50
|
*/
|
|
51
|
+
export const JE_APPROVAL_ENTRIES_SOURCES = ['parked', 'live'];
|
|
51
52
|
export const JE_APPROVAL_ERROR_KINDS = [
|
|
52
53
|
'forbidden',
|
|
53
54
|
'conflict',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createSelector } from '@reduxjs/toolkit';
|
|
1
2
|
import recordGet from 'lodash/get';
|
|
2
3
|
import { toAmount } from '../../commonStateTypes/amount';
|
|
3
4
|
import { getAccountBase } from '../account/accountSelector';
|
|
@@ -168,17 +169,19 @@ export const getJEScheduledTransactionByJEScheduleTransactionKey = (jeScheduleTr
|
|
|
168
169
|
recommendations,
|
|
169
170
|
};
|
|
170
171
|
};
|
|
171
|
-
/**
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
172
|
+
/** Schedules are keyed by transaction / accrued key, not schedule id, so this re-indexes both maps by schedule id. */
|
|
173
|
+
export const getApprovalInfoByScheduleId = createSelector((jeSchedulesState) => jeSchedulesState.schedulesByTransactionKey, (jeSchedulesState) => jeSchedulesState.schedulesByAccruedJEScheduleKey, (schedulesByTransactionKey, schedulesByAccruedJEScheduleKey) => {
|
|
174
|
+
const byScheduleId = {};
|
|
175
|
+
[
|
|
176
|
+
...Object.values(schedulesByTransactionKey),
|
|
177
|
+
...Object.values(schedulesByAccruedJEScheduleKey),
|
|
178
|
+
].forEach((schedule) => {
|
|
179
|
+
if (schedule.jeScheduleId != null && schedule.approvalInfo != null) {
|
|
180
|
+
byScheduleId[schedule.jeScheduleId] = schedule.approvalInfo;
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
return byScheduleId;
|
|
184
|
+
});
|
|
185
|
+
export const getScheduleApprovalInfo = (jeSchedulesState, jeScheduleId) => recordGet(getApprovalInfoByScheduleId(jeSchedulesState), jeScheduleId, undefined);
|
|
183
186
|
/** One-time accruals are keyed by accrual id, so this is a direct lookup, unlike the schedule scan. */
|
|
184
187
|
export const getOneTimeAccrualApprovalInfo = (jeSchedulesState, accrualId) => recordGet(jeSchedulesState.oneTimeAccrualsByKey, generateJEOneTimeAccrualKey(accrualId), undefined)?.approvalInfo;
|
package/lib/esm/index.js
CHANGED
|
@@ -62,7 +62,7 @@ import { updateEntities } from './entity/genericEntity/entityReducer';
|
|
|
62
62
|
import { getEntityByEntityIDs } from './entity/genericEntity/entitySelector';
|
|
63
63
|
import { toJEScheduleApprovalAPIStatus, toJEScheduleApprovalInfo, toJEScheduleApprovalRulePayload, toJEScheduleApprovalRuleState, toJEScheduleApprover, toJEScheduleApproverRole, } from './entity/jeScheduleApprovalRule/jeScheduleApprovalRulePayload';
|
|
64
64
|
import { JE_APPROVAL_CUSTOMER_ROLE_SUB_TYPES, JE_APPROVAL_OWNERS, JE_APPROVAL_ROLE_SUB_TYPES, JE_APPROVAL_STEP_ACTIONS, JE_APPROVAL_ZENI_ROLE_SUB_TYPES, JE_LEVEL_CONTROLLER, JE_LEVEL_LABELS, JE_LEVEL_PREPARER, JE_LEVEL_REVIEWER, JE_SCHEDULE_TYPES, JE_SCHEDULE_TYPE_LABELS, toJEApprovalOwner, toJEApprovalRoleSubType, toJEApprovalStepAction, toJEScheduleType, toJEScheduleTypeStrict, } from './entity/jeScheduleApprovalRule/jeScheduleApprovalRuleTypes';
|
|
65
|
-
import { getOneTimeAccrualApprovalInfo, getScheduleApprovalInfo, } from './entity/jeSchedules/jeSchedulesSelector';
|
|
65
|
+
import { getApprovalInfoByScheduleId, getOneTimeAccrualApprovalInfo, getScheduleApprovalInfo, } from './entity/jeSchedules/jeSchedulesSelector';
|
|
66
66
|
import { ALL_JE_SCHEDULE_IGNORE_REASONS, ALL_JE_SCHEDULE_REVERT_REASONS, ALL_ONE_TIME_ACCRUAL_IGNORE_REASONS, ALL_ONE_TIME_ACCRUAL_REVERT_REASONS, ALL_SCHEDULES_TYPES, getJEScheduleTransactionKey, toScheduleTypesType, toScheduleTypesTypeStrict, } from './entity/jeSchedules/jeSchedulesTypes';
|
|
67
67
|
import { ALL_MONTH_END_CLOSE_CHECKS_FREQUENCY, } from './entity/monthEndCloseChecks/monthEndCloseChecksState';
|
|
68
68
|
import { updateCommentsNotifications, updateCommentsNotificationsStatuses, } from './entity/notification/notificationReducer';
|
|
@@ -635,7 +635,7 @@ export { VERIFIED_PAYMENT_ACCOUNT_PROVIDER_VERIFICATION_STATUS, };
|
|
|
635
635
|
export { isSuccessResponse, isInvalidSessionError, isAccessDeniedError, };
|
|
636
636
|
export { getAmountCriteria, getApprovalRulesByEntityType, getDepartmentCriteria, getFallbackApprovalRule, getVendorCriteria, toAttributeTypeStrict, toAttributeOrRoleTypeStrict, toRoleTypeStrict, detectRuleOverlap, };
|
|
637
637
|
export { getBillPaySetupApproverView, getBillPaySetupApproverUpdateDataView, fetchBillPaySetupApproverView, fetchBillPayApproversDetails, fetchBillPayApproversList, deleteBillPayApprovalRule, reorderBillPayApprovalRules, saveBillPaySetupApproverViewUpdateData, saveBillPaySetupApproverViewUpdates, setBillsSetupApproverViewListeningToPusherEvent, initializeBillPaySetupApproverViewUpdateData, clearBillPaySetupApproverViewUpdateData, };
|
|
638
|
-
export { toJEScheduleApprovalAPIStatus, toJEScheduleApprovalInfo, toJEScheduleApprovalRulePayload, toJEScheduleApprovalRuleState, toJEScheduleApprover, toJEScheduleApproverRole, JE_APPROVAL_OWNERS, JE_APPROVAL_CUSTOMER_ROLE_SUB_TYPES, JE_APPROVAL_ROLE_SUB_TYPES, JE_APPROVAL_ZENI_ROLE_SUB_TYPES, JE_APPROVAL_STEP_ACTIONS, JE_LEVEL_CONTROLLER, JE_LEVEL_LABELS, JE_LEVEL_PREPARER, JE_LEVEL_REVIEWER, JE_SCHEDULE_TYPES, JE_SCHEDULE_TYPE_LABELS, toJEApprovalOwner, toJEApprovalRoleSubType, toJEApprovalStepAction, toJEScheduleType, toJEScheduleTypeStrict, toJEScheduleApprovalRulesList, getJEScheduleSetupApproverView, getJEScheduleOwnRules, getJEScheduleOtherRules, getJEScheduleOwnRuleCount, getApprovalStartsAt, getOneTimeAccrualApprovalInfo, getScheduleApprovalInfo, fetchJEScheduleApprovalRules, fetchJEScheduleApprovers, saveJEScheduleApprovalRule, deleteJEScheduleApprovalRule, reorderJEScheduleApprovalRules, jeScheduleApprovalAction, saveJEScheduleApprovalDraft, approveJEScheduleWithLocalEdits, clearJEScheduleApprovalRuleSaveStatus, };
|
|
638
|
+
export { toJEScheduleApprovalAPIStatus, toJEScheduleApprovalInfo, toJEScheduleApprovalRulePayload, toJEScheduleApprovalRuleState, toJEScheduleApprover, toJEScheduleApproverRole, JE_APPROVAL_OWNERS, JE_APPROVAL_CUSTOMER_ROLE_SUB_TYPES, JE_APPROVAL_ROLE_SUB_TYPES, JE_APPROVAL_ZENI_ROLE_SUB_TYPES, JE_APPROVAL_STEP_ACTIONS, JE_LEVEL_CONTROLLER, JE_LEVEL_LABELS, JE_LEVEL_PREPARER, JE_LEVEL_REVIEWER, JE_SCHEDULE_TYPES, JE_SCHEDULE_TYPE_LABELS, toJEApprovalOwner, toJEApprovalRoleSubType, toJEApprovalStepAction, toJEScheduleType, toJEScheduleTypeStrict, toJEScheduleApprovalRulesList, getJEScheduleSetupApproverView, getJEScheduleOwnRules, getJEScheduleOtherRules, getJEScheduleOwnRuleCount, getApprovalStartsAt, getApprovalInfoByScheduleId, getOneTimeAccrualApprovalInfo, getScheduleApprovalInfo, fetchJEScheduleApprovalRules, fetchJEScheduleApprovers, saveJEScheduleApprovalRule, deleteJEScheduleApprovalRule, reorderJEScheduleApprovalRules, jeScheduleApprovalAction, saveJEScheduleApprovalDraft, approveJEScheduleWithLocalEdits, clearJEScheduleApprovalRuleSaveStatus, };
|
|
639
639
|
export { getRemiSetupApproverView, getRemiSetupApproverUpdateDataView, fetchRemiSetupApproverView, fetchRemiApproversList, fetchRemiApproversDetails, deleteRemiApprovalRule, reorderRemiApprovalRules, saveRemiSetupApproverViewUpdateData, saveRemiSetupApproverViewUpdates, initializeRemiSetupApproverViewUpdateData, setRemiSetupApproverViewListeningToPusherEvent, clearRemiSetupApproverViewUpdateData, };
|
|
640
640
|
export { getRemiDetailView, checkApproveRejectBtnShowForRemi, };
|
|
641
641
|
export { saveRealTimeApproval, updateIsEditModeRealTimeApprovals, };
|
|
@@ -49,6 +49,7 @@ messageSection, accrualId, message, status) {
|
|
|
49
49
|
];
|
|
50
50
|
}
|
|
51
51
|
const MISSING_ACCOUNT_MESSAGE = 'This accrual is missing an expense or liability account.';
|
|
52
|
+
const MISSING_AMOUNT_MESSAGE = 'This accrual has no amount to save.';
|
|
52
53
|
/**
|
|
53
54
|
* The PUT /1.0/accruals/<id> body, shared by promote and save-draft. Returns undefined when either
|
|
54
55
|
* JE account is missing: promote posts a journal entry, and a draft saved without both sides would
|
|
@@ -167,9 +168,15 @@ export const saveJEOneTimeAccrualDraftEpic = (actions$, state$, zeniAPI) => acti
|
|
|
167
168
|
const state = state$.value;
|
|
168
169
|
const { accrualId, amount } = action.payload;
|
|
169
170
|
const accrual = getJEOneTimeAccrualByKey(generateJEOneTimeAccrualKey(accrualId), state.jeSchedulesState);
|
|
171
|
+
// The amount falls back to the stored estimate when the caller has none; with neither
|
|
172
|
+
// there is nothing to save, so refuse rather than park a 0 on the draft.
|
|
173
|
+
const draftAmount = amount ?? accrual?.estimatedAmount.amount;
|
|
174
|
+
if (draftAmount == null) {
|
|
175
|
+
return from(failureActions('je_schedule_approval_action', accrualId, MISSING_AMOUNT_MESSAGE));
|
|
176
|
+
}
|
|
170
177
|
// Same body as promote plus save_draft: the server keeps the edits on the held draft
|
|
171
|
-
// without posting.
|
|
172
|
-
const payload = buildOneTimeAccrualBody(state, accrualId,
|
|
178
|
+
// without posting.
|
|
179
|
+
const payload = buildOneTimeAccrualBody(state, accrualId, draftAmount);
|
|
173
180
|
if (payload == null) {
|
|
174
181
|
return from(failureActions('je_schedule_approval_action', accrualId, MISSING_ACCOUNT_MESSAGE));
|
|
175
182
|
}
|
|
@@ -26,6 +26,8 @@ export const fetchScheduleDetailsEpic = (actions$, state$, zeniAPI) => actions$.
|
|
|
26
26
|
const selectedJEScheduleKey = getJEScheduleTransactionDetailKeyPayload(response.data.je_schedules[0].base_transaction);
|
|
27
27
|
updateActions.push(updateJESchedules(response.data.je_schedules), updateSelectedJEScheduleKey({ selectedJEScheduleKey }), updateJESchedulesDetails(response.data.je_schedules, response.data.scheduled_journal_entries), saveScheduleDetailsSuccessOrFailure('Not-Started'), initializeScheduleDetailLocalData(scheduleType, selectedJEScheduleKey, selectedJeScheduleDetailId), updateScheduleDetailsSuccess());
|
|
28
28
|
if (response.data.je_schedules[0].status.code === 'draft' &&
|
|
29
|
+
response.data.je_schedules[0].approval_info
|
|
30
|
+
?.entries_source !== 'parked' &&
|
|
29
31
|
isCompleteJEScheduleFormDataPresent(response.data.je_schedules[0])) {
|
|
30
32
|
// check if all required data is present then only createNewSchedule
|
|
31
33
|
updateActions.push(createNewSchedules({ scheduleType }));
|
package/lib/esm/view/settings/jeScheduleApprovalRules/epic/deleteJEScheduleApprovalRuleEpic.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { from
|
|
2
|
-
import { catchError, filter, mergeMap,
|
|
1
|
+
import { from } from 'rxjs';
|
|
2
|
+
import { catchError, filter, mergeMap, takeUntil } from 'rxjs/operators';
|
|
3
3
|
import { toJEScheduleApprovalAPIStatus, } from '../../../../entity/jeScheduleApprovalRule/jeScheduleApprovalRulePayload';
|
|
4
4
|
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
5
5
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
6
|
+
import { clearAll } from '../../../../rootActions';
|
|
6
7
|
import { toJEScheduleApprovalRulesList } from '../jeScheduleSetupApproverViewPayload';
|
|
7
8
|
import { deleteJEScheduleApprovalRule, deleteJEScheduleApprovalRuleFailure, deleteJEScheduleApprovalRuleSuccess, } from '../jeScheduleSetupApproverViewReducer';
|
|
8
9
|
import { JE_SCHEDULE_APPROVAL_RULES_PATH } from './fetchJEScheduleApprovalRulesEpic';
|
|
9
|
-
export const deleteJEScheduleApprovalRuleEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(deleteJEScheduleApprovalRule.match),
|
|
10
|
+
export const deleteJEScheduleApprovalRuleEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(deleteJEScheduleApprovalRule.match),
|
|
11
|
+
// mergeMap: deleting two rules back to back must not cancel the first request.
|
|
12
|
+
mergeMap((action) => {
|
|
10
13
|
const { approvalRuleId } = action.payload;
|
|
11
14
|
return zeniAPI
|
|
12
15
|
.deleteAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}${JE_SCHEDULE_APPROVAL_RULES_PATH}/${approvalRuleId}`)
|
|
@@ -33,6 +36,21 @@ export const deleteJEScheduleApprovalRuleEpic = (actions$, _state$, zeniAPI) =>
|
|
|
33
36
|
],
|
|
34
37
|
}),
|
|
35
38
|
]);
|
|
36
|
-
}), catchError((error) =>
|
|
37
|
-
|
|
39
|
+
}), catchError((error) => {
|
|
40
|
+
const status = createZeniAPIStatus('Unexpected Error', 'Delete JE schedule approval rule errored out' +
|
|
41
|
+
JSON.stringify(error));
|
|
42
|
+
return from([
|
|
43
|
+
deleteJEScheduleApprovalRuleFailure(approvalRuleId, status),
|
|
44
|
+
openSnackbar({
|
|
45
|
+
messageSection: 'je_schedule_approval_delete',
|
|
46
|
+
messageText: 'failed',
|
|
47
|
+
type: 'error',
|
|
48
|
+
variables: [
|
|
49
|
+
{ variableName: '_api-error_', variableValue: status.message },
|
|
50
|
+
],
|
|
51
|
+
}),
|
|
52
|
+
]);
|
|
53
|
+
}),
|
|
54
|
+
// A tenant switch clears the store while this request is still in flight.
|
|
55
|
+
takeUntil(actions$.pipe(filter(clearAll.match))));
|
|
38
56
|
}));
|
package/lib/esm/view/settings/jeScheduleApprovalRules/epic/fetchJEScheduleApprovalRulesEpic.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
2
|
+
import { catchError, filter, mergeMap, switchMap, takeUntil, } from 'rxjs/operators';
|
|
3
3
|
import { toJEScheduleApprovalAPIStatus, } from '../../../../entity/jeScheduleApprovalRule/jeScheduleApprovalRulePayload';
|
|
4
4
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
5
|
+
import { clearAll } from '../../../../rootActions';
|
|
5
6
|
import { toJEScheduleApprovalRulesList } from '../jeScheduleSetupApproverViewPayload';
|
|
6
7
|
import { fetchJEScheduleApprovalRules, fetchJEScheduleApprovalRulesFailure, fetchJEScheduleApprovalRulesSuccess, } from '../jeScheduleSetupApproverViewReducer';
|
|
7
8
|
export const JE_SCHEDULE_APPROVAL_RULES_PATH = '/1.0/je-schedules/approval-rules';
|
|
@@ -24,5 +25,7 @@ export const fetchJEScheduleApprovalRulesEpic = (actions$, state$, zeniAPI) => a
|
|
|
24
25
|
}
|
|
25
26
|
return of(fetchJEScheduleApprovalRulesFailure(toJEScheduleApprovalAPIStatus(response.status)));
|
|
26
27
|
}), catchError((error) => of(fetchJEScheduleApprovalRulesFailure(createZeniAPIStatus('Unexpected Error', 'Fetch JE schedule approval rules errored out' +
|
|
27
|
-
JSON.stringify(error)))))
|
|
28
|
+
JSON.stringify(error))))),
|
|
29
|
+
// A tenant switch clears the store while this request is still in flight.
|
|
30
|
+
takeUntil(actions$.pipe(filter(clearAll.match))));
|
|
28
31
|
}));
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
2
|
+
import { catchError, filter, mergeMap, switchMap, takeUntil, } from 'rxjs/operators';
|
|
3
3
|
import { toJEScheduleApprovalAPIStatus, toJEScheduleApprover, toJEScheduleApproverRole, } from '../../../../entity/jeScheduleApprovalRule/jeScheduleApprovalRulePayload';
|
|
4
4
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
5
|
+
import { clearAll } from '../../../../rootActions';
|
|
5
6
|
import { fetchJEScheduleApprovers, fetchJEScheduleApproversFailure, fetchJEScheduleApproversSuccess, } from '../jeScheduleSetupApproverViewReducer';
|
|
6
7
|
export const JE_SCHEDULE_APPROVERS_PATH = '/1.0/je-schedules/approvers';
|
|
7
8
|
export const fetchJEScheduleApproversEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchJEScheduleApprovers.match), switchMap((action) => {
|
|
@@ -18,5 +19,7 @@ export const fetchJEScheduleApproversEpic = (actions$, state$, zeniAPI) => actio
|
|
|
18
19
|
}
|
|
19
20
|
return of(fetchJEScheduleApproversFailure(toJEScheduleApprovalAPIStatus(response.status)));
|
|
20
21
|
}), catchError((error) => of(fetchJEScheduleApproversFailure(createZeniAPIStatus('Unexpected Error', 'Fetch JE schedule approvers errored out' +
|
|
21
|
-
JSON.stringify(error)))))
|
|
22
|
+
JSON.stringify(error))))),
|
|
23
|
+
// A tenant switch clears the store while this request is still in flight.
|
|
24
|
+
takeUntil(actions$.pipe(filter(clearAll.match))));
|
|
22
25
|
}));
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { from
|
|
2
|
-
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
1
|
+
import { from } from 'rxjs';
|
|
2
|
+
import { catchError, filter, mergeMap, takeUntil } from 'rxjs/operators';
|
|
3
3
|
import { toJEScheduleApprovalAPIStatus } from '../../../../entity/jeScheduleApprovalRule/jeScheduleApprovalRulePayload';
|
|
4
4
|
import { updateAccruedJESchedulesDetails, updateJESchedulesDetails, } from '../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
5
5
|
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
6
6
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
7
|
+
import { clearAll } from '../../../../rootActions';
|
|
8
|
+
import { fetchScheduleAccruedDetails } from '../../../scheduleView/scheduleAccruedDetailView/scheduleAccruedDetailReducer';
|
|
9
|
+
import { fetchScheduleDetails } from '../../../scheduleView/scheduleDetailView/scheduleDetailReducer';
|
|
7
10
|
import { isAccruedJESchedulePayload, toJEScheduleApprovalActionRequestBody, } from '../jeScheduleSetupApproverViewPayload';
|
|
8
11
|
import { jeScheduleApprovalAction, jeScheduleApprovalActionFailure, jeScheduleApprovalActionSuccess, } from '../jeScheduleSetupApproverViewReducer';
|
|
9
12
|
/** mergeMap: approving two different schedules back to back must not cancel the first. */
|
|
10
13
|
export const jeScheduleApprovalActionEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(jeScheduleApprovalAction.match), mergeMap((action) => {
|
|
11
|
-
const { jeScheduleId, body } = action.payload;
|
|
14
|
+
const { jeScheduleId, body, refetch } = action.payload;
|
|
12
15
|
return zeniAPI
|
|
13
16
|
.postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${jeScheduleId}/approval-action`, toJEScheduleApprovalActionRequestBody(body))
|
|
14
17
|
.pipe(mergeMap((response) => {
|
|
@@ -26,7 +29,26 @@ export const jeScheduleApprovalActionEpic = (actions$, _state$, zeniAPI) => acti
|
|
|
26
29
|
}),
|
|
27
30
|
]);
|
|
28
31
|
}
|
|
29
|
-
const status = toJEScheduleApprovalAPIStatus(response.status);
|
|
32
|
+
const status = toJEScheduleApprovalAPIStatus(response.status, 'action');
|
|
33
|
+
const failureActions = [
|
|
34
|
+
jeScheduleApprovalActionFailure(jeScheduleId, status),
|
|
35
|
+
openSnackbar({
|
|
36
|
+
messageSection: 'je_schedule_approval_action',
|
|
37
|
+
messageText: 'failed',
|
|
38
|
+
type: 'error',
|
|
39
|
+
variables: [
|
|
40
|
+
{ variableName: '_api-error_', variableValue: status.message },
|
|
41
|
+
],
|
|
42
|
+
}),
|
|
43
|
+
];
|
|
44
|
+
if (status.kind === 'conflict' && refetch != null) {
|
|
45
|
+
failureActions.push(refetch.isAccrued
|
|
46
|
+
? fetchScheduleAccruedDetails(refetch.scheduleType, jeScheduleId)
|
|
47
|
+
: fetchScheduleDetails(refetch.scheduleType, jeScheduleId, true));
|
|
48
|
+
}
|
|
49
|
+
return from(failureActions);
|
|
50
|
+
}), catchError((error) => {
|
|
51
|
+
const status = createZeniAPIStatus('Unexpected Error', 'JE schedule approval action errored out' + JSON.stringify(error));
|
|
30
52
|
return from([
|
|
31
53
|
jeScheduleApprovalActionFailure(jeScheduleId, status),
|
|
32
54
|
openSnackbar({
|
|
@@ -38,6 +60,7 @@ export const jeScheduleApprovalActionEpic = (actions$, _state$, zeniAPI) => acti
|
|
|
38
60
|
],
|
|
39
61
|
}),
|
|
40
62
|
]);
|
|
41
|
-
}),
|
|
42
|
-
|
|
63
|
+
}),
|
|
64
|
+
// A tenant switch clears the store while this request is still in flight.
|
|
65
|
+
takeUntil(actions$.pipe(filter(clearAll.match))));
|
|
43
66
|
}));
|
package/lib/esm/view/settings/jeScheduleApprovalRules/epic/reorderJEScheduleApprovalRulesEpic.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { from } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
2
|
+
import { catchError, filter, mergeMap, switchMap, takeUntil, } from 'rxjs/operators';
|
|
3
3
|
import { toJEScheduleApprovalAPIStatus, } from '../../../../entity/jeScheduleApprovalRule/jeScheduleApprovalRulePayload';
|
|
4
4
|
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
5
5
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
6
|
+
import { clearAll } from '../../../../rootActions';
|
|
6
7
|
import { toJEScheduleApprovalRulesList, } from '../jeScheduleSetupApproverViewPayload';
|
|
7
8
|
import { fetchJEScheduleApprovalRules, reorderJEScheduleApprovalRules, reorderJEScheduleApprovalRulesFailure, reorderJEScheduleApprovalRulesSuccess, } from '../jeScheduleSetupApproverViewReducer';
|
|
8
9
|
import { JE_SCHEDULE_APPROVAL_RULES_PATH } from './fetchJEScheduleApprovalRulesEpic';
|
|
@@ -21,7 +22,8 @@ export const reorderJEScheduleApprovalRulesEpic = (actions$, _state$, zeniAPI) =
|
|
|
21
22
|
messageText: 'failed',
|
|
22
23
|
type: 'error',
|
|
23
24
|
}),
|
|
24
|
-
|
|
25
|
+
// Silent: the list is already on screen, a full-slice spinner would blank it.
|
|
26
|
+
fetchJEScheduleApprovalRules(true, true),
|
|
25
27
|
]);
|
|
26
28
|
return zeniAPI
|
|
27
29
|
.putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}${JE_SCHEDULE_APPROVAL_RULES_PATH}/reorder`, body)
|
|
@@ -38,5 +40,7 @@ export const reorderJEScheduleApprovalRulesEpic = (actions$, _state$, zeniAPI) =
|
|
|
38
40
|
}
|
|
39
41
|
return recover(toJEScheduleApprovalAPIStatus(response.status));
|
|
40
42
|
}), catchError((error) => recover(createZeniAPIStatus('Unexpected Error', 'Reorder JE schedule approval rules errored out' +
|
|
41
|
-
JSON.stringify(error))))
|
|
43
|
+
JSON.stringify(error)))),
|
|
44
|
+
// A tenant switch clears the store while this request is still in flight.
|
|
45
|
+
takeUntil(actions$.pipe(filter(clearAll.match))));
|
|
42
46
|
}));
|
package/lib/esm/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalDraftEpic.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { filter, map } from 'rxjs/operators';
|
|
2
|
+
import { getScheduleApprovalInfo } from '../../../../entity/jeSchedules/jeSchedulesSelector';
|
|
2
3
|
import { createZeniAPIStatus } from '../../../../responsePayload';
|
|
3
4
|
import { prepareScheduleAccruedDetailPayload, } from '../../../scheduleView/scheduleAccruedDetailView/scheduleAccruedDetailPayload';
|
|
4
5
|
import { prepareScheduleDetailPayload, } from '../../../scheduleView/scheduleDetailView/scheduleDetailPayload';
|
|
@@ -19,20 +20,24 @@ function buildDraftPayload(state, jeScheduleId, scheduleType, isAccrued) {
|
|
|
19
20
|
}
|
|
20
21
|
/**
|
|
21
22
|
* Builds the schedule body from the open schedule's local edits and reuses the approval-action call.
|
|
22
|
-
* Save Draft needs those edits
|
|
23
|
-
*
|
|
23
|
+
* Save Draft needs those edits. Approve sends the rows on screen plus the entries version it read,
|
|
24
|
+
* so the server posts what the approver saw (or 409s when the draft moved); it still goes out with
|
|
25
|
+
* neither when there are no local edits (the server falls back to the parked rows).
|
|
24
26
|
*/
|
|
25
27
|
export const saveJEScheduleApprovalDraftEpic = (actions$, state$) => actions$.pipe(filter((action) => saveJEScheduleApprovalDraft.match(action) ||
|
|
26
28
|
approveJEScheduleWithLocalEdits.match(action)), map((action) => {
|
|
27
29
|
const { jeScheduleId, scheduleType, isAccrued } = action.payload;
|
|
28
30
|
const payload = buildDraftPayload(state$.value, jeScheduleId, scheduleType, isAccrued);
|
|
31
|
+
const refetch = { scheduleType, isAccrued };
|
|
29
32
|
if (approveJEScheduleWithLocalEdits.match(action)) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
const approvalEntriesVersion = getScheduleApprovalInfo(state$.value.jeSchedulesState, jeScheduleId)?.entriesVersion;
|
|
34
|
+
return jeScheduleApprovalAction(jeScheduleId, {
|
|
35
|
+
action: 'approve',
|
|
36
|
+
...(payload != null
|
|
37
|
+
? { scheduledJournalEntries: payload.scheduled_journal_entries }
|
|
38
|
+
: {}),
|
|
39
|
+
...(approvalEntriesVersion != null ? { approvalEntriesVersion } : {}),
|
|
40
|
+
}, refetch);
|
|
36
41
|
}
|
|
37
42
|
if (payload == null) {
|
|
38
43
|
return jeScheduleApprovalActionFailure(jeScheduleId, createZeniAPIStatus('Unexpected Error', 'No local schedule edits to save as draft'));
|
|
@@ -41,5 +46,5 @@ export const saveJEScheduleApprovalDraftEpic = (actions$, state$) => actions$.pi
|
|
|
41
46
|
action: 'save_draft',
|
|
42
47
|
jeSchedules: payload.je_schedules,
|
|
43
48
|
scheduledJournalEntries: payload.scheduled_journal_entries,
|
|
44
|
-
});
|
|
49
|
+
}, refetch);
|
|
45
50
|
}));
|
package/lib/esm/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalRuleEpic.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { from
|
|
2
|
-
import { catchError, filter, mergeMap,
|
|
1
|
+
import { from } from 'rxjs';
|
|
2
|
+
import { catchError, filter, mergeMap, takeUntil } from 'rxjs/operators';
|
|
3
3
|
import { toJEScheduleApprovalAPIStatus, toJEScheduleApprovalRulePayload, } from '../../../../entity/jeScheduleApprovalRule/jeScheduleApprovalRulePayload';
|
|
4
4
|
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
5
5
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
6
|
+
import { clearAll } from '../../../../rootActions';
|
|
6
7
|
import { toJEScheduleApprovalRulesList } from '../jeScheduleSetupApproverViewPayload';
|
|
7
8
|
import { saveJEScheduleApprovalRule, saveJEScheduleApprovalRuleFailure, saveJEScheduleApprovalRuleSuccess, } from '../jeScheduleSetupApproverViewReducer';
|
|
8
9
|
import { JE_SCHEDULE_APPROVAL_RULES_PATH } from './fetchJEScheduleApprovalRulesEpic';
|
|
9
|
-
export const saveJEScheduleApprovalRuleEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(saveJEScheduleApprovalRule.match),
|
|
10
|
+
export const saveJEScheduleApprovalRuleEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(saveJEScheduleApprovalRule.match),
|
|
11
|
+
// mergeMap: saving two rules back to back must not cancel the first request.
|
|
12
|
+
mergeMap((action) => {
|
|
10
13
|
const { formData } = action.payload;
|
|
11
14
|
const body = toJEScheduleApprovalRulePayload(formData);
|
|
12
15
|
const isUpdate = formData.approvalRuleId != null;
|
|
@@ -40,6 +43,20 @@ export const saveJEScheduleApprovalRuleEpic = (actions$, _state$, zeniAPI) => ac
|
|
|
40
43
|
],
|
|
41
44
|
}),
|
|
42
45
|
]);
|
|
43
|
-
}), catchError((error) =>
|
|
44
|
-
JSON.stringify(error))
|
|
46
|
+
}), catchError((error) => {
|
|
47
|
+
const status = createZeniAPIStatus('Unexpected Error', 'Save JE schedule approval rule errored out' + JSON.stringify(error));
|
|
48
|
+
return from([
|
|
49
|
+
saveJEScheduleApprovalRuleFailure(status),
|
|
50
|
+
openSnackbar({
|
|
51
|
+
messageSection: section,
|
|
52
|
+
messageText: 'failed',
|
|
53
|
+
type: 'error',
|
|
54
|
+
variables: [
|
|
55
|
+
{ variableName: '_api-error_', variableValue: status.message },
|
|
56
|
+
],
|
|
57
|
+
}),
|
|
58
|
+
]);
|
|
59
|
+
}),
|
|
60
|
+
// A tenant switch clears the store while this request is still in flight.
|
|
61
|
+
takeUntil(actions$.pipe(filter(clearAll.match))));
|
|
45
62
|
}));
|