@zeniai/client-epic-state 5.3.24-betaAK1 → 5.3.25-betaGS1
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 +105 -0
- package/lib/entity/jeScheduleApprovalRule/jeScheduleApprovalRulePayload.js +158 -0
- package/lib/entity/jeScheduleApprovalRule/jeScheduleApprovalRuleState.d.ts +89 -0
- package/lib/entity/jeScheduleApprovalRule/jeScheduleApprovalRuleState.js +2 -0
- package/lib/entity/jeScheduleApprovalRule/jeScheduleApprovalRuleTypes.d.ts +33 -0
- package/lib/entity/jeScheduleApprovalRule/jeScheduleApprovalRuleTypes.js +64 -0
- package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +15 -1
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +31 -0
- package/lib/entity/jeSchedules/jeSchedulesReducer.js +16 -0
- package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +8 -0
- package/lib/entity/jeSchedules/jeSchedulesSelector.js +51 -1
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +15 -1
- package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +6 -0
- package/lib/entity/jeSchedules/jeSchedulesTypes.js +14 -1
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +5 -0
- package/lib/entity/userRole/userRoleTenantAccess.d.ts +9 -0
- package/lib/entity/userRole/userRoleTenantAccess.js +25 -1
- package/lib/entity/userRole/userRoleType.d.ts +2 -2
- package/lib/epic.d.ts +8 -1
- package/lib/epic.js +15 -0
- package/lib/esm/entity/jeScheduleApprovalRule/jeScheduleApprovalRulePayload.js +147 -0
- package/lib/esm/entity/jeScheduleApprovalRule/jeScheduleApprovalRuleState.js +1 -0
- package/lib/esm/entity/jeScheduleApprovalRule/jeScheduleApprovalRuleTypes.js +55 -0
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +31 -1
- package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +16 -0
- package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +48 -0
- package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +11 -0
- package/lib/esm/entity/snackbar/snackbarTypes.js +5 -0
- package/lib/esm/entity/userRole/userRoleTenantAccess.js +22 -0
- package/lib/esm/epic.js +16 -1
- package/lib/esm/index.js +11 -4
- package/lib/esm/reducer.js +3 -0
- package/lib/esm/view/dashboard/dashboardSelector.js +2 -2
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +62 -10
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +16 -1
- package/lib/esm/view/opEx/opExSelector.js +4 -1
- package/lib/esm/view/scheduleView/scheduleDetailView/epics/fetchScheduleDetailsEpic.js +2 -0
- package/lib/esm/view/settings/jeScheduleApprovalRules/epic/deleteJEScheduleApprovalRuleEpic.js +56 -0
- package/lib/esm/view/settings/jeScheduleApprovalRules/epic/fetchJEScheduleApprovalRulesEpic.js +31 -0
- package/lib/esm/view/settings/jeScheduleApprovalRules/epic/fetchJEScheduleApproversEpic.js +25 -0
- package/lib/esm/view/settings/jeScheduleApprovalRules/epic/jeScheduleApprovalActionEpic.js +66 -0
- package/lib/esm/view/settings/jeScheduleApprovalRules/epic/reorderJEScheduleApprovalRulesEpic.js +46 -0
- package/lib/esm/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalDraftEpic.js +50 -0
- package/lib/esm/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalRuleEpic.js +62 -0
- package/lib/esm/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewPayload.js +31 -0
- package/lib/esm/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewReducer.js +275 -0
- package/lib/esm/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewSelector.js +60 -0
- package/lib/esm/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewSelectorTypes.js +1 -0
- package/lib/esm/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewState.js +1 -0
- package/lib/esm/view/settingsView/settingsViewHelpers.js +7 -3
- package/lib/index.d.ts +14 -5
- package/lib/index.js +96 -47
- package/lib/reducer.d.ts +1 -0
- package/lib/reducer.js +3 -0
- package/lib/rootStateTypes.d.ts +2 -0
- package/lib/view/companyView/types/cockpitTypes.d.ts +1 -1
- package/lib/view/dashboard/dashboardSelector.js +1 -1
- package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.d.ts +3 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +62 -9
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +2 -0
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +4 -1
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +18 -3
- package/lib/view/expenseAutomationView/types/actualMatchingViewState.d.ts +1 -1
- package/lib/view/invoicing/couponView/couponViewState.d.ts +1 -1
- package/lib/view/opEx/opExSelector.d.ts +4 -1
- package/lib/view/opEx/opExSelector.js +5 -2
- package/lib/view/scheduleView/scheduleDetailView/epics/fetchScheduleDetailsEpic.js +2 -0
- package/lib/view/scheduleView/scheduleDetailView/scheduleDetailPayload.d.ts +1 -1
- package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +1 -1
- package/lib/view/settings/jeScheduleApprovalRules/epic/deleteJEScheduleApprovalRuleEpic.d.ts +9 -0
- package/lib/view/settings/jeScheduleApprovalRules/epic/deleteJEScheduleApprovalRuleEpic.js +60 -0
- package/lib/view/settings/jeScheduleApprovalRules/epic/fetchJEScheduleApprovalRulesEpic.d.ts +9 -0
- package/lib/view/settings/jeScheduleApprovalRules/epic/fetchJEScheduleApprovalRulesEpic.js +35 -0
- package/lib/view/settings/jeScheduleApprovalRules/epic/fetchJEScheduleApproversEpic.d.ts +9 -0
- package/lib/view/settings/jeScheduleApprovalRules/epic/fetchJEScheduleApproversEpic.js +29 -0
- package/lib/view/settings/jeScheduleApprovalRules/epic/jeScheduleApprovalActionEpic.d.ts +13 -0
- package/lib/view/settings/jeScheduleApprovalRules/epic/jeScheduleApprovalActionEpic.js +70 -0
- package/lib/view/settings/jeScheduleApprovalRules/epic/reorderJEScheduleApprovalRulesEpic.d.ts +13 -0
- package/lib/view/settings/jeScheduleApprovalRules/epic/reorderJEScheduleApprovalRulesEpic.js +50 -0
- package/lib/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalDraftEpic.d.ts +11 -0
- package/lib/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalDraftEpic.js +54 -0
- package/lib/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalRuleEpic.d.ts +9 -0
- package/lib/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalRuleEpic.js +66 -0
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewPayload.d.ts +51 -0
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewPayload.js +37 -0
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewReducer.d.ts +51 -0
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewReducer.js +280 -0
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewSelector.d.ts +8 -0
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewSelector.js +64 -0
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewSelectorTypes.d.ts +23 -0
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewSelectorTypes.js +2 -0
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewState.d.ts +28 -0
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleSetupApproverViewState.js +2 -0
- package/lib/view/settingsView/settingsViewHelpers.d.ts +1 -1
- package/lib/view/settingsView/settingsViewHelpers.js +6 -2
- package/lib/view/spendManagement/billPay/billList/billListReducer.d.ts +1 -1
- package/lib/view/spendManagement/billPay/billList/billListState.d.ts +1 -1
- package/lib/view/spendManagement/reimbursement/remiListView/remiListReducer.d.ts +1 -1
- package/lib/view/spendManagement/reimbursement/remiListView/remiListState.d.ts +3 -3
- package/lib/view/taskManager/taskListView/taskListReducer.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { ID } from '../../commonStateTypes/common';
|
|
2
|
+
import { ZeniAPIResponse, ZeniAPIStatus } from '../../responsePayload';
|
|
3
|
+
import { JEScheduleApprovalAPIStatus, JEScheduleApprovalInfo, JEScheduleApprovalRuleFormData, JEScheduleApprovalRuleState, JEScheduleApprovalStepState, JEScheduleApprover, JEScheduleApproverRole } from './jeScheduleApprovalRuleState';
|
|
4
|
+
import { JEApprovalEntriesSource, JEScheduleType, JE_APPROVAL_STEP_ACTION } from './jeScheduleApprovalRuleTypes';
|
|
5
|
+
export interface JEScheduleApprovalUserActorPayload {
|
|
6
|
+
id: ID;
|
|
7
|
+
type: 'user';
|
|
8
|
+
}
|
|
9
|
+
export interface JEScheduleApprovalRoleActorPayload {
|
|
10
|
+
sub_type: string;
|
|
11
|
+
type: 'role';
|
|
12
|
+
}
|
|
13
|
+
export type JEScheduleApprovalActorPayload = JEScheduleApprovalUserActorPayload | JEScheduleApprovalRoleActorPayload;
|
|
14
|
+
export interface JEScheduleApprovalStepPayload {
|
|
15
|
+
action: string;
|
|
16
|
+
actors: JEScheduleApprovalActorPayload[];
|
|
17
|
+
}
|
|
18
|
+
export interface JEScheduleApprovalStepRequestPayload {
|
|
19
|
+
action: typeof JE_APPROVAL_STEP_ACTION;
|
|
20
|
+
actors: JEScheduleApprovalActorPayload[];
|
|
21
|
+
}
|
|
22
|
+
export interface JEScheduleApprovalRulePayload {
|
|
23
|
+
create_time: string;
|
|
24
|
+
created_by_user_id: ID | null;
|
|
25
|
+
description: string | null;
|
|
26
|
+
id: ID;
|
|
27
|
+
is_separation_of_duty_enabled: boolean;
|
|
28
|
+
monthly_amount_min: number;
|
|
29
|
+
name: string;
|
|
30
|
+
owner: string;
|
|
31
|
+
priority: number;
|
|
32
|
+
schedule_types: string[];
|
|
33
|
+
step: JEScheduleApprovalStepPayload;
|
|
34
|
+
update_time: string;
|
|
35
|
+
updated_by_user_id: ID | null;
|
|
36
|
+
}
|
|
37
|
+
export interface JEScheduleApprovalRulesListPayload {
|
|
38
|
+
can_edit: boolean;
|
|
39
|
+
rules: JEScheduleApprovalRulePayload[];
|
|
40
|
+
rules_version: number;
|
|
41
|
+
viewer_owner: string;
|
|
42
|
+
}
|
|
43
|
+
export interface JEScheduleApprovalRuleSavePayload extends JEScheduleApprovalRulesListPayload {
|
|
44
|
+
rule: JEScheduleApprovalRulePayload;
|
|
45
|
+
}
|
|
46
|
+
/** Body for POST / PUT `/1.0/je-schedules/approval-rules[/<id>]`; a type alias so it satisfies the `Record<string, unknown>` body param. */
|
|
47
|
+
export type JEScheduleApprovalRuleRequestBody = {
|
|
48
|
+
description: string | null;
|
|
49
|
+
is_applicable_on_pending_approval_entity: boolean;
|
|
50
|
+
is_separation_of_duty_enabled: boolean;
|
|
51
|
+
monthly_amount_min: number;
|
|
52
|
+
name: string;
|
|
53
|
+
schedule_types: JEScheduleType[];
|
|
54
|
+
step: JEScheduleApprovalStepRequestPayload;
|
|
55
|
+
};
|
|
56
|
+
export interface JEScheduleApproverPayload {
|
|
57
|
+
email: string;
|
|
58
|
+
first_name: string;
|
|
59
|
+
is_zeni: boolean;
|
|
60
|
+
je_level: number | null;
|
|
61
|
+
je_level_label: string | null;
|
|
62
|
+
last_name: string;
|
|
63
|
+
user_id: ID;
|
|
64
|
+
}
|
|
65
|
+
export interface JEScheduleApproverRolePayload {
|
|
66
|
+
label: string;
|
|
67
|
+
level: number | null;
|
|
68
|
+
sub_type: string;
|
|
69
|
+
}
|
|
70
|
+
export interface JEScheduleApproversPayload {
|
|
71
|
+
roles: JEScheduleApproverRolePayload[];
|
|
72
|
+
users: JEScheduleApproverPayload[];
|
|
73
|
+
viewer_owner: string;
|
|
74
|
+
}
|
|
75
|
+
export interface JEScheduleApprovalInfoPayload {
|
|
76
|
+
approver_labels: string[];
|
|
77
|
+
approver_roles: string[];
|
|
78
|
+
approver_user_ids: ID[];
|
|
79
|
+
can_approve: boolean;
|
|
80
|
+
entries_source: JEApprovalEntriesSource;
|
|
81
|
+
entries_version: number;
|
|
82
|
+
matched_rule_ids: ID[];
|
|
83
|
+
matched_rule_name: string | null;
|
|
84
|
+
matched_rule_owner: string | null;
|
|
85
|
+
message: string;
|
|
86
|
+
monthly_amount: number | null;
|
|
87
|
+
preparer_user_id: ID | null;
|
|
88
|
+
requires_approval: boolean;
|
|
89
|
+
rule_min: number | null;
|
|
90
|
+
separation_of_duties: boolean;
|
|
91
|
+
unevaluable_reason: string | null;
|
|
92
|
+
}
|
|
93
|
+
export type JEScheduleApprovalRulesListResponse = ZeniAPIResponse<JEScheduleApprovalRulesListPayload>;
|
|
94
|
+
export type JEScheduleApprovalRuleSaveResponse = ZeniAPIResponse<JEScheduleApprovalRuleSavePayload>;
|
|
95
|
+
export type JEScheduleApproversResponse = ZeniAPIResponse<JEScheduleApproversPayload>;
|
|
96
|
+
export declare const toJEScheduleApprovalStepState: (payload: JEScheduleApprovalStepPayload) => JEScheduleApprovalStepState;
|
|
97
|
+
export declare const toJEScheduleTypes: (scheduleTypes: string[]) => JEScheduleType[];
|
|
98
|
+
export declare const toJEScheduleApprovalRuleState: (payload: JEScheduleApprovalRulePayload) => JEScheduleApprovalRuleState;
|
|
99
|
+
/** Reverse mapper for create / update. The contract carries exactly one step. */
|
|
100
|
+
export declare const toJEScheduleApprovalRulePayload: (formData: JEScheduleApprovalRuleFormData) => JEScheduleApprovalRuleRequestBody;
|
|
101
|
+
export declare const toJEScheduleApprover: (payload: JEScheduleApproverPayload) => JEScheduleApprover;
|
|
102
|
+
export declare const toJEScheduleApproverRole: (payload: JEScheduleApproverRolePayload) => JEScheduleApproverRole;
|
|
103
|
+
export declare const toJEScheduleApprovalInfo: (payload: JEScheduleApprovalInfoPayload | null | undefined) => JEScheduleApprovalInfo | undefined;
|
|
104
|
+
/** 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. */
|
|
105
|
+
export declare const toJEScheduleApprovalAPIStatus: (status: ZeniAPIStatus, context?: "rules" | "action") => JEScheduleApprovalAPIStatus;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toJEScheduleApprovalAPIStatus = exports.toJEScheduleApprovalInfo = exports.toJEScheduleApproverRole = exports.toJEScheduleApprover = exports.toJEScheduleApprovalRulePayload = exports.toJEScheduleApprovalRuleState = exports.toJEScheduleTypes = exports.toJEScheduleApprovalStepState = void 0;
|
|
4
|
+
const zeniDayJS_1 = require("../../zeniDayJS");
|
|
5
|
+
const jeScheduleApprovalRuleTypes_1 = require("./jeScheduleApprovalRuleTypes");
|
|
6
|
+
const isUserActor = (actor) => actor.type === 'user';
|
|
7
|
+
const toJEScheduleApprovalStepState = (payload) => {
|
|
8
|
+
const nonUserActors = [];
|
|
9
|
+
payload.actors.forEach((actor) => {
|
|
10
|
+
if (isUserActor(actor)) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const subType = (0, jeScheduleApprovalRuleTypes_1.toJEApprovalRoleSubTypeStrict)(actor.sub_type);
|
|
14
|
+
if (subType == null) {
|
|
15
|
+
console.warn(`[jeScheduleApprovalRule] dropping unknown role actor "${actor.sub_type}"`);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
nonUserActors.push({ subType });
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
actorUserIds: payload.actors.filter(isUserActor).map((actor) => actor.id),
|
|
22
|
+
nonUserActors,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
exports.toJEScheduleApprovalStepState = toJEScheduleApprovalStepState;
|
|
26
|
+
const toJEScheduleTypes = (scheduleTypes) => {
|
|
27
|
+
const result = [];
|
|
28
|
+
scheduleTypes.forEach((scheduleType) => {
|
|
29
|
+
const known = (0, jeScheduleApprovalRuleTypes_1.toJEScheduleTypeStrict)(scheduleType);
|
|
30
|
+
if (known == null) {
|
|
31
|
+
console.warn(`[jeScheduleApprovalRule] dropping unknown schedule type "${scheduleType}"`);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
result.push(known);
|
|
35
|
+
});
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
exports.toJEScheduleTypes = toJEScheduleTypes;
|
|
39
|
+
const toJEScheduleApprovalRuleState = (payload) => ({
|
|
40
|
+
approvalRuleId: payload.id,
|
|
41
|
+
owner: (0, jeScheduleApprovalRuleTypes_1.toJEApprovalOwner)(payload.owner),
|
|
42
|
+
priority: payload.priority,
|
|
43
|
+
name: payload.name,
|
|
44
|
+
description: payload.description ?? undefined,
|
|
45
|
+
separationOfDuties: payload.is_separation_of_duty_enabled,
|
|
46
|
+
criteria: {
|
|
47
|
+
scheduleTypes: (0, exports.toJEScheduleTypes)(payload.schedule_types),
|
|
48
|
+
monthlyAmountMin: payload.monthly_amount_min,
|
|
49
|
+
},
|
|
50
|
+
steps: payload.step.action === jeScheduleApprovalRuleTypes_1.JE_APPROVAL_STEP_ACTION
|
|
51
|
+
? [(0, exports.toJEScheduleApprovalStepState)(payload.step)]
|
|
52
|
+
: [],
|
|
53
|
+
createdByUserId: payload.created_by_user_id ?? undefined,
|
|
54
|
+
updatedByUserId: payload.updated_by_user_id ?? undefined,
|
|
55
|
+
createTime: (0, zeniDayJS_1.date)(payload.create_time),
|
|
56
|
+
updateTime: (0, zeniDayJS_1.date)(payload.update_time),
|
|
57
|
+
});
|
|
58
|
+
exports.toJEScheduleApprovalRuleState = toJEScheduleApprovalRuleState;
|
|
59
|
+
const toJEScheduleApprovalStepPayload = (step) => ({
|
|
60
|
+
action: jeScheduleApprovalRuleTypes_1.JE_APPROVAL_STEP_ACTION,
|
|
61
|
+
actors: [
|
|
62
|
+
...step.actorUserIds.map((userId) => ({
|
|
63
|
+
type: 'user',
|
|
64
|
+
id: userId,
|
|
65
|
+
})),
|
|
66
|
+
...step.nonUserActors.map((actor) => ({
|
|
67
|
+
type: 'role',
|
|
68
|
+
sub_type: actor.subType,
|
|
69
|
+
})),
|
|
70
|
+
],
|
|
71
|
+
});
|
|
72
|
+
/** Reverse mapper for create / update. The contract carries exactly one step. */
|
|
73
|
+
const toJEScheduleApprovalRulePayload = (formData) => ({
|
|
74
|
+
name: formData.name,
|
|
75
|
+
description: formData.description ?? null,
|
|
76
|
+
is_separation_of_duty_enabled: formData.separationOfDuties,
|
|
77
|
+
schedule_types: formData.criteria.scheduleTypes,
|
|
78
|
+
monthly_amount_min: formData.criteria.monthlyAmountMin,
|
|
79
|
+
step: toJEScheduleApprovalStepPayload(formData.steps[0] ?? {
|
|
80
|
+
actorUserIds: [],
|
|
81
|
+
nonUserActors: [],
|
|
82
|
+
}),
|
|
83
|
+
is_applicable_on_pending_approval_entity: formData.isApplicableOnPendingApprovalEntity,
|
|
84
|
+
});
|
|
85
|
+
exports.toJEScheduleApprovalRulePayload = toJEScheduleApprovalRulePayload;
|
|
86
|
+
const toJEScheduleApprover = (payload) => ({
|
|
87
|
+
userId: payload.user_id,
|
|
88
|
+
email: payload.email,
|
|
89
|
+
firstName: payload.first_name,
|
|
90
|
+
lastName: payload.last_name,
|
|
91
|
+
isZeni: payload.is_zeni,
|
|
92
|
+
jeLevel: payload.je_level ?? undefined,
|
|
93
|
+
jeLevelLabel: payload.je_level_label ?? undefined,
|
|
94
|
+
});
|
|
95
|
+
exports.toJEScheduleApprover = toJEScheduleApprover;
|
|
96
|
+
const toJEScheduleApproverRole = (payload) => ({
|
|
97
|
+
subType: (0, jeScheduleApprovalRuleTypes_1.toJEApprovalRoleSubType)(payload.sub_type),
|
|
98
|
+
level: payload.level ?? undefined,
|
|
99
|
+
label: payload.label,
|
|
100
|
+
});
|
|
101
|
+
exports.toJEScheduleApproverRole = toJEScheduleApproverRole;
|
|
102
|
+
const toJEScheduleApprovalInfo = (payload) => {
|
|
103
|
+
if (payload == null) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
requiresApproval: payload.requires_approval,
|
|
108
|
+
canApprove: payload.can_approve,
|
|
109
|
+
entriesSource: payload.entries_source,
|
|
110
|
+
entriesVersion: payload.entries_version,
|
|
111
|
+
approverLabels: payload.approver_labels,
|
|
112
|
+
approverRoles: payload.approver_roles,
|
|
113
|
+
approverUserIds: payload.approver_user_ids,
|
|
114
|
+
matchedRuleIds: payload.matched_rule_ids,
|
|
115
|
+
matchedRuleName: payload.matched_rule_name ?? undefined,
|
|
116
|
+
matchedRuleOwner: payload.matched_rule_owner != null
|
|
117
|
+
? (0, jeScheduleApprovalRuleTypes_1.toJEApprovalOwner)(payload.matched_rule_owner)
|
|
118
|
+
: undefined,
|
|
119
|
+
monthlyAmount: payload.monthly_amount ?? undefined,
|
|
120
|
+
ruleMin: payload.rule_min ?? undefined,
|
|
121
|
+
separationOfDuties: payload.separation_of_duties,
|
|
122
|
+
preparerUserId: payload.preparer_user_id ?? undefined,
|
|
123
|
+
unevaluableReason: payload.unevaluable_reason ?? undefined,
|
|
124
|
+
message: payload.message,
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
exports.toJEScheduleApprovalInfo = toJEScheduleApprovalInfo;
|
|
128
|
+
const toJEApprovalErrorKind = (code) => {
|
|
129
|
+
switch (code) {
|
|
130
|
+
case 403:
|
|
131
|
+
return 'forbidden';
|
|
132
|
+
case 409:
|
|
133
|
+
return 'conflict';
|
|
134
|
+
case 400:
|
|
135
|
+
return 'validation';
|
|
136
|
+
case 404:
|
|
137
|
+
return 'not_found';
|
|
138
|
+
default:
|
|
139
|
+
return 'unknown';
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
const USER_FACING_MESSAGES = {
|
|
143
|
+
forbidden: 'You are not allowed to perform this action.',
|
|
144
|
+
conflict: undefined, // already-claimed and stale-draft both arrive with a user-facing message
|
|
145
|
+
validation: undefined, // backend's status.message is already user-facing
|
|
146
|
+
not_found: 'JE schedule approval rules are not available for this account.',
|
|
147
|
+
unknown: undefined,
|
|
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') => {
|
|
152
|
+
const kind = toJEApprovalErrorKind(status.code);
|
|
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 };
|
|
157
|
+
};
|
|
158
|
+
exports.toJEScheduleApprovalAPIStatus = toJEScheduleApprovalAPIStatus;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ID } from '../../commonStateTypes/common';
|
|
2
|
+
import { ZeniAPIStatus } from '../../responsePayload';
|
|
3
|
+
import { ZeniDate } from '../../zeniDayJS';
|
|
4
|
+
import { JEApprovalEntriesSource, JEApprovalErrorKind, JEApprovalOwner, JEApprovalRoleSubType, JEScheduleType } from './jeScheduleApprovalRuleTypes';
|
|
5
|
+
/** A user eligible to approve JE schedules, as `/je-schedules/approvers` reports them. */
|
|
6
|
+
export interface JEScheduleApprover {
|
|
7
|
+
email: string;
|
|
8
|
+
firstName: string;
|
|
9
|
+
isZeni: boolean;
|
|
10
|
+
lastName: string;
|
|
11
|
+
userId: ID;
|
|
12
|
+
jeLevel?: number;
|
|
13
|
+
jeLevelLabel?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface JEScheduleApproverRole {
|
|
16
|
+
label: string;
|
|
17
|
+
subType: JEApprovalRoleSubType;
|
|
18
|
+
level?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface JEScheduleApprovalNonUserActor {
|
|
21
|
+
subType: JEApprovalRoleSubType;
|
|
22
|
+
}
|
|
23
|
+
export interface JEScheduleApprovalCriteria {
|
|
24
|
+
monthlyAmountMin: number;
|
|
25
|
+
scheduleTypes: JEScheduleType[];
|
|
26
|
+
}
|
|
27
|
+
/** Stored shape: actors are user ids; the view selector joins them against the approvers list. */
|
|
28
|
+
export interface JEScheduleApprovalStepState {
|
|
29
|
+
actorUserIds: ID[];
|
|
30
|
+
nonUserActors: JEScheduleApprovalNonUserActor[];
|
|
31
|
+
}
|
|
32
|
+
export interface JEScheduleApprovalRuleBase {
|
|
33
|
+
approvalRuleId: ID;
|
|
34
|
+
createTime: ZeniDate;
|
|
35
|
+
criteria: JEScheduleApprovalCriteria;
|
|
36
|
+
name: string;
|
|
37
|
+
owner: JEApprovalOwner;
|
|
38
|
+
priority: number;
|
|
39
|
+
separationOfDuties: boolean;
|
|
40
|
+
updateTime: ZeniDate;
|
|
41
|
+
createdByUserId?: ID;
|
|
42
|
+
description?: string;
|
|
43
|
+
updatedByUserId?: ID;
|
|
44
|
+
}
|
|
45
|
+
export interface JEScheduleApprovalRuleState extends JEScheduleApprovalRuleBase {
|
|
46
|
+
steps: JEScheduleApprovalStepState[];
|
|
47
|
+
}
|
|
48
|
+
/** Selector shape: actors resolved to approver records. */
|
|
49
|
+
export interface JEScheduleApprovalStep {
|
|
50
|
+
actors: JEScheduleApprover[];
|
|
51
|
+
nonUserActors: JEScheduleApprovalNonUserActor[];
|
|
52
|
+
}
|
|
53
|
+
export interface JEScheduleApprovalRule extends JEScheduleApprovalRuleBase {
|
|
54
|
+
steps: JEScheduleApprovalStep[];
|
|
55
|
+
}
|
|
56
|
+
/** Form-side shape for create / update; mapped to the wire by `toJEScheduleApprovalRulePayload`. */
|
|
57
|
+
export interface JEScheduleApprovalRuleFormData {
|
|
58
|
+
criteria: JEScheduleApprovalCriteria;
|
|
59
|
+
isApplicableOnPendingApprovalEntity: boolean;
|
|
60
|
+
name: string;
|
|
61
|
+
separationOfDuties: boolean;
|
|
62
|
+
steps: JEScheduleApprovalStepState[];
|
|
63
|
+
approvalRuleId?: ID;
|
|
64
|
+
description?: string;
|
|
65
|
+
}
|
|
66
|
+
/** Per-schedule approval evaluation carried on JE schedule rows (`approval_info`). */
|
|
67
|
+
export interface JEScheduleApprovalInfo {
|
|
68
|
+
approverLabels: string[];
|
|
69
|
+
approverRoles: string[];
|
|
70
|
+
approverUserIds: ID[];
|
|
71
|
+
canApprove: boolean;
|
|
72
|
+
/** 'parked' when the detail read served the rows saved while held; 'live' otherwise. */
|
|
73
|
+
entriesSource: JEApprovalEntriesSource;
|
|
74
|
+
/** Echoed back on approve; the server answers 409 when the draft was re-parked since. */
|
|
75
|
+
entriesVersion: number;
|
|
76
|
+
matchedRuleIds: ID[];
|
|
77
|
+
message: string;
|
|
78
|
+
requiresApproval: boolean;
|
|
79
|
+
separationOfDuties: boolean;
|
|
80
|
+
matchedRuleName?: string;
|
|
81
|
+
matchedRuleOwner?: JEApprovalOwner;
|
|
82
|
+
monthlyAmount?: number;
|
|
83
|
+
preparerUserId?: ID;
|
|
84
|
+
ruleMin?: number;
|
|
85
|
+
unevaluableReason?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface JEScheduleApprovalAPIStatus extends ZeniAPIStatus {
|
|
88
|
+
kind: JEApprovalErrorKind;
|
|
89
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const JE_SCHEDULE_TYPES: readonly ["prepaid_expenses", "fixed_assets", "accrued_expenses"];
|
|
2
|
+
export declare const toJEScheduleType: (v: string) => "prepaid_expenses" | "fixed_assets" | "accrued_expenses";
|
|
3
|
+
export declare const toJEScheduleTypeStrict: (v: string) => "prepaid_expenses" | "fixed_assets" | "accrued_expenses" | undefined;
|
|
4
|
+
export type JEScheduleType = ReturnType<typeof toJEScheduleType>;
|
|
5
|
+
export declare const JE_APPROVAL_OWNERS: readonly ["zeni", "customer"];
|
|
6
|
+
export declare const toJEApprovalOwner: (v: string) => "customer" | "zeni";
|
|
7
|
+
export declare const toJEApprovalOwnerStrict: (v: string) => "customer" | "zeni" | undefined;
|
|
8
|
+
export type JEApprovalOwner = ReturnType<typeof toJEApprovalOwner>;
|
|
9
|
+
/** The only step action the backend accepts; older notify steps are dropped on read. */
|
|
10
|
+
export declare const JE_APPROVAL_STEP_ACTION = "require_approval";
|
|
11
|
+
export declare const JE_APPROVAL_ZENI_ROLE_SUB_TYPES: readonly ["reviewer", "controller"];
|
|
12
|
+
/** Role actors valid only on customer-owned rules. */
|
|
13
|
+
export declare const JE_APPROVAL_CUSTOMER_ROLE_SUB_TYPES: readonly ["customer_super_admin", "customer_finance_admin"];
|
|
14
|
+
export declare const JE_APPROVAL_ROLE_SUB_TYPES: readonly ["reviewer", "controller", "customer_super_admin", "customer_finance_admin"];
|
|
15
|
+
export declare const toJEApprovalRoleSubType: (v: string) => "reviewer" | "controller" | "customer_super_admin" | "customer_finance_admin";
|
|
16
|
+
export declare const toJEApprovalRoleSubTypeStrict: (v: string) => "reviewer" | "controller" | "customer_super_admin" | "customer_finance_admin" | undefined;
|
|
17
|
+
export type JEApprovalRoleSubType = ReturnType<typeof toJEApprovalRoleSubType>;
|
|
18
|
+
export declare const JE_APPROVAL_ACTIONS: readonly ["approve", "reject", "save_draft"];
|
|
19
|
+
export type JEApprovalAction = (typeof JE_APPROVAL_ACTIONS)[number];
|
|
20
|
+
export declare const JE_LEVEL_PREPARER = 1;
|
|
21
|
+
export declare const JE_LEVEL_REVIEWER = 2;
|
|
22
|
+
export declare const JE_LEVEL_CONTROLLER = 3;
|
|
23
|
+
export declare const JE_LEVEL_LABELS: Record<number, string>;
|
|
24
|
+
export declare const JE_SCHEDULE_TYPE_LABELS: Record<JEScheduleType, string>;
|
|
25
|
+
/**
|
|
26
|
+
* Typed failure kinds for the approval-rule / approval-action endpoints.
|
|
27
|
+
* 403 = viewer may not edit (or touched the other owner's rule / is not an
|
|
28
|
+
* eligible approver / SoD); 409 = someone else already approved.
|
|
29
|
+
*/
|
|
30
|
+
export declare const JE_APPROVAL_ENTRIES_SOURCES: readonly ["parked", "live"];
|
|
31
|
+
export type JEApprovalEntriesSource = (typeof JE_APPROVAL_ENTRIES_SOURCES)[number];
|
|
32
|
+
export declare const JE_APPROVAL_ERROR_KINDS: readonly ["forbidden", "conflict", "validation", "not_found", "unknown"];
|
|
33
|
+
export type JEApprovalErrorKind = (typeof JE_APPROVAL_ERROR_KINDS)[number];
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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.JE_APPROVAL_STEP_ACTION = exports.toJEApprovalOwnerStrict = exports.toJEApprovalOwner = exports.JE_APPROVAL_OWNERS = exports.toJEScheduleTypeStrict = exports.toJEScheduleType = exports.JE_SCHEDULE_TYPES = void 0;
|
|
4
|
+
const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
|
|
5
|
+
exports.JE_SCHEDULE_TYPES = [
|
|
6
|
+
'prepaid_expenses',
|
|
7
|
+
'fixed_assets',
|
|
8
|
+
'accrued_expenses',
|
|
9
|
+
];
|
|
10
|
+
const toJEScheduleType = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.JE_SCHEDULE_TYPES);
|
|
11
|
+
exports.toJEScheduleType = toJEScheduleType;
|
|
12
|
+
const toJEScheduleTypeStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v, exports.JE_SCHEDULE_TYPES);
|
|
13
|
+
exports.toJEScheduleTypeStrict = toJEScheduleTypeStrict;
|
|
14
|
+
exports.JE_APPROVAL_OWNERS = ['zeni', 'customer'];
|
|
15
|
+
const toJEApprovalOwner = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.JE_APPROVAL_OWNERS);
|
|
16
|
+
exports.toJEApprovalOwner = toJEApprovalOwner;
|
|
17
|
+
const toJEApprovalOwnerStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v, exports.JE_APPROVAL_OWNERS);
|
|
18
|
+
exports.toJEApprovalOwnerStrict = toJEApprovalOwnerStrict;
|
|
19
|
+
/** The only step action the backend accepts; older notify steps are dropped on read. */
|
|
20
|
+
exports.JE_APPROVAL_STEP_ACTION = 'require_approval';
|
|
21
|
+
exports.JE_APPROVAL_ZENI_ROLE_SUB_TYPES = [
|
|
22
|
+
'reviewer',
|
|
23
|
+
'controller',
|
|
24
|
+
];
|
|
25
|
+
/** Role actors valid only on customer-owned rules. */
|
|
26
|
+
exports.JE_APPROVAL_CUSTOMER_ROLE_SUB_TYPES = [
|
|
27
|
+
'customer_super_admin',
|
|
28
|
+
'customer_finance_admin',
|
|
29
|
+
];
|
|
30
|
+
exports.JE_APPROVAL_ROLE_SUB_TYPES = [
|
|
31
|
+
...exports.JE_APPROVAL_ZENI_ROLE_SUB_TYPES,
|
|
32
|
+
...exports.JE_APPROVAL_CUSTOMER_ROLE_SUB_TYPES,
|
|
33
|
+
];
|
|
34
|
+
const toJEApprovalRoleSubType = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.JE_APPROVAL_ROLE_SUB_TYPES);
|
|
35
|
+
exports.toJEApprovalRoleSubType = toJEApprovalRoleSubType;
|
|
36
|
+
const toJEApprovalRoleSubTypeStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v, exports.JE_APPROVAL_ROLE_SUB_TYPES);
|
|
37
|
+
exports.toJEApprovalRoleSubTypeStrict = toJEApprovalRoleSubTypeStrict;
|
|
38
|
+
exports.JE_APPROVAL_ACTIONS = ['approve', 'reject', 'save_draft'];
|
|
39
|
+
exports.JE_LEVEL_PREPARER = 1;
|
|
40
|
+
exports.JE_LEVEL_REVIEWER = 2;
|
|
41
|
+
exports.JE_LEVEL_CONTROLLER = 3;
|
|
42
|
+
exports.JE_LEVEL_LABELS = {
|
|
43
|
+
[exports.JE_LEVEL_PREPARER]: 'Preparer',
|
|
44
|
+
[exports.JE_LEVEL_REVIEWER]: 'Reviewer',
|
|
45
|
+
[exports.JE_LEVEL_CONTROLLER]: 'Controller',
|
|
46
|
+
};
|
|
47
|
+
exports.JE_SCHEDULE_TYPE_LABELS = {
|
|
48
|
+
prepaid_expenses: 'Prepaid Expenses',
|
|
49
|
+
fixed_assets: 'Fixed Assets',
|
|
50
|
+
accrued_expenses: 'Accrued Expenses',
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Typed failure kinds for the approval-rule / approval-action endpoints.
|
|
54
|
+
* 403 = viewer may not edit (or touched the other owner's rule / is not an
|
|
55
|
+
* eligible approver / SoD); 409 = someone else already approved.
|
|
56
|
+
*/
|
|
57
|
+
exports.JE_APPROVAL_ENTRIES_SOURCES = ['parked', 'live'];
|
|
58
|
+
exports.JE_APPROVAL_ERROR_KINDS = [
|
|
59
|
+
'forbidden',
|
|
60
|
+
'conflict',
|
|
61
|
+
'validation',
|
|
62
|
+
'not_found',
|
|
63
|
+
'unknown',
|
|
64
|
+
];
|
|
@@ -2,12 +2,13 @@ import { StatusCodeWithLabelPayload } from '../../commonPayloadTypes/statusPaylo
|
|
|
2
2
|
import { ID } from '../../commonStateTypes/common';
|
|
3
3
|
import { AccountPayload } from '../account/accountPayload';
|
|
4
4
|
import { ClassBasePayload } from '../class/classPayload';
|
|
5
|
+
import { JEScheduleApprovalInfoPayload } from '../jeScheduleApprovalRule/jeScheduleApprovalRulePayload';
|
|
5
6
|
import { ScheduleTransactionPayload } from '../transaction/payloadTypes/scheduleTransactionPayload';
|
|
6
7
|
import { TransactionIDPayload } from '../transaction/payloadTypes/transactionIDPayload';
|
|
7
8
|
import { TransactionCategory } from '../transaction/stateTypes/transactionType';
|
|
8
9
|
import { UserPayload } from '../user/userPayload';
|
|
9
10
|
import { VendorPayload } from '../vendor/vendorPayload';
|
|
10
|
-
import { JEAccruedScheduledTransactionState, JEOneTimeAccrualState, JEScheduledTransactionState, ScheduledJournalEntryState } from './jeSchedulesState';
|
|
11
|
+
import { JEAccruedScheduledTransactionState, JEOneTimeAccrualState, JEScheduleContributor, JEScheduledTransactionState, ScheduledJournalEntryState } from './jeSchedulesState';
|
|
11
12
|
import { JEScheduleKey, JEScheduleTransactionKey } from './jeSchedulesTypes';
|
|
12
13
|
export interface JEScheduleOtherAttributesPayload {
|
|
13
14
|
asset_id?: string | null;
|
|
@@ -83,7 +84,9 @@ export interface JEScheduledTransactionPayload {
|
|
|
83
84
|
updated_by: UserPayload;
|
|
84
85
|
vendor: VendorPayload;
|
|
85
86
|
ai_summaries?: JEScheduleAISummariesPayload;
|
|
87
|
+
approval_info?: JEScheduleApprovalInfoPayload | null;
|
|
86
88
|
confidence_score?: number | null;
|
|
89
|
+
contributors?: JEScheduleContributorPayload[] | null;
|
|
87
90
|
create_time?: string | null;
|
|
88
91
|
created_by?: UserPayload;
|
|
89
92
|
end_date?: string | null;
|
|
@@ -92,6 +95,14 @@ export interface JEScheduledTransactionPayload {
|
|
|
92
95
|
recurring_amount?: number | null;
|
|
93
96
|
updated_at?: string | null;
|
|
94
97
|
}
|
|
98
|
+
export interface JEScheduleContributorPayload {
|
|
99
|
+
kind: string;
|
|
100
|
+
last_action: string;
|
|
101
|
+
name: string;
|
|
102
|
+
user_id: ID;
|
|
103
|
+
first_action_at?: string | null;
|
|
104
|
+
last_action_at?: string | null;
|
|
105
|
+
}
|
|
95
106
|
export interface JEAccruedScheduledTransactionPayload extends Omit<JEScheduledTransactionPayload, 'base_transaction' | 'je_schedule_id' | 'je_schedule_type'> {
|
|
96
107
|
create_time: string;
|
|
97
108
|
je_schedule_id: ID;
|
|
@@ -166,6 +177,7 @@ export interface JEOneTimeAccrualPayload {
|
|
|
166
177
|
actual_post_date?: string | null;
|
|
167
178
|
actual_reversal_post_date?: string | null;
|
|
168
179
|
ai_suggestion?: JEOneTimeAccrualAiSuggestionPayload | null;
|
|
180
|
+
approval_info?: JEScheduleApprovalInfoPayload | null;
|
|
169
181
|
automation_tier?: string | null;
|
|
170
182
|
cleared?: JEOneTimeAccrualClearedPayload | null;
|
|
171
183
|
created_by_user?: UserPayload | null;
|
|
@@ -221,6 +233,8 @@ export declare function toJEAccruedAccountPayload(payload: JEScheduledTransactio
|
|
|
221
233
|
export declare function toJEClassPayload(payload: JEScheduledTransactionPayload | JEAccruedScheduledTransactionPayload, type: TransactionCategory): ClassBasePayload | undefined;
|
|
222
234
|
export declare function getJEScheduleTransactionDetailKeyPayload(payload: ScheduleTransactionPayload): JEScheduleTransactionKey;
|
|
223
235
|
export declare function getJEScheduleKey(payload: JEAccruedScheduledTransactionPayload): JEScheduleKey;
|
|
236
|
+
/** Drops entries whose kind or action this client does not know, so an unknown actor is never shown as an editor. */
|
|
237
|
+
export declare function toJEScheduleContributors(payload: JEScheduleContributorPayload[] | null | undefined): JEScheduleContributor[];
|
|
224
238
|
export declare function toJEScheduledTransaction(payload: JEScheduledTransactionPayload): JEScheduledTransactionState;
|
|
225
239
|
export declare function toJEAccruedScheduledTransaction(payload: JEAccruedScheduledTransactionPayload): JEAccruedScheduledTransactionState;
|
|
226
240
|
export declare function toJEOneTimeAccrual(payload: JEOneTimeAccrualPayload): JEOneTimeAccrualState;
|
|
@@ -6,6 +6,7 @@ exports.toJEAccruedAccountPayload = toJEAccruedAccountPayload;
|
|
|
6
6
|
exports.toJEClassPayload = toJEClassPayload;
|
|
7
7
|
exports.getJEScheduleTransactionDetailKeyPayload = getJEScheduleTransactionDetailKeyPayload;
|
|
8
8
|
exports.getJEScheduleKey = getJEScheduleKey;
|
|
9
|
+
exports.toJEScheduleContributors = toJEScheduleContributors;
|
|
9
10
|
exports.toJEScheduledTransaction = toJEScheduledTransaction;
|
|
10
11
|
exports.toJEAccruedScheduledTransaction = toJEAccruedScheduledTransaction;
|
|
11
12
|
exports.toJEOneTimeAccrual = toJEOneTimeAccrual;
|
|
@@ -13,6 +14,7 @@ const amount_1 = require("../../commonStateTypes/amount");
|
|
|
13
14
|
const timePeriod_1 = require("../../commonStateTypes/timePeriod");
|
|
14
15
|
const zeniDayJS_1 = require("../../zeniDayJS");
|
|
15
16
|
const zeniUrl_1 = require("../../zeniUrl");
|
|
17
|
+
const jeScheduleApprovalRulePayload_1 = require("../jeScheduleApprovalRule/jeScheduleApprovalRulePayload");
|
|
16
18
|
const transactionIDPayload_1 = require("../transaction/payloadTypes/transactionIDPayload");
|
|
17
19
|
const jeScheduleHelper_1 = require("./jeScheduleHelper");
|
|
18
20
|
const jeSchedulesTypes_1 = require("./jeSchedulesTypes");
|
|
@@ -254,6 +256,30 @@ function toJEScheduleAISummaries(payload) {
|
|
|
254
256
|
}
|
|
255
257
|
return Object.keys(result).length > 0 ? result : undefined;
|
|
256
258
|
}
|
|
259
|
+
/** Drops entries whose kind or action this client does not know, so an unknown actor is never shown as an editor. */
|
|
260
|
+
function toJEScheduleContributors(payload) {
|
|
261
|
+
const contributors = [];
|
|
262
|
+
(payload ?? []).forEach((contributor) => {
|
|
263
|
+
const kind = (0, jeSchedulesTypes_1.toJEScheduleContributorKind)(contributor.kind);
|
|
264
|
+
const lastAction = (0, jeSchedulesTypes_1.toJEScheduleContributorAction)(contributor.last_action);
|
|
265
|
+
if (kind == null || lastAction == null) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
contributors.push({
|
|
269
|
+
userId: contributor.user_id,
|
|
270
|
+
kind,
|
|
271
|
+
name: contributor.name,
|
|
272
|
+
lastAction,
|
|
273
|
+
firstActionAt: contributor.first_action_at != null
|
|
274
|
+
? (0, zeniDayJS_1.date)(contributor.first_action_at)
|
|
275
|
+
: undefined,
|
|
276
|
+
lastActionAt: contributor.last_action_at != null
|
|
277
|
+
? (0, zeniDayJS_1.date)(contributor.last_action_at)
|
|
278
|
+
: undefined,
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
return contributors;
|
|
282
|
+
}
|
|
257
283
|
function toJEScheduleRecommendations(payload) {
|
|
258
284
|
if (payload == null) {
|
|
259
285
|
return undefined;
|
|
@@ -334,9 +360,11 @@ function toJEScheduledTransaction(payload) {
|
|
|
334
360
|
: {},
|
|
335
361
|
scheduledJournalEntry: [],
|
|
336
362
|
aiSummaries: toJEScheduleAISummaries(payload.ai_summaries),
|
|
363
|
+
approvalInfo: (0, jeScheduleApprovalRulePayload_1.toJEScheduleApprovalInfo)(payload.approval_info),
|
|
337
364
|
confidenceScore: payload.confidence_score ?? undefined,
|
|
338
365
|
createdByUserID: payload.created_by?.user_id ?? undefined,
|
|
339
366
|
recommendations: toJEScheduleRecommendations(payload.recommendations),
|
|
367
|
+
contributors: toJEScheduleContributors(payload.contributors),
|
|
340
368
|
};
|
|
341
369
|
}
|
|
342
370
|
function toJEAccruedScheduledTransaction(payload) {
|
|
@@ -384,6 +412,7 @@ function toJEAccruedScheduledTransaction(payload) {
|
|
|
384
412
|
},
|
|
385
413
|
currencyCode: payload.currency_code,
|
|
386
414
|
currencySymbol: payload.currency_symbol,
|
|
415
|
+
approvalInfo: (0, jeScheduleApprovalRulePayload_1.toJEScheduleApprovalInfo)(payload.approval_info),
|
|
387
416
|
dayOfPostingDate: payload.posting_date != null &&
|
|
388
417
|
payload.posting_date >= timePeriod_1.MIN_SCHEDULE_DAY_OF_MONTH &&
|
|
389
418
|
payload.posting_date <= timePeriod_1.MAX_SCHEDULE_DAY_OF_MONTH
|
|
@@ -396,6 +425,7 @@ function toJEAccruedScheduledTransaction(payload) {
|
|
|
396
425
|
scheduledJournalEntry: [],
|
|
397
426
|
createTime: (0, zeniDayJS_1.date)(payload.create_time),
|
|
398
427
|
jeScheduleType: (0, jeSchedulesTypes_1.toScheduleTypesTypeStrict)(payload.je_schedule_type),
|
|
428
|
+
contributors: toJEScheduleContributors(payload.contributors),
|
|
399
429
|
};
|
|
400
430
|
}
|
|
401
431
|
/**
|
|
@@ -514,6 +544,7 @@ function toJEOneTimeAccrual(payload) {
|
|
|
514
544
|
automationTier: payload.automation_tier != null
|
|
515
545
|
? (0, jeSchedulesTypes_1.toOneTimeAccrualAutomationTierType)(payload.automation_tier)
|
|
516
546
|
: undefined,
|
|
547
|
+
approvalInfo: (0, jeScheduleApprovalRulePayload_1.toJEScheduleApprovalInfo)(payload.approval_info),
|
|
517
548
|
estimatedAmount: toOneTimeAccrualAmount(payload.estimated_amount, payload.currency),
|
|
518
549
|
memo: payload.memo ?? '',
|
|
519
550
|
profileSnapshot: toJEOneTimeAccrualProfileSnapshot(payload.profile_snapshot, payload.currency),
|
|
@@ -183,6 +183,10 @@ function doUpdateJEScheduledTransaction(draft, id, payload, updateType) {
|
|
|
183
183
|
const jeTransaction = (0, jeSchedulesPayload_1.toJEScheduledTransaction)(payload);
|
|
184
184
|
const existingTransaction = draft[id];
|
|
185
185
|
if (existingTransaction != null && updateType === 'merge') {
|
|
186
|
+
// A payload without a contributors ledger maps to [], which would otherwise wipe the stored one.
|
|
187
|
+
if (payload.contributors == null) {
|
|
188
|
+
jeTransaction.contributors = existingTransaction.contributors;
|
|
189
|
+
}
|
|
186
190
|
// scheduledJournalEntry is held back from the merge. The list payload never carries journal
|
|
187
191
|
// entries -- toJEScheduledTransaction always sets [] -- and [] is not nullish, so the
|
|
188
192
|
// customizer below would treat it as a value and wipe whatever updateJESchedulesDetails had
|
|
@@ -199,6 +203,10 @@ function doUpdateJEAccruedScheduledTransaction(draft, id, payload, updateType) {
|
|
|
199
203
|
const jeTransaction = (0, jeSchedulesPayload_1.toJEAccruedScheduledTransaction)(payload);
|
|
200
204
|
const existingTransaction = draft[id];
|
|
201
205
|
if (existingTransaction != null && updateType === 'merge') {
|
|
206
|
+
// A payload without a contributors ledger maps to [], which would otherwise wipe the stored one.
|
|
207
|
+
if (payload.contributors == null) {
|
|
208
|
+
jeTransaction.contributors = existingTransaction.contributors;
|
|
209
|
+
}
|
|
202
210
|
(0, assignWith_1.default)(draft[id], jeTransaction, (objValue, srcValue) => srcValue ?? objValue); // IMPORTANT: replace the value only when source has valid value. Otherwise keep the existing value!
|
|
203
211
|
}
|
|
204
212
|
else {
|
|
@@ -244,6 +252,10 @@ function doUpdateAccruedScheduledDetailTransaction(draft, id, jeSchedulePayload,
|
|
|
244
252
|
}
|
|
245
253
|
const existingTransaction = draft[id];
|
|
246
254
|
if (existingTransaction != null && updateType === 'merge') {
|
|
255
|
+
// A payload without a contributors ledger maps to [], which would otherwise wipe the stored one.
|
|
256
|
+
if (jeSchedulePayload.contributors == null) {
|
|
257
|
+
jeTransaction.contributors = existingTransaction.contributors;
|
|
258
|
+
}
|
|
247
259
|
// An empty array here means "this payload carried no entries for this schedule", not "this
|
|
248
260
|
// schedule has none" -- and [] is not nullish, so the customizer below would treat it as a
|
|
249
261
|
// value and clear entries another call already wrote. Only overwrite when there is something
|
|
@@ -274,6 +286,10 @@ function doUpdateScheduledDetailTransaction(draft, id, jeSchedulePayload, schedu
|
|
|
274
286
|
}
|
|
275
287
|
const existingTransaction = draft[id];
|
|
276
288
|
if (existingTransaction != null && updateType === 'merge') {
|
|
289
|
+
// A payload without a contributors ledger maps to [], which would otherwise wipe the stored one.
|
|
290
|
+
if (jeSchedulePayload.contributors == null) {
|
|
291
|
+
jeTransaction.contributors = existingTransaction.contributors;
|
|
292
|
+
}
|
|
277
293
|
// An empty array here means "this payload carried no entries for this schedule", not "this
|
|
278
294
|
// schedule has none" -- and [] is not nullish, so the customizer below would treat it as a
|
|
279
295
|
// value and clear entries another call already wrote. Only overwrite when there is something
|
|
@@ -5,6 +5,7 @@ import { RootState } from '../../rootStateTypes';
|
|
|
5
5
|
import { ZeniDate } from '../../zeniDayJS';
|
|
6
6
|
import { AccountBase } from '../account/accountState';
|
|
7
7
|
import { Class } from '../class/classState';
|
|
8
|
+
import { JEScheduleApprovalInfo } from '../jeScheduleApprovalRule/jeScheduleApprovalRuleState';
|
|
8
9
|
import { ScheduleTransaction } from '../transaction/stateTypes/scheduleTransaction';
|
|
9
10
|
import { TransactionID } from '../transaction/stateTypes/transactionID';
|
|
10
11
|
import { User } from '../user/userState';
|
|
@@ -84,3 +85,10 @@ export interface JEOneTimeAccrual extends JEOneTimeAccrualState {
|
|
|
84
85
|
export declare const getJEOneTimeAccrualByKey: (jeOneTimeAccrualKey: JEOneTimeAccrualKey, jeSchedulesState: JESchedulesState) => JEOneTimeAccrual | undefined;
|
|
85
86
|
export declare const getJEAccruedScheduleByJEScheduleKey: (JEScheduleKey: JEScheduleKey, state: RootState) => JEAccruedSchedule | undefined;
|
|
86
87
|
export declare const getJEScheduledTransactionByJEScheduleTransactionKey: (jeScheduleTransactionKey: JEScheduleTransactionKey, state: RootState) => JEScheduledTransaction;
|
|
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>;
|
|
90
|
+
export declare const getScheduleApprovalInfo: (jeSchedulesState: JESchedulesState, jeScheduleId: ID) => JEScheduleApprovalInfo | undefined;
|
|
91
|
+
/** One-time accruals are keyed by accrual id, so this is a direct lookup, unlike the schedule scan. */
|
|
92
|
+
export declare const getOneTimeAccrualApprovalInfo: (jeSchedulesState: JESchedulesState, accrualId: ID) => JEScheduleApprovalInfo | undefined;
|
|
93
|
+
/** Human contributors other than the creator, earliest first; schedules nobody else touched are omitted. */
|
|
94
|
+
export declare const getEditedByNamesByScheduleId: (jeSchedulesState: JESchedulesState) => Record<ID, string[]>;
|