law-common 10.27.0 → 10.28.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/api/interface/billing.transaction.create.dto.interface.d.ts +7 -2
- package/dist/src/api/interface/billing.transaction.entity.response.d.ts +24 -1
- package/dist/src/api/interface/billing.transaction.update.dto.interface.d.ts +13 -2
- package/dist/src/constants/entity_constants.d.ts +1 -0
- package/dist/src/constants/entity_constants.js +2 -1
- package/dist/src/entities/enums/billing-transaction-action.enum.d.ts +5 -0
- package/dist/src/entities/enums/billing-transaction-action.enum.js +15 -0
- package/dist/src/entities/enums/billing-transaction-status.enum.d.ts +6 -0
- package/dist/src/entities/enums/billing-transaction-status.enum.js +10 -0
- package/dist/src/entities/index.d.ts +5 -1
- package/dist/src/entities/index.js +5 -2
- package/dist/src/entities/interface/billing-transaction-history.entity.d.ts +7 -0
- package/dist/src/entities/interface/billing-transaction-history.entity.js +2 -0
- package/dist/src/entities/interface/billing.entity.interface.d.ts +1 -0
- package/dist/src/entities/interface/billing_transaction.entity.interface.d.ts +7 -0
- package/dist/src/entities/interface/entity.utils.interface.d.ts +14 -5
- package/dist/src/entities/interface/entity.utils.interface.js +1 -0
- package/dist/src/entities/model/base.entity.model.d.ts +8 -2
- package/dist/src/entities/model/base.entity.model.js +53 -34
- package/dist/src/entities/model/billing-reimbursement-expense.entity.model.d.ts +1 -1
- package/dist/src/entities/model/billing-reimbursement-expense.entity.model.js +1 -1
- package/dist/src/entities/model/billing-timesheet.entity.model.d.ts +1 -1
- package/dist/src/entities/model/billing-timesheet.entity.model.js +1 -1
- package/dist/src/entities/model/billing-transaction.model.d.ts +38 -0
- package/dist/src/entities/model/billing-transaction.model.js +71 -0
- package/dist/src/entities/model/billing.entity.model.d.ts +4 -1
- package/dist/src/entities/model/billing.entity.model.js +9 -0
- package/dist/src/entities/model/entity.model.interface.d.ts +12 -1
- package/dist/src/entities/model/entity.model.interface.js +46 -2
- package/dist/src/entities/model/holiday.entity.model.d.ts +14 -1
- package/dist/src/entities/model/holiday.entity.model.js +26 -42
- package/dist/src/entities/model/leave.entity.model.d.ts +50 -3
- package/dist/src/entities/model/leave.entity.model.js +169 -21
- 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/entity.flow.util.d.ts +32 -0
- package/dist/src/utils/entity.flow.util.js +83 -0
- package/dist/src/utils/helper.fn.util.d.ts +37 -1
- package/dist/src/utils/helper.fn.util.js +53 -0
- package/dist/src/utils/index.d.ts +2 -0
- package/dist/src/utils/index.js +2 -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
- package/dist/src/entities/func/convert-to-common-entity.func.d.ts +0 -15
- package/dist/src/entities/func/convert-to-common-entity.func.js +0 -24
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EntityEnum, EntityIndexMap, EntityMap, EnumEntityType, IBaseEntityApiResponse } from "../interface/entity.utils.interface";
|
|
1
|
+
import { EntityEnum, EntityIndexMap, EntityMap, EnumEntityType, EnumToModel, IApiEntity, 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;
|
|
@@ -6,3 +6,14 @@ export declare function getEntityIndexMap<T extends EntityEnum>(data: IBaseEntit
|
|
|
6
6
|
}): EntityIndexMap;
|
|
7
7
|
export declare function populateRelationsFor(entityIndexMap: EntityIndexMap, enumEntities: EntityEnum[]): void;
|
|
8
8
|
export declare function parseEntities<T extends EnumEntityType<EntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum, entityMap: EntityMap): EntityMap;
|
|
9
|
+
export declare const entityEnumToEntityModel: {
|
|
10
|
+
[E in EntityEnum | VirtualEntityEnum]?: (json: IApiEntity<EnumEntityType<E>> & {
|
|
11
|
+
createdOn: number;
|
|
12
|
+
updatedOn: number;
|
|
13
|
+
}) => EnumToModel<E>;
|
|
14
|
+
};
|
|
15
|
+
export declare function parseEntitiesWithoutModels<T extends EnumEntityType<EntityEnum | VirtualEntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum | VirtualEntityEnum, entityMap?: {
|
|
16
|
+
[E in EntityEnum | VirtualEntityEnum]?: IApiEntity<EnumEntityType<E>>[];
|
|
17
|
+
}): {
|
|
18
|
+
[E in EntityEnum | VirtualEntityEnum]?: IApiEntity<EnumEntityType<E>>[];
|
|
19
|
+
};
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.entityEnumToEntityModel = void 0;
|
|
3
4
|
exports.mapToIndex = mapToIndex;
|
|
4
5
|
exports.getEntityIndexMap = getEntityIndexMap;
|
|
5
6
|
exports.populateRelationsFor = populateRelationsFor;
|
|
6
7
|
exports.parseEntities = parseEntities;
|
|
8
|
+
exports.parseEntitiesWithoutModels = parseEntitiesWithoutModels;
|
|
7
9
|
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
8
10
|
const bank_entity_model_1 = require("./bank.entity.model");
|
|
9
11
|
const base_entity_model_1 = require("./base.entity.model");
|
|
10
12
|
const billing_reimbursement_expense_entity_model_1 = require("./billing-reimbursement-expense.entity.model");
|
|
11
13
|
const billing_timesheet_entity_model_1 = require("./billing-timesheet.entity.model");
|
|
14
|
+
const billing_transaction_model_1 = require("./billing-transaction.model");
|
|
12
15
|
const billing_entity_model_1 = require("./billing.entity.model");
|
|
13
16
|
const client_affiliate_entity_model_1 = require("./client-affiliate.entity.model");
|
|
14
17
|
const client_entity_model_1 = require("./client.entity.model");
|
|
15
18
|
const configuration_model_1 = require("./configuration.model");
|
|
19
|
+
const holiday_entity_model_1 = require("./holiday.entity.model");
|
|
20
|
+
const leave_entity_model_1 = require("./leave.entity.model");
|
|
21
|
+
const leave_count_entity_model_1 = require("./leave_count.entity.model");
|
|
16
22
|
const project_user_mapping_entity_model_1 = require("./project-user-mapping.entity.model");
|
|
17
23
|
const project_entity_model_1 = require("./project.entity.model");
|
|
18
24
|
const reimbursement_expense_entity_model_1 = require("./reimbursement-expense.entity.model");
|
|
@@ -57,13 +63,14 @@ function parseEntities(json, baseEntity, entityMap) {
|
|
|
57
63
|
[entity_utils_interface_1.EntityEnum.PROJECT_USER_MAPPING]: project_user_mapping_entity_model_1.ProjectUserMappingEntityModel.fromEntity,
|
|
58
64
|
[entity_utils_interface_1.EntityEnum.REIMBURSEMENT]: reimbursement_entity_model_1.ReimbursementEntityModel.fromEntity,
|
|
59
65
|
[entity_utils_interface_1.EntityEnum.REIMBURSEMENT_EXPENSE]: reimbursement_expense_entity_model_1.ReimbursementExpenseEntityModel.fromEntity,
|
|
60
|
-
[entity_utils_interface_1.EntityEnum.BILLING_REIMBURSEMENT_EXPENSE]: billing_reimbursement_expense_entity_model_1.BillingReimbursementExpneseEntityModel.
|
|
66
|
+
[entity_utils_interface_1.EntityEnum.BILLING_REIMBURSEMENT_EXPENSE]: billing_reimbursement_expense_entity_model_1.BillingReimbursementExpneseEntityModel.fromEntity,
|
|
61
67
|
[entity_utils_interface_1.EntityEnum.CLIENT_AFFILIATE]: client_affiliate_entity_model_1.ClientAffiliateEntityModel.fromEntity,
|
|
62
68
|
[entity_utils_interface_1.EntityEnum.BANK]: bank_entity_model_1.BankEntityModel.fromEntity,
|
|
63
69
|
[entity_utils_interface_1.EntityEnum.CONFIGURATION]: configuration_model_1.ConfigurationEntityModel.fromEntity,
|
|
64
70
|
[entity_utils_interface_1.EntityEnum.TASK]: task_entity_model_1.TaskEntityModel.fromEntity,
|
|
65
|
-
[entity_utils_interface_1.EntityEnum.BILLING_TIMESHEET]: billing_timesheet_entity_model_1.BillingTimesheetEntityModel.
|
|
71
|
+
[entity_utils_interface_1.EntityEnum.BILLING_TIMESHEET]: billing_timesheet_entity_model_1.BillingTimesheetEntityModel.fromEntity,
|
|
66
72
|
[entity_utils_interface_1.EntityEnum.TIMESHEET]: timesheet_entity_model_1.TimesheetEntityModel.fromEntity,
|
|
73
|
+
[entity_utils_interface_1.EntityEnum.BILLING_TRANSACTION]: billing_transaction_model_1.BillingTransactionEntityModel.fromEntity,
|
|
67
74
|
};
|
|
68
75
|
if (!(baseEntity in entityFromJsonMappings)) {
|
|
69
76
|
throw new Error(`Unknown entity: ${baseEntity}`);
|
|
@@ -81,3 +88,40 @@ function parseEntities(json, baseEntity, entityMap) {
|
|
|
81
88
|
}
|
|
82
89
|
return entityMap;
|
|
83
90
|
}
|
|
91
|
+
exports.entityEnumToEntityModel = {
|
|
92
|
+
[entity_utils_interface_1.EntityEnum.PROJECT]: project_entity_model_1.ProjectEntityModel.fromEntity,
|
|
93
|
+
[entity_utils_interface_1.EntityEnum.CLIENT]: client_entity_model_1.ClientEntityModel.fromEntity,
|
|
94
|
+
[entity_utils_interface_1.EntityEnum.BILLING]: billing_entity_model_1.BillingEntityModel.fromEntity,
|
|
95
|
+
[entity_utils_interface_1.EntityEnum.USER]: user_entity_model_1.UserEntityModel.fromEntity,
|
|
96
|
+
[entity_utils_interface_1.EntityEnum.PROJECT_USER_MAPPING]: project_user_mapping_entity_model_1.ProjectUserMappingEntityModel.fromEntity,
|
|
97
|
+
[entity_utils_interface_1.EntityEnum.REIMBURSEMENT]: reimbursement_entity_model_1.ReimbursementEntityModel.fromEntity,
|
|
98
|
+
[entity_utils_interface_1.EntityEnum.REIMBURSEMENT_EXPENSE]: reimbursement_expense_entity_model_1.ReimbursementExpenseEntityModel.fromEntity,
|
|
99
|
+
[entity_utils_interface_1.EntityEnum.BILLING_REIMBURSEMENT_EXPENSE]: billing_reimbursement_expense_entity_model_1.BillingReimbursementExpneseEntityModel.fromEntity,
|
|
100
|
+
[entity_utils_interface_1.EntityEnum.HOLIDAY]: holiday_entity_model_1.HolidayEntityModel.fromEntity,
|
|
101
|
+
[entity_utils_interface_1.EntityEnum.LEAVE]: leave_entity_model_1.LeaveEntityModel.fromEntity,
|
|
102
|
+
[entity_utils_interface_1.VirtualEntityEnum.LEAVE_COUNT]: leave_count_entity_model_1.LeaveCountVirtualEntityModel.fromEntity,
|
|
103
|
+
// Add other entities here as needed
|
|
104
|
+
[entity_utils_interface_1.EntityEnum.CLIENT_AFFILIATE]: client_affiliate_entity_model_1.ClientAffiliateEntityModel.fromEntity,
|
|
105
|
+
[entity_utils_interface_1.EntityEnum.BANK]: bank_entity_model_1.BankEntityModel.fromEntity,
|
|
106
|
+
[entity_utils_interface_1.EntityEnum.CONFIGURATION]: configuration_model_1.ConfigurationEntityModel.fromEntity,
|
|
107
|
+
[entity_utils_interface_1.EntityEnum.TASK]: task_entity_model_1.TaskEntityModel.fromEntity,
|
|
108
|
+
[entity_utils_interface_1.EntityEnum.BILLING_TIMESHEET]: billing_timesheet_entity_model_1.BillingTimesheetEntityModel.fromEntity,
|
|
109
|
+
[entity_utils_interface_1.EntityEnum.TIMESHEET]: timesheet_entity_model_1.TimesheetEntityModel.fromEntity,
|
|
110
|
+
[entity_utils_interface_1.EntityEnum.BILLING_TRANSACTION]: billing_transaction_model_1.BillingTransactionEntityModel.fromEntity,
|
|
111
|
+
};
|
|
112
|
+
function parseEntitiesWithoutModels(json, baseEntity, entityMap = {}) {
|
|
113
|
+
var _a;
|
|
114
|
+
if (!(baseEntity in exports.entityEnumToEntityModel)) {
|
|
115
|
+
throw new Error(`Unknown entity: ${baseEntity}`);
|
|
116
|
+
}
|
|
117
|
+
entityMap[baseEntity] = ((_a = json["baseEntities"]) !== null && _a !== void 0 ? _a : []);
|
|
118
|
+
if (json["relatedEntities"]) {
|
|
119
|
+
const relatedEntities = json["relatedEntities"];
|
|
120
|
+
for (const entityName in relatedEntities) {
|
|
121
|
+
parseEntitiesWithoutModels(
|
|
122
|
+
// @ts-ignore
|
|
123
|
+
relatedEntities[entityName], entityName, entityMap);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return entityMap;
|
|
127
|
+
}
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { EntityEnum } from "../interface/entity.utils.interface";
|
|
2
|
+
import { IHolidayEntity } from "../interface/holiday.entity.interface";
|
|
3
|
+
import { BaseEntityModel } from "./base.entity.model";
|
|
4
|
+
export declare class HolidayEntityModel extends BaseEntityModel<EntityEnum.HOLIDAY> implements IHolidayEntity {
|
|
5
|
+
id: number;
|
|
6
|
+
holidayListId: number;
|
|
7
|
+
dateCode: string;
|
|
8
|
+
createdBy: number;
|
|
9
|
+
updatedBy: number;
|
|
10
|
+
createdOn: number;
|
|
11
|
+
updatedOn: number;
|
|
12
|
+
getRelationConfigs(): never[];
|
|
13
|
+
static fromEntity(entity: IHolidayEntity): HolidayEntityModel;
|
|
14
|
+
}
|
|
@@ -1,44 +1,28 @@
|
|
|
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
|
+
// import { EntityEnum, IHolidayEntity } from "law-common/dist/src/entities";
|
|
5
|
+
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
6
|
+
const base_entity_model_1 = require("./base.entity.model");
|
|
7
|
+
// import { IHolidayApiEntity } from "law-common/dist/src/api";
|
|
8
|
+
class HolidayEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.id = 0;
|
|
12
|
+
this.holidayListId = 0;
|
|
13
|
+
this.dateCode = "";
|
|
14
|
+
this.createdBy = 0;
|
|
15
|
+
this.updatedBy = 0;
|
|
16
|
+
this.createdOn = 0;
|
|
17
|
+
this.updatedOn = 0;
|
|
18
|
+
}
|
|
19
|
+
getRelationConfigs() {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
static fromEntity(entity) {
|
|
23
|
+
const result = new HolidayEntityModel(entity_utils_interface_1.EntityEnum.HOLIDAY);
|
|
24
|
+
Object.assign(result, entity);
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.HolidayEntityModel = HolidayEntityModel;
|
|
@@ -2,8 +2,13 @@ import { DateCodeModel, Weekday } from "../../utils";
|
|
|
2
2
|
import { DurationTypeEnum } from "../enums/duration-type.enum";
|
|
3
3
|
import { LeaveTypeEnum } from "../enums/leave-type.enum";
|
|
4
4
|
import { LeaveStatusEnum } from "../enums/leave.status.enum";
|
|
5
|
+
import { RelationType } from "../enums/relation-type.enum";
|
|
6
|
+
import { EntityEnum, VirtualEntityEnum } from "../interface/entity.utils.interface";
|
|
5
7
|
import { ILeaveEntity } from "../interface/leave.entity.interface";
|
|
6
|
-
|
|
8
|
+
import { BaseEntityModel } from "./base.entity.model";
|
|
9
|
+
import { LeaveCountVirtualEntityModel } from "./leave_count.entity.model";
|
|
10
|
+
import { UserEntityModel } from "./user.entity.model";
|
|
11
|
+
export declare class LeaveEntityModel extends BaseEntityModel<EntityEnum.LEAVE> implements ILeaveEntity {
|
|
7
12
|
id: number;
|
|
8
13
|
employeeId: number;
|
|
9
14
|
fromDate: string;
|
|
@@ -17,13 +22,55 @@ export declare class LeaveEntityModel implements ILeaveEntity {
|
|
|
17
22
|
updatedOn: number;
|
|
18
23
|
createdBy: number;
|
|
19
24
|
updatedBy: number;
|
|
20
|
-
|
|
25
|
+
leaveCount?: LeaveCountVirtualEntityModel;
|
|
26
|
+
createdByUser?: UserEntityModel;
|
|
27
|
+
updatedByUser?: UserEntityModel;
|
|
28
|
+
user?: UserEntityModel;
|
|
21
29
|
static fromEntity(data: ILeaveEntity): LeaveEntityModel;
|
|
22
|
-
isMoreThanOneDayLeave(): boolean;
|
|
23
30
|
getLeaveDuration(excludeWeekdays?: Weekday[], excludeDates?: DateCodeModel[]): number;
|
|
24
31
|
static getLeaveDuration(leaves: LeaveEntityModel[], excludeWeekdays?: Weekday[], excludeDates?: DateCodeModel[], leaveStatusEnum?: LeaveStatusEnum[]): number;
|
|
25
32
|
getDateCodeModels(dateCodeIncludePredicates?: ((dateModel: DateCodeModel) => boolean)[], dateCodeExcludePredicates?: ((dateModel: DateCodeModel) => boolean)[]): DateCodeModel[];
|
|
26
33
|
static getLeaveApprovePredicate(): (leave: LeaveEntityModel) => boolean;
|
|
27
34
|
static getLeavePendingPredicate(): (leave: LeaveEntityModel) => boolean;
|
|
28
35
|
static getLeavesByPredicates(leaves: LeaveEntityModel[], includePredicates?: ((leave: LeaveEntityModel) => boolean)[], excludePredicates?: ((leave: LeaveEntityModel) => boolean)[]): LeaveEntityModel[];
|
|
36
|
+
static orderByFromDateAsc(leaves: LeaveEntityModel[]): LeaveEntityModel[];
|
|
37
|
+
isWeekendSucceeds(): boolean;
|
|
38
|
+
isWeekendPrecedes(): boolean;
|
|
39
|
+
isHolidaySucceeds(holidays: DateCodeModel[]): boolean;
|
|
40
|
+
isHolidayPrecedes(holidays: DateCodeModel[]): boolean;
|
|
41
|
+
getRelationConfigs(): any[];
|
|
42
|
+
static relationConfigs: ({
|
|
43
|
+
name: VirtualEntityEnum;
|
|
44
|
+
relation: RelationType;
|
|
45
|
+
key: string;
|
|
46
|
+
mapKeyConfig: {
|
|
47
|
+
relationKey: string;
|
|
48
|
+
key: string;
|
|
49
|
+
};
|
|
50
|
+
} | {
|
|
51
|
+
name: EntityEnum;
|
|
52
|
+
relation: RelationType;
|
|
53
|
+
key: string;
|
|
54
|
+
mapKeyConfig: {
|
|
55
|
+
relationKey: string;
|
|
56
|
+
key: string;
|
|
57
|
+
};
|
|
58
|
+
})[];
|
|
59
|
+
static fromApiEntity(apiEntity: ILeaveEntity): LeaveEntityModel;
|
|
60
|
+
static getPendingApprovalStatuses(): LeaveStatusEnum[];
|
|
61
|
+
getStatusLabel(): string;
|
|
62
|
+
getTypeLabel(): string;
|
|
63
|
+
getLeaveCount(): number;
|
|
64
|
+
static getLeaveCount(leaveEntities: LeaveEntityModel[]): number;
|
|
65
|
+
isMoreThanOneDayLeave(): boolean;
|
|
66
|
+
getFromDateLabel(): string;
|
|
67
|
+
getToDateLabel(): string;
|
|
68
|
+
getDateDurationLabel(): string;
|
|
69
|
+
static getLeaveStatusPriority(): {
|
|
70
|
+
pending_approval: number;
|
|
71
|
+
edit_approval: number;
|
|
72
|
+
delete_approval: number;
|
|
73
|
+
approved: number;
|
|
74
|
+
rejected: number;
|
|
75
|
+
};
|
|
29
76
|
}
|
|
@@ -2,33 +2,33 @@
|
|
|
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");
|
|
7
|
+
const leave_type_enum_1 = require("../enums/leave-type.enum");
|
|
6
8
|
const leave_status_enum_1 = require("../enums/leave.status.enum");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
const relation_type_enum_1 = require("../enums/relation-type.enum");
|
|
10
|
+
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
11
|
+
const base_entity_model_1 = require("./base.entity.model");
|
|
12
|
+
class LeaveEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.id = 0;
|
|
16
|
+
this.employeeId = 0;
|
|
17
|
+
this.fromDate = "";
|
|
18
|
+
this.toDate = "";
|
|
19
|
+
this.reason = "";
|
|
20
|
+
this.durationType = duration_type_enum_1.DurationTypeEnum.FULL;
|
|
21
|
+
this.status = leave_status_enum_1.LeaveStatusEnum.DELETED;
|
|
22
|
+
this.type = leave_type_enum_1.LeaveTypeEnum.SICK;
|
|
9
23
|
this.createdOn = 0;
|
|
10
24
|
this.updatedOn = 0;
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
13
|
-
this.fromDate = data.fromDate;
|
|
14
|
-
this.toDate = data.toDate;
|
|
15
|
-
this.reason = data.reason;
|
|
16
|
-
this.durationType = data.durationType;
|
|
17
|
-
this.status = data.status;
|
|
18
|
-
this.remark = data.remark;
|
|
19
|
-
this.type = data.type;
|
|
20
|
-
this.createdOn = data.createdOn;
|
|
21
|
-
this.updatedOn = data.updatedOn;
|
|
22
|
-
this.createdBy = data.createdBy;
|
|
23
|
-
this.updatedBy = data.updatedBy;
|
|
25
|
+
this.createdBy = 0;
|
|
26
|
+
this.updatedBy = 0;
|
|
24
27
|
}
|
|
25
28
|
static fromEntity(data) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const fromDate = new utils_1.DateCodeModel(this.fromDate);
|
|
30
|
-
const toDate = new utils_1.DateCodeModel(this.toDate);
|
|
31
|
-
return fromDate.diffInDays(toDate) > 1;
|
|
29
|
+
const entity = new LeaveEntityModel(entity_utils_interface_1.EntityEnum.LEAVE);
|
|
30
|
+
Object.assign(entity, data);
|
|
31
|
+
return entity;
|
|
32
32
|
}
|
|
33
33
|
getLeaveDuration(excludeWeekdays = [], excludeDates = []) {
|
|
34
34
|
if (!this.isMoreThanOneDayLeave()) {
|
|
@@ -80,5 +80,153 @@ 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 LeaveEntityModel.fromEntity(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 = [
|
|
154
|
+
duration_type_enum_1.DurationTypeEnum.SECOND,
|
|
155
|
+
duration_type_enum_1.DurationTypeEnum.SECOND_FULL,
|
|
156
|
+
duration_type_enum_1.DurationTypeEnum.SECOND_FIRST,
|
|
157
|
+
];
|
|
158
|
+
if (statues.includes(this.durationType)) {
|
|
159
|
+
return "Second Half";
|
|
160
|
+
}
|
|
161
|
+
return "Full Day";
|
|
162
|
+
}
|
|
163
|
+
getToDateLabel() {
|
|
164
|
+
const statues = [
|
|
165
|
+
duration_type_enum_1.DurationTypeEnum.FIRST,
|
|
166
|
+
duration_type_enum_1.DurationTypeEnum.FULL_FIRST,
|
|
167
|
+
duration_type_enum_1.DurationTypeEnum.SECOND_FIRST,
|
|
168
|
+
];
|
|
169
|
+
if (statues.includes(this.durationType)) {
|
|
170
|
+
return "First Half";
|
|
171
|
+
}
|
|
172
|
+
return "Full Day";
|
|
173
|
+
}
|
|
174
|
+
getDateDurationLabel() {
|
|
175
|
+
if (!this.isMoreThanOneDayLeave()) {
|
|
176
|
+
return `${new utils_1.DateCodeModel(this.fromDate).getFormattedDateWithMonthName()} ${this.durationType === duration_type_enum_1.DurationTypeEnum.FULL
|
|
177
|
+
? "(Full Day)"
|
|
178
|
+
: this.durationType === duration_type_enum_1.DurationTypeEnum.FIRST
|
|
179
|
+
? "(First Half)"
|
|
180
|
+
: "(Second Half)"}`;
|
|
181
|
+
}
|
|
182
|
+
return `${new utils_1.DateCodeModel(this.fromDate).getFormattedDateWithMonthName()} (${this.getFromDateLabel()}) - ${new utils_1.DateCodeModel(this.toDate).getFormattedDateWithMonthName()} (${this.getToDateLabel()})`;
|
|
183
|
+
}
|
|
184
|
+
static getLeaveStatusPriority() {
|
|
185
|
+
return {
|
|
186
|
+
[leave_status_enum_1.LeaveStatusEnum.PENDING_APPROVAL]: 1,
|
|
187
|
+
[leave_status_enum_1.LeaveStatusEnum.EDIT_APPROVAL]: 2,
|
|
188
|
+
[leave_status_enum_1.LeaveStatusEnum.DELETE_APPROVAL]: 3,
|
|
189
|
+
[leave_status_enum_1.LeaveStatusEnum.APPROVED]: 4,
|
|
190
|
+
[leave_status_enum_1.LeaveStatusEnum.REJECTED]: 5,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
83
193
|
}
|
|
84
194
|
exports.LeaveEntityModel = LeaveEntityModel;
|
|
195
|
+
LeaveEntityModel.relationConfigs = [
|
|
196
|
+
{
|
|
197
|
+
name: entity_utils_interface_1.VirtualEntityEnum.LEAVE_COUNT,
|
|
198
|
+
relation: relation_type_enum_1.RelationType.ONE,
|
|
199
|
+
key: "leaveCount",
|
|
200
|
+
mapKeyConfig: {
|
|
201
|
+
relationKey: "leaveId",
|
|
202
|
+
key: "id",
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
name: entity_utils_interface_1.EntityEnum.USER,
|
|
207
|
+
relation: relation_type_enum_1.RelationType.ONE,
|
|
208
|
+
key: "createdByUser",
|
|
209
|
+
mapKeyConfig: {
|
|
210
|
+
relationKey: "id",
|
|
211
|
+
key: "createdBy",
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: entity_utils_interface_1.EntityEnum.USER,
|
|
216
|
+
relation: relation_type_enum_1.RelationType.ONE,
|
|
217
|
+
key: "updatedByUser",
|
|
218
|
+
mapKeyConfig: {
|
|
219
|
+
relationKey: "id",
|
|
220
|
+
key: "updatedBy",
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
name: entity_utils_interface_1.EntityEnum.USER,
|
|
225
|
+
relation: relation_type_enum_1.RelationType.ONE,
|
|
226
|
+
key: "user",
|
|
227
|
+
mapKeyConfig: {
|
|
228
|
+
relationKey: "id",
|
|
229
|
+
key: "employeeId",
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DateCodeModel } from "../../utils";
|
|
2
|
+
import { 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 ILeaveCountVirtualEntity {
|
|
7
|
+
id: number;
|
|
8
|
+
period: string;
|
|
9
|
+
leaveId?: number;
|
|
10
|
+
count: number;
|
|
11
|
+
createdBy: number;
|
|
12
|
+
updatedBy: number;
|
|
13
|
+
createdOn: number;
|
|
14
|
+
updatedOn: number;
|
|
15
|
+
static fromEntity(entity: 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 = 0;
|
|
17
|
+
this.updatedOn = 0;
|
|
18
|
+
}
|
|
19
|
+
static fromEntity(entity) {
|
|
20
|
+
const result = new LeaveCountVirtualEntityModel(entity_utils_interface_1.VirtualEntityEnum.LEAVE_COUNT);
|
|
21
|
+
Object.assign(result, entity);
|
|
22
|
+
return result;
|
|
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.fromEntity(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 = [];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { LeaveActionEnum, LeaveStatusEnum } from "../entities";
|
|
2
|
+
export type LeaveStatusActionPair = {
|
|
3
|
+
status: LeaveStatusEnum;
|
|
4
|
+
action: LeaveActionEnum;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Gets available actions for a leave based on current status and user permissions
|
|
8
|
+
* @param entityFlowConfig - The flow configuration for the entity
|
|
9
|
+
* @param currentStatus - The current status of the leave
|
|
10
|
+
* @param userPermissions - Array of permissions the user has
|
|
11
|
+
* @param combineActions - Array of action values to combine into a single action
|
|
12
|
+
* @param actionLabels - Object mapping actions to custom labels
|
|
13
|
+
* @param data - Optional function to provide additional visibility conditions
|
|
14
|
+
* @returns Array of available actions with labels and values
|
|
15
|
+
*/
|
|
16
|
+
export declare function getPermittedActions<T extends LeaveStatusActionPair, E>(entityFlowConfig: {
|
|
17
|
+
[key in T["status"]]?: {
|
|
18
|
+
actions: {
|
|
19
|
+
[key in T["action"]]?: {
|
|
20
|
+
permissions: string[];
|
|
21
|
+
next: () => T["status"];
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}, currentStatus: T["status"] | null, userPermissions: string[], combineActions?: T["action"][], actionLabels?: {
|
|
26
|
+
[key in T["action"]]?: string;
|
|
27
|
+
}, data?: (a: E) => {
|
|
28
|
+
[key: string]: () => boolean;
|
|
29
|
+
}): {
|
|
30
|
+
label: string;
|
|
31
|
+
value: T["action"] | string;
|
|
32
|
+
}[];
|