@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,227 @@
|
|
|
1
|
+
import { ObjectUtils } from "../../utils/object.utils";
|
|
2
|
+
import { ContextReference } from "../context/contextReference";
|
|
3
|
+
import { Situation } from "../foundation/situation";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @hidden
|
|
7
|
+
* Parâmetros necessários para criar uma instância de LeaveHistory.
|
|
8
|
+
*/
|
|
9
|
+
export interface LeaveHistoryParams {
|
|
10
|
+
startDate: Date;
|
|
11
|
+
endDate: Date | null;
|
|
12
|
+
startTime: number;
|
|
13
|
+
timeEvaluationStartDate: Date | null;
|
|
14
|
+
timeEvaluationEndDate: Date | null;
|
|
15
|
+
endTime: number;
|
|
16
|
+
situationId: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Representa um histórico de afastamento.
|
|
21
|
+
* O histórico de afastamento é utilizado para verificar o afastamento do colaborador em uma data específica.
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* leaveHistory.startDate; // Retorna a data inicial do histórico de afastamento.
|
|
25
|
+
* leaveHistory.endDate; // Retorna a data final do histórico de afastamento ou null se não estiver definida.
|
|
26
|
+
* leaveHistory.startTime; // Retorna a hora inicial do afastamento em minutos desde a meia-noite (08:00 = 480 min).
|
|
27
|
+
* leaveHistory.endTime; // Retorna a hora final do afastamento em minutos desde a meia-noite (08:00 = 480 min).
|
|
28
|
+
* leaveHistory.timeEvaluationStartDate; // Retorna a data inicial da apuração do afastamento ou null se o afastamento não foi aplicado ao dia apurado.
|
|
29
|
+
* leaveHistory.timeEvaluationEndDate; // Retorna a data final da apuração do afastamento ou null seo afastamento não foi aplicado ao dia apurado.
|
|
30
|
+
* leaveHistory.situation; // Retorna a situação do afastamento.
|
|
31
|
+
* leaveHistory.startDateTime; // Retorna a data e hora inicial do afastamento, no formado de Date.
|
|
32
|
+
* leaveHistory.endDateTime; // Retorna a data e hora final do afastamento ou null se não houver data final, no formado de Date.
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export class LeaveHistory {
|
|
36
|
+
private readonly _startDate: Date;
|
|
37
|
+
private readonly _endDate: Date | null;
|
|
38
|
+
private readonly _startTime: number;
|
|
39
|
+
private readonly _endTime: number;
|
|
40
|
+
private readonly _timeEvaluationStartDate: Date | null;
|
|
41
|
+
private readonly _timeEvaluationEndDate: Date | null;
|
|
42
|
+
private readonly _situationId: string;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @hidden
|
|
46
|
+
* @param params Parâmetros necessários para criar uma instância de LeaveHistory.
|
|
47
|
+
*/
|
|
48
|
+
constructor(params: LeaveHistoryParams) {
|
|
49
|
+
this._startDate = ObjectUtils.toDateOrThrow(params.startDate, "LeaveHistory.startDate");
|
|
50
|
+
this._endDate = ObjectUtils.toDateOrNull(params.endDate);
|
|
51
|
+
this._startTime = params.startTime;
|
|
52
|
+
this._endTime = params.endTime;
|
|
53
|
+
this._timeEvaluationStartDate = ObjectUtils.toDateOrNull(params.timeEvaluationStartDate);
|
|
54
|
+
this._timeEvaluationEndDate = ObjectUtils.toDateOrNull(params.timeEvaluationEndDate);
|
|
55
|
+
this._situationId = params.situationId;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Data inicial do histórico de afastamento.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* let startDate = leaveHistory.startDate; // Retorna a data inicial do histórico de afastamento.
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @returns Data inicial do histórico de afastamento.
|
|
67
|
+
*/
|
|
68
|
+
get startDate(): Date {
|
|
69
|
+
return this._startDate;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Data da final de afastamento, opcional.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* let endDate = leaveHistory.endDate; // Retorna a data final do afastamento ou null se não estiver definida.
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @returns Data final do afastamento.
|
|
81
|
+
*/
|
|
82
|
+
get endDate(): Date | null {
|
|
83
|
+
return this._endDate;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Hora inicial do afastamento. Formatado em quantidade de minutos desde a meia-noite.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* let startTime = leaveHistory.startTime; // Retorna a hora inicial do afastamento em minutos desde a meia-noite.
|
|
92
|
+
* startTime; // Exemplo: 480 representa 08:00.
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @returns Hora inicial do afastamento.
|
|
96
|
+
*/
|
|
97
|
+
get startTime(): number {
|
|
98
|
+
return this._startTime;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Hora final do afastamento. Formatado em quantidade de minutos desde a meia-noite.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* let endTime = leaveHistory.endTime; // Retorna a hora final do afastamento em minutos desde a meia-noite.
|
|
107
|
+
* endTime; // Exemplo: 1020 representa 17:00.
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* @returns Hora final do afastamento.
|
|
111
|
+
*/
|
|
112
|
+
get endTime(): number {
|
|
113
|
+
return this._endTime;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @hidden
|
|
118
|
+
* Identificador da situação do afastamento.
|
|
119
|
+
* @returns Identificador da situação do afastamento.
|
|
120
|
+
*/
|
|
121
|
+
private get situationId(): string {
|
|
122
|
+
return this._situationId;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* A partir de qual data na apuração calculada o afastamento foi utilizado no cálculo da apuração, para gerar alguma alteração.
|
|
127
|
+
* Cenários:
|
|
128
|
+
* - Afastamentos em DSR, não são aplicados.
|
|
129
|
+
* - Afastamento em DSR podem ser aplicados em datas diferentes.
|
|
130
|
+
* - Históricos não aplicados no dia retornam null.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* let timeEvaluationStartDate = leaveHistory.timeEvaluationStartDate; // Retorna a menor data de apuração que o histórico foi aplicado, ou null se não foi aplicado.
|
|
135
|
+
* ```
|
|
136
|
+
* @returns Menor data de apuração que o histórico foi aplicado, e null, se não foi aplicado.
|
|
137
|
+
*/
|
|
138
|
+
get timeEvaluationStartDate(): Date | null {
|
|
139
|
+
return this._timeEvaluationStartDate;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Até qual data na apuração calculada o afastamento foi utilizado no cálculo da apuração, para gerar alguma alteração.
|
|
144
|
+
* Cenários:
|
|
145
|
+
* - Afastamentos em DSR, não são aplicados.
|
|
146
|
+
* - Data final de um afastamento sem data final, é a maior data de apuração.
|
|
147
|
+
* - Históricos não aplicados no dia retornam null.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```typescript
|
|
151
|
+
* let timeEvaluationEndDate = leaveHistory.timeEvaluationEndDate; // Retorna a maior data de apuração que o histórico foi aplicado, ou null se não foi aplicado.
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* @returns Maior data de apuração que o histórico foi aplicado, e null se não foi aplicado.
|
|
155
|
+
*/
|
|
156
|
+
get timeEvaluationEndDate(): Date | null {
|
|
157
|
+
return this._timeEvaluationEndDate;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Situação do afastamento.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* let situation = leaveHistory.situation; // Retorna a situação do afastamento.
|
|
166
|
+
* sitation.code; // Retorna o código da situação.
|
|
167
|
+
* ```
|
|
168
|
+
* @returns Situação do afastamento.
|
|
169
|
+
*/
|
|
170
|
+
get situation(): Situation {
|
|
171
|
+
const situation = ContextReference.getGlobalInstance().getSituationById(this._situationId);
|
|
172
|
+
if (!situation) {
|
|
173
|
+
throw new Error(`Situação com ID ${this._situationId} não encontrada no contexto.`);
|
|
174
|
+
}
|
|
175
|
+
return situation;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Data e hora inicial do afastamento, no formato de Date.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```typescript
|
|
183
|
+
* let startDateTime = leaveHistory.startDateTime; // Retorna a data e hora inicial do afastamento.
|
|
184
|
+
* startDateTime.toISOString(); // Formato ISO da data e hora, por exemplo: "2023-10-01T08:00:00.000Z".
|
|
185
|
+
* ```
|
|
186
|
+
* @returns Data e hora inicial do afastamento.
|
|
187
|
+
*/
|
|
188
|
+
get startDateTime(): Date {
|
|
189
|
+
const date = new Date(this._startDate);
|
|
190
|
+
date.setMinutes(this._startTime);
|
|
191
|
+
return date;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Data e hora final do afastamento, no formato de Date.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```typescript
|
|
199
|
+
* let endDateTime = leaveHistory.endDateTime; // Retorna a data e hora final do afastamento, ou null se não houver data final.
|
|
200
|
+
* endDateTime ? endDateTime.toISOString() : null; // Formato ISO da data e hora, por exemplo: "2023-10-01T17:00:00.000Z".
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* @returns Data e hora final do afastamento, ou null se não houver data final.
|
|
204
|
+
*/
|
|
205
|
+
get endDateTime(): Date | null {
|
|
206
|
+
if (this._endDate === null) {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
const date = new Date(this._endDate);
|
|
210
|
+
date.setMinutes(this._endTime);
|
|
211
|
+
return date;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
public static clone(leaveHistory: LeaveHistory): LeaveHistory {
|
|
215
|
+
const leaveHistoryParams = {
|
|
216
|
+
startDate: leaveHistory.startDate,
|
|
217
|
+
endDate: leaveHistory.endDate,
|
|
218
|
+
startTime: leaveHistory.startTime,
|
|
219
|
+
endTime: leaveHistory.endTime,
|
|
220
|
+
situationId: leaveHistory.situationId,
|
|
221
|
+
timeEvaluationStartDate: leaveHistory.timeEvaluationStartDate,
|
|
222
|
+
timeEvaluationEndDate: leaveHistory.timeEvaluationEndDate
|
|
223
|
+
};
|
|
224
|
+
return new LeaveHistory(leaveHistoryParams)
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { ObjectUtils } from "../../utils/object.utils";
|
|
2
|
+
import { TimeEvaluationSituationDefinitionHistory } from "../definition/timeEvaluationSituationDefinitionHistory";
|
|
3
|
+
import { ContextReference } from "../context/contextReference";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @hidden
|
|
7
|
+
* Histórico de apuração do colaborador.
|
|
8
|
+
* O histórico de apuração é utilizado para verificar a apuração do colaborador em uma data específica.
|
|
9
|
+
*/
|
|
10
|
+
export interface TimeEvaluationHistoryParams {
|
|
11
|
+
startDate: Date;
|
|
12
|
+
endDate: Date | null;
|
|
13
|
+
type: TimeEvaluationType;
|
|
14
|
+
situationDefinitionKey: string[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Representa o histórico de apuração do colaborador.
|
|
19
|
+
* O histórico de apuração é utilizado para verificar a apuração do colaborador em uma data específica.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* timeEvaluationHistory.startDate; // Retorna a data inicial do histórico de apuração.
|
|
24
|
+
* timeEvaluationHistory.endDate; // Retorna a data final do histórico de apuração do colaborador ou null se não estiver definida.
|
|
25
|
+
* timeEvaluationHistory.type; // Retorna o tipo de apuração do colaborador.
|
|
26
|
+
* const situationDefinitions = timeEvaluationHistory.situationDefinition; // Retorna uma lista de históricos de definição de situação conforme o período de apuração.
|
|
27
|
+
* ```
|
|
28
|
+
* @see {@link TimeEvaluationSituationDefinitionHistory}
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
export class TimeEvaluationHistory {
|
|
32
|
+
private readonly _startDate: Date;
|
|
33
|
+
private readonly _endDate: Date | null;
|
|
34
|
+
private readonly _type: TimeEvaluationType;
|
|
35
|
+
private readonly _situationDefinitionKey: string[];
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @hidden
|
|
39
|
+
* @param params Parâmetros necessários para criar uma instância de TimeEvaluationHistory.
|
|
40
|
+
*/
|
|
41
|
+
constructor(params: TimeEvaluationHistoryParams) {
|
|
42
|
+
this._startDate = ObjectUtils.toDateOrThrow(params.startDate, "TimeEvaluationHistory.startDate");
|
|
43
|
+
this._endDate = ObjectUtils.toDateOrNull(params.endDate);
|
|
44
|
+
this._type = params.type;
|
|
45
|
+
this._situationDefinitionKey = params.situationDefinitionKey;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Data inicial do histórico de apuração do colaborador.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* let startDate = timeEvaluationHistory.startDate; // Retorna a data inicial do histórico de apuração do colaborador.
|
|
54
|
+
* ```
|
|
55
|
+
* @returns Data inicial do histórico de apuração do colaborador.
|
|
56
|
+
*/
|
|
57
|
+
get startDate(): Date {
|
|
58
|
+
return this._startDate;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Data final do histórico de apuração do colaborador.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* let endDate = timeEvaluationHistory.endDate; // Retorna a data final do histórico de apuração do colaborador.
|
|
67
|
+
* ```
|
|
68
|
+
* @returns Data final do histórico de apuração do colaborador.
|
|
69
|
+
*/
|
|
70
|
+
get endDate(): Date | null {
|
|
71
|
+
return this._endDate;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Tipo de apuração do colaborador.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* let evaluationType = timeEvaluationHistory.type; // Retorna o tipo de apuração do colaborador.
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @returns Tipo de apuração do colaborador.
|
|
83
|
+
* @see {@link TimeEvaluationType}
|
|
84
|
+
*/
|
|
85
|
+
get type(): TimeEvaluationType {
|
|
86
|
+
return this._type;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @hidden
|
|
91
|
+
* Chaves de definição de situação do histórico de apuração.
|
|
92
|
+
*/
|
|
93
|
+
private get situationDefinitionKey(): string[] {
|
|
94
|
+
return this._situationDefinitionKey;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Definição de situação do histórico de apuração.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const situationDefinitions = timeEvaluationHistory.situationDefinition; // Retorna uma lista de históricos de definição de situação conforme o período de apuração.
|
|
103
|
+
* situationDefinitions.forEach(definition => {
|
|
104
|
+
* console.log(definition.code); // Exibe o código da definição de situação.
|
|
105
|
+
* });
|
|
106
|
+
*
|
|
107
|
+
* ```
|
|
108
|
+
* @returns Retorna uma lista de históricos de definição de situação conforme o período de apuração.
|
|
109
|
+
*/
|
|
110
|
+
get situationDefinition(): TimeEvaluationSituationDefinitionHistory[] {
|
|
111
|
+
// Definição de situação é opcional no histórico de apuração
|
|
112
|
+
if (!this._situationDefinitionKey) {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const timeEvaluationHistory: TimeEvaluationSituationDefinitionHistory[] = [];
|
|
117
|
+
|
|
118
|
+
this._situationDefinitionKey.forEach(key => {
|
|
119
|
+
timeEvaluationHistory.push(ContextReference.getGlobalInstance().getTimeEvaluationSituationDefinitionHistory(key));
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
return timeEvaluationHistory;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Busca uma definição de situação baseado numa data específica.
|
|
127
|
+
* A data deve estar dentro do intervalo de início e fim da apuração.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* const date = new Date("2025-06-01");
|
|
132
|
+
* const situationDefinition = timeEvaluationHistory.findSituationDefinitionByDate(date);
|
|
133
|
+
* if (situationDefinition) {
|
|
134
|
+
* console.log(situationDefinition.code); // Exibe o código da definição de situação encontrada.
|
|
135
|
+
* } else {
|
|
136
|
+
* console.log("Nenhuma definição de situação encontrada para essa data.");
|
|
137
|
+
* }
|
|
138
|
+
* ```
|
|
139
|
+
*
|
|
140
|
+
*
|
|
141
|
+
* @param date Data para buscar a definição de situação.
|
|
142
|
+
* @returns TimeEvaluationSituationDefinitionHistory baseado na data fornecida ou null se não houver definição de situação para essa data.
|
|
143
|
+
*/
|
|
144
|
+
findSituationDefinitionByDate(date: Date): TimeEvaluationSituationDefinitionHistory | null {
|
|
145
|
+
const situationDefinitions = this.situationDefinition;
|
|
146
|
+
for (const definition of situationDefinitions) {
|
|
147
|
+
if (definition.startDate <= date && (definition.endDate === null || definition.endDate >= date)) {
|
|
148
|
+
return definition;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Clona o histórico de apuração.
|
|
156
|
+
*
|
|
157
|
+
* @returns Uma nova instância de TimeEvaluationHistory com os mesmos valores.
|
|
158
|
+
*/
|
|
159
|
+
public static clone(object: TimeEvaluationHistory): TimeEvaluationHistory {
|
|
160
|
+
const timeEvaluationHistoryParams = {
|
|
161
|
+
startDate: object.startDate,
|
|
162
|
+
endDate: object.endDate,
|
|
163
|
+
type: object.type,
|
|
164
|
+
situationDefinitionKey: object.situationDefinitionKey
|
|
165
|
+
};
|
|
166
|
+
return new TimeEvaluationHistory(timeEvaluationHistoryParams);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Enumeração para os tipos de apuração.
|
|
172
|
+
* @enum
|
|
173
|
+
*/
|
|
174
|
+
export enum TimeEvaluationType {
|
|
175
|
+
/**
|
|
176
|
+
* Apuração normal.
|
|
177
|
+
*/
|
|
178
|
+
NORMAL = "NORMAL",
|
|
179
|
+
/**
|
|
180
|
+
* Dispensado do ponto.
|
|
181
|
+
*/
|
|
182
|
+
DISMISSEDFROMTIMECONTROL = "DISMISSEDFROMTIMECONTROL",
|
|
183
|
+
/**
|
|
184
|
+
* Sem controle de ponto.
|
|
185
|
+
*/
|
|
186
|
+
NOTIMECONTROL = "NOTIMECONTROL",
|
|
187
|
+
/**
|
|
188
|
+
* Ponto por exceção.
|
|
189
|
+
*/
|
|
190
|
+
CLOCKINGEVENTBYEXCEPTION = "CLOCKINGEVENTBYEXCEPTION",
|
|
191
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ObjectUtils } from "src/utils/object.utils";
|
|
2
|
+
import { WorkshiftBase, WorkshiftBaseParams } from "../foundation/workshiftBase";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @hidden
|
|
6
|
+
* Histórico de escala do colaborador.
|
|
7
|
+
* O histórico de escala é utilizado para verificar a escala do colaborador em uma data específica.
|
|
8
|
+
*/
|
|
9
|
+
export interface WorkshiftHistoryParams extends WorkshiftBaseParams {
|
|
10
|
+
endDate: Date | null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Representa o histórico de escala.
|
|
15
|
+
* O histórico de escala é utilizado para verificar a escala do colaborador em uma data específica.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* workshiftHistory.startDate; // Retorna a data inicial do histórico de escala.
|
|
20
|
+
* workshiftHistory.endDate; // Retorna a data final do histórico de escala ou null se não estiver definida.
|
|
21
|
+
* workshiftHistory.workshift; // Retorna a escala associada ao histórico.
|
|
22
|
+
* workshiftHistory.workshift.code; // Retorna o código da escala.
|
|
23
|
+
* ```
|
|
24
|
+
* @see {@link Workshift}
|
|
25
|
+
*/
|
|
26
|
+
export class WorkshiftHistory extends WorkshiftBase {
|
|
27
|
+
|
|
28
|
+
protected readonly _endDate: Date | null;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @hidden
|
|
32
|
+
* @param params Parâmetros necessários para criar uma instância de WorkshiftHistory.
|
|
33
|
+
*/
|
|
34
|
+
constructor(params: WorkshiftHistoryParams) {
|
|
35
|
+
super(params);
|
|
36
|
+
this._endDate = ObjectUtils.toDateOrNull(params.endDate);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Data final do histórico de escala.
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* let endDate = workshiftBase.endDate; // Retorna a data final da escala ou null se não estiver definida.
|
|
45
|
+
* ```
|
|
46
|
+
* @returns Data final do histórico de escala ou null se não estiver definida.
|
|
47
|
+
*/
|
|
48
|
+
get endDate(): Date | null {
|
|
49
|
+
return this._endDate;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Clona a instância de WorkshiftHistory.
|
|
54
|
+
*
|
|
55
|
+
* @returns Uma nova instância de WorkshiftHistory com os mesmos parâmetros.
|
|
56
|
+
*/
|
|
57
|
+
public static clone(object: WorkshiftHistory): WorkshiftHistory {
|
|
58
|
+
const workshiftHistory = {
|
|
59
|
+
startDate: object.startDate,
|
|
60
|
+
endDate: object.endDate,
|
|
61
|
+
workshiftId: object.workshiftId,
|
|
62
|
+
workshiftGroupId: object.workshiftGroupId
|
|
63
|
+
};
|
|
64
|
+
return new WorkshiftHistory(workshiftHistory);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hidden
|
|
3
|
+
* Interface para os parâmetros do construtor de HourBank.
|
|
4
|
+
*/
|
|
5
|
+
export interface HourBankParams {
|
|
6
|
+
code: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Representa um banco de horas.
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* console.log(hourBank.code); // Retorna 123.
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
export class HourBank {
|
|
18
|
+
/**
|
|
19
|
+
* Código do banco de horas.
|
|
20
|
+
* @param code Código do banco de horas.
|
|
21
|
+
*/
|
|
22
|
+
private readonly _code: number;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @hidden
|
|
26
|
+
* @param params Parâmetros necessários para criar uma instância do banco de horas.
|
|
27
|
+
*/
|
|
28
|
+
constructor(params: HourBankParams) {
|
|
29
|
+
this._code = params.code;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Retorna o código do banco de horas.
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* let code = hourBank.code; // Retorna o código do banco de horas.
|
|
37
|
+
* ```
|
|
38
|
+
* @return Código do banco de horas.
|
|
39
|
+
*/
|
|
40
|
+
get code(): number {
|
|
41
|
+
return this._code;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ObjectUtils } from "../../utils/object.utils";
|
|
2
|
+
import { HourBank } from "./hourBank";
|
|
3
|
+
/**
|
|
4
|
+
* @hidden
|
|
5
|
+
* Interface para os parâmetros do construtor de HourBankAccount.
|
|
6
|
+
*/
|
|
7
|
+
export interface HourBankAccountParams {
|
|
8
|
+
hourBank: HourBank;
|
|
9
|
+
creationDate: Date;
|
|
10
|
+
extinctionDate?: Date | null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Representa uma conta de banco de horas de um colaborador.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* hourBankAccount.hourBank.code; // Retorna o código do banco de horas associado.
|
|
19
|
+
* hourBankAccount.creationDate; // Retorna a data de criação da conta de banco de horas.
|
|
20
|
+
* hourBankAccount.extinctionDate; // Retorna a data de extinção da conta de banco de horas, se existir.
|
|
21
|
+
* ```
|
|
22
|
+
* @see {@link HourBank}
|
|
23
|
+
*/
|
|
24
|
+
export class HourBankAccount {
|
|
25
|
+
private readonly _hourBank: HourBank;
|
|
26
|
+
private readonly _creationDate: Date;
|
|
27
|
+
private readonly _extinctionDate: Date | null;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @hidden
|
|
31
|
+
* @param params Parâmetros necessários para criar uma instância de conta de banco de horas.
|
|
32
|
+
*/
|
|
33
|
+
constructor(params: HourBankAccountParams) {
|
|
34
|
+
this._hourBank = params.hourBank;
|
|
35
|
+
this._creationDate = ObjectUtils.toDateOrThrow(params.creationDate, "hourBankAccount.creationDate");
|
|
36
|
+
this._extinctionDate = ObjectUtils.toDateOrNull(params.extinctionDate);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Retorna o banco de horas associado.
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* let hourBank = hourBankAccount.hourBank; // Retorna a conta de banco de horas associado.
|
|
44
|
+
* hourBank.code; // Retorna o código da conta de banco de horas.
|
|
45
|
+
* ```
|
|
46
|
+
* @return O banco de horas associado à conta de banco de horas.
|
|
47
|
+
* @see {@link HourBank}
|
|
48
|
+
*/
|
|
49
|
+
get hourBank(): HourBank {
|
|
50
|
+
return this._hourBank;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Retorna a data de criação.
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* let creationDate = hourBankAccount.creationDate; // Retorna a data de criação da conta de banco de horas.
|
|
58
|
+
* ```
|
|
59
|
+
* @return A data de criação da conta de banco de horas.
|
|
60
|
+
*/
|
|
61
|
+
get creationDate(): Date {
|
|
62
|
+
return this._creationDate;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Retorna a data de extinção, se existir.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* let extinctionDate = hourBankAccount.extinctionDate; // Retorna a data de extinção da conta de banco de horas ou null se não existir.
|
|
71
|
+
* ```
|
|
72
|
+
* @return A data de extinção da conta de banco de horas ou null se não existir.
|
|
73
|
+
*/
|
|
74
|
+
get extinctionDate(): Date | null {
|
|
75
|
+
return this._extinctionDate;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hidden
|
|
3
|
+
* @enum
|
|
4
|
+
*/
|
|
5
|
+
export enum LogType {
|
|
6
|
+
ERROR = "ERROR",
|
|
7
|
+
WARNING = "WARNING",
|
|
8
|
+
INFO = "INFO",
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @hidden
|
|
13
|
+
*/
|
|
14
|
+
export interface LogParams {
|
|
15
|
+
type: LogType;
|
|
16
|
+
message: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @hidden
|
|
21
|
+
*/
|
|
22
|
+
export class Log {
|
|
23
|
+
private readonly _type: LogType;
|
|
24
|
+
private readonly _message: string;
|
|
25
|
+
|
|
26
|
+
constructor(params: LogParams) {
|
|
27
|
+
this._type = params.type;
|
|
28
|
+
this._message = params.message;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
get type(): LogType {
|
|
32
|
+
return this._type;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
get message(): string {
|
|
36
|
+
return this._message;
|
|
37
|
+
}
|
|
38
|
+
}
|