@seniorsistemas/hcm-clocking-event-rule-nodejs 0.35.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/.github/copilot-instructions.md +11 -0
- package/.github/workflows/release.yaml +10 -0
- package/.gitlab-ci.yml +68 -0
- package/CHANGELOG.md +274 -0
- package/README.doc.md +658 -0
- package/README.md +117 -0
- package/assets/favicon.ico +0 -0
- package/catalog-info.yaml +19 -0
- package/jest.config.js +17 -0
- package/package.json +48 -0
- package/prompt.md +15 -0
- package/run_build_win.bat +1 -0
- package/run_link.bat +3 -0
- package/run_test.bat +1 -0
- package/sonar-project.properties +21 -0
- package/src/data/changes/changes.ts +92 -0
- package/src/data/context/context.ts +251 -0
- package/src/data/context/contextReference.ts +376 -0
- package/src/data/contract/contract.ts +272 -0
- package/src/data/dataset/database.ts +130 -0
- package/src/data/dataset/dataset.ts +275 -0
- package/src/data/definition/timeEvaluationSituationDefinitionHistory.ts +1425 -0
- package/src/data/employee/employee.ts +434 -0
- package/src/data/foundation/companyBranch.ts +66 -0
- package/src/data/foundation/costCenter.ts +47 -0
- package/src/data/foundation/employer.ts +35 -0
- package/src/data/foundation/employmentRelationship.ts +63 -0
- package/src/data/foundation/holiday.ts +84 -0
- package/src/data/foundation/holidayGroup.ts +47 -0
- package/src/data/foundation/jobPosition.ts +73 -0
- package/src/data/foundation/person.ts +35 -0
- package/src/data/foundation/situation.ts +301 -0
- package/src/data/foundation/syndicate.ts +244 -0
- package/src/data/foundation/workschedule.ts +688 -0
- package/src/data/foundation/workshift.ts +647 -0
- package/src/data/foundation/workshiftBase.ts +113 -0
- package/src/data/histories/companyBranchHistory.ts +128 -0
- package/src/data/histories/costCenterHistory.ts +114 -0
- package/src/data/histories/employmentRelationshipHistory.ts +116 -0
- package/src/data/histories/histories.ts +419 -0
- package/src/data/histories/jobPositionHistory.ts +117 -0
- package/src/data/histories/leaveHistory.ts +227 -0
- package/src/data/histories/timeEvaluationHistory.ts +191 -0
- package/src/data/histories/workshiftHistory.ts +66 -0
- package/src/data/hourBank/hourBank.ts +43 -0
- package/src/data/hourBank/hourBankAccount.ts +77 -0
- package/src/data/log/log.ts +38 -0
- package/src/data/schedules/bridge.ts +84 -0
- package/src/data/schedules/compensation.ts +332 -0
- package/src/data/schedules/overtimeAuthorization.ts +174 -0
- package/src/data/schedules/readiness.ts +150 -0
- package/src/data/schedules/schedules.ts +398 -0
- package/src/data/schedules/workscheduleChange.ts +91 -0
- package/src/data/schedules/workshiftChange.ts +76 -0
- package/src/data/timeEvaluation/adjustmentReason.ts +46 -0
- package/src/data/timeEvaluation/clockingEvent.ts +198 -0
- package/src/data/timeEvaluation/estimatedHours.ts +245 -0
- package/src/data/timeEvaluation/interval.ts +568 -0
- package/src/data/timeEvaluation/separatedHours.ts +134 -0
- package/src/data/timeEvaluation/timeEvaluation.ts +1540 -0
- package/src/data/timeEvaluation/timeEvaluationSituation.ts +154 -0
- package/src/data/user/user.ts +44 -0
- package/src/index.ts +60 -0
- package/src/test/builder/bridgeBuilder.builder.ts +28 -0
- package/src/test/builder/clockingEvent.builder.ts +49 -0
- package/src/test/builder/companyBranchHistoryBuilder.ts +29 -0
- package/src/test/builder/compensation.builder.ts +84 -0
- package/src/test/builder/contextReference.builder.ts +69 -0
- package/src/test/builder/costCenterHistoryBuilder.ts +29 -0
- package/src/test/builder/database.builder.ts +21 -0
- package/src/test/builder/datasetBuilder.ts +111 -0
- package/src/test/builder/dateIntervalBuilder.ts +25 -0
- package/src/test/builder/employee.builder.ts +91 -0
- package/src/test/builder/employmentRelationshipBuilder.ts +35 -0
- package/src/test/builder/employmentRelationshipHistoryBuilder.ts +29 -0
- package/src/test/builder/historiesBuilder.ts +56 -0
- package/src/test/builder/holiday.builder.ts +44 -0
- package/src/test/builder/hourBankAccountBuilder.ts +77 -0
- package/src/test/builder/hourBankBuilder.ts +32 -0
- package/src/test/builder/interval.builder.ts +113 -0
- package/src/test/builder/jobPositionHistoryBuilder.ts +29 -0
- package/src/test/builder/overtimeAuthorization.builder.ts +42 -0
- package/src/test/builder/readinessBuilder.builder.ts +57 -0
- package/src/test/builder/schedules.builder.ts +126 -0
- package/src/test/builder/situation.builder.ts +59 -0
- package/src/test/builder/syndicate.builder.ts +96 -0
- package/src/test/builder/syndicateHistoryBuilder.ts +33 -0
- package/src/test/builder/timeEvaluation.builder.ts +138 -0
- package/src/test/builder/timeEvaluationHistory.builder.ts +49 -0
- package/src/test/builder/timeEvaluationSituation.builder.ts +34 -0
- package/src/test/builder/workschedule.builder.ts +96 -0
- package/src/test/builder/workshift.builder.ts +179 -0
- package/src/test/builder/workshiftBuilder.ts +55 -0
- package/src/test/data/clockingEvent.spec.ts +56 -0
- package/src/test/data/context.spec.ts +176 -0
- package/src/test/data/currentUser.spec.ts +11 -0
- package/src/test/data/dataset.spec.ts +144 -0
- package/src/test/data/employee/employee.spec.ts +20 -0
- package/src/test/data/employmentRelationship/employmentRelationship.spec.ts +48 -0
- package/src/test/data/estimatedHours/estimatedHours.spec.ts +96 -0
- package/src/test/data/histories/costCenterHistory.spec.ts +32 -0
- package/src/test/data/histories/histories.spec.ts +306 -0
- package/src/test/data/holyday.spec.ts +89 -0
- package/src/test/data/hourBank/hourBank.spec.ts +48 -0
- package/src/test/data/hourBank/hourBankAccount.spec.ts +32 -0
- package/src/test/data/schedules/bridge.spec.ts +13 -0
- package/src/test/data/schedules/compesation.spect.ts +89 -0
- package/src/test/data/schedules/overtimeAuthorization.spec.ts +52 -0
- package/src/test/data/schedules/readiness.spec.ts +64 -0
- package/src/test/data/schedules/schedules.spec.ts +134 -0
- package/src/test/data/schedules/workscheduleChange.spec.ts +21 -0
- package/src/test/data/syndicate/syndicate.spec.ts +51 -0
- package/src/test/data/timeEvaluation.spec.ts +1057 -0
- package/src/test/data/timeEvaluationDefinition.spec.ts +144 -0
- package/src/test/data/workschedule/workschedule.spec.ts +194 -0
- package/src/test/data/workshift/workshift.spec.ts +79 -0
- package/src/test/utils/date.utils.spec.ts +198 -0
- package/src/test/utils/dateIntervalUtils.spec.ts +210 -0
- package/src/test/utils/object.utils.spec.ts +83 -0
- package/src/utils/dateIntervalUtils.ts +284 -0
- package/src/utils/dateUtils.ts +456 -0
- package/src/utils/decompressGzipLambda.ts +15 -0
- package/src/utils/object.utils.ts +156 -0
- package/trivy/vulnerabilities_scan.json +1160 -0
- package/tsconfig.json +32 -0
- package/tsconfig.spec.json +21 -0
- package/tslint.json +92 -0
- package/typedoc.json +22 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ObjectUtils } from "src/utils/object.utils";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @hidden
|
|
5
|
+
* Parâmetros para criar uma programação de Bridge.
|
|
6
|
+
* @param originDate Data de origem da ponte.
|
|
7
|
+
* @param destinationDate Data de destino da ponte.
|
|
8
|
+
* @typedef {Object} BridgeParams
|
|
9
|
+
*/
|
|
10
|
+
export interface BridgeParams {
|
|
11
|
+
originDate: Date;
|
|
12
|
+
destinationDate: Date;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Representa uma programação de ponte entre dois dias.
|
|
17
|
+
* Uma ponte é uma programação onde há a troca de horários entre um dia útil com um dia não trabalhado, um feriado, por exemplo.
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* bridge.originDate; // Retorna a data de origem da ponte.
|
|
21
|
+
* bridge.destinationDate; // Retorna a data de destino da ponte.
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export class Bridge {
|
|
25
|
+
/**
|
|
26
|
+
* Data de origem da ponte.
|
|
27
|
+
* @param originDate Data de origem da ponte.
|
|
28
|
+
*/
|
|
29
|
+
private readonly _originDate: Date;
|
|
30
|
+
/**
|
|
31
|
+
* Data de destino da ponte.
|
|
32
|
+
* @param destinationDate Data de destino da ponte.
|
|
33
|
+
*/
|
|
34
|
+
private readonly _destinationDate: Date;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @hidden
|
|
38
|
+
*/
|
|
39
|
+
constructor(params: BridgeParams) {
|
|
40
|
+
this._originDate = ObjectUtils.toDateOrThrow(params.originDate, "bridge.originDate");
|
|
41
|
+
this._destinationDate = ObjectUtils.toDateOrThrow(params.destinationDate, "bridge.destinationDate");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Data de origem da ponte.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* let originDate = bridge.originDate; // Retorna a data de origem da ponte.
|
|
50
|
+
* ```
|
|
51
|
+
* @returns Data de origem da ponte.
|
|
52
|
+
*/
|
|
53
|
+
get originDate(): Date {
|
|
54
|
+
return this._originDate;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Data de destino da ponte.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* let destinationDate = bridge.destinationDate; // Retorna a data de destino da ponte.
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @returns Data de destino da ponte.
|
|
66
|
+
*/
|
|
67
|
+
get destinationDate(): Date {
|
|
68
|
+
return this._destinationDate;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Clona a instância de Bridge.
|
|
73
|
+
*
|
|
74
|
+
* @returns Uma nova instância de Bridge com os mesmos valores de origem e destino.
|
|
75
|
+
*/
|
|
76
|
+
public static clone(object: Bridge): Bridge {
|
|
77
|
+
return new Bridge({
|
|
78
|
+
originDate: object.originDate,
|
|
79
|
+
destinationDate: object.destinationDate,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import { ObjectUtils } from "../../utils/object.utils";
|
|
2
|
+
import { Situation } from "../foundation/situation";
|
|
3
|
+
import { Workschedule } from "../foundation/workschedule";
|
|
4
|
+
import { ContextReference } from "../context/contextReference";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @hidden
|
|
9
|
+
* Parâmetros para criar uma programação de Compensation.
|
|
10
|
+
* @param startDate Data inicial da compensação.
|
|
11
|
+
* @param endDate Data final da compensação.
|
|
12
|
+
* @param intervalStart Hora inicial do intervalo de compensação.
|
|
13
|
+
* @param intervalEnd Hora final do intervalo de compensação.
|
|
14
|
+
* @param compensationType Tipo de compensação (ex: extra para compensação, ausência para compensação).
|
|
15
|
+
* @param periodType Tipo de período (ex: início e fim do expediente, qualquer parte do expediente).
|
|
16
|
+
* @param numberOfHours Número de horas a serem compensadas.
|
|
17
|
+
* @param situationId ID da situação da compensação.
|
|
18
|
+
* @param workscheduleId ID do horário de trabalho associado à compensação.
|
|
19
|
+
*
|
|
20
|
+
* @typedef {Object} CompensationParams
|
|
21
|
+
*/
|
|
22
|
+
export interface CompensationParams {
|
|
23
|
+
startDate: Date;
|
|
24
|
+
endDate: Date;
|
|
25
|
+
intervalStart: number;
|
|
26
|
+
intervalEnd: number;
|
|
27
|
+
compensationType: CompensationType;
|
|
28
|
+
periodType: PeriodType;
|
|
29
|
+
numberOfHours: number;
|
|
30
|
+
situationId: string;
|
|
31
|
+
workscheduleId: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Representa uma programação de compensação de horas.
|
|
36
|
+
* Uma compensação permite que o colaborador compense horas em um período específico.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* compensation.startDate; // Retorna a data inicial da compensação.
|
|
41
|
+
* compensation.endDate; // Retorna a data final da compensação.
|
|
42
|
+
* compensation.intervalStart; // Retorna a hora inicial do intervalo em minutos (0-1439).
|
|
43
|
+
* compensation.intervalEnd; // Retorna a hora final do intervalo em minutos (0-1439).
|
|
44
|
+
* compensation.compensationType; // Retorna o tipo de compensação (ex: extra para compensação, ausência para compensação).
|
|
45
|
+
* compensation.periodType; // Retorna o tipo de período (ex: início e fim do expediente, qualquer parte do expediente).
|
|
46
|
+
* compensation.numberOfHours; // Retorna o número de horas a serem compensadas.
|
|
47
|
+
* compensation.situation; // Retorna a situação da compensação.
|
|
48
|
+
* compensation.workschedule; // Retorna o horário associado à compensação.
|
|
49
|
+
* ```
|
|
50
|
+
* @see {@link CompensationType}
|
|
51
|
+
* @see {@link PeriodType}
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
|
+
export class Compensation {
|
|
55
|
+
private readonly _startDate: Date;
|
|
56
|
+
private readonly _endDate: Date;
|
|
57
|
+
private readonly _intervalStart: number;
|
|
58
|
+
private readonly _intervalEnd: number;
|
|
59
|
+
private readonly _compensationType: CompensationType;
|
|
60
|
+
private readonly _periodType: PeriodType;
|
|
61
|
+
private readonly _numberOfHours: number;
|
|
62
|
+
private readonly _situationId: string;
|
|
63
|
+
private readonly _workscheduleId: string;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @hidden
|
|
67
|
+
* Parâmetros para criar uma programação de compensação de horas.
|
|
68
|
+
*/
|
|
69
|
+
constructor(params: CompensationParams) {
|
|
70
|
+
this._startDate = ObjectUtils.toDateOrThrow(params.startDate, "compensation.startDate");
|
|
71
|
+
this._endDate = ObjectUtils.toDateOrThrow(params.endDate, "compensation.endDate");
|
|
72
|
+
this._intervalStart = params.intervalStart;
|
|
73
|
+
this._intervalEnd = params.intervalEnd;
|
|
74
|
+
this._compensationType = params.compensationType;
|
|
75
|
+
this._periodType = params.periodType;
|
|
76
|
+
this._numberOfHours = params.numberOfHours;
|
|
77
|
+
this._situationId = params.situationId;
|
|
78
|
+
this._workscheduleId = params.workscheduleId;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Data inicial da compensação.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* let startDate = compensation.startDate; // Retorna a data inicial da compensação.
|
|
87
|
+
* ```
|
|
88
|
+
* @returns Data inicial da compensação.
|
|
89
|
+
*/
|
|
90
|
+
get startDate(): Date {
|
|
91
|
+
return this._startDate;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Data final da compensação.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* let endDate = compensation.endDate; // Retorna a data final da compensação.
|
|
100
|
+
* ```
|
|
101
|
+
* @returns Data final da compensação.
|
|
102
|
+
*/
|
|
103
|
+
get endDate(): Date {
|
|
104
|
+
return this._endDate;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Hora inicial do intervalo de compensação em minutos (0-1439).
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* let startInterval = compensation.intervalStart; // Retorna a hora inicial do intervalo em minutos.
|
|
113
|
+
* ```
|
|
114
|
+
* @returns Hora inicial do intervalo em minutos se houver.
|
|
115
|
+
*/
|
|
116
|
+
get intervalStart(): number {
|
|
117
|
+
return this._intervalStart;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Hora final do intervalo de compensação em minutos (0-1439).
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* let endInterval = compensation.intervalEnd; // Retorna a hora final do intervalo.
|
|
126
|
+
* ```
|
|
127
|
+
* @returns Hora final do intervalo em minutos se houver.
|
|
128
|
+
*/
|
|
129
|
+
get intervalEnd(): number {
|
|
130
|
+
return this._intervalEnd;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Tipo de compensação.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* let type = compensation.compensationType; // Retorna o tipo de compensação.
|
|
139
|
+
* ```
|
|
140
|
+
* @returns Tipo de compensação.
|
|
141
|
+
* @see {@link CompensationType}
|
|
142
|
+
*/
|
|
143
|
+
get compensationType(): CompensationType {
|
|
144
|
+
return this._compensationType;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Tipo de período.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* let type = compensation.periodType; // Retorna o tipo de período.
|
|
153
|
+
* ```
|
|
154
|
+
* @returns Tipo de período.
|
|
155
|
+
* @see {@link PeriodType}
|
|
156
|
+
*/
|
|
157
|
+
get periodType(): PeriodType {
|
|
158
|
+
return this._periodType;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Número de horas a serem compensadas.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* let hours = compensation.numberOfHours; // Retorna o número de horas a serem compensadas.
|
|
167
|
+
* ```
|
|
168
|
+
* @returns Número de horas.
|
|
169
|
+
*/
|
|
170
|
+
get numberOfHours(): number {
|
|
171
|
+
return this._numberOfHours;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* @hidden
|
|
176
|
+
* ID da situação da compensação.
|
|
177
|
+
* @returns ID da situação.
|
|
178
|
+
*/
|
|
179
|
+
private get situationId(): string {
|
|
180
|
+
return this._situationId;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Obtém a situação associada à compensação.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* let situation = compensation.situation; // Retorna a situação associada à compensação.
|
|
189
|
+
* ```
|
|
190
|
+
* @returns Situação associada à compensação.
|
|
191
|
+
* @throws Se a situação não for encontrada no contexto.
|
|
192
|
+
*/
|
|
193
|
+
get situation(): Situation {
|
|
194
|
+
const situation = ContextReference.getGlobalInstance().getSituationById(this._situationId);
|
|
195
|
+
if (!situation) {
|
|
196
|
+
throw new Error(`Situation with id ${this._situationId} not found`);
|
|
197
|
+
}
|
|
198
|
+
return situation;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Obtém o horário de trabalho associado à compensação.
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* let workschedule = compensation.workschedule; // Retorna o horário de trabalho associado à compensação.
|
|
207
|
+
* ```
|
|
208
|
+
* @returns Horário de trabalho associado à compensação.
|
|
209
|
+
* @throws Se o horário de trabalho não for encontrado no contexto.
|
|
210
|
+
*/
|
|
211
|
+
get workschedule(): Workschedule | undefined {
|
|
212
|
+
const workschedule = ContextReference.getGlobalInstance().getWorkschedule(this._workscheduleId);
|
|
213
|
+
if (!workschedule && !!this.workscheduleId) {
|
|
214
|
+
throw new Error(`Workschedule with id ${this._workscheduleId} not found`);
|
|
215
|
+
}
|
|
216
|
+
return workschedule;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* @hidden
|
|
221
|
+
* ID do horário de trabalho associado à compensação.
|
|
222
|
+
* @returns ID do horário de trabalho.
|
|
223
|
+
*/
|
|
224
|
+
private get workscheduleId(): string {
|
|
225
|
+
return this._workscheduleId;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Data e hora inicial da programação, no formato de Date.
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```typescript
|
|
233
|
+
* let startDateTime = compensation.startDateTimeInterval; // Retorna a data e hora inicial da programação.
|
|
234
|
+
* startDateTime.toISOString(); // Formato ISO da data e hora, por exemplo: "2023-10-01T08:00:00.000Z".
|
|
235
|
+
* ```
|
|
236
|
+
* @returns Data e hora inicial da programação.
|
|
237
|
+
*/
|
|
238
|
+
get startDateTimeInterval(): Date {
|
|
239
|
+
const date = new Date(this._startDate);
|
|
240
|
+
date.setMinutes(this._intervalStart);
|
|
241
|
+
return date;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Data e hora final da programação, no formato de Date.
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* ```typescript
|
|
249
|
+
* let endDateTime = compensation.endDateTimeInterval; // Retorna a data e hora final da programação.
|
|
250
|
+
* endDateTime.toISOString(); // Formato ISO da data e hora, por exemplo: "2023-10-01T17:00:00.000Z".
|
|
251
|
+
* ```
|
|
252
|
+
* @returns Data e hora final da programação.
|
|
253
|
+
*/
|
|
254
|
+
get endDateTimeInterval(): Date {
|
|
255
|
+
const date = new Date(this._endDate);
|
|
256
|
+
date.setMinutes(this._intervalEnd);
|
|
257
|
+
return date;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
public static clone(compensation: Compensation): Compensation {
|
|
261
|
+
return new Compensation({
|
|
262
|
+
startDate: compensation.startDate,
|
|
263
|
+
endDate: compensation.endDate,
|
|
264
|
+
intervalStart: compensation.intervalStart,
|
|
265
|
+
intervalEnd: compensation.intervalEnd,
|
|
266
|
+
compensationType: compensation.compensationType,
|
|
267
|
+
periodType: compensation.periodType,
|
|
268
|
+
numberOfHours: compensation.numberOfHours,
|
|
269
|
+
situationId: compensation.situationId,
|
|
270
|
+
workscheduleId: compensation.workscheduleId
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Enumeração para os tipos de compensação.
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```typescript
|
|
279
|
+
* let type = CompensationType.OVERTIME_FOR_COMPENSATION; // Retorna o tipo de compensação para horas extras.
|
|
280
|
+
* ```
|
|
281
|
+
* @enum {string}
|
|
282
|
+
*/
|
|
283
|
+
export enum CompensationType {
|
|
284
|
+
/** Extra para compensação. */
|
|
285
|
+
OVERTIME_FOR_COMPENSATION = "OVERTIME_FOR_COMPENSATION",
|
|
286
|
+
|
|
287
|
+
/** Ausência para compensação. */
|
|
288
|
+
ABSENCE_FOR_COMPENSATION = "ABSENCE_FOR_COMPENSATION",
|
|
289
|
+
|
|
290
|
+
/** Dispensar parte expediente. */
|
|
291
|
+
RELEASE_PART_OF_WORKDAY = "RELEASE_PART_OF_WORKDAY",
|
|
292
|
+
|
|
293
|
+
/** Dispensar intervalo de horas. */
|
|
294
|
+
RELEASE_HOUR_INTERVAL = "RELEASE_HOUR_INTERVAL",
|
|
295
|
+
|
|
296
|
+
/** Intervalo fora expediente. */
|
|
297
|
+
INTERVAL_OUTSIDE_WORKDAY = "INTERVAL_OUTSIDE_WORKDAY"
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Enumeração para o período de compensação.
|
|
302
|
+
*
|
|
303
|
+
* @enum {string}
|
|
304
|
+
*/
|
|
305
|
+
export enum PeriodType {
|
|
306
|
+
/** Qualquer parte do expediente. */
|
|
307
|
+
ANY_PART_OF_WORKDAY = "ANY_PART_OF_WORKDAY",
|
|
308
|
+
|
|
309
|
+
/** Início e fim do expediente. */
|
|
310
|
+
START_AND_END_OF_WORKDAY = "START_AND_END_OF_WORKDAY",
|
|
311
|
+
|
|
312
|
+
/** Durante intervalos de refeição. */
|
|
313
|
+
DURING_MEAL_BREAKS = "DURING_MEAL_BREAKS",
|
|
314
|
+
|
|
315
|
+
/** Início do expediente. */
|
|
316
|
+
START_OF_WORKDAY = "START_OF_WORKDAY",
|
|
317
|
+
|
|
318
|
+
/** Fim do expediente. */
|
|
319
|
+
END_OF_WORKDAY = "END_OF_WORKDAY",
|
|
320
|
+
|
|
321
|
+
/** Início do expediente antecipando horário. */
|
|
322
|
+
START_OF_WORKDAY_ANTICIPATING_TIME = "START_OF_WORKDAY_ANTICIPATING_TIME",
|
|
323
|
+
|
|
324
|
+
/** Fim do expediente prorrogando horário. */
|
|
325
|
+
END_OF_WORKDAY_EXTENDING_TIME = "END_OF_WORKDAY_EXTENDING_TIME",
|
|
326
|
+
|
|
327
|
+
/** Dispensar 1ª parte do expediente. */
|
|
328
|
+
DISMISS_FIRST_PART_OF_WORKDAY = "DISMISS_FIRST_PART_OF_WORKDAY",
|
|
329
|
+
|
|
330
|
+
/** Dispensar 2ª parte do expediente. */
|
|
331
|
+
DISMISS_SECOND_PART_OF_WORKDAY = "DISMISS_SECOND_PART_OF_WORKDAY"
|
|
332
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { ObjectUtils } from "src/utils/object.utils";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @hidden
|
|
5
|
+
* Parâmetros para criar uma OvertimeAuthorization.
|
|
6
|
+
* @param startDate Data inicial.
|
|
7
|
+
* @param endDate Data final.
|
|
8
|
+
* @param startTime Hora inicial.
|
|
9
|
+
* @param endTime Hora final.
|
|
10
|
+
* @typedef {Object} OvertimeAuthorizationParams
|
|
11
|
+
*/
|
|
12
|
+
export interface OvertimeAuthorizationParams {
|
|
13
|
+
startDate: Date;
|
|
14
|
+
endDate: Date;
|
|
15
|
+
startTime: number;
|
|
16
|
+
endTime: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Representa uma programação de autorização de horas extras.
|
|
21
|
+
* Programação utilizada quando as normas da empresa estabelecem que as horas extras necessitam ser
|
|
22
|
+
* autorizadas por algum nível de chefia da empresa.
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* overtimeAuthorization.startDate; // Retorna a data inicial da programação.
|
|
26
|
+
* overtimeAuthorization.startTime; // Retorna a hora inicial da programação.
|
|
27
|
+
* overtimeAuthorization.endDate; // Retorna a data final da programação.
|
|
28
|
+
* overtimeAuthorization.endTime; // Retorna a hora final da programação.
|
|
29
|
+
* overtimeAuthorization.startDateTime; // Retorna a data e hora inicial da programação, no formado de Date.
|
|
30
|
+
* overtimeAuthorization.endDateTime; // Retorna a data e hora final da programação ou null se não houver data final, no formado de Date.
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export class OvertimeAuthorization {
|
|
34
|
+
/**
|
|
35
|
+
* Data inicial da programação de autorização de horas extras.
|
|
36
|
+
* @param startDate Data inicial.
|
|
37
|
+
*/
|
|
38
|
+
private readonly _startDate: Date;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Data final da programação de autorização de horas extras.
|
|
42
|
+
* @param endDate Data final.
|
|
43
|
+
*/
|
|
44
|
+
private readonly _endDate: Date;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Hora inicial da programação de autorização de horas extras.
|
|
48
|
+
* @param startTime Hora inicial.
|
|
49
|
+
*/
|
|
50
|
+
private readonly _startTime: number;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Hora final da programação de autorização de horas extras.
|
|
54
|
+
* @param endTime Hora final.
|
|
55
|
+
*/
|
|
56
|
+
private readonly _endTime: number;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @hidden
|
|
60
|
+
*/
|
|
61
|
+
constructor(params: OvertimeAuthorizationParams) {
|
|
62
|
+
this._startDate = ObjectUtils.toDateOrThrow(params.startDate, "overtimeAuthorization.startDate");
|
|
63
|
+
this._endDate = ObjectUtils.toDateOrThrow(params.endDate, "overtimeAuthorization.endDate");
|
|
64
|
+
this._startTime = params.startTime;
|
|
65
|
+
this._endTime = params.endTime;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Data inicial da programação.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* let startDate = overtimeAuthorization.startDate; // Retorna a data inicial da programação.
|
|
74
|
+
* ```
|
|
75
|
+
* @returns Data inicial da programação.
|
|
76
|
+
*/
|
|
77
|
+
get startDate(): Date {
|
|
78
|
+
return this._startDate;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Data final da programação.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* let endDate = overtimeAuthorization.endDate; // Retorna a data final da programação.
|
|
87
|
+
* ```
|
|
88
|
+
* @returns Data final da programação.
|
|
89
|
+
*/
|
|
90
|
+
get endDate(): Date {
|
|
91
|
+
return this._endDate;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Hora inicial da programação.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* let startTime = overtimeAuthorization.startTime; // Retorna a hora inicial da programação.
|
|
100
|
+
* ```
|
|
101
|
+
* @returns Hora inicial da programação.
|
|
102
|
+
*/
|
|
103
|
+
get startTime(): number {
|
|
104
|
+
return this._startTime;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Hora final da programação.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* let endTime = overtimeAuthorization.endTime; // Retorna a hora final da programação.
|
|
113
|
+
* ```
|
|
114
|
+
* @returns Hora final da programação.
|
|
115
|
+
*/
|
|
116
|
+
get endTime(): number {
|
|
117
|
+
return this._endTime;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Data e hora inicial da programação, no formato de Date.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* let startDateTime = overtimeAuthorization.startDateTime; // Retorna a data e hora inicial da programação.
|
|
126
|
+
* startDateTime.toISOString(); // Formato ISO da data e hora, por exemplo: "2023-10-01T08:00:00.000Z".
|
|
127
|
+
* ```
|
|
128
|
+
* @returns Data e hora inicial da programação.
|
|
129
|
+
*/
|
|
130
|
+
get startDateTime(): Date {
|
|
131
|
+
const date = new Date(this._startDate);
|
|
132
|
+
date.setMinutes(this._startTime);
|
|
133
|
+
return date;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Data e hora final da programação, no formato de Date.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```typescript
|
|
141
|
+
* let endDateTime = overtimeAuthorization.endDateTime; // Retorna a data e hora final da programação.
|
|
142
|
+
* endDateTime.toISOString(); // Formato ISO da data e hora, por exemplo: "2023-10-01T17:00:00.000Z"
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* @returns Data e hora final da programação.
|
|
146
|
+
*/
|
|
147
|
+
get endDateTime(): Date | null {
|
|
148
|
+
if (this._endDate === null) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
const date = new Date(this._endDate);
|
|
152
|
+
date.setMinutes(this._endTime);
|
|
153
|
+
return date;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Clona a programação de autorização de horas extras.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```typescript
|
|
161
|
+
* let clonedAuthorization = OvertimeAuthorization.clone(overtimeAuthorization);
|
|
162
|
+
* ```
|
|
163
|
+
* @returns Uma nova instância da programação de autorização de horas extras.
|
|
164
|
+
*/
|
|
165
|
+
static clone(overtimeAuthorization: OvertimeAuthorization): OvertimeAuthorization {
|
|
166
|
+
return new OvertimeAuthorization({
|
|
167
|
+
startDate: overtimeAuthorization.startDate,
|
|
168
|
+
endDate: overtimeAuthorization.endDate,
|
|
169
|
+
startTime: overtimeAuthorization.startTime,
|
|
170
|
+
endTime: overtimeAuthorization.endTime
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|