law-common 10.75.1-beta.13 → 10.75.1-beta.14
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/dist/src/entities/flow-configs/leave.flow.config.d.ts +5 -1
- package/dist/src/entities/flow-configs/leave.flow.config.js +10 -0
- package/dist/src/entities/model/leave.entity.model.d.ts +3 -1
- package/dist/src/entities/model/leave.entity.model.js +15 -2
- package/dist/src/entities/model/leave_approval.entity.model.d.ts +3 -0
- package/dist/src/entities/model/leave_approval.entity.model.js +9 -0
- package/package.json +1 -1
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { LeaveActionEnum } from "../enums/leave.action.enum";
|
|
2
2
|
import { LeaveStatusEnum } from "../enums/leave.status.enum";
|
|
3
|
+
import { LeaveEntityModel } from "../model/leave.entity.model";
|
|
3
4
|
import { FlowConfig } from "./flow-config.type";
|
|
4
|
-
export
|
|
5
|
+
export interface ILeaveFlowConfigContextData {
|
|
6
|
+
leaveEntity?: LeaveEntityModel;
|
|
7
|
+
}
|
|
8
|
+
export declare const leaveFlowConfig: FlowConfig<LeaveStatusEnum, LeaveActionEnum, ILeaveFlowConfigContextData>;
|
|
@@ -31,6 +31,16 @@ exports.leaveFlowConfig = {
|
|
|
31
31
|
next: () => leave_status_enum_1.LeaveStatusEnum.DELETED,
|
|
32
32
|
description: "Deletes the leave request entirely before it has been approved.",
|
|
33
33
|
},
|
|
34
|
+
[leave_action_enum_1.LeaveActionEnum.LEAVE_APPROVAL_APPROVE]: {
|
|
35
|
+
permissions: ["LEAVE_APPROVER_ORG"],
|
|
36
|
+
next: (context) => { var _a; return ((_a = context.leaveEntity) === null || _a === void 0 ? void 0 : _a.getOverallStatusByLeaveApprovals()) || context.leaveEntity.status; },
|
|
37
|
+
description: "Approves the leave request. The employee's leave will be marked as approved.",
|
|
38
|
+
},
|
|
39
|
+
[leave_action_enum_1.LeaveActionEnum.LEAVE_APPROVAL_REJECT]: {
|
|
40
|
+
permissions: ["LEAVE_APPROVER_ORG"],
|
|
41
|
+
next: (context) => { var _a; return ((_a = context.leaveEntity) === null || _a === void 0 ? void 0 : _a.getOverallStatusByLeaveApprovals()) || context.leaveEntity.status; },
|
|
42
|
+
description: "Rejects the leave request. The employee will be notified of the rejection.",
|
|
43
|
+
},
|
|
34
44
|
},
|
|
35
45
|
},
|
|
36
46
|
[leave_status_enum_1.LeaveStatusEnum.EDIT_APPROVAL]: {
|
|
@@ -4,6 +4,7 @@ import { DurationTypeEnum } from "../enums/duration-type.enum";
|
|
|
4
4
|
import { LeaveTypeEnum } from "../enums/leave-type.enum";
|
|
5
5
|
import { LeaveActionEnum } from "../enums/leave.action.enum";
|
|
6
6
|
import { LeaveStatusEnum } from "../enums/leave.status.enum";
|
|
7
|
+
import { ILeaveFlowConfigContextData } from "../flow-configs/leave.flow.config";
|
|
7
8
|
import { EntityEnum, VirtualEntityEnum } from "../interface/entity.utils.interface";
|
|
8
9
|
import { ILeaveEntity } from "../interface/leave.entity.interface";
|
|
9
10
|
import { RelationConfigs } from "../interface/relation-config.interface";
|
|
@@ -78,7 +79,8 @@ export declare class LeaveEntityModel extends BaseEntityModel<EntityEnum.LEAVE>
|
|
|
78
79
|
getUpdateActionVisibility(currentUser: UserEntityModel): {
|
|
79
80
|
[key: string]: () => boolean;
|
|
80
81
|
};
|
|
81
|
-
getNextStatus(currentUser: UserEntityModel, dto: ILeaveUpdateDto): LeaveStatusEnum;
|
|
82
|
+
getNextStatus(currentUser: UserEntityModel, dto: ILeaveUpdateDto, leaveFlowContext?: ILeaveFlowConfigContextData): LeaveStatusEnum;
|
|
82
83
|
mapStatusLabel(status: LeaveStatusEnum): string;
|
|
83
84
|
static getFormattedStatus(status: LeaveStatusEnum): string;
|
|
85
|
+
getOverallStatusByLeaveApprovals(): LeaveStatusEnum;
|
|
84
86
|
}
|
|
@@ -12,6 +12,7 @@ const relation_type_enum_1 = require("../enums/relation-type.enum");
|
|
|
12
12
|
const leave_flow_config_1 = require("../flow-configs/leave.flow.config");
|
|
13
13
|
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
14
14
|
const base_entity_model_1 = require("./base.entity.model");
|
|
15
|
+
const leave_approval_entity_model_1 = require("./leave_approval.entity.model");
|
|
15
16
|
class LeaveEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
16
17
|
constructor() {
|
|
17
18
|
super(...arguments);
|
|
@@ -190,7 +191,7 @@ class LeaveEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
190
191
|
LEAVE_DELETE_SELF: () => currentUser.id === this.createdBy,
|
|
191
192
|
};
|
|
192
193
|
}
|
|
193
|
-
getNextStatus(currentUser, dto) {
|
|
194
|
+
getNextStatus(currentUser, dto, leaveFlowContext = {}) {
|
|
194
195
|
if (!this.status) {
|
|
195
196
|
throw new exceptions_1.AppBadRequestException({
|
|
196
197
|
key: error_key_enum_1.ErrorKeyEnum.STATUS,
|
|
@@ -233,7 +234,7 @@ class LeaveEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
233
234
|
message: [`Current user does not have permission to ${dto.actionData.action} leave`],
|
|
234
235
|
});
|
|
235
236
|
}
|
|
236
|
-
const nextStatus = matchingPermissionConfig.next(
|
|
237
|
+
const nextStatus = matchingPermissionConfig.next(leaveFlowContext);
|
|
237
238
|
return nextStatus;
|
|
238
239
|
}
|
|
239
240
|
mapStatusLabel(status) {
|
|
@@ -262,6 +263,18 @@ class LeaveEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
262
263
|
}
|
|
263
264
|
return (0, string_util_1.formatString)(statusToReturn);
|
|
264
265
|
}
|
|
266
|
+
getOverallStatusByLeaveApprovals() {
|
|
267
|
+
if (!this.leaveApprovals || this.leaveApprovals.length === 0) {
|
|
268
|
+
return this.status;
|
|
269
|
+
}
|
|
270
|
+
if (leave_approval_entity_model_1.LeaveApprovalEntityModel.areAllApproved(this.leaveApprovals)) {
|
|
271
|
+
return leave_status_enum_1.LeaveStatusEnum.APPROVED;
|
|
272
|
+
}
|
|
273
|
+
if (leave_approval_entity_model_1.LeaveApprovalEntityModel.isAnyRejected(this.leaveApprovals)) {
|
|
274
|
+
return leave_status_enum_1.LeaveStatusEnum.REJECTED;
|
|
275
|
+
}
|
|
276
|
+
return this.status;
|
|
277
|
+
}
|
|
265
278
|
}
|
|
266
279
|
exports.LeaveEntityModel = LeaveEntityModel;
|
|
267
280
|
LeaveEntityModel.relationConfigs = [
|
|
@@ -35,4 +35,7 @@ export declare class LeaveApprovalEntityModel extends BaseEntityModel<EntityEnum
|
|
|
35
35
|
getUpdateActionVisibility(currentUser: UserEntityModel): {
|
|
36
36
|
[key: string]: () => boolean;
|
|
37
37
|
};
|
|
38
|
+
static areAllApproved(models: LeaveApprovalEntityModel[]): boolean;
|
|
39
|
+
static isAnyRejected(models: LeaveApprovalEntityModel[]): boolean;
|
|
40
|
+
static isAnyPending(models: LeaveApprovalEntityModel[]): boolean;
|
|
38
41
|
}
|
|
@@ -87,6 +87,15 @@ class LeaveApprovalEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
87
87
|
getUpdateActionVisibility(currentUser) {
|
|
88
88
|
return {};
|
|
89
89
|
}
|
|
90
|
+
static areAllApproved(models) {
|
|
91
|
+
return models.every((model) => model.status === leave_approval_status_enum_1.LeaveApprovalStatusEnum.APPROVED);
|
|
92
|
+
}
|
|
93
|
+
static isAnyRejected(models) {
|
|
94
|
+
return models.some((model) => model.status === leave_approval_status_enum_1.LeaveApprovalStatusEnum.REJECTED);
|
|
95
|
+
}
|
|
96
|
+
static isAnyPending(models) {
|
|
97
|
+
return models.some((model) => model.status === leave_approval_status_enum_1.LeaveApprovalStatusEnum.CREATE_APPROVAL_PENDING);
|
|
98
|
+
}
|
|
90
99
|
}
|
|
91
100
|
exports.LeaveApprovalEntityModel = LeaveApprovalEntityModel;
|
|
92
101
|
LeaveApprovalEntityModel.relationConfigs = [
|