law-common 10.18.1-beta.9 → 10.18.2-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/entities/index.d.ts +1 -0
- package/dist/src/entities/index.js +1 -0
- package/dist/src/entities/interface/entity.utils.interface.d.ts +6 -3
- package/dist/src/entities/model/base.entity.model.d.ts +2 -2
- package/dist/src/entities/model/billing.entity.model.js +1 -1
- package/dist/src/entities/model/entity.model.interface.d.ts +2 -2
- package/dist/src/entities/model/entity.model.interface.js +7 -0
- package/dist/src/entities/model/holiday.entity.model.d.ts +14 -1
- package/dist/src/entities/model/holiday.entity.model.js +25 -42
- package/dist/src/entities/model/leave.entity.model.d.ts +46 -2
- package/dist/src/entities/model/leave.entity.model.js +139 -6
- package/dist/src/entities/model/leave_count.entity.model.d.ts +19 -0
- package/dist/src/entities/model/leave_count.entity.model.js +60 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.js +1 -0
- package/dist/src/utils/string.util.d.ts +1 -0
- package/dist/src/utils/string.util.js +14 -0
- package/package.json +1 -1
|
@@ -66,6 +66,7 @@ export * from "./interface/intermediary_bank.entity.interface";
|
|
|
66
66
|
export * from "./interface/holiday-list.entity.interface";
|
|
67
67
|
export * from "./interface/holiday.entity.interface";
|
|
68
68
|
export * from "./model/leave.entity.model";
|
|
69
|
+
export * from "./model/leave_count.entity.model";
|
|
69
70
|
export * from "./model/holiday.entity.model";
|
|
70
71
|
export * from "./enums/cron-jobs-name.enum";
|
|
71
72
|
export * from "./enums/cron-jobs-status.enum";
|
|
@@ -83,6 +83,7 @@ __exportStar(require("./interface/intermediary_bank.entity.interface"), exports)
|
|
|
83
83
|
__exportStar(require("./interface/holiday-list.entity.interface"), exports);
|
|
84
84
|
__exportStar(require("./interface/holiday.entity.interface"), exports);
|
|
85
85
|
__exportStar(require("./model/leave.entity.model"), exports);
|
|
86
|
+
__exportStar(require("./model/leave_count.entity.model"), exports);
|
|
86
87
|
__exportStar(require("./model/holiday.entity.model"), exports);
|
|
87
88
|
__exportStar(require("./enums/cron-jobs-name.enum"), exports);
|
|
88
89
|
__exportStar(require("./enums/cron-jobs-status.enum"), exports);
|
|
@@ -6,6 +6,9 @@ import { HistoryOperationEnum } from "../enums/history_operation.enum";
|
|
|
6
6
|
import { BillingReimbursementExpneseEntityModel } from "../model/billing-reimbursement-expense.entity.model";
|
|
7
7
|
import { BillingEntityModel } from "../model/billing.entity.model";
|
|
8
8
|
import { ClientEntityModel } from "../model/client.entity.model";
|
|
9
|
+
import { HolidayEntityModel } from "../model/holiday.entity.model";
|
|
10
|
+
import { LeaveEntityModel } from "../model/leave.entity.model";
|
|
11
|
+
import { LeaveCountVirtualEntityModel } from "../model/leave_count.entity.model";
|
|
9
12
|
import { ProjectUserMappingEntityModel } from "../model/project-user-mapping.entity.model";
|
|
10
13
|
import { ProjectEntityModel } from "../model/project.entity.model";
|
|
11
14
|
import { ReimbursementExpenseEntityModel } from "../model/reimbursement-expense.entity.model";
|
|
@@ -275,12 +278,12 @@ export declare enum VirtualEntityEnum {
|
|
|
275
278
|
}
|
|
276
279
|
export type IHistoryConstraintSearchResponse<T> = IBaseResponse<IHistoryEntitySearchByConstraintResponse<T>[]>;
|
|
277
280
|
export type IHistoryConstraintSearchServiceResponse<T> = IHistoryEntitySearchByConstraintResponse<T>[];
|
|
278
|
-
export type EnumToModel<T extends EntityEnum | VirtualEntityEnum> = T extends EntityEnum.BILLING ? BillingEntityModel : T extends EntityEnum.CLIENT ? ClientEntityModel : T extends EntityEnum.PROJECT ? ProjectEntityModel : T extends EntityEnum.PROJECT_USER_MAPPING ? ProjectUserMappingEntityModel : T extends EntityEnum.REIMBURSEMENT ? ReimbursementEntityModel : T extends EntityEnum.REIMBURSEMENT_EXPENSE ? ReimbursementExpenseEntityModel : T extends EntityEnum.BILLING_REIMBURSEMENT_EXPENSE ? BillingReimbursementExpneseEntityModel : UserEntityModel;
|
|
281
|
+
export type EnumToModel<T extends EntityEnum | VirtualEntityEnum> = T extends EntityEnum.BILLING ? BillingEntityModel : T extends EntityEnum.CLIENT ? ClientEntityModel : T extends EntityEnum.PROJECT ? ProjectEntityModel : T extends EntityEnum.PROJECT_USER_MAPPING ? ProjectUserMappingEntityModel : T extends EntityEnum.REIMBURSEMENT ? ReimbursementEntityModel : T extends EntityEnum.REIMBURSEMENT_EXPENSE ? ReimbursementExpenseEntityModel : T extends EntityEnum.BILLING_REIMBURSEMENT_EXPENSE ? BillingReimbursementExpneseEntityModel : T extends EntityEnum.LEAVE ? LeaveEntityModel : T extends EntityEnum.HOLIDAY ? HolidayEntityModel : T extends VirtualEntityEnum.LEAVE_COUNT ? LeaveCountVirtualEntityModel : UserEntityModel;
|
|
279
282
|
export type EntityMap = {
|
|
280
|
-
[key in EntityEnum]: EnumToModel<key>[];
|
|
283
|
+
[key in EntityEnum | VirtualEntityEnum]: EnumToModel<key>[];
|
|
281
284
|
};
|
|
282
285
|
export type EntityIndexMap = {
|
|
283
|
-
[key in EntityEnum]: {
|
|
286
|
+
[key in EntityEnum | VirtualEntityEnum]: {
|
|
284
287
|
[id: number]: EnumToModel<key>;
|
|
285
288
|
};
|
|
286
289
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EntityEnum, EntityIndexMap } from "../interface/entity.utils.interface";
|
|
2
|
-
export declare abstract class BaseEntityModel<T extends EntityEnum> {
|
|
1
|
+
import { EntityEnum, EntityIndexMap, VirtualEntityEnum } from "../interface/entity.utils.interface";
|
|
2
|
+
export declare abstract class BaseEntityModel<T extends EntityEnum | VirtualEntityEnum> {
|
|
3
3
|
protected entityName: T;
|
|
4
4
|
constructor(entityName: T);
|
|
5
5
|
abstract getRelationConfigs(): any[];
|
|
@@ -83,12 +83,12 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
83
83
|
// Define mapping sets
|
|
84
84
|
const categories = {
|
|
85
85
|
[BillingStatusCategoryEnumForUI.INTERNAL_REVIEW_STATUS]: [
|
|
86
|
+
billing_status_enum_1.BillingStatusEnum.INTERNAL_APPROVED,
|
|
86
87
|
billing_status_enum_1.BillingStatusEnum.PENDING_APPROVAL,
|
|
87
88
|
billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES,
|
|
88
89
|
billing_status_enum_1.BillingStatusEnum.CANCELLED,
|
|
89
90
|
],
|
|
90
91
|
[BillingStatusCategoryEnumForUI.CLIENT_REVIEW_STATUS]: [
|
|
91
|
-
billing_status_enum_1.BillingStatusEnum.INTERNAL_APPROVED,
|
|
92
92
|
billing_status_enum_1.BillingStatusEnum.PENDING_CLIENT_REVIEW,
|
|
93
93
|
billing_status_enum_1.BillingStatusEnum.CLIENT_REVISION_APPROVAL,
|
|
94
94
|
billing_status_enum_1.BillingStatusEnum.REJECT_CLIENT_REVISION,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { EntityEnum, EntityIndexMap, EntityMap, EnumEntityType, IBaseEntityApiResponse } from "../interface/entity.utils.interface";
|
|
1
|
+
import { EntityEnum, EntityIndexMap, EntityMap, EnumEntityType, IBaseEntityApiResponse, VirtualEntityEnum } from "../interface/entity.utils.interface";
|
|
2
2
|
export declare function mapToIndex(entityMap: EntityMap): EntityIndexMap;
|
|
3
3
|
export declare function getEntityIndexMap<T extends EntityEnum>(data: IBaseEntityApiResponse<EnumEntityType<T>>, baseEntity: T, reusedConfig?: {
|
|
4
4
|
existingEntityIndexMap: EntityIndexMap;
|
|
5
5
|
enumEntities: EntityEnum[];
|
|
6
6
|
}): EntityIndexMap;
|
|
7
7
|
export declare function populateRelationsFor(entityIndexMap: EntityIndexMap, enumEntities: EntityEnum[]): void;
|
|
8
|
-
export declare function parseEntities<T extends EnumEntityType<EntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum, entityMap: EntityMap): EntityMap;
|
|
8
|
+
export declare function parseEntities<T extends EnumEntityType<EntityEnum | VirtualEntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum | VirtualEntityEnum, entityMap: EntityMap): EntityMap;
|
|
@@ -9,6 +9,9 @@ const base_entity_model_1 = require("./base.entity.model");
|
|
|
9
9
|
const billing_reimbursement_expense_entity_model_1 = require("./billing-reimbursement-expense.entity.model");
|
|
10
10
|
const billing_entity_model_1 = require("./billing.entity.model");
|
|
11
11
|
const client_entity_model_1 = require("./client.entity.model");
|
|
12
|
+
const holiday_entity_model_1 = require("./holiday.entity.model");
|
|
13
|
+
const leave_entity_model_1 = require("./leave.entity.model");
|
|
14
|
+
const leave_count_entity_model_1 = require("./leave_count.entity.model");
|
|
12
15
|
const project_user_mapping_entity_model_1 = require("./project-user-mapping.entity.model");
|
|
13
16
|
const project_entity_model_1 = require("./project.entity.model");
|
|
14
17
|
const reimbursement_expense_entity_model_1 = require("./reimbursement-expense.entity.model");
|
|
@@ -52,6 +55,10 @@ function parseEntities(json, baseEntity, entityMap) {
|
|
|
52
55
|
[entity_utils_interface_1.EntityEnum.REIMBURSEMENT]: reimbursement_entity_model_1.ReimbursementEntityModel.fromApiEntity,
|
|
53
56
|
[entity_utils_interface_1.EntityEnum.REIMBURSEMENT_EXPENSE]: reimbursement_expense_entity_model_1.ReimbursementExpenseEntityModel.fromApiEntity,
|
|
54
57
|
[entity_utils_interface_1.EntityEnum.BILLING_REIMBURSEMENT_EXPENSE]: billing_reimbursement_expense_entity_model_1.BillingReimbursementExpneseEntityModel.fromApiEntity,
|
|
58
|
+
[entity_utils_interface_1.EntityEnum.HOLIDAY]: holiday_entity_model_1.HolidayEntityModel.fromApiEntity,
|
|
59
|
+
[entity_utils_interface_1.EntityEnum.LEAVE]: leave_entity_model_1.LeaveEntityModel.fromApiEntity,
|
|
60
|
+
[entity_utils_interface_1.VirtualEntityEnum.LEAVE_COUNT]: leave_count_entity_model_1.LeaveCountVirtualEntityModel.fromApiEntity,
|
|
61
|
+
// Add other entities here as needed
|
|
55
62
|
};
|
|
56
63
|
if (!(baseEntity in entityFromJsonMappings)) {
|
|
57
64
|
throw new Error(`Unknown entity: ${baseEntity}`);
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { IHolidayApiEntity } from "../../api";
|
|
2
|
+
import { EntityEnum } from "../interface/entity.utils.interface";
|
|
3
|
+
import { BaseEntityModel } from "./base.entity.model";
|
|
4
|
+
export declare class HolidayEntityModel extends BaseEntityModel<EntityEnum.HOLIDAY> implements IHolidayApiEntity {
|
|
5
|
+
id: number;
|
|
6
|
+
holidayListId: number;
|
|
7
|
+
dateCode: string;
|
|
8
|
+
createdBy: number;
|
|
9
|
+
updatedBy: number;
|
|
10
|
+
createdOn: string;
|
|
11
|
+
updatedOn: string;
|
|
12
|
+
getRelationConfigs(): never[];
|
|
13
|
+
static fromApiEntity(apiEntity: IHolidayApiEntity): HolidayEntityModel;
|
|
14
|
+
}
|
|
@@ -1,44 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// import { DateCodeModel } from "../../utils";
|
|
3
|
-
// import { IAuditColumnEntity } from "../interface/audit-column.entity.interface";
|
|
4
|
-
// import { IHolidayEntity } from "../interface/holiday.entity.interface";
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
// }
|
|
32
|
-
// getDateCodeModel(): DateCodeModel {
|
|
33
|
-
// return new DateCodeModel(this.dateCode);
|
|
34
|
-
// }
|
|
35
|
-
// static fromEntity(data: IHolidayEntity): HolidayEntityModel {
|
|
36
|
-
// return new HolidayEntityModel(data);
|
|
37
|
-
// }
|
|
38
|
-
// static getDateCodeModelFromDate(
|
|
39
|
-
// models: HolidayEntityModel[]
|
|
40
|
-
// ): DateCodeModel[] {
|
|
41
|
-
// return models.map((model) => model.getDateCodeModel());
|
|
42
|
-
// }
|
|
43
|
-
// }
|
|
44
|
-
exports.toBeDeleted = "holiday";
|
|
3
|
+
exports.HolidayEntityModel = void 0;
|
|
4
|
+
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
5
|
+
const base_entity_model_1 = require("./base.entity.model");
|
|
6
|
+
// import { IHolidayApiEntity } from "law-common/dist/src/api";
|
|
7
|
+
class HolidayEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.id = 0;
|
|
11
|
+
this.holidayListId = 0;
|
|
12
|
+
this.dateCode = "";
|
|
13
|
+
this.createdBy = 0;
|
|
14
|
+
this.updatedBy = 0;
|
|
15
|
+
this.createdOn = "";
|
|
16
|
+
this.updatedOn = "";
|
|
17
|
+
}
|
|
18
|
+
getRelationConfigs() {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
static fromApiEntity(apiEntity) {
|
|
22
|
+
const entity = new HolidayEntityModel(entity_utils_interface_1.EntityEnum.HOLIDAY);
|
|
23
|
+
Object.assign(entity, apiEntity);
|
|
24
|
+
return entity;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.HolidayEntityModel = HolidayEntityModel;
|
|
@@ -3,7 +3,11 @@ import { DateCodeModel, Weekday } from "../../utils";
|
|
|
3
3
|
import { DurationTypeEnum } from "../enums/duration-type.enum";
|
|
4
4
|
import { LeaveTypeEnum } from "../enums/leave-type.enum";
|
|
5
5
|
import { LeaveStatusEnum } from "../enums/leave.status.enum";
|
|
6
|
-
|
|
6
|
+
import { RelationType } from "../enums/relation-type.enum";
|
|
7
|
+
import { EntityEnum, VirtualEntityEnum } from "../interface/entity.utils.interface";
|
|
8
|
+
import { BaseEntityModel } from "./base.entity.model";
|
|
9
|
+
import { LeaveCountVirtualEntityModel } from "./leave_count.entity.model";
|
|
10
|
+
export declare class LeaveEntityModel extends BaseEntityModel<EntityEnum.LEAVE> implements ILeaveApiEntity {
|
|
7
11
|
id: number;
|
|
8
12
|
employeeId: number;
|
|
9
13
|
fromDate: string;
|
|
@@ -17,13 +21,53 @@ export declare class LeaveEntityModel implements ILeaveApiEntity {
|
|
|
17
21
|
updatedOn: string;
|
|
18
22
|
createdBy: number;
|
|
19
23
|
updatedBy: number;
|
|
24
|
+
leaveCount?: LeaveCountVirtualEntityModel;
|
|
20
25
|
private constructor();
|
|
21
26
|
static fromEntity(data: ILeaveApiEntity): LeaveEntityModel;
|
|
22
|
-
isMoreThanOneDayLeave(): boolean;
|
|
23
27
|
getLeaveDuration(excludeWeekdays?: Weekday[], excludeDates?: DateCodeModel[]): number;
|
|
24
28
|
static getLeaveDuration(leaves: LeaveEntityModel[], excludeWeekdays?: Weekday[], excludeDates?: DateCodeModel[], leaveStatusEnum?: LeaveStatusEnum[]): number;
|
|
25
29
|
getDateCodeModels(dateCodeIncludePredicates?: ((dateModel: DateCodeModel) => boolean)[], dateCodeExcludePredicates?: ((dateModel: DateCodeModel) => boolean)[]): DateCodeModel[];
|
|
26
30
|
static getLeaveApprovePredicate(): (leave: LeaveEntityModel) => boolean;
|
|
27
31
|
static getLeavePendingPredicate(): (leave: LeaveEntityModel) => boolean;
|
|
28
32
|
static getLeavesByPredicates(leaves: LeaveEntityModel[], includePredicates?: ((leave: LeaveEntityModel) => boolean)[], excludePredicates?: ((leave: LeaveEntityModel) => boolean)[]): LeaveEntityModel[];
|
|
33
|
+
static orderByFromDateAsc(leaves: LeaveEntityModel[]): LeaveEntityModel[];
|
|
34
|
+
isWeekendSucceeds(): boolean;
|
|
35
|
+
isWeekendPrecedes(): boolean;
|
|
36
|
+
isHolidaySucceeds(holidays: DateCodeModel[]): boolean;
|
|
37
|
+
isHolidayPrecedes(holidays: DateCodeModel[]): boolean;
|
|
38
|
+
getRelationConfigs(): any[];
|
|
39
|
+
static relationConfigs: ({
|
|
40
|
+
name: VirtualEntityEnum;
|
|
41
|
+
relation: RelationType;
|
|
42
|
+
key: string;
|
|
43
|
+
mapKeyConfig: {
|
|
44
|
+
relationKey: string;
|
|
45
|
+
key: string;
|
|
46
|
+
};
|
|
47
|
+
} | {
|
|
48
|
+
name: EntityEnum;
|
|
49
|
+
relation: RelationType;
|
|
50
|
+
key: string;
|
|
51
|
+
mapKeyConfig: {
|
|
52
|
+
relationKey: string;
|
|
53
|
+
key: string;
|
|
54
|
+
};
|
|
55
|
+
})[];
|
|
56
|
+
static fromApiEntity(apiEntity: ILeaveApiEntity): LeaveEntityModel;
|
|
57
|
+
static getPendingApprovalStatuses(): LeaveStatusEnum[];
|
|
58
|
+
getStatusLabel(): string;
|
|
59
|
+
getTypeLabel(): string;
|
|
60
|
+
getLeaveCount(): number;
|
|
61
|
+
static getLeaveCount(leaveEntities: LeaveEntityModel[]): number;
|
|
62
|
+
isMoreThanOneDayLeave(): boolean;
|
|
63
|
+
getFromDateLabel(): string;
|
|
64
|
+
getToDateLabel(): string;
|
|
65
|
+
getDateDurationLabel(): string;
|
|
66
|
+
static getLeaveStatusPriority(): {
|
|
67
|
+
pending_approval: number;
|
|
68
|
+
edit_approval: number;
|
|
69
|
+
delete_approval: number;
|
|
70
|
+
approved: number;
|
|
71
|
+
rejected: number;
|
|
72
|
+
};
|
|
29
73
|
}
|
|
@@ -2,10 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LeaveEntityModel = void 0;
|
|
4
4
|
const utils_1 = require("../../utils");
|
|
5
|
+
const string_util_1 = require("../../utils/string.util");
|
|
5
6
|
const duration_type_enum_1 = require("../enums/duration-type.enum");
|
|
6
7
|
const leave_status_enum_1 = require("../enums/leave.status.enum");
|
|
7
|
-
|
|
8
|
+
const relation_type_enum_1 = require("../enums/relation-type.enum");
|
|
9
|
+
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
10
|
+
const base_entity_model_1 = require("./base.entity.model");
|
|
11
|
+
class LeaveEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
8
12
|
constructor(data) {
|
|
13
|
+
super(entity_utils_interface_1.EntityEnum.LEAVE);
|
|
9
14
|
this.createdOn = "";
|
|
10
15
|
this.updatedOn = "";
|
|
11
16
|
this.id = data.id;
|
|
@@ -25,11 +30,6 @@ class LeaveEntityModel {
|
|
|
25
30
|
static fromEntity(data) {
|
|
26
31
|
return new LeaveEntityModel(data);
|
|
27
32
|
}
|
|
28
|
-
isMoreThanOneDayLeave() {
|
|
29
|
-
const fromDate = new utils_1.DateCodeModel(this.fromDate);
|
|
30
|
-
const toDate = new utils_1.DateCodeModel(this.toDate);
|
|
31
|
-
return fromDate.diffInDays(toDate) > 1;
|
|
32
|
-
}
|
|
33
33
|
getLeaveDuration(excludeWeekdays = [], excludeDates = []) {
|
|
34
34
|
if (!this.isMoreThanOneDayLeave()) {
|
|
35
35
|
return this.durationType === duration_type_enum_1.DurationTypeEnum.FULL ? 1 : 0.5;
|
|
@@ -80,5 +80,138 @@ class LeaveEntityModel {
|
|
|
80
80
|
return leaves.filter((leave) => includePredicates.every((predicate) => predicate(leave)) &&
|
|
81
81
|
excludePredicates.every((predicate) => !predicate(leave)));
|
|
82
82
|
}
|
|
83
|
+
static orderByFromDateAsc(leaves) {
|
|
84
|
+
return leaves.sort((a, b) => {
|
|
85
|
+
const dateA = new Date(a.fromDate);
|
|
86
|
+
const dateB = new Date(b.fromDate);
|
|
87
|
+
return dateA.getTime() - dateB.getTime();
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
isWeekendSucceeds() {
|
|
91
|
+
const toDate = new utils_1.DateCodeModel(this.toDate);
|
|
92
|
+
const nextDate = toDate.getByOffset(1);
|
|
93
|
+
return nextDate.isDayPresent([utils_1.Weekday.Saturday, utils_1.Weekday.Sunday]);
|
|
94
|
+
}
|
|
95
|
+
isWeekendPrecedes() {
|
|
96
|
+
const fromDate = new utils_1.DateCodeModel(this.fromDate);
|
|
97
|
+
const prevDate = fromDate.getByOffset(-1);
|
|
98
|
+
return prevDate.isDayPresent([utils_1.Weekday.Saturday, utils_1.Weekday.Sunday]);
|
|
99
|
+
}
|
|
100
|
+
isHolidaySucceeds(holidays) {
|
|
101
|
+
const toDate = new utils_1.DateCodeModel(this.toDate);
|
|
102
|
+
const nextDate = toDate.getByOffset(1);
|
|
103
|
+
return holidays.some((holiday) => holiday.isSame(nextDate));
|
|
104
|
+
}
|
|
105
|
+
isHolidayPrecedes(holidays) {
|
|
106
|
+
const fromDate = new utils_1.DateCodeModel(this.fromDate);
|
|
107
|
+
const prevDate = fromDate.getByOffset(-1);
|
|
108
|
+
return holidays.some((holiday) => holiday.isSame(prevDate));
|
|
109
|
+
}
|
|
110
|
+
getRelationConfigs() {
|
|
111
|
+
return this.constructor.prototype.constructor.relationConfigs;
|
|
112
|
+
}
|
|
113
|
+
static fromApiEntity(apiEntity) {
|
|
114
|
+
return new LeaveEntityModel(apiEntity);
|
|
115
|
+
}
|
|
116
|
+
static getPendingApprovalStatuses() {
|
|
117
|
+
return [
|
|
118
|
+
leave_status_enum_1.LeaveStatusEnum.PENDING_APPROVAL,
|
|
119
|
+
leave_status_enum_1.LeaveStatusEnum.DELETE_APPROVAL,
|
|
120
|
+
leave_status_enum_1.LeaveStatusEnum.EDIT_APPROVAL,
|
|
121
|
+
];
|
|
122
|
+
}
|
|
123
|
+
getStatusLabel() {
|
|
124
|
+
const pendingStatuses = LeaveEntityModel.getPendingApprovalStatuses();
|
|
125
|
+
let statusLabel = '';
|
|
126
|
+
if (pendingStatuses.includes(this.status)) {
|
|
127
|
+
statusLabel = 'PENDING_APPROVAL';
|
|
128
|
+
}
|
|
129
|
+
else if (this.status === leave_status_enum_1.LeaveStatusEnum.RESOLVE_REJECTED) {
|
|
130
|
+
statusLabel = 'CHANGES_REJECTED';
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
statusLabel = this.status.toString();
|
|
134
|
+
}
|
|
135
|
+
return (0, string_util_1.formatString)(statusLabel);
|
|
136
|
+
}
|
|
137
|
+
getTypeLabel() {
|
|
138
|
+
return (0, string_util_1.formatString)(this.type.toString());
|
|
139
|
+
}
|
|
140
|
+
getLeaveCount() {
|
|
141
|
+
var _a;
|
|
142
|
+
return ((_a = this.leaveCount) === null || _a === void 0 ? void 0 : _a.count) || 0;
|
|
143
|
+
}
|
|
144
|
+
static getLeaveCount(leaveEntities) {
|
|
145
|
+
return leaveEntities.reduce((acc, leave) => acc + leave.getLeaveCount(), 0);
|
|
146
|
+
}
|
|
147
|
+
isMoreThanOneDayLeave() {
|
|
148
|
+
const fromDate = new utils_1.DateCodeModel(this.fromDate);
|
|
149
|
+
const toDate = new utils_1.DateCodeModel(this.toDate);
|
|
150
|
+
return fromDate.diffInDays(toDate) > 1;
|
|
151
|
+
}
|
|
152
|
+
getFromDateLabel() {
|
|
153
|
+
const statues = [duration_type_enum_1.DurationTypeEnum.SECOND, duration_type_enum_1.DurationTypeEnum.SECOND_FULL, duration_type_enum_1.DurationTypeEnum.SECOND_FIRST];
|
|
154
|
+
if (statues.includes(this.durationType)) {
|
|
155
|
+
return 'Second Half';
|
|
156
|
+
}
|
|
157
|
+
return 'Full Day';
|
|
158
|
+
}
|
|
159
|
+
getToDateLabel() {
|
|
160
|
+
const statues = [duration_type_enum_1.DurationTypeEnum.FIRST, duration_type_enum_1.DurationTypeEnum.FULL_FIRST, duration_type_enum_1.DurationTypeEnum.SECOND_FIRST];
|
|
161
|
+
if (statues.includes(this.durationType)) {
|
|
162
|
+
return 'First Half';
|
|
163
|
+
}
|
|
164
|
+
return 'Full Day';
|
|
165
|
+
}
|
|
166
|
+
getDateDurationLabel() {
|
|
167
|
+
if (!this.isMoreThanOneDayLeave()) {
|
|
168
|
+
return `${new utils_1.DateCodeModel(this.fromDate).getFormattedDateWithMonthName()} ${this.durationType === duration_type_enum_1.DurationTypeEnum.FULL ? '(Full Day)' : this.durationType === duration_type_enum_1.DurationTypeEnum.FIRST ? '(First Half)' : '(Second Half)'}`;
|
|
169
|
+
}
|
|
170
|
+
return `${new utils_1.DateCodeModel(this.fromDate).getFormattedDateWithMonthName()} (${this.getFromDateLabel()}) - ${new utils_1.DateCodeModel(this.toDate).getFormattedDateWithMonthName()} (${this.getToDateLabel()})`;
|
|
171
|
+
}
|
|
172
|
+
static getLeaveStatusPriority() {
|
|
173
|
+
return {
|
|
174
|
+
[leave_status_enum_1.LeaveStatusEnum.PENDING_APPROVAL]: 1,
|
|
175
|
+
[leave_status_enum_1.LeaveStatusEnum.EDIT_APPROVAL]: 2,
|
|
176
|
+
[leave_status_enum_1.LeaveStatusEnum.DELETE_APPROVAL]: 3,
|
|
177
|
+
[leave_status_enum_1.LeaveStatusEnum.APPROVED]: 4,
|
|
178
|
+
[leave_status_enum_1.LeaveStatusEnum.REJECTED]: 5,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
83
181
|
}
|
|
84
182
|
exports.LeaveEntityModel = LeaveEntityModel;
|
|
183
|
+
LeaveEntityModel.relationConfigs = [
|
|
184
|
+
{
|
|
185
|
+
name: entity_utils_interface_1.VirtualEntityEnum.LEAVE_COUNT,
|
|
186
|
+
relation: relation_type_enum_1.RelationType.ONE,
|
|
187
|
+
key: 'leaveCount',
|
|
188
|
+
mapKeyConfig: {
|
|
189
|
+
relationKey: 'leaveId',
|
|
190
|
+
key: 'id',
|
|
191
|
+
},
|
|
192
|
+
}, {
|
|
193
|
+
name: entity_utils_interface_1.EntityEnum.USER,
|
|
194
|
+
relation: relation_type_enum_1.RelationType.ONE,
|
|
195
|
+
key: 'createdByUser',
|
|
196
|
+
mapKeyConfig: {
|
|
197
|
+
relationKey: 'id',
|
|
198
|
+
key: 'createdBy',
|
|
199
|
+
},
|
|
200
|
+
}, {
|
|
201
|
+
name: entity_utils_interface_1.EntityEnum.USER,
|
|
202
|
+
relation: relation_type_enum_1.RelationType.ONE,
|
|
203
|
+
key: 'updatedByUser',
|
|
204
|
+
mapKeyConfig: {
|
|
205
|
+
relationKey: 'id',
|
|
206
|
+
key: 'updatedBy',
|
|
207
|
+
},
|
|
208
|
+
}, {
|
|
209
|
+
name: entity_utils_interface_1.EntityEnum.USER,
|
|
210
|
+
relation: relation_type_enum_1.RelationType.ONE,
|
|
211
|
+
key: 'user',
|
|
212
|
+
mapKeyConfig: {
|
|
213
|
+
relationKey: 'id',
|
|
214
|
+
key: 'employeeId',
|
|
215
|
+
},
|
|
216
|
+
}
|
|
217
|
+
];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DateCodeModel } from "../../utils";
|
|
2
|
+
import { IApiEntity, VirtualEntityEnum } from "../interface/entity.utils.interface";
|
|
3
|
+
import { ILeaveCountVirtualEntity } from "../interface/leave.entity.interface";
|
|
4
|
+
import { BaseEntityModel } from "./base.entity.model";
|
|
5
|
+
import { LeaveEntityModel } from "./leave.entity.model";
|
|
6
|
+
export declare class LeaveCountVirtualEntityModel extends BaseEntityModel<VirtualEntityEnum.LEAVE_COUNT> implements IApiEntity<ILeaveCountVirtualEntity> {
|
|
7
|
+
id: number;
|
|
8
|
+
period: string;
|
|
9
|
+
leaveId?: number;
|
|
10
|
+
count: number;
|
|
11
|
+
createdBy: number;
|
|
12
|
+
updatedBy: number;
|
|
13
|
+
createdOn: string;
|
|
14
|
+
updatedOn: string;
|
|
15
|
+
static fromApiEntity(apiEntity: IApiEntity<ILeaveCountVirtualEntity>): LeaveCountVirtualEntityModel;
|
|
16
|
+
getRelationConfigs(): any[];
|
|
17
|
+
static relationConfigs: never[];
|
|
18
|
+
static fromLeaveHoliday(leaveModel: LeaveEntityModel, holidayDateCodes: DateCodeModel[]): LeaveCountVirtualEntityModel;
|
|
19
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LeaveCountVirtualEntityModel = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const leave_type_enum_1 = require("../enums/leave-type.enum");
|
|
6
|
+
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
7
|
+
const base_entity_model_1 = require("./base.entity.model");
|
|
8
|
+
class LeaveCountVirtualEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.id = 0;
|
|
12
|
+
this.period = "";
|
|
13
|
+
this.count = 0;
|
|
14
|
+
this.createdBy = 0;
|
|
15
|
+
this.updatedBy = 0;
|
|
16
|
+
this.createdOn = "";
|
|
17
|
+
this.updatedOn = "";
|
|
18
|
+
}
|
|
19
|
+
static fromApiEntity(apiEntity) {
|
|
20
|
+
const entity = new LeaveCountVirtualEntityModel(entity_utils_interface_1.VirtualEntityEnum.LEAVE_COUNT);
|
|
21
|
+
Object.assign(entity, apiEntity);
|
|
22
|
+
return entity;
|
|
23
|
+
}
|
|
24
|
+
getRelationConfigs() {
|
|
25
|
+
return this.constructor.prototype.constructor.relationConfigs;
|
|
26
|
+
}
|
|
27
|
+
static fromLeaveHoliday(leaveModel, holidayDateCodes) {
|
|
28
|
+
const leaveCountVirtualEntity = {
|
|
29
|
+
leaveId: leaveModel.id,
|
|
30
|
+
count: leaveModel.getLeaveDuration([utils_1.Weekday.Sunday, utils_1.Weekday.Saturday], holidayDateCodes) +
|
|
31
|
+
(leaveModel.type === leave_type_enum_1.LeaveTypeEnum.SICK &&
|
|
32
|
+
(leaveModel.isWeekendPrecedes() ||
|
|
33
|
+
leaveModel.isWeekendSucceeds() ||
|
|
34
|
+
leaveModel.isHolidayPrecedes(holidayDateCodes) ||
|
|
35
|
+
leaveModel.isHolidaySucceeds(holidayDateCodes))
|
|
36
|
+
? 2
|
|
37
|
+
: 0),
|
|
38
|
+
createdBy: leaveModel.createdBy,
|
|
39
|
+
updatedBy: leaveModel.updatedBy,
|
|
40
|
+
createdOn: leaveModel.createdOn,
|
|
41
|
+
updatedOn: leaveModel.updatedOn,
|
|
42
|
+
id: leaveModel.id,
|
|
43
|
+
period: leaveModel.fromDate + leaveModel.toDate + leaveModel.durationType,
|
|
44
|
+
};
|
|
45
|
+
return LeaveCountVirtualEntityModel.fromApiEntity(leaveCountVirtualEntity);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.LeaveCountVirtualEntityModel = LeaveCountVirtualEntityModel;
|
|
49
|
+
// static relationConfigs = [
|
|
50
|
+
// {
|
|
51
|
+
// name: EntityEnum.LEAVE,
|
|
52
|
+
// relation: RelationType.ONE,
|
|
53
|
+
// key: 'leaveCount',
|
|
54
|
+
// mapKeyConfig: {
|
|
55
|
+
// relationKey: 'id',
|
|
56
|
+
// key: 'leaveId',
|
|
57
|
+
// },
|
|
58
|
+
// },
|
|
59
|
+
// ];
|
|
60
|
+
LeaveCountVirtualEntityModel.relationConfigs = [];
|
package/dist/src/utils/index.js
CHANGED
|
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./date.util"), exports);
|
|
18
18
|
__exportStar(require("./helper.fn.util"), exports);
|
|
19
19
|
__exportStar(require("./models/date-code.model.util"), exports);
|
|
20
|
+
__exportStar(require("./string.util"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatString(input: string): string;
|
|
@@ -1 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatString = formatString;
|
|
4
|
+
function formatString(input) {
|
|
5
|
+
if (input.includes('_')) {
|
|
6
|
+
return input
|
|
7
|
+
.split('_')
|
|
8
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
9
|
+
.join(' ');
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
// For single-word strings, capitalize the first letter
|
|
13
|
+
return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase();
|
|
14
|
+
}
|
|
15
|
+
}
|