@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,419 @@
|
|
|
1
|
+
import { DateUtils } from "../../utils/dateUtils";
|
|
2
|
+
import { JobPositionHistory } from "./jobPositionHistory";
|
|
3
|
+
import { CompanyBranchHistory } from "./companyBranchHistory";
|
|
4
|
+
import { EmploymentRelationshipHistory } from "./employmentRelationshipHistory";
|
|
5
|
+
import { TimeEvaluationHistory } from './timeEvaluationHistory';
|
|
6
|
+
import { WorkshiftHistory } from "./workshiftHistory";
|
|
7
|
+
import { CostCenterHistory } from "./costCenterHistory";
|
|
8
|
+
import { LeaveHistory } from "./leaveHistory";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @hidden
|
|
12
|
+
* Parâmetros necessários para criar uma instância de Histories.
|
|
13
|
+
*/
|
|
14
|
+
export interface HistoriesParams {
|
|
15
|
+
jobPositionHistories: JobPositionHistory[];
|
|
16
|
+
companyBranchHistories: CompanyBranchHistory[];
|
|
17
|
+
employmentRelationshipHistories: EmploymentRelationshipHistory[];
|
|
18
|
+
timeEvaluationHistories: TimeEvaluationHistory[];
|
|
19
|
+
workshiftHistories: WorkshiftHistory[];
|
|
20
|
+
costCenterHistories: CostCenterHistory[];
|
|
21
|
+
leaveHistories: LeaveHistory[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Representa os históricos de um colaborador no período calculado.
|
|
26
|
+
* Aqui são armazenados os históricos de cargos, filiais de empresa, vínculos, apurações, escalas, centros de custo e afastamentos do colaborador.
|
|
27
|
+
*
|
|
28
|
+
* - O período calculado considera, no mínimo, o período de apuração do cálculo da competência mais 5 dias anteriores e 4 dias posteriores conforme configurado em "Retornar dias" na definição de apuração.
|
|
29
|
+
*
|
|
30
|
+
* ```
|
|
31
|
+
* Demonstração do período calculado
|
|
32
|
+
*
|
|
33
|
+
* Período de apuração do cálculo = 24/03/2025 a 23/04/2025
|
|
34
|
+
* Data inicial = data início do cálculo - 4 dias extras - valor parametrizado em `Retornar dias` (se for nulo assume 1 dia)
|
|
35
|
+
* Data final = data fim do cálculo + 4 dias extras
|
|
36
|
+
* Período calculado = 19/03/2025 a 27/04/2025
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* histories.jobPositionHistories; // Retorna a lista de histórico de cargos do colaborador no período calculado.
|
|
42
|
+
* histories.companyBranchHistories; // Retorna a lista de histórico de filiais de empresas do colaborador no período calculado.
|
|
43
|
+
* histories.employmentRelationshipHistories; // Retorna a lista de histórico de vínculos do colaborador no período calculado.
|
|
44
|
+
* histories.timeEvaluationHistories; // Retorna a lista de histórico de apurações do colaborador no período calculado.
|
|
45
|
+
* histories.workshiftHistories; // Retorna a lista de histórico de escalas do colaborador no período calculado.
|
|
46
|
+
* histories.costCenterHistories; // Retorna a lista de histórico de centros de custo do colaborador no período calculado.
|
|
47
|
+
* histories.leaveHistories; // Retorna a lista de histórico de afastamentos do colaborador no período calculado.
|
|
48
|
+
* ```
|
|
49
|
+
* @see {@link JobPositionHistory}
|
|
50
|
+
* @see {@link CompanyBranchHistory}
|
|
51
|
+
* @see {@link EmploymentRelationshipHistory}
|
|
52
|
+
* @see {@link TimeEvaluationHistory}
|
|
53
|
+
* @see {@link WorkshiftHistory}
|
|
54
|
+
* @see {@link CostCenterHistory}
|
|
55
|
+
* @see {@link LeaveHistory}
|
|
56
|
+
*
|
|
57
|
+
*
|
|
58
|
+
*/
|
|
59
|
+
export class Histories {
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
private readonly _jobPositionHistories: JobPositionHistory[];
|
|
63
|
+
private readonly _companyBranchHistories: CompanyBranchHistory[];
|
|
64
|
+
private readonly _employmentRelationshipHistories: EmploymentRelationshipHistory[];
|
|
65
|
+
private readonly _timeEvaluationHistories: TimeEvaluationHistory[];
|
|
66
|
+
private readonly _workshiftHistories: WorkshiftHistory[];
|
|
67
|
+
private readonly _costCenterHistories: CostCenterHistory[];
|
|
68
|
+
private readonly _leaveHistories: LeaveHistory[];
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @hidden
|
|
72
|
+
* @param params Parâmetros necessários para inicializar os históricos do colaborador no período calculado.
|
|
73
|
+
*/
|
|
74
|
+
constructor(params: HistoriesParams) {
|
|
75
|
+
this._jobPositionHistories = [];
|
|
76
|
+
this._companyBranchHistories = [];
|
|
77
|
+
this._employmentRelationshipHistories = [];
|
|
78
|
+
this._timeEvaluationHistories = [];
|
|
79
|
+
this._workshiftHistories = [];
|
|
80
|
+
this._costCenterHistories = [];
|
|
81
|
+
this._leaveHistories = [];
|
|
82
|
+
|
|
83
|
+
this.createJobPositionHistories(params);
|
|
84
|
+
this.createCompanyBranches(params);
|
|
85
|
+
this.createEmploymentRelationshipHistories(params);
|
|
86
|
+
this.createTimeEvaluationHistories(params);
|
|
87
|
+
this.createWorkshiftHistories(params);
|
|
88
|
+
this.createLeaveHistories(params);
|
|
89
|
+
this.createCostCenterHistories(params);
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private createCompanyBranches(params: HistoriesParams) {
|
|
94
|
+
if (params.companyBranchHistories) {
|
|
95
|
+
for (const companyBranchHistory of params.companyBranchHistories) {
|
|
96
|
+
this._companyBranchHistories.push(CompanyBranchHistory.clone(companyBranchHistory));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private createJobPositionHistories(params: HistoriesParams) {
|
|
102
|
+
if (params.jobPositionHistories) {
|
|
103
|
+
for (const jobPositionHistory of params.jobPositionHistories) {
|
|
104
|
+
this._jobPositionHistories.push(JobPositionHistory.clone(jobPositionHistory));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private createEmploymentRelationshipHistories(params: HistoriesParams) {
|
|
110
|
+
if (params.employmentRelationshipHistories) {
|
|
111
|
+
for (const employmentRelationship of params.employmentRelationshipHistories) {
|
|
112
|
+
this._employmentRelationshipHistories.push(EmploymentRelationshipHistory.clone(employmentRelationship));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private createLeaveHistories(params: HistoriesParams) {
|
|
118
|
+
if (params.leaveHistories) {
|
|
119
|
+
for (const leaveHistory of params.leaveHistories) {
|
|
120
|
+
this._leaveHistories.push(LeaveHistory.clone(leaveHistory));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
private createWorkshiftHistories(params: HistoriesParams) {
|
|
127
|
+
if (params.workshiftHistories) {
|
|
128
|
+
for (const workshiftHistory of params.workshiftHistories) {
|
|
129
|
+
this._workshiftHistories.push(WorkshiftHistory.clone(workshiftHistory));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
private createTimeEvaluationHistories(params: HistoriesParams) {
|
|
136
|
+
if (params.timeEvaluationHistories) {
|
|
137
|
+
for (const timeEvaluationHistory of params.timeEvaluationHistories) {
|
|
138
|
+
this._timeEvaluationHistories.push(TimeEvaluationHistory.clone(timeEvaluationHistory));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
private createCostCenterHistories(params: HistoriesParams) {
|
|
144
|
+
if (params.costCenterHistories) {
|
|
145
|
+
for (const costCenterHistory of params.costCenterHistories) {
|
|
146
|
+
this._costCenterHistories.push(CostCenterHistory.clone(costCenterHistory));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Lista de histórico de cargos do colaborador no período calculado.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```typescript
|
|
157
|
+
* histories.jobPositionHistories; // Retorna a lista de históricos de cargos do colaborador no período calculado.
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* @returns Lista de histórico de cargos do colaborador no período calculado.
|
|
161
|
+
* @see {@link JobPositionHistory}
|
|
162
|
+
*/
|
|
163
|
+
get jobPositionHistories(): JobPositionHistory[] {
|
|
164
|
+
return this._jobPositionHistories;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Lista de histórico de filiais de empresas do colaborador no período calculado.
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* histories.companyBranchHistories; // Retorna a lista de histórico de filiais da empresa do colaborador no período calculado.
|
|
172
|
+
* ```
|
|
173
|
+
*
|
|
174
|
+
* @returns Lista de histórico de filiais da empresa do colaborador no período calculado.
|
|
175
|
+
* @see {@link CompanyBranchHistory}
|
|
176
|
+
*/
|
|
177
|
+
get companyBranchHistories(): CompanyBranchHistory[] {
|
|
178
|
+
return this._companyBranchHistories;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Lista de histórico de vínculos do colaborador no período calculado.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```typescript
|
|
186
|
+
* histories.employmentRelationshipHistories; // Retorna a lista de vínculos do colaborador no período calculado.
|
|
187
|
+
* ```
|
|
188
|
+
*
|
|
189
|
+
* @returns Lista de histórico de vínculos do colaborador no período calculado.
|
|
190
|
+
* @see {@link EmploymentRelationshipHistory}
|
|
191
|
+
*/
|
|
192
|
+
get employmentRelationshipHistories(): EmploymentRelationshipHistory[] {
|
|
193
|
+
return this._employmentRelationshipHistories;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Lista de histórico de apurações do colaborador no período calculado.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```typescript
|
|
201
|
+
* histories.timeEvaluationHistories; // Retorna a lista de histórico de apurações do colaborador no período calculado.
|
|
202
|
+
* ```
|
|
203
|
+
*
|
|
204
|
+
* @returns Lista de histórico de apurações do colaborador no período calculado.
|
|
205
|
+
* @see {@link TimeEvaluationHistory}
|
|
206
|
+
*/
|
|
207
|
+
get timeEvaluationHistories(): TimeEvaluationHistory[] {
|
|
208
|
+
return this._timeEvaluationHistories;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Lista de histórico de escalas do colaborador no período calculado.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* histories.workshiftHistories; // Retorna a lista de histórico de escalas do colaborador no período calculado.
|
|
217
|
+
* ```
|
|
218
|
+
*
|
|
219
|
+
* @returns Lista de histórico de escalas do colaborador no período calculado.
|
|
220
|
+
* @see {@link WorkshiftHistory}
|
|
221
|
+
*/
|
|
222
|
+
get workshiftHistories(): WorkshiftHistory[] {
|
|
223
|
+
return this._workshiftHistories;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Lista de histórico de afastamentos do colaborador no período calculado.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```typescript
|
|
231
|
+
* histories.leaveHistories; // Retorna a lista de histórico de afastamentos do colaborador no período calculado.
|
|
232
|
+
* ```
|
|
233
|
+
*
|
|
234
|
+
* @returns Lista de histórico de afastamentos do colaborador no período calculado.
|
|
235
|
+
* @see {@link LeaveHistory}
|
|
236
|
+
*/
|
|
237
|
+
get leaveHistories(): LeaveHistory[] {
|
|
238
|
+
return this._leaveHistories;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Lista de histórico de centro de custo do colaborador no período calculado.
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```typescript
|
|
246
|
+
* histories.costCenterHistories; // Retorna a lista de histórico de centro de custo do colaborador no período calculado.
|
|
247
|
+
* ```
|
|
248
|
+
*
|
|
249
|
+
* @returns Lista de histórico de centro de custo do colaborador no período calculado.
|
|
250
|
+
* @see {@link CostCenterHistory}
|
|
251
|
+
*/
|
|
252
|
+
get costCenterHistories(): CostCenterHistory[] {
|
|
253
|
+
return this._costCenterHistories;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Busca um histórico de cargo com base na data.
|
|
258
|
+
* @example
|
|
259
|
+
* ```typescript
|
|
260
|
+
* const jobPosition = findJobPositionByDate(new Date("2024-02-02"));
|
|
261
|
+
* if(jobPosition) {
|
|
262
|
+
* ...
|
|
263
|
+
* }
|
|
264
|
+
* ```
|
|
265
|
+
*
|
|
266
|
+
* @param date Data a ser usada no filtro
|
|
267
|
+
* @returns Histórico de cargo conforme a data ou undefined caso não encontre.
|
|
268
|
+
*
|
|
269
|
+
*
|
|
270
|
+
* @see {@link JobPositionHistory}
|
|
271
|
+
*/
|
|
272
|
+
findJobPositionByDate(date: Date): JobPositionHistory | undefined{
|
|
273
|
+
const jobPositionHistories = this._jobPositionHistories.find((jobPosition) => {
|
|
274
|
+
return DateUtils.isAfterOrEquals(date, jobPosition.startDate) && (jobPosition.endDate == null || DateUtils.isBeforeOrEquals(date, jobPosition.endDate));
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
return jobPositionHistories;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Busca o histórico de filial de empresa com base na data.
|
|
282
|
+
* @example
|
|
283
|
+
* ```typescript
|
|
284
|
+
* const companyBranch = findCompanyBranchByDate(new Date("2024-02-02"));
|
|
285
|
+
* if(companyBranch) {
|
|
286
|
+
* ...
|
|
287
|
+
* }
|
|
288
|
+
* ```
|
|
289
|
+
*
|
|
290
|
+
* @param date Data a ser usada no filtro.
|
|
291
|
+
* @returns Histórico de filial ou undefined caso não encontre.
|
|
292
|
+
*
|
|
293
|
+
* @see {@link CompanyBranchHistory}
|
|
294
|
+
*/
|
|
295
|
+
findCompanyBranchByDate(date: Date): CompanyBranchHistory | undefined{
|
|
296
|
+
const companyBranchHistories = this._companyBranchHistories.find((companyBranch) => {
|
|
297
|
+
return DateUtils.isAfterOrEquals(date, companyBranch.startDate) && (companyBranch.endDate == null || DateUtils.isBeforeOrEquals(date, companyBranch.endDate));
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
return companyBranchHistories;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Busca o histórico de vínculo com base na data.
|
|
305
|
+
* @example
|
|
306
|
+
* ```typescript
|
|
307
|
+
* const employmentRelationship = findEmploymentRelationshipByDate(new Date("2024-02-02"));
|
|
308
|
+
* if(employmentRelationship) {
|
|
309
|
+
* ...
|
|
310
|
+
* }
|
|
311
|
+
* ```
|
|
312
|
+
* @param date Data a ser usada no filtro.
|
|
313
|
+
* @returns Histórico de vínculo ou undefined caso não encontre.
|
|
314
|
+
*
|
|
315
|
+
* @see {@link EmploymentRelationshipHistory}
|
|
316
|
+
*/
|
|
317
|
+
findEmploymentRelationshipByDate(date: Date): EmploymentRelationshipHistory | undefined{
|
|
318
|
+
const employmentRelationship = this._employmentRelationshipHistories.find((employmentRelationship) => {
|
|
319
|
+
return DateUtils.isAfterOrEquals(date, employmentRelationship.startDate) && (employmentRelationship.endDate == null || DateUtils.isBeforeOrEquals(date, employmentRelationship.endDate));
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
return employmentRelationship;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Busca o histórico de apuração com base na data.
|
|
327
|
+
* @example
|
|
328
|
+
* ```typescript
|
|
329
|
+
* const timeEvaluationHistory = findTimeEvaluationByDate(new Date("2024-02-02"));
|
|
330
|
+
* if(timeEvaluationHistory) {
|
|
331
|
+
* ...
|
|
332
|
+
* }
|
|
333
|
+
* ```
|
|
334
|
+
*
|
|
335
|
+
* @param date Data a ser usada no filtro.
|
|
336
|
+
* @returns Histórico de apuração ou undefined caso não encontre.
|
|
337
|
+
* @see {@link TimeEvaluationHistory}
|
|
338
|
+
*/
|
|
339
|
+
findTimeEvaluationHistoryByDate(date: Date): TimeEvaluationHistory | undefined {
|
|
340
|
+
const timeEvaluationHistories = this._timeEvaluationHistories.find((timeEvaluationHistory) => {
|
|
341
|
+
return DateUtils.isAfterOrEquals(date, timeEvaluationHistory.startDate) && (timeEvaluationHistory.endDate == null || DateUtils.isBeforeOrEquals(date, timeEvaluationHistory.endDate));
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
return timeEvaluationHistories;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Busca o histórico de escala com base na data.
|
|
349
|
+
* @example
|
|
350
|
+
* ```typescript
|
|
351
|
+
* const workshiftHistory = findWorkshiftByDate(new Date("2024-02-02"));
|
|
352
|
+
* if(workshiftHistory) {
|
|
353
|
+
* ...
|
|
354
|
+
* }
|
|
355
|
+
* ```
|
|
356
|
+
*
|
|
357
|
+
* @param date Data a ser usada no filtro.
|
|
358
|
+
* @returns Histórico de escala ou undefined caso não encontre.
|
|
359
|
+
*
|
|
360
|
+
* @see {@link WorkshiftHistory}
|
|
361
|
+
*/
|
|
362
|
+
findWorkshiftHistoryByDate(date: Date): WorkshiftHistory | undefined{
|
|
363
|
+
const workshiftHistories = this._workshiftHistories.find((workshiftHistory) => {
|
|
364
|
+
return DateUtils.isAfterOrEquals(date, workshiftHistory.startDate) && (workshiftHistory.endDate == null || DateUtils.isBeforeOrEquals(date, workshiftHistory.endDate));
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
return workshiftHistories;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Busca o histórico de afastamento com base na data da apuração, históricos não associados não são retornados.
|
|
373
|
+
* @example
|
|
374
|
+
* ```typescript
|
|
375
|
+
* const leaveHistory = findLeaveByDate(new Date("2024-02-02"));
|
|
376
|
+
* if(leaveHistory) {
|
|
377
|
+
* ...
|
|
378
|
+
* }
|
|
379
|
+
* ```
|
|
380
|
+
*
|
|
381
|
+
* @param timeEvaluationDate Data a ser usada no filtro.
|
|
382
|
+
* @returns Históricos de afastamento ou um array vazio caso não encontre.
|
|
383
|
+
* @see {@link LeaveHistory}
|
|
384
|
+
*/
|
|
385
|
+
findLeaveHistoryByTimeEvaluationDate(timeEvaluationDate: Date): LeaveHistory[] {
|
|
386
|
+
const leaveHistories = this._leaveHistories.filter((leaveHistory) => {
|
|
387
|
+
return leaveHistory.timeEvaluationStartDate != null && DateUtils.isAfterOrEquals(timeEvaluationDate, leaveHistory.timeEvaluationStartDate) //
|
|
388
|
+
&& (leaveHistory.timeEvaluationEndDate != null && DateUtils.isBeforeOrEquals(timeEvaluationDate, leaveHistory.timeEvaluationEndDate));
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
if (!leaveHistories || leaveHistories.length === 0) {
|
|
392
|
+
return [];
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
return leaveHistories;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Busca o histórico de centro de custo com base na data.
|
|
400
|
+
* @example
|
|
401
|
+
* ```typescript
|
|
402
|
+
* const costCenterHistory = findCostCenterByDate(new Date("2024-02-02"));
|
|
403
|
+
* if(costCenterHistory) {
|
|
404
|
+
* ...
|
|
405
|
+
* }
|
|
406
|
+
* ```
|
|
407
|
+
*
|
|
408
|
+
* @param date Data a ser usada no filtro.
|
|
409
|
+
* @returns Histórico de centro de custo ou undefined caso não encontre.
|
|
410
|
+
* @see {@link CostCenterHistory}
|
|
411
|
+
*/
|
|
412
|
+
findCostCenterHistoryByDate(date: Date): CostCenterHistory | undefined{
|
|
413
|
+
const costCenterHistories = this._costCenterHistories.find((costCenterHistory) => {
|
|
414
|
+
return DateUtils.isAfterOrEquals(date, costCenterHistory.startDate) && (costCenterHistory.endDate == null || DateUtils.isBeforeOrEquals(date, costCenterHistory.endDate));
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
return costCenterHistories;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { ObjectUtils } from "../../utils/object.utils";
|
|
2
|
+
import { ContextReference } from "../context/contextReference";
|
|
3
|
+
import { JobPosition } from "../foundation/jobPosition";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @hidden
|
|
7
|
+
* Histórico de cargo do colaborador.
|
|
8
|
+
* O histórico de cargo é utilizado para verificar o cargo do colaborador em uma data específica.
|
|
9
|
+
*/
|
|
10
|
+
export interface JobPositionHistoryParams {
|
|
11
|
+
startDate: Date;
|
|
12
|
+
endDate: Date | null;
|
|
13
|
+
jobPositionKey: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Representa o histórico de cargo do colaborador.
|
|
18
|
+
* O histórico de cargo é utilizado para verificar o cargo do colaborador em uma data específica.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* jobPositionHistory.startDate; // Retorna a data inicial do histórico de cargo.
|
|
23
|
+
* jobPositionHistory.endDate; // Retorna a data final do histórico de cargo ou null se não estiver definida.
|
|
24
|
+
* const jobPosition = jobPositionHistory.jobPosition;
|
|
25
|
+
* jobPosition.code; // Retorna o código do cargo.
|
|
26
|
+
* ```
|
|
27
|
+
* @see {@link JobPosition}
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
export class JobPositionHistory {
|
|
31
|
+
private readonly _startDate: Date;
|
|
32
|
+
private readonly _endDate: Date | null;
|
|
33
|
+
private readonly _jobPositionKey: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @hidden
|
|
37
|
+
* @param params Parâmetros necessários para criar uma instância de JobPositionHistory.
|
|
38
|
+
*/
|
|
39
|
+
constructor(params: JobPositionHistoryParams) {
|
|
40
|
+
this._startDate = ObjectUtils.toDateOrThrow(params.startDate, "JobPositionHistory.startDate");
|
|
41
|
+
this._endDate = ObjectUtils.toDateOrNull(params.endDate);
|
|
42
|
+
this._jobPositionKey = params.jobPositionKey;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Data inicial do histórico de cargo.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* let startDate = jobPositionHistory.startDate; // Retorna a data inicial do histórico de cargo.
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @returns Data inicial do histórico de cargo.
|
|
54
|
+
*/
|
|
55
|
+
get startDate(): Date {
|
|
56
|
+
return this._startDate;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Data final do histórico de cargo, caso exista.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* let endDate = jobPositionHistory.endDate; // Retorna a data final do histórico de cargo ou null se não estiver definida.
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @returns Data final do histórico de cargo.
|
|
68
|
+
*/
|
|
69
|
+
get endDate(): Date | null {
|
|
70
|
+
return this._endDate;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @hidden
|
|
75
|
+
* Chave única do cargo do colaborador.
|
|
76
|
+
*/
|
|
77
|
+
private get jobPositionKey(): string {
|
|
78
|
+
return this._jobPositionKey;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Cargo do colaborador.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const jobPosition = jobPositionHistory.jobPosition; // Retorna o cargo do colaborador.
|
|
87
|
+
* jobPosition.code; // Retorna o código do cargo.
|
|
88
|
+
* jobPosition.structureCode; // Retorna o código da estrutura do cargo.
|
|
89
|
+
* ```
|
|
90
|
+
* @returns Cargo do colaborador.
|
|
91
|
+
* @throws Se o cargo não for encontrado.
|
|
92
|
+
* @see {@link JobPosition}
|
|
93
|
+
*/
|
|
94
|
+
get jobPosition(): JobPosition {
|
|
95
|
+
const jobPosition = ContextReference.getGlobalInstance().getJobPosition(this._jobPositionKey);
|
|
96
|
+
if (!jobPosition) {
|
|
97
|
+
throw new Error(`Job position not found for key: ${this._jobPositionKey}`);
|
|
98
|
+
}
|
|
99
|
+
return jobPosition;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Clona o histórico de cargo.
|
|
105
|
+
*
|
|
106
|
+
* @param jobPositionHistory Histórico de cargo a ser clonado.
|
|
107
|
+
* @returns Uma nova instância de JobPositionHistory com os mesmos dados.
|
|
108
|
+
*/
|
|
109
|
+
public static clone(jobPositionHistory: JobPositionHistory): JobPositionHistory {
|
|
110
|
+
const jobPositionHistoryParams = {
|
|
111
|
+
startDate: jobPositionHistory.startDate,
|
|
112
|
+
endDate: jobPositionHistory.endDate,
|
|
113
|
+
jobPositionKey: jobPositionHistory.jobPositionKey
|
|
114
|
+
};
|
|
115
|
+
return new JobPositionHistory(jobPositionHistoryParams);
|
|
116
|
+
}
|
|
117
|
+
}
|