@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,113 @@
|
|
|
1
|
+
import { ObjectUtils } from "../../utils/object.utils";
|
|
2
|
+
import { ContextReference } from "../context/contextReference";
|
|
3
|
+
import { Workshift, WorkshiftGroup } from "./workshift";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @hidden
|
|
7
|
+
*/
|
|
8
|
+
export interface WorkshiftBaseParams {
|
|
9
|
+
/**
|
|
10
|
+
* Data inicial da escala.
|
|
11
|
+
*/
|
|
12
|
+
startDate: Date;
|
|
13
|
+
/**
|
|
14
|
+
* Identificador da escala.
|
|
15
|
+
*/
|
|
16
|
+
workshiftId: string;
|
|
17
|
+
/**
|
|
18
|
+
* Código do turma da escala.
|
|
19
|
+
*/
|
|
20
|
+
workshiftGroupId: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export abstract class WorkshiftBase {
|
|
24
|
+
/**
|
|
25
|
+
* Data inicial da escala.
|
|
26
|
+
*/
|
|
27
|
+
protected readonly _startDate: Date;
|
|
28
|
+
/**
|
|
29
|
+
* Identificador da escala.
|
|
30
|
+
*/
|
|
31
|
+
protected readonly _workshiftId: string;
|
|
32
|
+
/**
|
|
33
|
+
* Código do turma da escala.
|
|
34
|
+
*/
|
|
35
|
+
protected readonly _workshiftGroupId: string;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @hidden
|
|
39
|
+
* @param params Parâmetros necessários para criar uma instância de WorkshiftBase.
|
|
40
|
+
*/
|
|
41
|
+
constructor(params: WorkshiftBaseParams) {
|
|
42
|
+
this._startDate = ObjectUtils.toDateOrThrow(params.startDate, `${this.constructor.name}.startDate`);
|
|
43
|
+
this._workshiftId = params.workshiftId;
|
|
44
|
+
this._workshiftGroupId = params.workshiftGroupId;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Data inicial da escala.
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* let startDate = workshiftBase.startDate; // Retorna a data inicial da escala.
|
|
52
|
+
* ```
|
|
53
|
+
* @return Data inicial da escala.
|
|
54
|
+
*
|
|
55
|
+
*/
|
|
56
|
+
get startDate(): Date {
|
|
57
|
+
return this._startDate;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @hidden
|
|
62
|
+
* Identificador da escala.
|
|
63
|
+
*/
|
|
64
|
+
protected get workshiftId(): string {
|
|
65
|
+
return this._workshiftId;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @hidden
|
|
70
|
+
* Código do turma da escala.
|
|
71
|
+
* @return ID da turma da escala.
|
|
72
|
+
*/
|
|
73
|
+
protected get workshiftGroupId(): string {
|
|
74
|
+
return this._workshiftGroupId;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Escala
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* const workshift = item.workshift; // Retorna a escala associada ao histórico/programação.
|
|
83
|
+
* workshift.code; // Retorna o código da escala.
|
|
84
|
+
* ```
|
|
85
|
+
* @return Escala associada ao histórico/programação.
|
|
86
|
+
* @see {@link Workshift}
|
|
87
|
+
*/
|
|
88
|
+
get workshift(): Workshift {
|
|
89
|
+
const workshift = ContextReference.getGlobalInstance().getWorkshift(this._workshiftId);
|
|
90
|
+
if (!workshift) {
|
|
91
|
+
throw new Error(`Workshift not found for key: ${this._workshiftId}`);
|
|
92
|
+
}
|
|
93
|
+
return workshift;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Turma da escala.
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* const workshiftGroup = item.workshiftGroup; // Retorna o turma da escala associado ao histórico/programação.
|
|
101
|
+
* workshiftGroup.code; // Retorna o código do turma da escala.
|
|
102
|
+
* ```
|
|
103
|
+
* @return Turma da escala associado ao histórico/programação.
|
|
104
|
+
* @see {@link WorkshiftGroup}
|
|
105
|
+
*/
|
|
106
|
+
get workshiftGroups(): WorkshiftGroup {
|
|
107
|
+
const workshiftGroup = ContextReference.getGlobalInstance().getWorkshiftGroup(this._workshiftGroupId);
|
|
108
|
+
if (!workshiftGroup) {
|
|
109
|
+
throw new Error(`WorkshiftGroup not found for key: ${this._workshiftGroupId}`);
|
|
110
|
+
}
|
|
111
|
+
return workshiftGroup;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { ObjectUtils } from "../../utils/object.utils";
|
|
2
|
+
import { ContextReference } from "../context/contextReference";
|
|
3
|
+
import { CompanyBranch } from "../foundation/companyBranch";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @hidden
|
|
7
|
+
* Parâmetros necessários para criar uma instância de CompanyBranchHistory.
|
|
8
|
+
*/
|
|
9
|
+
export interface CompanyBranchHistoryParams {
|
|
10
|
+
/** A data inicial do histórico de filial de empresa. */
|
|
11
|
+
startDate: Date;
|
|
12
|
+
/** A data final do histórico de filial de empresa (opcional). */
|
|
13
|
+
endDate: Date | null;
|
|
14
|
+
/** A chave única que identifica a filial de empresa. */
|
|
15
|
+
companyBranchKey: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Representa o histórico de filial de empresa.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* companyBranchHistory.startDate; // Retorna a data inicial do histórico de filial.
|
|
24
|
+
* companyBranchHistory.endDate; // Retorna a data final do histórico de filial.
|
|
25
|
+
* const branch = companyBranchHistory.companyBranch; // Obtém a filial de empresa associada ao histórico.
|
|
26
|
+
* branch.code; // Retorna o código da filial.
|
|
27
|
+
* ```
|
|
28
|
+
* @see {@link CompanyBranch}
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
export class CompanyBranchHistory {
|
|
32
|
+
/** A data inicial do histórico de filial de empresa. */
|
|
33
|
+
private readonly _startDate: Date;
|
|
34
|
+
/** A data final do histórico de filial de empresa (opcional). */
|
|
35
|
+
private readonly _endDate: Date | null;
|
|
36
|
+
/** A chave única que identifica a filial de empresa. */
|
|
37
|
+
private readonly _companyBranchKey: string;
|
|
38
|
+
/**
|
|
39
|
+
* @hidden
|
|
40
|
+
* Cria uma nova instância de CompanyBranchHistory.
|
|
41
|
+
* @param params - Os parâmetros necessários para criar a instância.
|
|
42
|
+
*/
|
|
43
|
+
constructor(params: CompanyBranchHistoryParams) {
|
|
44
|
+
this._startDate = ObjectUtils.toDateOrThrow(params.startDate, "CompanyBranchHistory.startDate");
|
|
45
|
+
this._endDate = ObjectUtils.toDateOrNull(params.endDate);
|
|
46
|
+
this._companyBranchKey = params.companyBranchKey;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Obtém a data inicial do histórico de filial de empresa.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const startDate = companyBranchHistory.startDate; // Retorna a data inicial do histórico de filial.
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @returns A data inicial.
|
|
58
|
+
*/
|
|
59
|
+
get startDate(): Date {
|
|
60
|
+
return this._startDate;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Obtém a data final do histórico de filial de empresa.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* const endDate = companyBranchHistory.endDate; // Retorna a data final do histórico de filial.
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @returns A data final ou null se não estiver definida.
|
|
72
|
+
*/
|
|
73
|
+
get endDate(): Date | null {
|
|
74
|
+
return this._endDate;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @hidden
|
|
79
|
+
* Obtém a chave única que identifica a filial da empresa.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* const branchKey = companyBranchHistory.companyBranchKey; // Retorna a chave de filial de empresa.
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @returns A chave de filial de empresa.
|
|
87
|
+
*/
|
|
88
|
+
private get companyBranchKey(): string {
|
|
89
|
+
return this._companyBranchKey;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Obtém a filial de empresa associada ao histórico.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const branch = companyBranchHistory.companyBranch; // Obtém a filial de empresa associada ao histórico.
|
|
99
|
+
* * branch.code; // Retorna o código da filial.
|
|
100
|
+
* ```
|
|
101
|
+
* @returns A filial da empresa.
|
|
102
|
+
* @throws Se a filial de empresa não for encontrada.
|
|
103
|
+
* @see {@link CompanyBranch}
|
|
104
|
+
*/
|
|
105
|
+
get companyBranch(): CompanyBranch {
|
|
106
|
+
const companyBranch = ContextReference.getGlobalInstance().getCompanyBranch(this._companyBranchKey);
|
|
107
|
+
if (!companyBranch) {
|
|
108
|
+
throw new Error(`Company branch not found for key: ${this._companyBranchKey}`);
|
|
109
|
+
}
|
|
110
|
+
return companyBranch;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Clona o histórico de filial de empresa.
|
|
116
|
+
*
|
|
117
|
+
* @param companyBranchHistory - O histórico de filial de empresa a ser clonado.
|
|
118
|
+
* @returns Uma nova instância de CompanyBranchHistory com os mesmos dados.
|
|
119
|
+
*/
|
|
120
|
+
public static clone(companyBranchHistory: CompanyBranchHistory): CompanyBranchHistory {
|
|
121
|
+
const companyBranchHistoryParams: CompanyBranchHistoryParams = {
|
|
122
|
+
startDate: companyBranchHistory.startDate,
|
|
123
|
+
endDate: companyBranchHistory.endDate,
|
|
124
|
+
companyBranchKey: companyBranchHistory.companyBranchKey
|
|
125
|
+
};
|
|
126
|
+
return new CompanyBranchHistory(companyBranchHistoryParams);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { ObjectUtils } from "../../utils/object.utils";
|
|
2
|
+
import { ContextReference } from "../context/contextReference";
|
|
3
|
+
import { CostCenter } from "../foundation/costCenter";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Histórico de centro de custo do colaborador.
|
|
7
|
+
* O histórico de centro de custo é utilizado para verificar o centro de custo do colaborador em uma data específica.
|
|
8
|
+
* @hidden
|
|
9
|
+
*/
|
|
10
|
+
export interface CostCenterHistoryParams {
|
|
11
|
+
startDate: Date;
|
|
12
|
+
endDate: Date | null;
|
|
13
|
+
costCenterKey: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Representa o histórico de centro de custo do colaborador.
|
|
18
|
+
* O histórico de centro de custo é utilizado para verificar o centro de custo do colaborador em uma data específica.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```javascript
|
|
22
|
+
* costCenterHistory.startDate; // Data inicial do histórico de centro de custo.
|
|
23
|
+
* costCenterHistory.endDate; // Data final do histórico de centro de custo (pode ser null).
|
|
24
|
+
* costCenterHistory.costCenter; // Objeto CostCenter associado ao histórico.
|
|
25
|
+
* ```
|
|
26
|
+
* @see CostCenter
|
|
27
|
+
*/
|
|
28
|
+
export class CostCenterHistory {
|
|
29
|
+
private readonly _startDate: Date;
|
|
30
|
+
private readonly _endDate: Date | null;
|
|
31
|
+
private readonly _costCenterKey: string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @hidden
|
|
35
|
+
* @param params Parâmetros para a criação de CostCenterHistory.
|
|
36
|
+
*/
|
|
37
|
+
constructor(params: CostCenterHistoryParams) {
|
|
38
|
+
this._startDate = ObjectUtils.toDateOrThrow(params.startDate, "CostCenterHistory.startDate");
|
|
39
|
+
this._endDate = ObjectUtils.toDateOrNull(params.endDate);
|
|
40
|
+
this._costCenterKey = params.costCenterKey;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Data inicial do histórico de centro de custo.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```javascript
|
|
48
|
+
* let startDate = costCenterHistory.startDate;
|
|
49
|
+
* console.log(`Data inicial do histórico de centro de custo: ${startDate.toISOString()}`);
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @returns Data inicial do histórico de centro de custo.
|
|
53
|
+
*/
|
|
54
|
+
get startDate(): Date {
|
|
55
|
+
return this._startDate;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Data final do histórico de centro de custo.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```javascript
|
|
63
|
+
* let endDate = costCenterHistory.endDate;
|
|
64
|
+
* console.log(`Data final do histórico de centro de custo: ${endDate ? endDate.toISOString() : 'null'}`);
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @returns Data final do histórico de centro de custo.
|
|
68
|
+
*/
|
|
69
|
+
get endDate(): Date | null {
|
|
70
|
+
return this._endDate;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @hidden
|
|
75
|
+
*/
|
|
76
|
+
private get costCenterKey(): string {
|
|
77
|
+
return this._costCenterKey;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Centro de custo do colaborador.
|
|
82
|
+
* @example
|
|
83
|
+
*
|
|
84
|
+
* ```javascript
|
|
85
|
+
* let costCenter = costCenterHistory.costCenter;
|
|
86
|
+
* console.log(`Centro de custo: ${costCenter.code}`);
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @returns Centro de custo do colaborador.
|
|
90
|
+
* @throws Se o centro de custo não for encontrado.
|
|
91
|
+
*/
|
|
92
|
+
get costCenter(): CostCenter {
|
|
93
|
+
const costCenter = ContextReference.getGlobalInstance().getCostCenter(this._costCenterKey);
|
|
94
|
+
if (!costCenter) {
|
|
95
|
+
throw new Error(`Cost center not found for key: ${this._costCenterKey}`);
|
|
96
|
+
}
|
|
97
|
+
return costCenter;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Clona o histórico de centro de custo.
|
|
102
|
+
* @returns Uma nova instância de CostCenterHistory com os mesmos valores.
|
|
103
|
+
*/
|
|
104
|
+
public static clone(object: CostCenterHistory): CostCenterHistory {
|
|
105
|
+
|
|
106
|
+
const costCenterHistoryParams: CostCenterHistoryParams = {
|
|
107
|
+
startDate: object.startDate,
|
|
108
|
+
endDate: object.endDate,
|
|
109
|
+
costCenterKey: object.costCenterKey
|
|
110
|
+
};
|
|
111
|
+
return new CostCenterHistory(costCenterHistoryParams);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { ObjectUtils } from "../../utils/object.utils";
|
|
2
|
+
import { ContextReference } from "../context/contextReference";
|
|
3
|
+
import { EmploymentRelationship } from '../foundation/employmentRelationship';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @hidden
|
|
7
|
+
* Parâmetros necessários para criar uma instância de EmploymentRelationshipHistory.
|
|
8
|
+
*/
|
|
9
|
+
export interface EmploymentRelationshipHistoryParams {
|
|
10
|
+
/** A data inicial do histórico de vínculo. */
|
|
11
|
+
startDate: Date;
|
|
12
|
+
/** A data final do histórico de vínculo (opcional). */
|
|
13
|
+
endDate: Date | null;
|
|
14
|
+
/** ID que identifica o vínculo. */
|
|
15
|
+
employmentRelationshipId: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Representa o histórico de vínculo.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* employmentHistory.startDate; // Retorna a data inicial do histórico de vínculo.
|
|
24
|
+
* employmentHistory.endDate; // Retorna a data final do histórico de vínculo ou null se não estiver definida.
|
|
25
|
+
* const employmentRelationship = employmentHistory.employmentRelationship;
|
|
26
|
+
* employmentRelationship.type; // Retorna o tipo do vínculo.
|
|
27
|
+
* ```
|
|
28
|
+
* @see {@link EmploymentRelationship}
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
export class EmploymentRelationshipHistory {
|
|
32
|
+
/** A data inicial do histórico de vínculo. */
|
|
33
|
+
private readonly _startDate: Date;
|
|
34
|
+
/** A data final do histórico de vínculo (opcional). */
|
|
35
|
+
private readonly _endDate: Date | null;
|
|
36
|
+
/** ID que identifica o vínculo. */
|
|
37
|
+
private readonly _employmentRelationshipId: string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @hidden
|
|
41
|
+
* Cria uma nova instância de EmploymentRelationshipHistory.
|
|
42
|
+
* @param params - Os parâmetros necessários para criar a instância.
|
|
43
|
+
*/
|
|
44
|
+
constructor(params: EmploymentRelationshipHistoryParams) {
|
|
45
|
+
this._startDate = ObjectUtils.toDateOrThrow(params.startDate, "EmploymentRelationshipHistory.startDate");
|
|
46
|
+
this._endDate = ObjectUtils.toDateOrNull(params.endDate);
|
|
47
|
+
this._employmentRelationshipId = params.employmentRelationshipId;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Obtém a data inicial do histórico de vínculo.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* let startDate = employmentHistory.startDate; // Retorna a data inicial do histórico de vínculo.
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @returns A data inicial.
|
|
59
|
+
*/
|
|
60
|
+
get startDate(): Date {
|
|
61
|
+
return this._startDate;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Obtém a data final do histórico de vínculo. A data final pode ser null se for um histórico em aberto (sem data final definida).
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* let endDate = employmentHistory.endDate; // Retorna a data final do histórico de vínculo ou null se não estiver definida.
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
*
|
|
73
|
+
* @returns A data final ou null se não estiver definida.
|
|
74
|
+
*/
|
|
75
|
+
get endDate(): Date | null {
|
|
76
|
+
return this._endDate;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @hidden
|
|
81
|
+
* Obtém a chave única que identifica o vínculo.
|
|
82
|
+
* @returns ID do vínculo.
|
|
83
|
+
*/
|
|
84
|
+
private get employmentRelationshipId(): string {
|
|
85
|
+
return this._employmentRelationshipId;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Obtém o vínculo do colaborador associado ao histórico.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* let employmentRelationship = employmentHistory.employmentRelationship; // Retorna o vínculo do colaborador associado ao histórico.
|
|
94
|
+
* employmentRelationship.type; // Retorna o tipo do vínculo.
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @returns O vínculo.
|
|
98
|
+
* @throws Se o vínculo não for encontrado.
|
|
99
|
+
*/
|
|
100
|
+
get employmentRelationship(): EmploymentRelationship {
|
|
101
|
+
const employmentRelationship = ContextReference.getGlobalInstance().getEmploymentRelationship(this._employmentRelationshipId);
|
|
102
|
+
if (!employmentRelationship) {
|
|
103
|
+
throw new Error(`Employment relationship not found for key: ${this._employmentRelationshipId}`);
|
|
104
|
+
}
|
|
105
|
+
return employmentRelationship;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public static clone(object: EmploymentRelationshipHistory): EmploymentRelationshipHistory {
|
|
109
|
+
const employmentRelationshipParams = {
|
|
110
|
+
startDate: object.startDate,
|
|
111
|
+
endDate: object.endDate,
|
|
112
|
+
employmentRelationshipId: object.employmentRelationshipId
|
|
113
|
+
};
|
|
114
|
+
return new EmploymentRelationshipHistory(employmentRelationshipParams)
|
|
115
|
+
}
|
|
116
|
+
}
|