law-common 10.26.1-beta.1 → 10.26.1-beta.11
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/index.d.ts +0 -11
- package/dist/src/api/index.js +0 -12
- package/dist/src/api/interface/billing.entity.response.d.ts +2 -3
- 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 +25 -4
- package/dist/src/api/interface/billing.transaction.update.dto.interface.d.ts +13 -2
- package/dist/src/api/interface/leave.api.d.ts +1 -3
- package/dist/src/api/interface/reimbursement.entity.response.d.ts +3 -6
- 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/func/convert-to-common-entity.func.js +8 -2
- package/dist/src/entities/index.d.ts +5 -0
- package/dist/src/entities/index.js +5 -0
- package/dist/src/entities/interface/billing-reimbursement-expense.entity.interface.d.ts +2 -2
- package/dist/src/entities/interface/billing-transaction-history.entity.d.ts +7 -0
- package/dist/src/entities/interface/billing.entity.interface.d.ts +1 -0
- package/dist/src/entities/interface/billing_payment.entity.interface.d.ts +2 -2
- package/dist/src/entities/interface/billing_transaction.entity.interface.d.ts +9 -2
- package/dist/src/entities/interface/entity.utils.interface.d.ts +20 -10
- package/dist/src/entities/interface/entity.utils.interface.js +2 -1
- package/dist/src/entities/interface/leave.entity.interface.d.ts +3 -11
- package/dist/src/entities/interface/leave.entity.interface.js +1 -1
- package/dist/src/entities/interface/reimbursement.entity.interface.d.ts +2 -2
- package/dist/src/entities/interface/reimbursement_expense.entity.interface.d.ts +2 -2
- 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 +5 -5
- package/dist/src/entities/model/billing-reimbursement-expense.entity.model.js +6 -6
- 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 +11 -1
- package/dist/src/entities/model/entity.model.interface.d.ts +12 -1
- package/dist/src/entities/model/entity.model.interface.js +48 -4
- 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 +54 -7
- package/dist/src/entities/model/leave.entity.model.js +171 -23
- 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/entities/model/reimbursement-expense.entity.model.d.ts +5 -5
- package/dist/src/entities/model/reimbursement-expense.entity.model.js +3 -3
- package/dist/src/entities/model/reimbursement.entity.model.d.ts +5 -5
- package/dist/src/entities/model/reimbursement.entity.model.js +6 -6
- 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/api/interface/bank_history.api.d.ts +0 -3
- package/dist/src/api/interface/billing-reimbursement-expense-history.api.d.ts +0 -4
- package/dist/src/api/interface/billing-reimbursement-expense-history.api.js +0 -2
- package/dist/src/api/interface/billing-reimbursement-expense.api.d.ts +0 -3
- package/dist/src/api/interface/billing-reimbursement-expense.api.js +0 -2
- package/dist/src/api/interface/billing.history.api.d.ts +0 -3
- package/dist/src/api/interface/billing.history.api.js +0 -2
- package/dist/src/api/interface/billing.payment.entity.api.d.ts +0 -3
- package/dist/src/api/interface/billing.payment.entity.api.js +0 -2
- package/dist/src/api/interface/billing_timesheet_history.api.d.ts +0 -3
- package/dist/src/api/interface/billing_timesheet_history.api.js +0 -2
- package/dist/src/api/interface/leave_history.api.d.ts +0 -3
- package/dist/src/api/interface/leave_history.api.js +0 -2
- package/dist/src/api/interface/reimbursement_expense.api.d.ts +0 -3
- package/dist/src/api/interface/reimbursement_expense.api.js +0 -2
- package/dist/src/api/interface/reimbursement_history.api.d.ts +0 -3
- package/dist/src/api/interface/reimbursement_history.api.js +0 -2
- package/dist/src/api/interface/timesheet.history.api.d.ts +0 -3
- package/dist/src/api/interface/timesheet.history.api.js +0 -2
- package/dist/src/api/interface/work_from_home_history.api.d.ts +0 -4
- package/dist/src/api/interface/work_from_home_history.api.js +0 -2
- /package/dist/src/{api/interface/bank_history.api.js → entities/interface/billing-transaction-history.entity.js} +0 -0
|
@@ -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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
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;
|
|
23
|
+
this.createdOn = 0;
|
|
24
|
+
this.updatedOn = 0;
|
|
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 = [];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { IReimbursementExpenseApiEntity } from "../../api";
|
|
2
1
|
import { ReimbursementExpenseState } from "../enums/reimbursement.entity.enum";
|
|
3
2
|
import { EntityEnum, EnumEntityType } from "../interface/entity.utils.interface";
|
|
3
|
+
import { IReimbursementExpenseEntity } from "../interface/reimbursement_expense.entity.interface";
|
|
4
4
|
import { RelationConfigs } from "../interface/relation-config.interface";
|
|
5
5
|
import { BaseEntityModel } from "./base.entity.model";
|
|
6
6
|
import { ReimbursementEntityModel } from "./reimbursement.entity.model";
|
|
7
|
-
export declare class ReimbursementExpenseEntityModel extends BaseEntityModel<EntityEnum.REIMBURSEMENT_EXPENSE> implements
|
|
7
|
+
export declare class ReimbursementExpenseEntityModel extends BaseEntityModel<EntityEnum.REIMBURSEMENT_EXPENSE> implements IReimbursementExpenseEntity {
|
|
8
8
|
id: number;
|
|
9
9
|
reimbursementId: number;
|
|
10
10
|
userId: number;
|
|
@@ -16,10 +16,10 @@ export declare class ReimbursementExpenseEntityModel extends BaseEntityModel<Ent
|
|
|
16
16
|
sanctionedBy?: number;
|
|
17
17
|
createdBy: number;
|
|
18
18
|
updatedBy: number;
|
|
19
|
-
createdOn:
|
|
20
|
-
updatedOn:
|
|
19
|
+
createdOn: number;
|
|
20
|
+
updatedOn: number;
|
|
21
21
|
reimbursement?: ReimbursementEntityModel;
|
|
22
|
-
static
|
|
22
|
+
static fromEntity(apiEntity: IReimbursementExpenseEntity): ReimbursementExpenseEntityModel;
|
|
23
23
|
static relationConfigs: RelationConfigs<[
|
|
24
24
|
EntityEnum.REIMBURSEMENT
|
|
25
25
|
], EnumEntityType<EntityEnum.REIMBURSEMENT_EXPENSE>>;
|
|
@@ -17,10 +17,10 @@ class ReimbursementExpenseEntityModel extends base_entity_model_1.BaseEntityMode
|
|
|
17
17
|
this.state = reimbursement_entity_enum_1.ReimbursementExpenseState.PENDING;
|
|
18
18
|
this.createdBy = 0;
|
|
19
19
|
this.updatedBy = 0;
|
|
20
|
-
this.createdOn =
|
|
21
|
-
this.updatedOn =
|
|
20
|
+
this.createdOn = 0;
|
|
21
|
+
this.updatedOn = 0;
|
|
22
22
|
}
|
|
23
|
-
static
|
|
23
|
+
static fromEntity(apiEntity) {
|
|
24
24
|
const entity = new ReimbursementExpenseEntityModel(entity_utils_interface_1.EntityEnum.REIMBURSEMENT_EXPENSE);
|
|
25
25
|
Object.assign(entity, apiEntity);
|
|
26
26
|
return entity;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { IReimbursementApiEntity } from "../../api";
|
|
2
1
|
import { ReimbursementBillingPresentEnum, ReimbursementBillingTypeEnum, ReimbursementIncurredByEnum, ReimbursementPaymentStatusEnum, ReimbursementStatusEnum } from "../enums/reimbursement.entity.enum";
|
|
3
2
|
import { EntityEnum } from "../interface/entity.utils.interface";
|
|
3
|
+
import { IReimbursementEntity } from "../interface/reimbursement.entity.interface";
|
|
4
4
|
import { BaseEntityModel } from "./base.entity.model";
|
|
5
|
-
export declare class ReimbursementEntityModel extends BaseEntityModel<EntityEnum.REIMBURSEMENT> implements
|
|
5
|
+
export declare class ReimbursementEntityModel extends BaseEntityModel<EntityEnum.REIMBURSEMENT> implements IReimbursementEntity {
|
|
6
6
|
id: number;
|
|
7
7
|
billingType: ReimbursementBillingTypeEnum;
|
|
8
8
|
billDate: string;
|
|
@@ -24,9 +24,9 @@ export declare class ReimbursementEntityModel extends BaseEntityModel<EntityEnum
|
|
|
24
24
|
bankId?: number;
|
|
25
25
|
createdBy: number;
|
|
26
26
|
updatedBy: number;
|
|
27
|
-
createdOn:
|
|
28
|
-
updatedOn:
|
|
27
|
+
createdOn: number;
|
|
28
|
+
updatedOn: number;
|
|
29
29
|
static relationConfigs: never[];
|
|
30
30
|
getRelationConfigs(): any[];
|
|
31
|
-
static
|
|
31
|
+
static fromEntity(entity: IReimbursementEntity): ReimbursementEntityModel;
|
|
32
32
|
}
|
|
@@ -18,16 +18,16 @@ class ReimbursementEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
18
18
|
this.paymentStatus = reimbursement_entity_enum_1.ReimbursementPaymentStatusEnum.UNPAID;
|
|
19
19
|
this.createdBy = 0;
|
|
20
20
|
this.updatedBy = 0;
|
|
21
|
-
this.createdOn =
|
|
22
|
-
this.updatedOn =
|
|
21
|
+
this.createdOn = 0;
|
|
22
|
+
this.updatedOn = 0;
|
|
23
23
|
}
|
|
24
24
|
getRelationConfigs() {
|
|
25
25
|
return this.constructor.prototype.constructor.relationConfigs || [];
|
|
26
26
|
}
|
|
27
|
-
static
|
|
28
|
-
const
|
|
29
|
-
Object.assign(
|
|
30
|
-
return
|
|
27
|
+
static fromEntity(entity) {
|
|
28
|
+
const result = new ReimbursementEntityModel(entity_utils_interface_1.EntityEnum.REIMBURSEMENT);
|
|
29
|
+
Object.assign(result, entity);
|
|
30
|
+
return result;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
exports.ReimbursementEntityModel = ReimbursementEntityModel;
|
|
@@ -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
|
+
}[];
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPermittedActions = getPermittedActions;
|
|
4
|
+
/**
|
|
5
|
+
* Converts an action or combined action to a value-label pair
|
|
6
|
+
* @param action - The action or combined action key
|
|
7
|
+
* @param actionLabels - Object mapping actions to custom labels
|
|
8
|
+
* @returns Object with label and value
|
|
9
|
+
*/
|
|
10
|
+
function convertToValueLabel(action, actionLabels) {
|
|
11
|
+
return {
|
|
12
|
+
label: actionLabels[action] || action,
|
|
13
|
+
value: action,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Filters actions based on user permissions and visibility conditions
|
|
18
|
+
* @param actionConfig - The actions configuration for the current status
|
|
19
|
+
* @param userPermissions - Array of permissions the user has
|
|
20
|
+
* @param data - Optional function to provide additional visibility conditions
|
|
21
|
+
* @returns Array of permitted action keys
|
|
22
|
+
* @throws Error if multiple permissions are found for a single action
|
|
23
|
+
*/
|
|
24
|
+
function _getPermittedActions(actionConfig, userPermissions, data) {
|
|
25
|
+
return Object.entries(actionConfig)
|
|
26
|
+
.filter(([actionKey, config]) => {
|
|
27
|
+
var _a;
|
|
28
|
+
const actionRequiredPermissions = (_a = config === null || config === void 0 ? void 0 : config.permissions) !== null && _a !== void 0 ? _a : [];
|
|
29
|
+
const matchingPermissions = actionRequiredPermissions.filter((permission) => userPermissions.includes(permission));
|
|
30
|
+
if (matchingPermissions.length > 1) {
|
|
31
|
+
throw new Error(`Multiple permissions found for action ${actionKey}: ${matchingPermissions.join(", ")}`);
|
|
32
|
+
}
|
|
33
|
+
return (matchingPermissions.length > 0 &&
|
|
34
|
+
(!data ||
|
|
35
|
+
!data({})[matchingPermissions[0]] ||
|
|
36
|
+
data({})[matchingPermissions[0]]()));
|
|
37
|
+
})
|
|
38
|
+
.map(([actionKey, _]) => actionKey);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Combines specified actions into a single action if all are present
|
|
42
|
+
* @param permittedActions - Array of permitted action keys
|
|
43
|
+
* @param combineActions - Array of actions to combine
|
|
44
|
+
* @returns Array of action keys, with combined action if applicable
|
|
45
|
+
*/
|
|
46
|
+
function combinePermittedActions(permittedActions, combineActions) {
|
|
47
|
+
if (combineActions.length === 0) {
|
|
48
|
+
return permittedActions;
|
|
49
|
+
}
|
|
50
|
+
const isCombinedActionPresent = combineActions.every((action) => permittedActions.includes(action));
|
|
51
|
+
if (isCombinedActionPresent) {
|
|
52
|
+
const combinedValue = combineActions.join("_");
|
|
53
|
+
return [
|
|
54
|
+
...permittedActions.filter((action) => !combineActions.includes(action)),
|
|
55
|
+
combinedValue,
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
return permittedActions;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Gets available actions for a leave based on current status and user permissions
|
|
62
|
+
* @param entityFlowConfig - The flow configuration for the entity
|
|
63
|
+
* @param currentStatus - The current status of the leave
|
|
64
|
+
* @param userPermissions - Array of permissions the user has
|
|
65
|
+
* @param combineActions - Array of action values to combine into a single action
|
|
66
|
+
* @param actionLabels - Object mapping actions to custom labels
|
|
67
|
+
* @param data - Optional function to provide additional visibility conditions
|
|
68
|
+
* @returns Array of available actions with labels and values
|
|
69
|
+
*/
|
|
70
|
+
function getPermittedActions(entityFlowConfig, currentStatus, userPermissions, combineActions = [], actionLabels = {}, data = (_) => ({})) {
|
|
71
|
+
var _a;
|
|
72
|
+
// Handle invalid inputs
|
|
73
|
+
if (!currentStatus || !entityFlowConfig[currentStatus]) {
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
const actionConfig = ((_a = entityFlowConfig[currentStatus]) === null || _a === void 0 ? void 0 : _a.actions) || {};
|
|
77
|
+
// Get permitted actions
|
|
78
|
+
const permittedActions = _getPermittedActions(actionConfig, userPermissions, data);
|
|
79
|
+
// Combine actions if specified
|
|
80
|
+
const finalActions = combinePermittedActions(permittedActions, combineActions);
|
|
81
|
+
// Convert to value-label pairs
|
|
82
|
+
return finalActions.map((action) => convertToValueLabel(action, actionLabels));
|
|
83
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EntityEnum, EnumEntityType, IBaseEntityServiceResponse, IEntityFilterData } from "../entities";
|
|
1
|
+
import { EntityEnum, EnumEntityType, IBaseEntityServiceResponse, IEntityFilterData, IEntityServiceResponse } from "../entities";
|
|
2
2
|
import { Modify } from "../misc";
|
|
3
3
|
export declare function groupByFunction<T, K>(list: T[], keyGetter: (input: T) => K): Map<K, T[]>;
|
|
4
4
|
export declare function groupByOneToOneFunction<T, K>(list: T[], keyGetter: (input: T) => K): Map<K, T>;
|
|
@@ -176,6 +176,42 @@ export declare function transformDate<T extends {
|
|
|
176
176
|
export declare function capitalizeFirstWord(str: string): string;
|
|
177
177
|
export declare function getEntitiesFromSearchV2Response<E extends EntityEnum, // Enum key like EntityEnum.USER, EntityEnum.PROJECT, etc.
|
|
178
178
|
T extends EnumEntityType<E>>(searchResponseV2: IBaseEntityServiceResponse<EnumEntityType<EntityEnum>>, entityEnumKey: E, EntityClass: new () => T): T[];
|
|
179
|
+
/**
|
|
180
|
+
* Recursively searches for entities of a specific type within a nested `relatedEntities` structure.
|
|
181
|
+
*
|
|
182
|
+
* This function traverses the `relatedEntities` tree, looking for a target entity key.
|
|
183
|
+
* When found, it collects all `baseEntities` for that key and instantiates them
|
|
184
|
+
* as instances of the provided `EntityClass`. The function continues to traverse
|
|
185
|
+
* all nested `relatedEntities` recursively, accumulating all matches.
|
|
186
|
+
*
|
|
187
|
+
* @template E - The enum type representing the target entity key (`EntityEnum`).
|
|
188
|
+
* @template T - The corresponding entity type for the target key (`EnumEntityType<E>`).
|
|
189
|
+
*
|
|
190
|
+
* @param relatedEntities - The nested `relatedEntities` structure, typically from a
|
|
191
|
+
* `IBaseEntityServiceResponse`. Can be undefined, in which case an empty array is returned.
|
|
192
|
+
* @param targetKey - The entity key (`EntityEnum`) to search for in the nested structure.
|
|
193
|
+
* @param EntityClass - A constructor function for the entity type `T`. Used to
|
|
194
|
+
* instantiate new objects from the raw base entity data.
|
|
195
|
+
*
|
|
196
|
+
* @returns An array of entities of type `T` found at any level of the nested structure.
|
|
197
|
+
* If no entities are found, an empty array is returned.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* const billingEntities = findEntitiesAtAnyLevel(
|
|
202
|
+
* projectUserMappingsOfCurrentUser.relatedEntities,
|
|
203
|
+
* EntityEnum.BILLING,
|
|
204
|
+
* BillingEntity
|
|
205
|
+
* );
|
|
206
|
+
*
|
|
207
|
+
* console.log(billingEntities); // [BillingEntity {...}, BillingEntity {...}]
|
|
208
|
+
* ```
|
|
209
|
+
*
|
|
210
|
+
* @note
|
|
211
|
+
* - This function preserves the type of entities by mapping the raw objects to the provided `EntityClass`.
|
|
212
|
+
* - It can handle deeply nested `relatedEntities` structures.
|
|
213
|
+
*/
|
|
214
|
+
export declare function findEntitiesFromSearchV2RelatedEntities<E extends EntityEnum, T extends EnumEntityType<E>>(relatedEntities: IEntityServiceResponse | undefined, targetKey: EntityEnum, EntityClass: new () => T): T[];
|
|
179
215
|
/**
|
|
180
216
|
* Checks if two decimal numbers are approximately equal within a given tolerance.
|
|
181
217
|
*
|
|
@@ -33,6 +33,7 @@ exports.createKeyLabelMap = createKeyLabelMap;
|
|
|
33
33
|
exports.transformDate = transformDate;
|
|
34
34
|
exports.capitalizeFirstWord = capitalizeFirstWord;
|
|
35
35
|
exports.getEntitiesFromSearchV2Response = getEntitiesFromSearchV2Response;
|
|
36
|
+
exports.findEntitiesFromSearchV2RelatedEntities = findEntitiesFromSearchV2RelatedEntities;
|
|
36
37
|
exports.areDecimalNumbersEqual = areDecimalNumbersEqual;
|
|
37
38
|
exports.formatIndianNumber = formatIndianNumber;
|
|
38
39
|
exports.findDuplicateIds = findDuplicateIds;
|
|
@@ -403,6 +404,58 @@ function getEntitiesFromSearchV2Response(searchResponseV2, entityEnumKey, Entity
|
|
|
403
404
|
}
|
|
404
405
|
return (((_a = searchResponseV2.relatedEntities[entityEnumKey]) === null || _a === void 0 ? void 0 : _a.baseEntities) || []).map((entity) => Object.assign(new EntityClass(), entity));
|
|
405
406
|
}
|
|
407
|
+
/**
|
|
408
|
+
* Recursively searches for entities of a specific type within a nested `relatedEntities` structure.
|
|
409
|
+
*
|
|
410
|
+
* This function traverses the `relatedEntities` tree, looking for a target entity key.
|
|
411
|
+
* When found, it collects all `baseEntities` for that key and instantiates them
|
|
412
|
+
* as instances of the provided `EntityClass`. The function continues to traverse
|
|
413
|
+
* all nested `relatedEntities` recursively, accumulating all matches.
|
|
414
|
+
*
|
|
415
|
+
* @template E - The enum type representing the target entity key (`EntityEnum`).
|
|
416
|
+
* @template T - The corresponding entity type for the target key (`EnumEntityType<E>`).
|
|
417
|
+
*
|
|
418
|
+
* @param relatedEntities - The nested `relatedEntities` structure, typically from a
|
|
419
|
+
* `IBaseEntityServiceResponse`. Can be undefined, in which case an empty array is returned.
|
|
420
|
+
* @param targetKey - The entity key (`EntityEnum`) to search for in the nested structure.
|
|
421
|
+
* @param EntityClass - A constructor function for the entity type `T`. Used to
|
|
422
|
+
* instantiate new objects from the raw base entity data.
|
|
423
|
+
*
|
|
424
|
+
* @returns An array of entities of type `T` found at any level of the nested structure.
|
|
425
|
+
* If no entities are found, an empty array is returned.
|
|
426
|
+
*
|
|
427
|
+
* @example
|
|
428
|
+
* ```ts
|
|
429
|
+
* const billingEntities = findEntitiesAtAnyLevel(
|
|
430
|
+
* projectUserMappingsOfCurrentUser.relatedEntities,
|
|
431
|
+
* EntityEnum.BILLING,
|
|
432
|
+
* BillingEntity
|
|
433
|
+
* );
|
|
434
|
+
*
|
|
435
|
+
* console.log(billingEntities); // [BillingEntity {...}, BillingEntity {...}]
|
|
436
|
+
* ```
|
|
437
|
+
*
|
|
438
|
+
* @note
|
|
439
|
+
* - This function preserves the type of entities by mapping the raw objects to the provided `EntityClass`.
|
|
440
|
+
* - It can handle deeply nested `relatedEntities` structures.
|
|
441
|
+
*/
|
|
442
|
+
function findEntitiesFromSearchV2RelatedEntities(relatedEntities, targetKey, EntityClass) {
|
|
443
|
+
if (!relatedEntities)
|
|
444
|
+
return [];
|
|
445
|
+
let result = [];
|
|
446
|
+
for (const key of Object.keys(relatedEntities)) {
|
|
447
|
+
const value = relatedEntities[key];
|
|
448
|
+
// If this key is the target and has baseEntities
|
|
449
|
+
if (key === targetKey && (value === null || value === void 0 ? void 0 : value.baseEntities)) {
|
|
450
|
+
result.push(...value.baseEntities.map((entity) => Object.assign(new EntityClass(), entity)));
|
|
451
|
+
}
|
|
452
|
+
// If value has relatedEntities, recurse
|
|
453
|
+
if (value === null || value === void 0 ? void 0 : value.relatedEntities) {
|
|
454
|
+
result.push(...findEntitiesFromSearchV2RelatedEntities(value.relatedEntities, targetKey, EntityClass));
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return result;
|
|
458
|
+
}
|
|
406
459
|
/**
|
|
407
460
|
* Checks if two decimal numbers are approximately equal within a given tolerance.
|
|
408
461
|
*
|
package/dist/src/utils/index.js
CHANGED
|
@@ -17,3 +17,5 @@ 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);
|
|
21
|
+
__exportStar(require("./entity.flow.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
|
+
}
|
package/package.json
CHANGED