law-common 10.11.1-beta.1 → 10.12.1-beta.0
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/constants/entity_constants.d.ts +1 -0
- package/dist/src/constants/entity_constants.js +2 -1
- package/dist/src/entities/enums/duration-type.enum.d.ts +16 -0
- package/dist/src/entities/enums/duration-type.enum.js +87 -0
- package/dist/src/entities/enums/leave-type.enum.d.ts +6 -14
- package/dist/src/entities/enums/leave-type.enum.js +6 -81
- package/dist/src/entities/enums/user.entity.enum.d.ts +2 -1
- package/dist/src/entities/enums/user.entity.enum.js +1 -0
- package/dist/src/entities/index.d.ts +4 -1
- package/dist/src/entities/index.js +4 -1
- package/dist/src/entities/interface/entity.utils.interface.d.ts +28 -19
- package/dist/src/entities/interface/entity.utils.interface.js +5 -1
- package/dist/src/entities/interface/leave.entity.interface.d.ts +17 -3
- package/dist/src/entities/interface/work_from_home.entity.interface.d.ts +3 -0
- package/dist/src/entities/model/holiday.entity.model.d.ts +19 -0
- package/dist/src/entities/model/holiday.entity.model.js +31 -0
- package/dist/src/entities/model/leave.entity.model.d.ts +28 -0
- package/dist/src/entities/model/leave.entity.model.js +62 -0
- package/dist/src/utils/helper.fn.util.js +10 -7
- package/dist/src/utils/models/date-code.model.util.d.ts +19 -0
- package/dist/src/utils/models/date-code.model.util.js +124 -1
- package/dist/tests/date-code.model.util.spec.js +30 -0
- package/package.json +1 -1
|
@@ -10,3 +10,4 @@ export declare const freezeTimesheetAfterBillingStatus: BillingStatusEnum;
|
|
|
10
10
|
export declare const usersToExcludeFromSearchResponse: string[];
|
|
11
11
|
export declare const systemUsers: string[];
|
|
12
12
|
export declare const reimbursementExpenseProjectUserInactiveBuffer: number;
|
|
13
|
+
export declare const annualPaidLeaves = 24;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reimbursementExpenseProjectUserInactiveBuffer = exports.systemUsers = exports.usersToExcludeFromSearchResponse = exports.freezeTimesheetAfterBillingStatus = exports.leaveImplicitDays = exports.reimbursementPaymentProcessorPermissionName = exports.toDoListMinimumEstimatedDuration = exports.timesheetMinimumTotalDuration = exports.timesheetEnterThreshold = exports.timesheetThreshold = exports.timesheetViewThreshold = void 0;
|
|
3
|
+
exports.annualPaidLeaves = exports.reimbursementExpenseProjectUserInactiveBuffer = exports.systemUsers = exports.usersToExcludeFromSearchResponse = exports.freezeTimesheetAfterBillingStatus = exports.leaveImplicitDays = exports.reimbursementPaymentProcessorPermissionName = exports.toDoListMinimumEstimatedDuration = exports.timesheetMinimumTotalDuration = exports.timesheetEnterThreshold = exports.timesheetThreshold = exports.timesheetViewThreshold = void 0;
|
|
4
4
|
const entities_1 = require("../entities");
|
|
5
5
|
exports.timesheetViewThreshold = "timesheetViewThreshold";
|
|
6
6
|
exports.timesheetThreshold = "timesheetThreshold";
|
|
@@ -13,3 +13,4 @@ exports.freezeTimesheetAfterBillingStatus = entities_1.BillingStatusEnum.PENDING
|
|
|
13
13
|
exports.usersToExcludeFromSearchResponse = ["DB migration"];
|
|
14
14
|
exports.systemUsers = ["DB migration"];
|
|
15
15
|
exports.reimbursementExpenseProjectUserInactiveBuffer = 24 * 60;
|
|
16
|
+
exports.annualPaidLeaves = 24;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare enum DurationTypeEnum {
|
|
2
|
+
FIRST = "first",
|
|
3
|
+
SECOND = "second",
|
|
4
|
+
FULL = "full",
|
|
5
|
+
FULL_FIRST = "full_first",
|
|
6
|
+
SECOND_FULL = "second_full",
|
|
7
|
+
SECOND_FIRST = "second_first"
|
|
8
|
+
}
|
|
9
|
+
export declare namespace DurationTypeEnum {
|
|
10
|
+
function getDropdownLabel(action: DurationTypeEnum): string;
|
|
11
|
+
function getLeaveTypeFromStartEnd(from: DurationTypeEnum, to?: DurationTypeEnum): DurationTypeEnum;
|
|
12
|
+
function getStartEndFromLeaveType(type: DurationTypeEnum): {
|
|
13
|
+
fromType: DurationTypeEnum;
|
|
14
|
+
toType: DurationTypeEnum;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DurationTypeEnum = void 0;
|
|
4
|
+
const error_key_enum_1 = require("../../enums/error.key.enum");
|
|
5
|
+
const exceptions_1 = require("../../exceptions");
|
|
6
|
+
var DurationTypeEnum;
|
|
7
|
+
(function (DurationTypeEnum) {
|
|
8
|
+
DurationTypeEnum["FIRST"] = "first";
|
|
9
|
+
DurationTypeEnum["SECOND"] = "second";
|
|
10
|
+
DurationTypeEnum["FULL"] = "full";
|
|
11
|
+
DurationTypeEnum["FULL_FIRST"] = "full_first";
|
|
12
|
+
DurationTypeEnum["SECOND_FULL"] = "second_full";
|
|
13
|
+
DurationTypeEnum["SECOND_FIRST"] = "second_first";
|
|
14
|
+
})(DurationTypeEnum || (exports.DurationTypeEnum = DurationTypeEnum = {}));
|
|
15
|
+
(function (DurationTypeEnum) {
|
|
16
|
+
const typeLabelMap = {
|
|
17
|
+
[DurationTypeEnum.FIRST]: "First Half",
|
|
18
|
+
[DurationTypeEnum.SECOND]: "Second Half",
|
|
19
|
+
[DurationTypeEnum.FULL]: "Full Day",
|
|
20
|
+
};
|
|
21
|
+
function getDropdownLabel(action) {
|
|
22
|
+
if (!Object.values(DurationTypeEnum).includes(action)) {
|
|
23
|
+
throw new exceptions_1.AppBadRequestException({
|
|
24
|
+
key: error_key_enum_1.ErrorKeyEnum.LEAVE_TYPE,
|
|
25
|
+
message: ["Invalid type value"],
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
const label = typeLabelMap[action];
|
|
29
|
+
if (!label) {
|
|
30
|
+
throw new exceptions_1.AppBadRequestException({
|
|
31
|
+
key: error_key_enum_1.ErrorKeyEnum.LEAVE_TYPE,
|
|
32
|
+
message: ["Invalid type value"],
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return label;
|
|
36
|
+
}
|
|
37
|
+
DurationTypeEnum.getDropdownLabel = getDropdownLabel;
|
|
38
|
+
function getLeaveTypeFromStartEnd(from, to) {
|
|
39
|
+
if (!to || from === to)
|
|
40
|
+
return from;
|
|
41
|
+
if (from === DurationTypeEnum.FULL && to === DurationTypeEnum.FIRST)
|
|
42
|
+
return DurationTypeEnum.FULL_FIRST;
|
|
43
|
+
if (from === DurationTypeEnum.SECOND && to === DurationTypeEnum.FULL)
|
|
44
|
+
return DurationTypeEnum.SECOND_FULL;
|
|
45
|
+
if (from === DurationTypeEnum.SECOND && to === DurationTypeEnum.FIRST)
|
|
46
|
+
return DurationTypeEnum.SECOND_FIRST;
|
|
47
|
+
throw new Error(`Invalid leave type: ${from} + ${to}`);
|
|
48
|
+
}
|
|
49
|
+
DurationTypeEnum.getLeaveTypeFromStartEnd = getLeaveTypeFromStartEnd;
|
|
50
|
+
function getStartEndFromLeaveType(type) {
|
|
51
|
+
switch (type) {
|
|
52
|
+
case DurationTypeEnum.FIRST:
|
|
53
|
+
return {
|
|
54
|
+
fromType: DurationTypeEnum.FIRST,
|
|
55
|
+
toType: DurationTypeEnum.FIRST,
|
|
56
|
+
};
|
|
57
|
+
case DurationTypeEnum.SECOND:
|
|
58
|
+
return {
|
|
59
|
+
fromType: DurationTypeEnum.SECOND,
|
|
60
|
+
toType: DurationTypeEnum.SECOND,
|
|
61
|
+
};
|
|
62
|
+
case DurationTypeEnum.FULL:
|
|
63
|
+
return {
|
|
64
|
+
fromType: DurationTypeEnum.FULL,
|
|
65
|
+
toType: DurationTypeEnum.FULL,
|
|
66
|
+
};
|
|
67
|
+
case DurationTypeEnum.FULL_FIRST:
|
|
68
|
+
return {
|
|
69
|
+
fromType: DurationTypeEnum.FULL,
|
|
70
|
+
toType: DurationTypeEnum.FIRST,
|
|
71
|
+
};
|
|
72
|
+
case DurationTypeEnum.SECOND_FULL:
|
|
73
|
+
return {
|
|
74
|
+
fromType: DurationTypeEnum.SECOND,
|
|
75
|
+
toType: DurationTypeEnum.FULL,
|
|
76
|
+
};
|
|
77
|
+
case DurationTypeEnum.SECOND_FIRST:
|
|
78
|
+
return {
|
|
79
|
+
fromType: DurationTypeEnum.SECOND,
|
|
80
|
+
toType: DurationTypeEnum.FIRST,
|
|
81
|
+
};
|
|
82
|
+
default:
|
|
83
|
+
throw new Error(`Invalid DurationTypeEnum: ${type}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
DurationTypeEnum.getStartEndFromLeaveType = getStartEndFromLeaveType;
|
|
87
|
+
})(DurationTypeEnum || (exports.DurationTypeEnum = DurationTypeEnum = {}));
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
export declare enum LeaveTypeEnum {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
export declare namespace LeaveTypeEnum {
|
|
10
|
-
function getDropdownLabel(action: LeaveTypeEnum): string;
|
|
11
|
-
function getLeaveTypeFromStartEnd(from: LeaveTypeEnum, to?: LeaveTypeEnum): LeaveTypeEnum;
|
|
12
|
-
function getStartEndFromLeaveType(type: LeaveTypeEnum): {
|
|
13
|
-
fromType: LeaveTypeEnum;
|
|
14
|
-
toType: LeaveTypeEnum;
|
|
15
|
-
};
|
|
2
|
+
LEISURE = "leisure",
|
|
3
|
+
ILLNESS = "illness",
|
|
4
|
+
BEREAVEMENT = "bereavement",
|
|
5
|
+
SICK = "sick",
|
|
6
|
+
UNPAID = "unpaid",
|
|
7
|
+
BIRTHDAY = "birthday"
|
|
16
8
|
}
|
|
@@ -1,87 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LeaveTypeEnum = void 0;
|
|
4
|
-
const error_key_enum_1 = require("../../enums/error.key.enum");
|
|
5
|
-
const exceptions_1 = require("../../exceptions");
|
|
6
4
|
var LeaveTypeEnum;
|
|
7
5
|
(function (LeaveTypeEnum) {
|
|
8
|
-
LeaveTypeEnum["
|
|
9
|
-
LeaveTypeEnum["
|
|
10
|
-
LeaveTypeEnum["
|
|
11
|
-
LeaveTypeEnum["
|
|
12
|
-
LeaveTypeEnum["
|
|
13
|
-
LeaveTypeEnum["
|
|
14
|
-
})(LeaveTypeEnum || (exports.LeaveTypeEnum = LeaveTypeEnum = {}));
|
|
15
|
-
(function (LeaveTypeEnum) {
|
|
16
|
-
const typeLabelMap = {
|
|
17
|
-
[LeaveTypeEnum.FIRST]: "First Half",
|
|
18
|
-
[LeaveTypeEnum.SECOND]: "Second Half",
|
|
19
|
-
[LeaveTypeEnum.FULL]: "Full Day",
|
|
20
|
-
};
|
|
21
|
-
function getDropdownLabel(action) {
|
|
22
|
-
if (!Object.values(LeaveTypeEnum).includes(action)) {
|
|
23
|
-
throw new exceptions_1.AppBadRequestException({
|
|
24
|
-
key: error_key_enum_1.ErrorKeyEnum.LEAVE_TYPE,
|
|
25
|
-
message: ["Invalid type value"],
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
const label = typeLabelMap[action];
|
|
29
|
-
if (!label) {
|
|
30
|
-
throw new exceptions_1.AppBadRequestException({
|
|
31
|
-
key: error_key_enum_1.ErrorKeyEnum.LEAVE_TYPE,
|
|
32
|
-
message: ["Invalid type value"],
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
return label;
|
|
36
|
-
}
|
|
37
|
-
LeaveTypeEnum.getDropdownLabel = getDropdownLabel;
|
|
38
|
-
function getLeaveTypeFromStartEnd(from, to) {
|
|
39
|
-
if (!to || from === to)
|
|
40
|
-
return from;
|
|
41
|
-
if (from === LeaveTypeEnum.FULL && to === LeaveTypeEnum.FIRST)
|
|
42
|
-
return LeaveTypeEnum.FULL_FIRST;
|
|
43
|
-
if (from === LeaveTypeEnum.SECOND && to === LeaveTypeEnum.FULL)
|
|
44
|
-
return LeaveTypeEnum.SECOND_FULL;
|
|
45
|
-
if (from === LeaveTypeEnum.SECOND && to === LeaveTypeEnum.FIRST)
|
|
46
|
-
return LeaveTypeEnum.SECOND_FIRST;
|
|
47
|
-
throw new Error(`Invalid leave type: ${from} + ${to}`);
|
|
48
|
-
}
|
|
49
|
-
LeaveTypeEnum.getLeaveTypeFromStartEnd = getLeaveTypeFromStartEnd;
|
|
50
|
-
function getStartEndFromLeaveType(type) {
|
|
51
|
-
switch (type) {
|
|
52
|
-
case LeaveTypeEnum.FIRST:
|
|
53
|
-
return {
|
|
54
|
-
fromType: LeaveTypeEnum.FIRST,
|
|
55
|
-
toType: LeaveTypeEnum.FIRST,
|
|
56
|
-
};
|
|
57
|
-
case LeaveTypeEnum.SECOND:
|
|
58
|
-
return {
|
|
59
|
-
fromType: LeaveTypeEnum.SECOND,
|
|
60
|
-
toType: LeaveTypeEnum.SECOND,
|
|
61
|
-
};
|
|
62
|
-
case LeaveTypeEnum.FULL:
|
|
63
|
-
return {
|
|
64
|
-
fromType: LeaveTypeEnum.FULL,
|
|
65
|
-
toType: LeaveTypeEnum.FULL,
|
|
66
|
-
};
|
|
67
|
-
case LeaveTypeEnum.FULL_FIRST:
|
|
68
|
-
return {
|
|
69
|
-
fromType: LeaveTypeEnum.FULL,
|
|
70
|
-
toType: LeaveTypeEnum.FIRST,
|
|
71
|
-
};
|
|
72
|
-
case LeaveTypeEnum.SECOND_FULL:
|
|
73
|
-
return {
|
|
74
|
-
fromType: LeaveTypeEnum.SECOND,
|
|
75
|
-
toType: LeaveTypeEnum.FULL,
|
|
76
|
-
};
|
|
77
|
-
case LeaveTypeEnum.SECOND_FIRST:
|
|
78
|
-
return {
|
|
79
|
-
fromType: LeaveTypeEnum.SECOND,
|
|
80
|
-
toType: LeaveTypeEnum.FIRST,
|
|
81
|
-
};
|
|
82
|
-
default:
|
|
83
|
-
throw new Error(`Invalid LeaveTypeEnum: ${type}`);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
LeaveTypeEnum.getStartEndFromLeaveType = getStartEndFromLeaveType;
|
|
6
|
+
LeaveTypeEnum["LEISURE"] = "leisure";
|
|
7
|
+
LeaveTypeEnum["ILLNESS"] = "illness";
|
|
8
|
+
LeaveTypeEnum["BEREAVEMENT"] = "bereavement";
|
|
9
|
+
LeaveTypeEnum["SICK"] = "sick";
|
|
10
|
+
LeaveTypeEnum["UNPAID"] = "unpaid";
|
|
11
|
+
LeaveTypeEnum["BIRTHDAY"] = "birthday";
|
|
87
12
|
})(LeaveTypeEnum || (exports.LeaveTypeEnum = LeaveTypeEnum = {}));
|
|
@@ -9,6 +9,7 @@ var UserStatusEnum;
|
|
|
9
9
|
UserStatusEnum["deactive"] = "deactive";
|
|
10
10
|
UserStatusEnum["suspended"] = "suspended";
|
|
11
11
|
UserStatusEnum["pending"] = "pending";
|
|
12
|
+
UserStatusEnum["notice_period"] = "notice_period";
|
|
12
13
|
})(UserStatusEnum || (exports.UserStatusEnum = UserStatusEnum = {}));
|
|
13
14
|
var UserRoleEnum;
|
|
14
15
|
(function (UserRoleEnum) {
|
|
@@ -53,6 +53,8 @@ export * from "./enums/leave.action.enum";
|
|
|
53
53
|
export * from "./enums/leave.status.enum";
|
|
54
54
|
export * from "./interface/leave.entity.interface";
|
|
55
55
|
export * from "./interface/leave_history.entity.interface";
|
|
56
|
+
export * from "./enums/duration-type.enum";
|
|
57
|
+
export * from "./enums/leave-type.enum";
|
|
56
58
|
export * from "./enums/work.from.home.action.enum";
|
|
57
59
|
export * from "./enums/work.from.home.status.enum";
|
|
58
60
|
export * from "./interface/work_from_home.entity.interface";
|
|
@@ -61,9 +63,10 @@ export * from "./interface/country.entity.interface";
|
|
|
61
63
|
export * from "./enums/billing_invoice_type.enum";
|
|
62
64
|
export * from "./interface/billing_timesheet.entity.interface";
|
|
63
65
|
export * from "./interface/intermediary_bank.entity.interface";
|
|
64
|
-
export * from "./enums/leave-type.enum";
|
|
65
66
|
export * from "./interface/holiday-list.entity.interface";
|
|
66
67
|
export * from "./interface/holiday.entity.interface";
|
|
68
|
+
export * from "./model/leave.entity.model";
|
|
69
|
+
export * from "./model/holiday.entity.model";
|
|
67
70
|
export * from "./enums/cron-jobs-name.enum";
|
|
68
71
|
export * from "./enums/cron-jobs-status.enum";
|
|
69
72
|
export * from "./enums/configuration-key.enum";
|
|
@@ -70,6 +70,8 @@ __exportStar(require("./enums/leave.action.enum"), exports);
|
|
|
70
70
|
__exportStar(require("./enums/leave.status.enum"), exports);
|
|
71
71
|
__exportStar(require("./interface/leave.entity.interface"), exports);
|
|
72
72
|
__exportStar(require("./interface/leave_history.entity.interface"), exports);
|
|
73
|
+
__exportStar(require("./enums/duration-type.enum"), exports);
|
|
74
|
+
__exportStar(require("./enums/leave-type.enum"), exports);
|
|
73
75
|
__exportStar(require("./enums/work.from.home.action.enum"), exports);
|
|
74
76
|
__exportStar(require("./enums/work.from.home.status.enum"), exports);
|
|
75
77
|
__exportStar(require("./interface/work_from_home.entity.interface"), exports);
|
|
@@ -78,9 +80,10 @@ __exportStar(require("./interface/country.entity.interface"), exports);
|
|
|
78
80
|
__exportStar(require("./enums/billing_invoice_type.enum"), exports);
|
|
79
81
|
__exportStar(require("./interface/billing_timesheet.entity.interface"), exports);
|
|
80
82
|
__exportStar(require("./interface/intermediary_bank.entity.interface"), exports);
|
|
81
|
-
__exportStar(require("./enums/leave-type.enum"), exports);
|
|
82
83
|
__exportStar(require("./interface/holiday-list.entity.interface"), exports);
|
|
83
84
|
__exportStar(require("./interface/holiday.entity.interface"), exports);
|
|
85
|
+
__exportStar(require("./model/leave.entity.model"), exports);
|
|
86
|
+
__exportStar(require("./model/holiday.entity.model"), exports);
|
|
84
87
|
__exportStar(require("./enums/cron-jobs-name.enum"), exports);
|
|
85
88
|
__exportStar(require("./enums/cron-jobs-status.enum"), exports);
|
|
86
89
|
__exportStar(require("./enums/configuration-key.enum"), exports);
|
|
@@ -21,7 +21,7 @@ import { IHolidayListEntity } from "./holiday-list.entity.interface";
|
|
|
21
21
|
import { IHolidayEntity } from "./holiday.entity.interface";
|
|
22
22
|
import { IIndustryEntity } from "./industry.entity.interface";
|
|
23
23
|
import { IIntermediaryBankEntity } from "./intermediary_bank.entity.interface";
|
|
24
|
-
import { ILeaveEntity } from "./leave.entity.interface";
|
|
24
|
+
import { ILeaveEntity, IUserLeaveVirtualEntity } from "./leave.entity.interface";
|
|
25
25
|
import { IOfficeLocationEntity } from "./office.location.entity";
|
|
26
26
|
import { IOrganizationEntity } from "./organization.entity.interface";
|
|
27
27
|
import { IPermissionEntity } from "./permission.entity.interface";
|
|
@@ -89,23 +89,15 @@ export declare enum EntityEnum {
|
|
|
89
89
|
TO_DO_LIST = "to_do_list"
|
|
90
90
|
}
|
|
91
91
|
export type EntityRelations = {
|
|
92
|
-
[K in EntityEnum]: K;
|
|
92
|
+
[K in EntityEnum | VirtualEntityEnum]: K;
|
|
93
93
|
};
|
|
94
94
|
export type IEntityServiceResponse = {
|
|
95
|
-
[K in EntityEnum]?: IBaseEntityServiceResponse<EntityKeyType<K>>;
|
|
95
|
+
[K in EntityEnum | VirtualEntityEnum]?: IBaseEntityServiceResponse<EntityKeyType<K>>;
|
|
96
96
|
};
|
|
97
97
|
export type IBaseEntityServiceResponse<T> = {
|
|
98
98
|
baseEntities: T[];
|
|
99
99
|
relatedEntities?: IEntityServiceResponse;
|
|
100
|
-
|
|
101
|
-
export type IBaseEntityApiResponseOld<T extends {
|
|
102
|
-
createdOn: Date;
|
|
103
|
-
updatedOn: Date;
|
|
104
|
-
}> = {
|
|
105
|
-
baseEntities: IApiEntity<T>[];
|
|
106
|
-
relatedEntities?: {
|
|
107
|
-
[K in EntityEnum]?: K extends EntityEnum.BILLING ? IBaseEntityApiResponse<IBillingEntity> : K extends EntityEnum.BILLING_TIMESHEET ? IBaseEntityApiResponse<IBillingTimesheetEntity> : K extends EntityEnum.TIMESHEET ? IBaseEntityApiResponse<ITimesheetEntity> : K extends EntityEnum.USER ? IBaseEntityApiResponse<IUserEntity> : K extends EntityEnum.PROJECT ? IBaseEntityApiResponse<IProjectEntity> : K extends EntityEnum.CLIENT ? IBaseEntityApiResponse<IClientEntity> : K extends EntityEnum.TASK ? IBaseEntityApiResponse<ITaskEntity> : K extends EntityEnum.PROJECT_USER_MAPPING ? IBaseEntityApiResponse<IProjectUserMappingEntity> : never;
|
|
108
|
-
};
|
|
100
|
+
virtualEntities?: IEntityServiceResponse;
|
|
109
101
|
};
|
|
110
102
|
export type IBaseEntityApiResponse<T extends {
|
|
111
103
|
createdOn: Date;
|
|
@@ -113,25 +105,25 @@ export type IBaseEntityApiResponse<T extends {
|
|
|
113
105
|
}> = {
|
|
114
106
|
baseEntities: IApiEntity<T>[];
|
|
115
107
|
relatedEntities?: {
|
|
116
|
-
[K in EntityEnum]?: IBaseEntityApiResponse<EnumEntityType<K>>;
|
|
108
|
+
[K in EntityEnum | VirtualEntityEnum]?: IBaseEntityApiResponse<EnumEntityType<K>>;
|
|
117
109
|
};
|
|
118
110
|
};
|
|
119
|
-
export type EnumEntityType<T extends EntityEnum> = (T extends EntityEnum.BILLING ? IBillingEntity : T extends EntityEnum.BILLING_TIMESHEET ? IBillingTimesheetEntity : T extends EntityEnum.TIMESHEET ? ITimesheetEntity : T extends EntityEnum.USER ? IUserEntity : T extends EntityEnum.PROJECT ? IProjectEntity : T extends EntityEnum.CLIENT ? IClientEntity : T extends EntityEnum.LEAVE ? ILeaveEntity : T extends EntityEnum.BANK ? IBankEntity : T extends EntityEnum.BANK_HISTORY ? IBankHistoryEntity : T extends EntityEnum.BILLING_PAYMENT ? IBillingPaymentEntity : T extends EntityEnum.BILLING_TRANSACTION ? IBillingTransactionEntity : T extends EntityEnum.CLIENT_AFFILIATE ? IClientAffiliateEntity : T extends EntityEnum.CONFIGURATION ? IConfigurationEntity : T extends EntityEnum.HOLIDAY ? IHolidayEntity : T extends EntityEnum.HOLIDAY_LIST ? IHolidayListEntity : T extends EntityEnum.COUNTRY ? ICountryEntity : T extends EntityEnum.EXPENSE_TYPE ? IExpenseTypeEntity : T extends EntityEnum.INDUSTRY ? IIndustryEntity : T extends EntityEnum.INTERMEDIARY_BANK ? IIntermediaryBankEntity : T extends EntityEnum.OFFICE_LOCATION ? IOfficeLocationEntity : T extends EntityEnum.PERMISSION ? IPermissionEntity : T extends EntityEnum.ROLE ? IRoleEntity : T extends EntityEnum.TASK ? ITaskEntity : T extends EntityEnum.DESIGNATION ? IDesignationEntity : T extends EntityEnum.RATE ? IRateEntity : T extends EntityEnum.REIMBURSEMENT ? IReimbursementEntity : T extends EntityEnum.REIMBURSEMENT_EXPENSE ? IReimbursementExpenseEntity : T extends EntityEnum.WORK_FROM_HOME ? IWorkFromHomeEntity : T extends EntityEnum.ORGANIZATION ? IOrganizationEntity : T extends EntityEnum.PROJECT_USER_MAPPING ? IProjectUserMappingEntity : T extends EntityEnum.CLIENT_USER_MAPPING ? IClientUserMappingEntity : T extends EntityEnum.TO_DO_LIST ? IToDoListEntity : T extends EntityEnum.CRON_JOBS ? ICronJobsEntity : T extends EntityEnum.ROLE_PERMISSION_MAPPING ? IRolePermissionMappingEntity : never) & {
|
|
111
|
+
export type EnumEntityType<T extends EntityEnum | VirtualEntityEnum> = (T extends EntityEnum.BILLING ? IBillingEntity : T extends EntityEnum.BILLING_TIMESHEET ? IBillingTimesheetEntity : T extends EntityEnum.TIMESHEET ? ITimesheetEntity : T extends EntityEnum.USER ? IUserEntity : T extends EntityEnum.PROJECT ? IProjectEntity : T extends EntityEnum.CLIENT ? IClientEntity : T extends EntityEnum.LEAVE ? ILeaveEntity : T extends EntityEnum.BANK ? IBankEntity : T extends EntityEnum.BANK_HISTORY ? IBankHistoryEntity : T extends EntityEnum.BILLING_PAYMENT ? IBillingPaymentEntity : T extends EntityEnum.BILLING_TRANSACTION ? IBillingTransactionEntity : T extends EntityEnum.CLIENT_AFFILIATE ? IClientAffiliateEntity : T extends EntityEnum.CONFIGURATION ? IConfigurationEntity : T extends EntityEnum.HOLIDAY ? IHolidayEntity : T extends EntityEnum.HOLIDAY_LIST ? IHolidayListEntity : T extends EntityEnum.COUNTRY ? ICountryEntity : T extends EntityEnum.EXPENSE_TYPE ? IExpenseTypeEntity : T extends EntityEnum.INDUSTRY ? IIndustryEntity : T extends EntityEnum.INTERMEDIARY_BANK ? IIntermediaryBankEntity : T extends EntityEnum.OFFICE_LOCATION ? IOfficeLocationEntity : T extends EntityEnum.PERMISSION ? IPermissionEntity : T extends EntityEnum.ROLE ? IRoleEntity : T extends EntityEnum.TASK ? ITaskEntity : T extends EntityEnum.DESIGNATION ? IDesignationEntity : T extends EntityEnum.RATE ? IRateEntity : T extends EntityEnum.REIMBURSEMENT ? IReimbursementEntity : T extends EntityEnum.REIMBURSEMENT_EXPENSE ? IReimbursementExpenseEntity : T extends EntityEnum.WORK_FROM_HOME ? IWorkFromHomeEntity : T extends EntityEnum.ORGANIZATION ? IOrganizationEntity : T extends EntityEnum.PROJECT_USER_MAPPING ? IProjectUserMappingEntity : T extends EntityEnum.CLIENT_USER_MAPPING ? IClientUserMappingEntity : T extends EntityEnum.TO_DO_LIST ? IToDoListEntity : T extends EntityEnum.CRON_JOBS ? ICronJobsEntity : T extends EntityEnum.ROLE_PERMISSION_MAPPING ? IRolePermissionMappingEntity : T extends VirtualEntityEnum.USER_LEAVE ? IUserLeaveVirtualEntity : never) & {
|
|
120
112
|
id: number;
|
|
121
113
|
};
|
|
122
|
-
export type EntityRelationConfig<T extends EntityEnum> = {
|
|
123
|
-
[K in EntityEnum]?: {
|
|
114
|
+
export type EntityRelationConfig<T extends EntityEnum | VirtualEntityEnum> = {
|
|
115
|
+
[K in EntityEnum | VirtualEntityEnum]?: {
|
|
124
116
|
mappingProperties: EntityKeyType<T>[];
|
|
125
117
|
searchProperty: EntityKeyType<K>;
|
|
126
118
|
projectProperties?: EntityKeyType<K>[];
|
|
127
119
|
};
|
|
128
120
|
};
|
|
129
|
-
export type EntityKeyType<K extends EntityEnum> = keyof EnumEntityType<K>;
|
|
121
|
+
export type EntityKeyType<K extends EntityEnum | VirtualEntityEnum> = keyof EnumEntityType<K>;
|
|
130
122
|
export type IEntityApiResponse<T extends {
|
|
131
123
|
createdOn: Date;
|
|
132
124
|
updatedOn: Date;
|
|
133
125
|
}> = IApiEntity<T>;
|
|
134
|
-
export type IEntityFilterData<T extends EnumEntityType<EntityEnum>> = ConvertToArray<IEntityUpdateDto<T>> & {
|
|
126
|
+
export type IEntityFilterData<T extends EnumEntityType<EntityEnum | VirtualEntityEnum>> = ConvertToArray<IEntityUpdateDto<T>> & {
|
|
135
127
|
id?: number[];
|
|
136
128
|
range?: {
|
|
137
129
|
[key in keyof T]?: [T[key], T[key]];
|
|
@@ -148,11 +140,18 @@ export type IEntityFilterData<T extends EnumEntityType<EntityEnum>> = ConvertToA
|
|
|
148
140
|
lessThan?: {
|
|
149
141
|
[key in keyof T]?: T[key];
|
|
150
142
|
};
|
|
143
|
+
ge?: {
|
|
144
|
+
[key in keyof T]?: T[key];
|
|
145
|
+
};
|
|
146
|
+
le?: {
|
|
147
|
+
[key in keyof T]?: T[key];
|
|
148
|
+
};
|
|
151
149
|
relations?: ISearchIncludeEntity<EntityEnum>[];
|
|
152
150
|
entities?: ISearchIncludeEntity<EntityEnum>[];
|
|
153
151
|
columnKeys?: (keyof T)[];
|
|
152
|
+
virtualRelations?: ISearchIncludeEntity<VirtualEntityEnum>[];
|
|
154
153
|
};
|
|
155
|
-
export type ISearchIncludeEntity<T extends EntityEnum> = {
|
|
154
|
+
export type ISearchIncludeEntity<T extends EntityEnum | VirtualEntityEnum> = {
|
|
156
155
|
name: T;
|
|
157
156
|
relations?: ISearchIncludeEntity<EntityRelations[EntityEnum]>[];
|
|
158
157
|
entities?: ISearchIncludeEntity<EntityRelations[EntityEnum]>[];
|
|
@@ -168,6 +167,13 @@ export type ISearchIncludeEntity<T extends EntityEnum> = {
|
|
|
168
167
|
EnumEntityType<T>[key]
|
|
169
168
|
];
|
|
170
169
|
};
|
|
170
|
+
ge?: {
|
|
171
|
+
[key in keyof EnumEntityType<T>]?: EnumEntityType<T>[key];
|
|
172
|
+
};
|
|
173
|
+
le?: {
|
|
174
|
+
[key in keyof EnumEntityType<T>]?: EnumEntityType<T>[key];
|
|
175
|
+
};
|
|
176
|
+
virtualRelations?: ISearchIncludeEntity<EntityRelations[VirtualEntityEnum]>[];
|
|
171
177
|
};
|
|
172
178
|
export type IEntityHistoryParsed = {
|
|
173
179
|
parsedData: any;
|
|
@@ -203,5 +209,8 @@ export type IHistoryEntityChangedLogs<T> = {
|
|
|
203
209
|
oldValue: string | number;
|
|
204
210
|
timeStamp: string;
|
|
205
211
|
};
|
|
212
|
+
export declare enum VirtualEntityEnum {
|
|
213
|
+
USER_LEAVE = "user_leave"
|
|
214
|
+
}
|
|
206
215
|
export type IHistoryConstraintSearchResponse<T> = IBaseResponse<IHistoryEntitySearchByConstraintResponse<T>[]>;
|
|
207
216
|
export type IHistoryConstraintSearchServiceResponse<T> = IHistoryEntitySearchByConstraintResponse<T>[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EntityEnum = void 0;
|
|
3
|
+
exports.VirtualEntityEnum = exports.EntityEnum = void 0;
|
|
4
4
|
var EntityEnum;
|
|
5
5
|
(function (EntityEnum) {
|
|
6
6
|
EntityEnum["BILLING"] = "billing";
|
|
@@ -45,3 +45,7 @@ var EntityEnum;
|
|
|
45
45
|
EntityEnum["CRON_JOBS"] = "cron_jobs";
|
|
46
46
|
EntityEnum["TO_DO_LIST"] = "to_do_list";
|
|
47
47
|
})(EntityEnum || (exports.EntityEnum = EntityEnum = {}));
|
|
48
|
+
var VirtualEntityEnum;
|
|
49
|
+
(function (VirtualEntityEnum) {
|
|
50
|
+
VirtualEntityEnum["USER_LEAVE"] = "user_leave";
|
|
51
|
+
})(VirtualEntityEnum || (exports.VirtualEntityEnum = VirtualEntityEnum = {}));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DurationTypeEnum } from "../enums/duration-type.enum";
|
|
1
2
|
import { LeaveTypeEnum } from "../enums/leave-type.enum";
|
|
2
3
|
import { LeaveStatusEnum } from "../enums/leave.status.enum";
|
|
3
4
|
import { IAuditColumnEntity } from "./audit-column.entity.interface";
|
|
@@ -9,14 +10,15 @@ export interface ILeaveEntity extends IAuditColumnEntity {
|
|
|
9
10
|
fromDate: string;
|
|
10
11
|
toDate: string;
|
|
11
12
|
reason: string;
|
|
12
|
-
|
|
13
|
+
durationType: DurationTypeEnum;
|
|
13
14
|
status: LeaveStatusEnum;
|
|
14
15
|
remark?: string;
|
|
16
|
+
type: LeaveTypeEnum;
|
|
15
17
|
}
|
|
16
18
|
export type ILeaveEntityFilterData = IEntityFilterData<ILeaveEntity>;
|
|
17
19
|
export interface ILeaveDtoInclude {
|
|
18
|
-
fromType:
|
|
19
|
-
toType?:
|
|
20
|
+
fromType: DurationTypeEnum;
|
|
21
|
+
toType?: DurationTypeEnum;
|
|
20
22
|
}
|
|
21
23
|
export interface ILeaveEntityCreateDtoValidationData {
|
|
22
24
|
userEntity: IUserEntity;
|
|
@@ -24,3 +26,15 @@ export interface ILeaveEntityCreateDtoValidationData {
|
|
|
24
26
|
export interface ILeaveEntityUpdateDtoValidationData extends ILeaveEntityCreateDtoValidationData {
|
|
25
27
|
leaveEntity: ILeaveEntity;
|
|
26
28
|
}
|
|
29
|
+
export interface ILeaveVirtualEntityColumnKeys {
|
|
30
|
+
totalLeavesTaken: number;
|
|
31
|
+
totalLeavesPending: number;
|
|
32
|
+
}
|
|
33
|
+
export interface IUserLeaveVirtualEntity extends IAuditColumnEntity {
|
|
34
|
+
userId: number;
|
|
35
|
+
leavesTaken: number;
|
|
36
|
+
leavesPending: number;
|
|
37
|
+
period: string;
|
|
38
|
+
type: LeaveTypeEnum;
|
|
39
|
+
id: number;
|
|
40
|
+
}
|
|
@@ -12,3 +12,6 @@ export interface IWorkFromHomeEntity extends IAuditColumnEntity {
|
|
|
12
12
|
}
|
|
13
13
|
export interface IWorkFromHomeEntityFilterDto extends IEntityFilterData<IWorkFromHomeEntity> {
|
|
14
14
|
}
|
|
15
|
+
export interface IWorkFromHomeUpdateDtoValidationResult {
|
|
16
|
+
workFromHome: IWorkFromHomeEntity;
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DateCodeModel } from "../../utils";
|
|
2
|
+
import { IAuditColumnEntity } from "../interface/audit-column.entity.interface";
|
|
3
|
+
import { IHolidayEntity } from "../interface/holiday.entity.interface";
|
|
4
|
+
export declare class BaseEntityModel<T extends IAuditColumnEntity> {
|
|
5
|
+
createdOn: Date;
|
|
6
|
+
updatedOn: Date;
|
|
7
|
+
createdBy: number;
|
|
8
|
+
updatedBy: number;
|
|
9
|
+
constructor(data: T);
|
|
10
|
+
}
|
|
11
|
+
export declare class HolidayEntityModel extends BaseEntityModel<IHolidayEntity> implements IHolidayEntity {
|
|
12
|
+
id: number;
|
|
13
|
+
holidayListId: number;
|
|
14
|
+
dateCode: string;
|
|
15
|
+
private constructor();
|
|
16
|
+
getDateCodeModel(): DateCodeModel;
|
|
17
|
+
static fromEntity(data: IHolidayEntity): HolidayEntityModel;
|
|
18
|
+
static getDateCodeModelFromDate(models: HolidayEntityModel[]): DateCodeModel[];
|
|
19
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HolidayEntityModel = exports.BaseEntityModel = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
class BaseEntityModel {
|
|
6
|
+
constructor(data) {
|
|
7
|
+
this.createdOn = data.createdOn;
|
|
8
|
+
this.updatedOn = data.updatedOn;
|
|
9
|
+
this.createdBy = data.createdBy;
|
|
10
|
+
this.updatedBy = data.updatedBy;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.BaseEntityModel = BaseEntityModel;
|
|
14
|
+
class HolidayEntityModel extends BaseEntityModel {
|
|
15
|
+
constructor(data) {
|
|
16
|
+
super(data);
|
|
17
|
+
this.id = data.id;
|
|
18
|
+
this.holidayListId = data.holidayListId;
|
|
19
|
+
this.dateCode = data.dateCode;
|
|
20
|
+
}
|
|
21
|
+
getDateCodeModel() {
|
|
22
|
+
return new utils_1.DateCodeModel(this.dateCode);
|
|
23
|
+
}
|
|
24
|
+
static fromEntity(data) {
|
|
25
|
+
return new HolidayEntityModel(data);
|
|
26
|
+
}
|
|
27
|
+
static getDateCodeModelFromDate(models) {
|
|
28
|
+
return models.map((model) => model.getDateCodeModel());
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.HolidayEntityModel = HolidayEntityModel;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DateCodeModel, Weekday } from "../../utils";
|
|
2
|
+
import { DurationTypeEnum } from "../enums/duration-type.enum";
|
|
3
|
+
import { LeaveTypeEnum } from "../enums/leave-type.enum";
|
|
4
|
+
import { LeaveStatusEnum } from "../enums/leave.status.enum";
|
|
5
|
+
import { ILeaveEntity } from "../interface/leave.entity.interface";
|
|
6
|
+
export declare class LeaveEntityModel implements ILeaveEntity {
|
|
7
|
+
id: number;
|
|
8
|
+
employeeId: number;
|
|
9
|
+
fromDate: string;
|
|
10
|
+
toDate: string;
|
|
11
|
+
reason: string;
|
|
12
|
+
durationType: DurationTypeEnum;
|
|
13
|
+
status: LeaveStatusEnum;
|
|
14
|
+
remark?: string;
|
|
15
|
+
type: LeaveTypeEnum;
|
|
16
|
+
createdOn: Date;
|
|
17
|
+
updatedOn: Date;
|
|
18
|
+
createdBy: number;
|
|
19
|
+
updatedBy: number;
|
|
20
|
+
private constructor();
|
|
21
|
+
static fromEntity(data: ILeaveEntity): LeaveEntityModel;
|
|
22
|
+
getLeaveDuration(excludeWeekdays?: Weekday[], excludeDates?: DateCodeModel[]): number;
|
|
23
|
+
static getLeaveDuration(leaves: LeaveEntityModel[], excludeWeekdays?: Weekday[], excludeDates?: DateCodeModel[], leaveStatusEnum?: LeaveStatusEnum[]): number;
|
|
24
|
+
getDateCodeModels(dateCodeIncludePredicates?: ((dateModel: DateCodeModel) => boolean)[], dateCodeExcludePredicates?: ((dateModel: DateCodeModel) => boolean)[]): DateCodeModel[];
|
|
25
|
+
static getLeaveApprovePredicate(): (leave: LeaveEntityModel) => boolean;
|
|
26
|
+
static getLeavePendingPredicate(): (leave: LeaveEntityModel) => boolean;
|
|
27
|
+
static getLeavesByPredicates(leaves: LeaveEntityModel[], includePredicates?: ((leave: LeaveEntityModel) => boolean)[], excludePredicates?: ((leave: LeaveEntityModel) => boolean)[]): LeaveEntityModel[];
|
|
28
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LeaveEntityModel = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const leave_status_enum_1 = require("../enums/leave.status.enum");
|
|
6
|
+
class LeaveEntityModel {
|
|
7
|
+
constructor(data) {
|
|
8
|
+
this.id = data.id;
|
|
9
|
+
this.employeeId = data.employeeId;
|
|
10
|
+
this.fromDate = data.fromDate;
|
|
11
|
+
this.toDate = data.toDate;
|
|
12
|
+
this.reason = data.reason;
|
|
13
|
+
this.durationType = data.durationType;
|
|
14
|
+
this.status = data.status;
|
|
15
|
+
this.remark = data.remark;
|
|
16
|
+
this.type = data.type;
|
|
17
|
+
this.createdOn = data.createdOn;
|
|
18
|
+
this.updatedOn = data.updatedOn;
|
|
19
|
+
this.createdBy = data.createdBy;
|
|
20
|
+
this.updatedBy = data.updatedBy;
|
|
21
|
+
}
|
|
22
|
+
static fromEntity(data) {
|
|
23
|
+
return new LeaveEntityModel(data);
|
|
24
|
+
}
|
|
25
|
+
getLeaveDuration(excludeWeekdays = [], excludeDates = []) {
|
|
26
|
+
const fromDate = new utils_1.DateCodeModel(this.fromDate);
|
|
27
|
+
const toDate = new utils_1.DateCodeModel(this.toDate);
|
|
28
|
+
return fromDate.diffInDays(toDate, excludeWeekdays, excludeDates);
|
|
29
|
+
}
|
|
30
|
+
// getLeaveDurationByPredicates(predicates: ((leave: LeaveEntityModel) => boolean)[]): number {
|
|
31
|
+
// const fromDate = new DateCodeModel(this.fromDate);
|
|
32
|
+
// const toDate = new DateCodeModel(this.toDate);
|
|
33
|
+
// return fromDate.diffInDaysByPredicates(toDate, predicates);
|
|
34
|
+
// }
|
|
35
|
+
static getLeaveDuration(leaves, excludeWeekdays = [], excludeDates = [], leaveStatusEnum = []) {
|
|
36
|
+
const considerLeaveStatus = leaveStatusEnum.length > 0;
|
|
37
|
+
return leaves
|
|
38
|
+
.filter((leave) => !considerLeaveStatus || leaveStatusEnum.includes(leave.status))
|
|
39
|
+
.reduce((total, leave) => {
|
|
40
|
+
return total + leave.getLeaveDuration(excludeWeekdays, excludeDates);
|
|
41
|
+
}, 0);
|
|
42
|
+
}
|
|
43
|
+
getDateCodeModels(dateCodeIncludePredicates = [], dateCodeExcludePredicates = []) {
|
|
44
|
+
const dateCodes = new utils_1.DateCodeModel(this.fromDate).getRange(new utils_1.DateCodeModel(this.toDate));
|
|
45
|
+
return utils_1.DateCodeModel.getByPredicates(dateCodes, dateCodeIncludePredicates, dateCodeExcludePredicates);
|
|
46
|
+
}
|
|
47
|
+
static getLeaveApprovePredicate() {
|
|
48
|
+
return (leave) => leave.status === leave_status_enum_1.LeaveStatusEnum.APPROVED;
|
|
49
|
+
}
|
|
50
|
+
static getLeavePendingPredicate() {
|
|
51
|
+
return (leave) => [
|
|
52
|
+
leave_status_enum_1.LeaveStatusEnum.DELETE_APPROVAL,
|
|
53
|
+
leave_status_enum_1.LeaveStatusEnum.EDIT_APPROVAL,
|
|
54
|
+
leave_status_enum_1.LeaveStatusEnum.PENDING_APPROVAL,
|
|
55
|
+
].includes(leave.status);
|
|
56
|
+
}
|
|
57
|
+
static getLeavesByPredicates(leaves, includePredicates = [], excludePredicates = []) {
|
|
58
|
+
return leaves.filter((leave) => includePredicates.every((predicate) => predicate(leave)) &&
|
|
59
|
+
excludePredicates.every((predicate) => !predicate(leave)));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.LeaveEntityModel = LeaveEntityModel;
|
|
@@ -78,21 +78,24 @@ function getChangedProperties(source, target) {
|
|
|
78
78
|
return result;
|
|
79
79
|
}
|
|
80
80
|
function compareObjects(obj1, obj2) {
|
|
81
|
-
if (
|
|
82
|
-
return
|
|
83
|
-
|
|
81
|
+
if (obj1 === obj2)
|
|
82
|
+
return true;
|
|
83
|
+
if (!obj1 || !obj2)
|
|
84
|
+
return false;
|
|
84
85
|
const keys1 = Object.keys(obj1);
|
|
85
86
|
const keys2 = Object.keys(obj2);
|
|
86
|
-
if (keys1.length !== keys2.length)
|
|
87
|
+
if (keys1.length !== keys2.length)
|
|
87
88
|
return false;
|
|
88
|
-
}
|
|
89
89
|
return keys1.every((key) => {
|
|
90
90
|
const val1 = obj1[key];
|
|
91
91
|
const val2 = obj2[key];
|
|
92
|
-
if (typeof val1 === "object" &&
|
|
92
|
+
if (typeof val1 === "object" &&
|
|
93
|
+
val1 !== null &&
|
|
94
|
+
typeof val2 === "object" &&
|
|
95
|
+
val2 !== null) {
|
|
93
96
|
return compareObjects(val1, val2);
|
|
94
97
|
}
|
|
95
|
-
return val1 === val2;
|
|
98
|
+
return (val1 !== null && val1 !== void 0 ? val1 : null) === (val2 !== null && val2 !== void 0 ? val2 : null);
|
|
96
99
|
});
|
|
97
100
|
}
|
|
98
101
|
/**
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
export declare enum Weekday {
|
|
2
|
+
Sunday = 0,
|
|
3
|
+
Monday = 1,
|
|
4
|
+
Tuesday = 2,
|
|
5
|
+
Wednesday = 3,
|
|
6
|
+
Thursday = 4,
|
|
7
|
+
Friday = 5,
|
|
8
|
+
Saturday = 6
|
|
9
|
+
}
|
|
1
10
|
export declare class DateCodeModel {
|
|
2
11
|
dateCode: string;
|
|
3
12
|
constructor(dateCode: string);
|
|
@@ -14,5 +23,15 @@ export declare class DateCodeModel {
|
|
|
14
23
|
startDate: DateCodeModel;
|
|
15
24
|
endDate: DateCodeModel;
|
|
16
25
|
};
|
|
26
|
+
getRange(dateCodeModel: DateCodeModel): DateCodeModel[];
|
|
27
|
+
static diffInDays(startModel: DateCodeModel, endModel: DateCodeModel, excludeDays?: Weekday[], excludeDateCodes?: DateCodeModel[]): number;
|
|
28
|
+
static getByPredicates(models: DateCodeModel[], includePredicates: ((dateModel: DateCodeModel) => boolean)[], excludePredicates: ((dateModel: DateCodeModel) => boolean)[]): DateCodeModel[];
|
|
29
|
+
static getWeekdaysPredicate(weekdays: Weekday[]): (dateModel: DateCodeModel) => boolean;
|
|
30
|
+
static getDateCodesPredicate(dateCodes: DateCodeModel[]): (dateModel: DateCodeModel) => boolean;
|
|
31
|
+
diffInDays(endModel: DateCodeModel, excludeDays?: Weekday[], excludeDateCodes?: DateCodeModel[]): number;
|
|
32
|
+
static calculateNumberOfDays(startDateCode: string, endDateCode: string): number;
|
|
33
|
+
isDayPresent(days: Weekday[]): boolean;
|
|
34
|
+
isSame(dateCodeModel: DateCodeModel): boolean;
|
|
35
|
+
getWeekday(): Weekday;
|
|
17
36
|
getDateInIST(): Date;
|
|
18
37
|
}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DateCodeModel = void 0;
|
|
3
|
+
exports.DateCodeModel = exports.Weekday = void 0;
|
|
4
4
|
const date_fns_1 = require("date-fns");
|
|
5
|
+
var Weekday;
|
|
6
|
+
(function (Weekday) {
|
|
7
|
+
Weekday[Weekday["Sunday"] = 0] = "Sunday";
|
|
8
|
+
Weekday[Weekday["Monday"] = 1] = "Monday";
|
|
9
|
+
Weekday[Weekday["Tuesday"] = 2] = "Tuesday";
|
|
10
|
+
Weekday[Weekday["Wednesday"] = 3] = "Wednesday";
|
|
11
|
+
Weekday[Weekday["Thursday"] = 4] = "Thursday";
|
|
12
|
+
Weekday[Weekday["Friday"] = 5] = "Friday";
|
|
13
|
+
Weekday[Weekday["Saturday"] = 6] = "Saturday";
|
|
14
|
+
})(Weekday || (exports.Weekday = Weekday = {}));
|
|
5
15
|
class DateCodeModel {
|
|
6
16
|
constructor(dateCode) {
|
|
7
17
|
if (dateCode.length === 6) {
|
|
@@ -74,6 +84,119 @@ class DateCodeModel {
|
|
|
74
84
|
endDate: new DateCodeModel(DateCodeModel.fromDate(end)),
|
|
75
85
|
};
|
|
76
86
|
}
|
|
87
|
+
getRange(dateCodeModel) {
|
|
88
|
+
const startDate = this.getDate();
|
|
89
|
+
const endDate = dateCodeModel.getDate();
|
|
90
|
+
if (startDate > endDate) {
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
return DateCodeModel.getRange(new DateCodeModel(DateCodeModel.fromDate(startDate)), new DateCodeModel(DateCodeModel.fromDate(endDate)));
|
|
94
|
+
}
|
|
95
|
+
static diffInDays(startModel, endModel, excludeDays = [], excludeDateCodes = []) {
|
|
96
|
+
if (!startModel.isValid() || !endModel.isValid()) {
|
|
97
|
+
return 0;
|
|
98
|
+
}
|
|
99
|
+
const dateRange = startModel.getRange(endModel);
|
|
100
|
+
const excludeDayPredicates = (dateModel) => !dateModel.isDayPresent(excludeDays);
|
|
101
|
+
const excludeDatePredicates = (dateModel) => !excludeDateCodes.some(d => d.isSame(dateModel));
|
|
102
|
+
return dateRange.filter((dateModel => excludeDayPredicates(dateModel) && excludeDatePredicates(dateModel))).length;
|
|
103
|
+
}
|
|
104
|
+
static getByPredicates(models, includePredicates, excludePredicates) {
|
|
105
|
+
return models.filter((model) => includePredicates.every((predicate) => predicate(model)) &&
|
|
106
|
+
excludePredicates.every((predicate) => !predicate(model)));
|
|
107
|
+
}
|
|
108
|
+
static getWeekdaysPredicate(weekdays) {
|
|
109
|
+
return (dateModel) => {
|
|
110
|
+
const weekday = dateModel.getWeekday();
|
|
111
|
+
return weekdays.includes(weekday);
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
static getDateCodesPredicate(dateCodes) {
|
|
115
|
+
return (dateModel) => {
|
|
116
|
+
return dateCodes.some((d) => d.isSame(dateModel));
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
// static diffInDaysByPredicates(
|
|
120
|
+
// startModel: DateCodeModel,
|
|
121
|
+
// endModel: DateCodeModel,
|
|
122
|
+
// excludePredicates: ((dateModel: DateCodeModel) => boolean)[] = [],
|
|
123
|
+
// ): number {
|
|
124
|
+
// if (!startModel.isValid() || !endModel.isValid()) {
|
|
125
|
+
// return 0;
|
|
126
|
+
// }
|
|
127
|
+
// const dateRange = startModel.getRange(endModel);
|
|
128
|
+
// const excludeDayPredicates = (dateModel: DateCodeModel) => excludePredicates.every(predicate => predicate(dateModel));
|
|
129
|
+
// return dateRange.filter((dateModel => excludeDayPredicates(dateModel))).length;
|
|
130
|
+
// }
|
|
131
|
+
diffInDays(endModel, excludeDays = [], excludeDateCodes = []) {
|
|
132
|
+
if (!this.isValid() || !endModel.isValid()) {
|
|
133
|
+
return 0;
|
|
134
|
+
}
|
|
135
|
+
return DateCodeModel.diffInDays(this, endModel, excludeDays, excludeDateCodes);
|
|
136
|
+
}
|
|
137
|
+
// diffInDaysByPredicates(
|
|
138
|
+
// endModel: DateCodeModel,
|
|
139
|
+
// excludePredicates: ((dateModel: DateCodeModel) => boolean)[] = []
|
|
140
|
+
// ): number {
|
|
141
|
+
// if (!this.isValid() || !endModel.isValid()) {
|
|
142
|
+
// return 0;
|
|
143
|
+
// }
|
|
144
|
+
// return DateCodeModel.diffInDaysByPredicates(
|
|
145
|
+
// this,
|
|
146
|
+
// endModel,
|
|
147
|
+
// excludePredicates
|
|
148
|
+
// );
|
|
149
|
+
// }
|
|
150
|
+
static calculateNumberOfDays(startDateCode, endDateCode) {
|
|
151
|
+
const startModel = new DateCodeModel(startDateCode);
|
|
152
|
+
const endModel = new DateCodeModel(endDateCode);
|
|
153
|
+
if (!startModel.isValid() || !endModel.isValid()) {
|
|
154
|
+
return 0;
|
|
155
|
+
}
|
|
156
|
+
const fromDate = startModel.getDate();
|
|
157
|
+
const toDate = endModel.getDate();
|
|
158
|
+
if (fromDate > toDate) {
|
|
159
|
+
return 0;
|
|
160
|
+
}
|
|
161
|
+
let count = 0;
|
|
162
|
+
const currentDate = new Date(fromDate);
|
|
163
|
+
while (currentDate <= toDate) {
|
|
164
|
+
const day = currentDate.getDay(); // 0 = Sunday, 6 = Saturday
|
|
165
|
+
if (day !== 0 && day !== 6) {
|
|
166
|
+
count++;
|
|
167
|
+
}
|
|
168
|
+
currentDate.setDate(currentDate.getDate() + 1);
|
|
169
|
+
}
|
|
170
|
+
return count;
|
|
171
|
+
}
|
|
172
|
+
isDayPresent(days) {
|
|
173
|
+
const weekday = this.getWeekday();
|
|
174
|
+
return days.includes(weekday);
|
|
175
|
+
}
|
|
176
|
+
isSame(dateCodeModel) {
|
|
177
|
+
return this.dateCode === dateCodeModel.dateCode;
|
|
178
|
+
}
|
|
179
|
+
getWeekday() {
|
|
180
|
+
const week = this.getDate().getDay();
|
|
181
|
+
switch (week) {
|
|
182
|
+
case 0:
|
|
183
|
+
return Weekday.Sunday;
|
|
184
|
+
case 1:
|
|
185
|
+
return Weekday.Monday;
|
|
186
|
+
case 2:
|
|
187
|
+
return Weekday.Tuesday;
|
|
188
|
+
case 3:
|
|
189
|
+
return Weekday.Wednesday;
|
|
190
|
+
case 4:
|
|
191
|
+
return Weekday.Thursday;
|
|
192
|
+
case 5:
|
|
193
|
+
return Weekday.Friday;
|
|
194
|
+
case 6:
|
|
195
|
+
return Weekday.Saturday;
|
|
196
|
+
default:
|
|
197
|
+
throw new Error(`Invalid weekday value '${week}' in DateCodeModel.getWeekday() method`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
77
200
|
getDateInIST() {
|
|
78
201
|
// convert bill date (utc midnight) to ist midnight
|
|
79
202
|
const baseDateUTC = this.getDate();
|
|
@@ -26,4 +26,34 @@ describe("Test DateCodeModel class", () => {
|
|
|
26
26
|
const offsetDateCode = dateCode.getByOffset(0);
|
|
27
27
|
expect(offsetDateCode.dateCode).toBe(dateCode.dateCode);
|
|
28
28
|
});
|
|
29
|
+
it("Check diffInDays method", () => {
|
|
30
|
+
const startModel = new utils_1.DateCodeModel("20250701");
|
|
31
|
+
const endModel = new utils_1.DateCodeModel("20250712");
|
|
32
|
+
const diffDays = utils_1.DateCodeModel.diffInDays(startModel, endModel, [], []);
|
|
33
|
+
expect(diffDays).toBe(12);
|
|
34
|
+
});
|
|
35
|
+
it("Check diffInDays method", () => {
|
|
36
|
+
const startModel = new utils_1.DateCodeModel("20250701");
|
|
37
|
+
const endModel = new utils_1.DateCodeModel("20250712");
|
|
38
|
+
const diffDays = utils_1.DateCodeModel.diffInDays(startModel, endModel, [utils_1.Weekday.Saturday, utils_1.Weekday.Sunday], []);
|
|
39
|
+
expect(diffDays).toBe(9);
|
|
40
|
+
});
|
|
41
|
+
it("Check diffInDays method", () => {
|
|
42
|
+
const startModel = new utils_1.DateCodeModel("20250701");
|
|
43
|
+
const endModel = new utils_1.DateCodeModel("20250712");
|
|
44
|
+
const diffDays = utils_1.DateCodeModel.diffInDays(startModel, endModel, [], [new utils_1.DateCodeModel("20250705"), new utils_1.DateCodeModel("20250702"), new utils_1.DateCodeModel("20250711"), new utils_1.DateCodeModel("20250701")]);
|
|
45
|
+
expect(diffDays).toBe(8);
|
|
46
|
+
});
|
|
47
|
+
it("Check diffInDays method", () => {
|
|
48
|
+
const startModel = new utils_1.DateCodeModel("20250701");
|
|
49
|
+
const endModel = new utils_1.DateCodeModel("20250712");
|
|
50
|
+
const diffDays = utils_1.DateCodeModel.diffInDays(startModel, endModel, [utils_1.Weekday.Saturday, utils_1.Weekday.Sunday], [new utils_1.DateCodeModel("20250705"), new utils_1.DateCodeModel("20250702"), new utils_1.DateCodeModel("20250711"), new utils_1.DateCodeModel("20250701")]);
|
|
51
|
+
expect(diffDays).toBe(6);
|
|
52
|
+
});
|
|
53
|
+
it("Check diffInDays method", () => {
|
|
54
|
+
const startModel = new utils_1.DateCodeModel("20250701");
|
|
55
|
+
const endModel = new utils_1.DateCodeModel("20250712");
|
|
56
|
+
const diffDays = utils_1.DateCodeModel.diffInDays(startModel, endModel, [utils_1.Weekday.Saturday, utils_1.Weekday.Sunday], [new utils_1.DateCodeModel("20250705"), new utils_1.DateCodeModel("20250702"), new utils_1.DateCodeModel("20250711"), new utils_1.DateCodeModel("20250712")]);
|
|
57
|
+
expect(diffDays).toBe(7);
|
|
58
|
+
});
|
|
29
59
|
});
|