@zeniai/client-epic-state 5.3.6-betaGS2 → 5.3.6-betaGS3
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 +3 -1
- package/lib/entity/jeScheduleApprovalRule/jeScheduleApprovalRulePayload.js +3 -1
- 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/esm/entity/jeScheduleApprovalRule/jeScheduleApprovalRulePayload.js +3 -1
- package/lib/esm/entity/jeScheduleApprovalRule/jeScheduleApprovalRuleTypes.js +1 -0
- package/lib/esm/view/scheduleView/scheduleDetailView/epics/fetchScheduleDetailsEpic.js +2 -0
- package/lib/esm/view/settings/jeScheduleApprovalRules/epic/jeScheduleApprovalActionEpic.js +11 -3
- package/lib/esm/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalDraftEpic.js +14 -9
- package/lib/esm/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewPayload.js +9 -6
- package/lib/esm/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewReducer.js +2 -2
- package/lib/view/scheduleView/scheduleDetailView/epics/fetchScheduleDetailsEpic.js +2 -0
- package/lib/view/settings/jeScheduleApprovalRules/epic/jeScheduleApprovalActionEpic.d.ts +3 -1
- package/lib/view/settings/jeScheduleApprovalRules/epic/jeScheduleApprovalActionEpic.js +11 -3
- 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/jeScheduleSetupApproverViewPayload.d.ts +8 -0
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewPayload.js +9 -6
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewReducer.d.ts +3 -2
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewReducer.js +2 -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';
|
|
@@ -74,6 +74,8 @@ export interface JEScheduleApprovalInfoPayload {
|
|
|
74
74
|
approver_roles: string[];
|
|
75
75
|
approver_user_ids: ID[];
|
|
76
76
|
can_approve: boolean;
|
|
77
|
+
entries_source: JEApprovalEntriesSource;
|
|
78
|
+
entries_version: number;
|
|
77
79
|
matched_rule_ids: ID[];
|
|
78
80
|
matched_rule_name: string | null;
|
|
79
81
|
matched_rule_owner: string | null;
|
|
@@ -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,7 +141,7 @@ 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,
|
|
@@ -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',
|
|
@@ -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,7 +131,7 @@ 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,
|
|
@@ -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',
|
|
@@ -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 }));
|
|
@@ -4,11 +4,13 @@ import { toJEScheduleApprovalAPIStatus } from '../../../../entity/jeScheduleAppr
|
|
|
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 { fetchScheduleAccruedDetails } from '../../../scheduleView/scheduleAccruedDetailView/scheduleAccruedDetailReducer';
|
|
8
|
+
import { fetchScheduleDetails } from '../../../scheduleView/scheduleDetailView/scheduleDetailReducer';
|
|
7
9
|
import { isAccruedJESchedulePayload, toJEScheduleApprovalActionRequestBody, } from '../jeScheduleSetupApproverViewPayload';
|
|
8
10
|
import { jeScheduleApprovalAction, jeScheduleApprovalActionFailure, jeScheduleApprovalActionSuccess, } from '../jeScheduleSetupApproverViewReducer';
|
|
9
11
|
/** mergeMap: approving two different schedules back to back must not cancel the first. */
|
|
10
12
|
export const jeScheduleApprovalActionEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(jeScheduleApprovalAction.match), mergeMap((action) => {
|
|
11
|
-
const { jeScheduleId, body } = action.payload;
|
|
13
|
+
const { jeScheduleId, body, refetch } = action.payload;
|
|
12
14
|
return zeniAPI
|
|
13
15
|
.postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${jeScheduleId}/approval-action`, toJEScheduleApprovalActionRequestBody(body))
|
|
14
16
|
.pipe(mergeMap((response) => {
|
|
@@ -27,7 +29,7 @@ export const jeScheduleApprovalActionEpic = (actions$, _state$, zeniAPI) => acti
|
|
|
27
29
|
]);
|
|
28
30
|
}
|
|
29
31
|
const status = toJEScheduleApprovalAPIStatus(response.status);
|
|
30
|
-
|
|
32
|
+
const failureActions = [
|
|
31
33
|
jeScheduleApprovalActionFailure(jeScheduleId, status),
|
|
32
34
|
openSnackbar({
|
|
33
35
|
messageSection: 'je_schedule_approval_action',
|
|
@@ -37,7 +39,13 @@ export const jeScheduleApprovalActionEpic = (actions$, _state$, zeniAPI) => acti
|
|
|
37
39
|
{ variableName: '_api-error_', variableValue: status.message },
|
|
38
40
|
],
|
|
39
41
|
}),
|
|
40
|
-
]
|
|
42
|
+
];
|
|
43
|
+
if (status.kind === 'conflict' && refetch != null) {
|
|
44
|
+
failureActions.push(refetch.isAccrued
|
|
45
|
+
? fetchScheduleAccruedDetails(refetch.scheduleType, jeScheduleId)
|
|
46
|
+
: fetchScheduleDetails(refetch.scheduleType, jeScheduleId, true));
|
|
47
|
+
}
|
|
48
|
+
return from(failureActions);
|
|
41
49
|
}), catchError((error) => of(jeScheduleApprovalActionFailure(jeScheduleId, createZeniAPIStatus('Unexpected Error', 'JE schedule approval action errored out' +
|
|
42
50
|
JSON.stringify(error))))));
|
|
43
51
|
}));
|
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
|
}));
|
|
@@ -9,12 +9,15 @@ export const toJEScheduleApprovalRulesList = (payload) => ({
|
|
|
9
9
|
export const toJEScheduleApprovalActionRequestBody = (body) => {
|
|
10
10
|
switch (body.action) {
|
|
11
11
|
case 'approve':
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
scheduled_journal_entries: body.scheduledJournalEntries
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
return {
|
|
13
|
+
action: 'approve',
|
|
14
|
+
...(body.scheduledJournalEntries != null
|
|
15
|
+
? { scheduled_journal_entries: body.scheduledJournalEntries }
|
|
16
|
+
: {}),
|
|
17
|
+
...(body.approvalEntriesVersion != null
|
|
18
|
+
? { approval_entries_version: body.approvalEntriesVersion }
|
|
19
|
+
: {}),
|
|
20
|
+
};
|
|
18
21
|
case 'reject':
|
|
19
22
|
return { action: 'reject', rejection_reason: body.rejectionReason };
|
|
20
23
|
case 'save_draft':
|
|
@@ -203,8 +203,8 @@ const jeScheduleSetupApproverView = createSlice({
|
|
|
203
203
|
error: undefined,
|
|
204
204
|
};
|
|
205
205
|
},
|
|
206
|
-
prepare(jeScheduleId, body) {
|
|
207
|
-
return { payload: { jeScheduleId, body } };
|
|
206
|
+
prepare(jeScheduleId, body, refetch) {
|
|
207
|
+
return { payload: { jeScheduleId, body, refetch } };
|
|
208
208
|
},
|
|
209
209
|
},
|
|
210
210
|
saveJEScheduleApprovalDraft: {
|
|
@@ -29,6 +29,8 @@ const fetchScheduleDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe((0
|
|
|
29
29
|
const selectedJEScheduleKey = (0, jeSchedulesPayload_1.getJEScheduleTransactionDetailKeyPayload)(response.data.je_schedules[0].base_transaction);
|
|
30
30
|
updateActions.push((0, jeSchedulesReducer_1.updateJESchedules)(response.data.je_schedules), (0, scheduleDetailReducer_1.updateSelectedJEScheduleKey)({ selectedJEScheduleKey }), (0, jeSchedulesReducer_1.updateJESchedulesDetails)(response.data.je_schedules, response.data.scheduled_journal_entries), (0, scheduleDetailReducer_1.saveScheduleDetailsSuccessOrFailure)('Not-Started'), (0, scheduleDetailReducer_1.initializeScheduleDetailLocalData)(scheduleType, selectedJEScheduleKey, selectedJeScheduleDetailId), (0, scheduleDetailReducer_1.updateScheduleDetailsSuccess)());
|
|
31
31
|
if (response.data.je_schedules[0].status.code === 'draft' &&
|
|
32
|
+
response.data.je_schedules[0].approval_info
|
|
33
|
+
?.entries_source !== 'parked' &&
|
|
32
34
|
isCompleteJEScheduleFormDataPresent(response.data.je_schedules[0])) {
|
|
33
35
|
// check if all required data is present then only createNewSchedule
|
|
34
36
|
updateActions.push((0, scheduleDetailReducer_1.createNewSchedules)({ scheduleType }));
|
|
@@ -4,7 +4,9 @@ import { updateAccruedJESchedulesDetails, updateJESchedulesDetails } from '../..
|
|
|
4
4
|
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
5
5
|
import { RootState } from '../../../../rootStateTypes';
|
|
6
6
|
import { ZeniAPI } from '../../../../zeniAPI';
|
|
7
|
+
import { fetchScheduleAccruedDetails } from '../../../scheduleView/scheduleAccruedDetailView/scheduleAccruedDetailReducer';
|
|
8
|
+
import { fetchScheduleDetails } from '../../../scheduleView/scheduleDetailView/scheduleDetailReducer';
|
|
7
9
|
import { jeScheduleApprovalAction, jeScheduleApprovalActionFailure, jeScheduleApprovalActionSuccess } from '../jeScheduleSetupApproverViewReducer';
|
|
8
|
-
export type ActionType = ReturnType<typeof jeScheduleApprovalAction> | ReturnType<typeof updateJESchedulesDetails> | ReturnType<typeof updateAccruedJESchedulesDetails> | ReturnType<typeof openSnackbar> | ReturnType<typeof jeScheduleApprovalActionSuccess> | ReturnType<typeof jeScheduleApprovalActionFailure>;
|
|
10
|
+
export type ActionType = ReturnType<typeof jeScheduleApprovalAction> | ReturnType<typeof updateJESchedulesDetails> | ReturnType<typeof updateAccruedJESchedulesDetails> | ReturnType<typeof openSnackbar> | ReturnType<typeof jeScheduleApprovalActionSuccess> | ReturnType<typeof jeScheduleApprovalActionFailure> | ReturnType<typeof fetchScheduleDetails> | ReturnType<typeof fetchScheduleAccruedDetails>;
|
|
9
11
|
/** mergeMap: approving two different schedules back to back must not cancel the first. */
|
|
10
12
|
export declare const jeScheduleApprovalActionEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -7,11 +7,13 @@ const jeScheduleApprovalRulePayload_1 = require("../../../../entity/jeScheduleAp
|
|
|
7
7
|
const jeSchedulesReducer_1 = require("../../../../entity/jeSchedules/jeSchedulesReducer");
|
|
8
8
|
const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
|
|
9
9
|
const responsePayload_1 = require("../../../../responsePayload");
|
|
10
|
+
const scheduleAccruedDetailReducer_1 = require("../../../scheduleView/scheduleAccruedDetailView/scheduleAccruedDetailReducer");
|
|
11
|
+
const scheduleDetailReducer_1 = require("../../../scheduleView/scheduleDetailView/scheduleDetailReducer");
|
|
10
12
|
const jeScheduleSetupApproverViewPayload_1 = require("../jeScheduleSetupApproverViewPayload");
|
|
11
13
|
const jeScheduleSetupApproverViewReducer_1 = require("../jeScheduleSetupApproverViewReducer");
|
|
12
14
|
/** mergeMap: approving two different schedules back to back must not cancel the first. */
|
|
13
15
|
const jeScheduleApprovalActionEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeScheduleSetupApproverViewReducer_1.jeScheduleApprovalAction.match), (0, operators_1.mergeMap)((action) => {
|
|
14
|
-
const { jeScheduleId, body } = action.payload;
|
|
16
|
+
const { jeScheduleId, body, refetch } = action.payload;
|
|
15
17
|
return zeniAPI
|
|
16
18
|
.postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${jeScheduleId}/approval-action`, (0, jeScheduleSetupApproverViewPayload_1.toJEScheduleApprovalActionRequestBody)(body))
|
|
17
19
|
.pipe((0, operators_1.mergeMap)((response) => {
|
|
@@ -30,7 +32,7 @@ const jeScheduleApprovalActionEpic = (actions$, _state$, zeniAPI) => actions$.pi
|
|
|
30
32
|
]);
|
|
31
33
|
}
|
|
32
34
|
const status = (0, jeScheduleApprovalRulePayload_1.toJEScheduleApprovalAPIStatus)(response.status);
|
|
33
|
-
|
|
35
|
+
const failureActions = [
|
|
34
36
|
(0, jeScheduleSetupApproverViewReducer_1.jeScheduleApprovalActionFailure)(jeScheduleId, status),
|
|
35
37
|
(0, snackbarReducer_1.openSnackbar)({
|
|
36
38
|
messageSection: 'je_schedule_approval_action',
|
|
@@ -40,7 +42,13 @@ const jeScheduleApprovalActionEpic = (actions$, _state$, zeniAPI) => actions$.pi
|
|
|
40
42
|
{ variableName: '_api-error_', variableValue: status.message },
|
|
41
43
|
],
|
|
42
44
|
}),
|
|
43
|
-
]
|
|
45
|
+
];
|
|
46
|
+
if (status.kind === 'conflict' && refetch != null) {
|
|
47
|
+
failureActions.push(refetch.isAccrued
|
|
48
|
+
? (0, scheduleAccruedDetailReducer_1.fetchScheduleAccruedDetails)(refetch.scheduleType, jeScheduleId)
|
|
49
|
+
: (0, scheduleDetailReducer_1.fetchScheduleDetails)(refetch.scheduleType, jeScheduleId, true));
|
|
50
|
+
}
|
|
51
|
+
return (0, rxjs_1.from)(failureActions);
|
|
44
52
|
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, jeScheduleSetupApproverViewReducer_1.jeScheduleApprovalActionFailure)(jeScheduleId, (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'JE schedule approval action errored out' +
|
|
45
53
|
JSON.stringify(error))))));
|
|
46
54
|
}));
|
|
@@ -4,7 +4,8 @@ import { approveJEScheduleWithLocalEdits, jeScheduleApprovalAction, jeScheduleAp
|
|
|
4
4
|
export type ActionType = ReturnType<typeof saveJEScheduleApprovalDraft> | ReturnType<typeof approveJEScheduleWithLocalEdits> | ReturnType<typeof jeScheduleApprovalAction> | ReturnType<typeof jeScheduleApprovalActionFailure>;
|
|
5
5
|
/**
|
|
6
6
|
* Builds the schedule body from the open schedule's local edits and reuses the approval-action call.
|
|
7
|
-
* Save Draft needs those edits
|
|
8
|
-
*
|
|
7
|
+
* Save Draft needs those edits. Approve sends the rows on screen plus the entries version it read,
|
|
8
|
+
* so the server posts what the approver saw (or 409s when the draft moved); it still goes out with
|
|
9
|
+
* neither when there are no local edits (the server falls back to the parked rows).
|
|
9
10
|
*/
|
|
10
11
|
export declare const saveJEScheduleApprovalDraftEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => import("rxjs").Observable<ActionType>;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.saveJEScheduleApprovalDraftEpic = void 0;
|
|
4
4
|
const operators_1 = require("rxjs/operators");
|
|
5
|
+
const jeSchedulesSelector_1 = require("../../../../entity/jeSchedules/jeSchedulesSelector");
|
|
5
6
|
const responsePayload_1 = require("../../../../responsePayload");
|
|
6
7
|
const scheduleAccruedDetailPayload_1 = require("../../../scheduleView/scheduleAccruedDetailView/scheduleAccruedDetailPayload");
|
|
7
8
|
const scheduleDetailPayload_1 = require("../../../scheduleView/scheduleDetailView/scheduleDetailPayload");
|
|
@@ -22,20 +23,24 @@ function buildDraftPayload(state, jeScheduleId, scheduleType, isAccrued) {
|
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
24
25
|
* Builds the schedule body from the open schedule's local edits and reuses the approval-action call.
|
|
25
|
-
* Save Draft needs those edits
|
|
26
|
-
*
|
|
26
|
+
* Save Draft needs those edits. Approve sends the rows on screen plus the entries version it read,
|
|
27
|
+
* so the server posts what the approver saw (or 409s when the draft moved); it still goes out with
|
|
28
|
+
* neither when there are no local edits (the server falls back to the parked rows).
|
|
27
29
|
*/
|
|
28
30
|
const saveJEScheduleApprovalDraftEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)((action) => jeScheduleSetupApproverViewReducer_1.saveJEScheduleApprovalDraft.match(action) ||
|
|
29
31
|
jeScheduleSetupApproverViewReducer_1.approveJEScheduleWithLocalEdits.match(action)), (0, operators_1.map)((action) => {
|
|
30
32
|
const { jeScheduleId, scheduleType, isAccrued } = action.payload;
|
|
31
33
|
const payload = buildDraftPayload(state$.value, jeScheduleId, scheduleType, isAccrued);
|
|
34
|
+
const refetch = { scheduleType, isAccrued };
|
|
32
35
|
if (jeScheduleSetupApproverViewReducer_1.approveJEScheduleWithLocalEdits.match(action)) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
const approvalEntriesVersion = (0, jeSchedulesSelector_1.getScheduleApprovalInfo)(state$.value.jeSchedulesState, jeScheduleId)?.entriesVersion;
|
|
37
|
+
return (0, jeScheduleSetupApproverViewReducer_1.jeScheduleApprovalAction)(jeScheduleId, {
|
|
38
|
+
action: 'approve',
|
|
39
|
+
...(payload != null
|
|
40
|
+
? { scheduledJournalEntries: payload.scheduled_journal_entries }
|
|
41
|
+
: {}),
|
|
42
|
+
...(approvalEntriesVersion != null ? { approvalEntriesVersion } : {}),
|
|
43
|
+
}, refetch);
|
|
39
44
|
}
|
|
40
45
|
if (payload == null) {
|
|
41
46
|
return (0, jeScheduleSetupApproverViewReducer_1.jeScheduleApprovalActionFailure)(jeScheduleId, (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'No local schedule edits to save as draft'));
|
|
@@ -44,6 +49,6 @@ const saveJEScheduleApprovalDraftEpic = (actions$, state$) => actions$.pipe((0,
|
|
|
44
49
|
action: 'save_draft',
|
|
45
50
|
jeSchedules: payload.je_schedules,
|
|
46
51
|
scheduledJournalEntries: payload.scheduled_journal_entries,
|
|
47
|
-
});
|
|
52
|
+
}, refetch);
|
|
48
53
|
}));
|
|
49
54
|
exports.saveJEScheduleApprovalDraftEpic = saveJEScheduleApprovalDraftEpic;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ID } from '../../../commonStateTypes/common';
|
|
2
2
|
import { JEScheduleApprovalRulesListPayload } from '../../../entity/jeScheduleApprovalRule/jeScheduleApprovalRulePayload';
|
|
3
3
|
import { JEAccruedScheduledTransactionPayload, JEScheduledTransactionPayload } from '../../../entity/jeSchedules/jeSchedulesPayload';
|
|
4
|
+
import { ScheduleTypes } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
4
5
|
import { ZeniAPIResponse } from '../../../responsePayload';
|
|
5
6
|
import type { SaveScheduleDetailPayload as SaveAccruedScheduleDetailPayload } from '../../scheduleView/scheduleAccruedDetailView/scheduleAccruedDetailPayload';
|
|
6
7
|
import type { SaveScheduleDetailPayload } from '../../scheduleView/scheduleDetailView/scheduleDetailPayload';
|
|
@@ -8,8 +9,14 @@ import { JEScheduleApprovalRulesList } from './jeScheduleSetupApproverViewState'
|
|
|
8
9
|
export declare const toJEScheduleApprovalRulesList: (payload: JEScheduleApprovalRulesListPayload) => JEScheduleApprovalRulesList;
|
|
9
10
|
type DraftSchedulePayload = SaveScheduleDetailPayload['je_schedules'][number] | SaveAccruedScheduleDetailPayload['je_schedules'][number];
|
|
10
11
|
type DraftScheduledJournalEntryPayload = SaveScheduleDetailPayload['scheduled_journal_entries'][number];
|
|
12
|
+
/** Where a 409 (draft changed since it was read) reloads the schedule from. */
|
|
13
|
+
export interface JEScheduleApprovalActionRefetch {
|
|
14
|
+
isAccrued: boolean;
|
|
15
|
+
scheduleType: ScheduleTypes;
|
|
16
|
+
}
|
|
11
17
|
export type JEScheduleApprovalActionBody = {
|
|
12
18
|
action: 'approve';
|
|
19
|
+
approvalEntriesVersion?: number;
|
|
13
20
|
scheduledJournalEntries?: DraftScheduledJournalEntryPayload[];
|
|
14
21
|
} | {
|
|
15
22
|
action: 'reject';
|
|
@@ -21,6 +28,7 @@ export type JEScheduleApprovalActionBody = {
|
|
|
21
28
|
};
|
|
22
29
|
export type JEScheduleApprovalActionRequestBody = {
|
|
23
30
|
action: 'approve';
|
|
31
|
+
approval_entries_version?: number;
|
|
24
32
|
scheduled_journal_entries?: DraftScheduledJournalEntryPayload[];
|
|
25
33
|
} | {
|
|
26
34
|
action: 'reject';
|
|
@@ -13,12 +13,15 @@ exports.toJEScheduleApprovalRulesList = toJEScheduleApprovalRulesList;
|
|
|
13
13
|
const toJEScheduleApprovalActionRequestBody = (body) => {
|
|
14
14
|
switch (body.action) {
|
|
15
15
|
case 'approve':
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
scheduled_journal_entries: body.scheduledJournalEntries
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
return {
|
|
17
|
+
action: 'approve',
|
|
18
|
+
...(body.scheduledJournalEntries != null
|
|
19
|
+
? { scheduled_journal_entries: body.scheduledJournalEntries }
|
|
20
|
+
: {}),
|
|
21
|
+
...(body.approvalEntriesVersion != null
|
|
22
|
+
? { approval_entries_version: body.approvalEntriesVersion }
|
|
23
|
+
: {}),
|
|
24
|
+
};
|
|
22
25
|
case 'reject':
|
|
23
26
|
return { action: 'reject', rejection_reason: body.rejectionReason };
|
|
24
27
|
case 'save_draft':
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ID } from '../../../commonStateTypes/common';
|
|
2
2
|
import { JEScheduleApprovalRuleFormData, JEScheduleApprovalRuleState, JEScheduleApprover, JEScheduleApproverRole } from '../../../entity/jeScheduleApprovalRule/jeScheduleApprovalRuleState';
|
|
3
3
|
import { ZeniAPIStatus } from '../../../responsePayload';
|
|
4
|
-
import { JEScheduleApprovalActionBody } from './jeScheduleSetupApproverViewPayload';
|
|
4
|
+
import { JEScheduleApprovalActionBody, JEScheduleApprovalActionRefetch } from './jeScheduleSetupApproverViewPayload';
|
|
5
5
|
import { JEScheduleApprovalRulesList, JEScheduleSetupApproverViewState } from './jeScheduleSetupApproverViewState';
|
|
6
6
|
export declare const initialState: JEScheduleSetupApproverViewState;
|
|
7
7
|
/** Reorders only the viewer's own rules; the other owner's block keeps its positions. */
|
|
@@ -28,9 +28,10 @@ export declare const fetchJEScheduleApprovalRules: import("@reduxjs/toolkit").Ac
|
|
|
28
28
|
status: ZeniAPIStatus<Record<string, unknown>>;
|
|
29
29
|
}, "jeScheduleSetupApproverView/deleteJEScheduleApprovalRuleFailure", never, never>, reorderJEScheduleApprovalRules: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[ruleIds: string[]], {
|
|
30
30
|
ruleIds: string[];
|
|
31
|
-
}, "jeScheduleSetupApproverView/reorderJEScheduleApprovalRules", never, never>, reorderJEScheduleApprovalRulesSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[list: JEScheduleApprovalRulesList], JEScheduleApprovalRulesList, "jeScheduleSetupApproverView/reorderJEScheduleApprovalRulesSuccess", never, never>, reorderJEScheduleApprovalRulesFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[status: ZeniAPIStatus<Record<string, unknown>>], ZeniAPIStatus<Record<string, unknown>>, "jeScheduleSetupApproverView/reorderJEScheduleApprovalRulesFailure", never, never>, jeScheduleApprovalAction: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[jeScheduleId: string, body: JEScheduleApprovalActionBody], {
|
|
31
|
+
}, "jeScheduleSetupApproverView/reorderJEScheduleApprovalRules", never, never>, reorderJEScheduleApprovalRulesSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[list: JEScheduleApprovalRulesList], JEScheduleApprovalRulesList, "jeScheduleSetupApproverView/reorderJEScheduleApprovalRulesSuccess", never, never>, reorderJEScheduleApprovalRulesFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[status: ZeniAPIStatus<Record<string, unknown>>], ZeniAPIStatus<Record<string, unknown>>, "jeScheduleSetupApproverView/reorderJEScheduleApprovalRulesFailure", never, never>, jeScheduleApprovalAction: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[jeScheduleId: string, body: JEScheduleApprovalActionBody, refetch?: JEScheduleApprovalActionRefetch | undefined], {
|
|
32
32
|
jeScheduleId: string;
|
|
33
33
|
body: JEScheduleApprovalActionBody;
|
|
34
|
+
refetch: JEScheduleApprovalActionRefetch | undefined;
|
|
34
35
|
}, "jeScheduleSetupApproverView/jeScheduleApprovalAction", never, never>, saveJEScheduleApprovalDraft: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[jeScheduleId: string, scheduleType: "prepaid_expenses" | "fixed_assets" | "accrued_expenses" | "deferred_revenue", isAccrued: boolean], {
|
|
35
36
|
jeScheduleId: string;
|
|
36
37
|
scheduleType: "prepaid_expenses" | "fixed_assets" | "accrued_expenses" | "deferred_revenue";
|
|
@@ -208,8 +208,8 @@ const jeScheduleSetupApproverView = (0, toolkit_1.createSlice)({
|
|
|
208
208
|
error: undefined,
|
|
209
209
|
};
|
|
210
210
|
},
|
|
211
|
-
prepare(jeScheduleId, body) {
|
|
212
|
-
return { payload: { jeScheduleId, body } };
|
|
211
|
+
prepare(jeScheduleId, body, refetch) {
|
|
212
|
+
return { payload: { jeScheduleId, body, refetch } };
|
|
213
213
|
},
|
|
214
214
|
},
|
|
215
215
|
saveJEScheduleApprovalDraft: {
|
|
@@ -15,7 +15,7 @@ export declare const fetchTaskListPage: import("@reduxjs/toolkit").ActionCreator
|
|
|
15
15
|
completed?: TaskPayload[];
|
|
16
16
|
deleted?: TaskPayload[];
|
|
17
17
|
snoozed?: TaskPayload[];
|
|
18
|
-
}, "taskList/updateTaskList">, updateTaskListTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<"completed" | "deleted" | "
|
|
18
|
+
}, "taskList/updateTaskList">, updateTaskListTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<"completed" | "deleted" | "live" | "archived" | "snoozed", "taskList/updateTaskListTab">, updateTaskListFetchStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
19
19
|
fetchState: FetchState;
|
|
20
20
|
error?: ZeniAPIStatus;
|
|
21
21
|
}, "taskList/updateTaskListFetchStatus">, updateTaskListSearchText: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.3.6-
|
|
3
|
+
"version": "5.3.6-betaGS3",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|