@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,154 @@
|
|
|
1
|
+
import { ContextReference } from "../context/contextReference";
|
|
2
|
+
import { Situation } from "../foundation/situation";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @hidden
|
|
6
|
+
*/
|
|
7
|
+
export interface TimeEvaluationSituationParams {
|
|
8
|
+
situationId: string | undefined;
|
|
9
|
+
situationCode: number;
|
|
10
|
+
numberOfHours: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Representa uma situação de apuração de horas de um dia.
|
|
15
|
+
* Uma situação de apuração é utilizada para registrar a quantidade de horas apuradas em uma situação específica, como horas extras, faltas, atrasos, etc.
|
|
16
|
+
*
|
|
17
|
+
* Exemplo de uso:
|
|
18
|
+
* ```typescript
|
|
19
|
+
* timeEvalSituation.situation.code; // Retorna o código da situação.
|
|
20
|
+
* timeEvalSituation.numberOfHours; // Retorna a quantidade de horas apuradas.
|
|
21
|
+
* timeEvalSituation.addNumberOfHours(2); // Adiciona 2 horas à situação apurada.
|
|
22
|
+
* ```
|
|
23
|
+
* @see {@link Situation}
|
|
24
|
+
*/
|
|
25
|
+
export class TimeEvaluationSituation {
|
|
26
|
+
/**
|
|
27
|
+
* @hidden
|
|
28
|
+
* Identificador
|
|
29
|
+
*/
|
|
30
|
+
id: string;
|
|
31
|
+
/**
|
|
32
|
+
* Situação.
|
|
33
|
+
*/
|
|
34
|
+
private readonly _situationId: string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Número de horas.
|
|
37
|
+
*/
|
|
38
|
+
private _numberOfHours: number;
|
|
39
|
+
private readonly _situationCode: number;
|
|
40
|
+
private _changed: boolean;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @hidden
|
|
44
|
+
* Construtor da classe TimeEvaluationSituation.
|
|
45
|
+
*/
|
|
46
|
+
constructor(params: TimeEvaluationSituationParams) {
|
|
47
|
+
this._situationId = params.situationId;
|
|
48
|
+
this._numberOfHours = params.numberOfHours;
|
|
49
|
+
this._changed = false;
|
|
50
|
+
this._situationCode = params.situationCode;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Retorna a quantidade de horas da situação em minutos.
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* timeEvalSituation.numberOfHours; // Retorna a quantidade de horas em minutos.
|
|
58
|
+
* ```
|
|
59
|
+
* @returns Quantidade de horas em minutos.
|
|
60
|
+
*
|
|
61
|
+
*/
|
|
62
|
+
get numberOfHours(): number {
|
|
63
|
+
return this._numberOfHours;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Atualiza a quantidade de horas da situação em minutos.
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* timeEvalSituation.numberOfHours = 120; // Define a quantidade de horas para 120 minutos.
|
|
71
|
+
* ```
|
|
72
|
+
* @param value Quantidade de horas em minutos.
|
|
73
|
+
*/
|
|
74
|
+
set numberOfHours(value: number) {
|
|
75
|
+
this._changed = true;
|
|
76
|
+
this._numberOfHours = value;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Retorna a situação associada a esta apuração de horas.
|
|
81
|
+
* Se o código da situação tiver sido carregado no contexto, retorna a situação correspondente com todos os dados.
|
|
82
|
+
* Caso contrário, constrói uma nova situação com base no código da situação e no contexto.
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* timeEvalSituation.situation.code; // Retorna o código da situação.
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @returns Situação associada à apuração.
|
|
89
|
+
*/
|
|
90
|
+
get situation(): Situation {
|
|
91
|
+
if (this._situationId) {
|
|
92
|
+
const situation = ContextReference.getGlobalInstance().getSituationById(this._situationId);
|
|
93
|
+
if (situation) {
|
|
94
|
+
return situation;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return Situation.build(this._situationCode);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Retorna o código da situação associada a esta apuração de horas.
|
|
103
|
+
* Vai sempre retornar um valor, mesmo que a situação não esteja carregada no contexto.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* timeEvalSituation.situationCode; // Retorna o código da situação.
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
get situationCode(): number {
|
|
111
|
+
return this._situationCode;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @hidden
|
|
116
|
+
*/
|
|
117
|
+
get changed(): boolean {
|
|
118
|
+
return this._changed;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Soma uma quantidade de horas a uma situação apurada em minutos.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* timeEvaluationSituation.numberOfHours; // Retorna a quantidade de horas apuradas, exemplo: 120 minutos (2 horas).
|
|
127
|
+
* timeEvalSituation.addNumberOfHours(120); // Adiciona 2 horas à situação apurada, exemplo: 240 minutos (4 horas).
|
|
128
|
+
* // Após a adição, a quantidade de horas apuradas será 240 minutos (4 horas).
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* @param numberOfHours Quantidade de horas a ser adicionada.
|
|
132
|
+
*/
|
|
133
|
+
public addNumberOfHours(numberOfHours: number) {
|
|
134
|
+
this._changed = true;
|
|
135
|
+
this._numberOfHours += numberOfHours;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @hidden
|
|
140
|
+
* Retorna o id da situação.
|
|
141
|
+
* Somente retorna caso exista referência para a situação.
|
|
142
|
+
*/
|
|
143
|
+
private get situationId(): string | undefined {
|
|
144
|
+
return this._situationId;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
public static clone(object: TimeEvaluationSituation): TimeEvaluationSituation {
|
|
148
|
+
return new TimeEvaluationSituation({
|
|
149
|
+
situationId: object.situationId,
|
|
150
|
+
situationCode: object.situationCode,
|
|
151
|
+
numberOfHours: object.numberOfHours,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hidden
|
|
3
|
+
* Interface para os parâmetros do construtor do User.
|
|
4
|
+
*/
|
|
5
|
+
export interface UserParams {
|
|
6
|
+
userName: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Representa o usuário corrente.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* console.log(user.userName); // Retorna o usuário corrente. Exemplo: "admin@senior.com.br"
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export class User {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Usuário corrente.
|
|
21
|
+
*/
|
|
22
|
+
private readonly _userName: string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @hidden
|
|
26
|
+
* @param params Parâmetros necessários para criar uma instância de User.
|
|
27
|
+
*/
|
|
28
|
+
constructor(params: UserParams) {
|
|
29
|
+
this._userName = params.userName;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Retorna o usuário corrente.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* let userName = user.userName; // Retorna o usuário corrente.
|
|
38
|
+
* ```
|
|
39
|
+
* @return Usuário corrente.
|
|
40
|
+
*/
|
|
41
|
+
get userName(): string {
|
|
42
|
+
return this._userName;
|
|
43
|
+
}
|
|
44
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export { Context } from './data/context/context';
|
|
2
|
+
export { Changes, ChangesItems, ChangesType } from './data/changes/changes';
|
|
3
|
+
export { ClockingEvent, ClockingEventOriginType, ClockingUseType } from './data/timeEvaluation/clockingEvent';
|
|
4
|
+
export { Contract, ContractType } from './data/contract/contract';
|
|
5
|
+
export { DateUtils, WeekDay } from './utils/dateUtils';
|
|
6
|
+
export { ObjectUtils } from './utils/object.utils';
|
|
7
|
+
export { Employee } from './data/employee/employee';
|
|
8
|
+
export { Employer } from './data/foundation/employer';
|
|
9
|
+
export { EmploymentRelationship } from './data/foundation/employmentRelationship';
|
|
10
|
+
export { Log, LogType } from './data/log/log';
|
|
11
|
+
export { Histories } from './data/histories/histories';
|
|
12
|
+
export { Holiday } from './data/foundation/holiday';
|
|
13
|
+
export { HolidayGroup } from './data/foundation/holidayGroup';
|
|
14
|
+
export { Interval, IntervalSubTypes, IntervalTypes, PositionWorkHours } from './data/timeEvaluation/interval';
|
|
15
|
+
export { Person } from './data/foundation/person';
|
|
16
|
+
export { Dataset as RuleParams } from './data/dataset/dataset';
|
|
17
|
+
export { Schedules } from './data/schedules/schedules';
|
|
18
|
+
export { Bridge } from './data/schedules/bridge';
|
|
19
|
+
export { WorkscheduleChange } from './data/schedules/workscheduleChange';
|
|
20
|
+
export { WorkshiftChange } from './data/schedules/workshiftChange';
|
|
21
|
+
export { LeaveHistory } from './data/histories/leaveHistory';
|
|
22
|
+
export { SeparatedHours } from './data/timeEvaluation/separatedHours';
|
|
23
|
+
export { Situation, SituationType } from './data/foundation/situation';
|
|
24
|
+
export { Syndicate } from './data/foundation/syndicate';
|
|
25
|
+
export { TimeEvaluation } from './data/timeEvaluation/timeEvaluation';
|
|
26
|
+
export { TimeEvaluationSituation } from './data/timeEvaluation/timeEvaluationSituation';
|
|
27
|
+
export {
|
|
28
|
+
Workschedule,
|
|
29
|
+
WorkscheduleClockingRegister,
|
|
30
|
+
WorkscheduleClockingEvent,
|
|
31
|
+
WorkscheduleParams,
|
|
32
|
+
WorkscheduleType,
|
|
33
|
+
ClockingEventScheduleType,
|
|
34
|
+
WorkscheduleDefinitionType,
|
|
35
|
+
UsingType,
|
|
36
|
+
IntervalType
|
|
37
|
+
} from './data/foundation/workschedule';
|
|
38
|
+
export { Workshift, WorkshiftParams, WorkshiftType, AutoSearchType, TimeShiftType, WorkshiftGroup, WorkshiftDetail, HolidayGroupParams, HolidayType } from './data/foundation/workshift';
|
|
39
|
+
export { TimeEvaluationSituationDefinitionHistory } from './data/definition/timeEvaluationSituationDefinitionHistory';
|
|
40
|
+
export { JobPositionHistory } from './data/histories/jobPositionHistory';
|
|
41
|
+
export { WorkshiftHistory } from './data/histories/workshiftHistory';
|
|
42
|
+
export { JobPosition } from './data/foundation/jobPosition';
|
|
43
|
+
export { CompanyBranchHistory } from './data/histories/companyBranchHistory';
|
|
44
|
+
export { CompanyBranch } from './data/foundation/companyBranch';
|
|
45
|
+
export { DateInterval, DateIntervalUtils } from './utils/dateIntervalUtils';
|
|
46
|
+
export { ContextReference } from './data/context/contextReference';
|
|
47
|
+
export { User } from './data/user/user';
|
|
48
|
+
export { HourBankAccount } from './data/hourBank/hourBankAccount';
|
|
49
|
+
export { EmploymentRelationshipHistory } from "./data/histories/employmentRelationshipHistory";
|
|
50
|
+
export { TimeEvaluationHistory, TimeEvaluationType } from './data/histories/timeEvaluationHistory';
|
|
51
|
+
export { EstimatedHours } from "./data/timeEvaluation/estimatedHours";
|
|
52
|
+
export { HourBank } from "./data/hourBank/hourBank";
|
|
53
|
+
export { Readiness } from './data/schedules/readiness';
|
|
54
|
+
export { OvertimeAuthorization } from "./data/schedules/overtimeAuthorization";
|
|
55
|
+
export { Compensation, CompensationType, PeriodType } from './data/schedules/compensation';
|
|
56
|
+
export { CostCenter } from "./data/foundation/costCenter";
|
|
57
|
+
export { Database } from "./data/dataset/database";
|
|
58
|
+
export { Dataset } from "./data/dataset/dataset";
|
|
59
|
+
export { CostCenterHistory } from "./data/histories/costCenterHistory";
|
|
60
|
+
export { AdjustmentReason, AdjustmentReasonParams } from './data/timeEvaluation/adjustmentReason';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Bridge, BridgeParams } from "../../data/schedules/bridge";
|
|
2
|
+
|
|
3
|
+
export class BridgeBuilder {
|
|
4
|
+
private originDate: Date = new Date();
|
|
5
|
+
private destinationDate: Date = new Date();
|
|
6
|
+
|
|
7
|
+
static builder(): BridgeBuilder {
|
|
8
|
+
return new BridgeBuilder();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
withOriginDate(originDate: Date): BridgeBuilder {
|
|
12
|
+
this.originDate = originDate;
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
withDestinationDate(destinationDate: Date): BridgeBuilder {
|
|
17
|
+
this.destinationDate = destinationDate;
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
build(): Bridge {
|
|
22
|
+
const params: BridgeParams = {
|
|
23
|
+
originDate: this.originDate,
|
|
24
|
+
destinationDate: this.destinationDate,
|
|
25
|
+
};
|
|
26
|
+
return new Bridge(params);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ObjectUtils } from "../../../src/utils/object.utils";
|
|
2
|
+
import { ClockingEventOriginType, ClockingUseType, ClockingEvent, ClockingEventParams } from "../../../src/data/timeEvaluation/clockingEvent";
|
|
3
|
+
|
|
4
|
+
export class ClockingEventBuilder {
|
|
5
|
+
|
|
6
|
+
private clockingEventDate = new Date("2025-01-01");
|
|
7
|
+
private clockingEventTime = 429;
|
|
8
|
+
private functionCode = 0;
|
|
9
|
+
private originType = ClockingEventOriginType.TYPED;
|
|
10
|
+
private useType = ClockingUseType.CLOCKING;
|
|
11
|
+
|
|
12
|
+
public withClockingEventDate(clockingEventDate: Date): ClockingEventBuilder {
|
|
13
|
+
this.clockingEventDate = clockingEventDate;
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public withClockingEventTime(clockingEventTime: number): ClockingEventBuilder {
|
|
18
|
+
this.clockingEventTime = clockingEventTime;
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public withFunctionCode(functionCode: number): ClockingEventBuilder {
|
|
23
|
+
this.functionCode = functionCode;
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public withOriginType(originType: ClockingEventOriginType): ClockingEventBuilder {
|
|
28
|
+
this.originType = originType;
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public withUseType(useType: ClockingUseType): ClockingEventBuilder {
|
|
33
|
+
this.useType = useType;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
public build(): ClockingEvent {
|
|
39
|
+
const params: ClockingEventParams = {
|
|
40
|
+
clockingEventDate: ObjectUtils.toDateOrThrow(this.clockingEventDate, "clockingEvent.clockingEventDate"),
|
|
41
|
+
clockingEventTime: this.clockingEventTime,
|
|
42
|
+
functionCode: this.functionCode,
|
|
43
|
+
originType: this.originType,
|
|
44
|
+
useType: this.useType,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return new ClockingEvent(params);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CompanyBranchHistory, CompanyBranchHistoryParams } from "../../data/histories/companyBranchHistory";
|
|
2
|
+
|
|
3
|
+
export class CompanyBranchHistoryBuilder {
|
|
4
|
+
static defaultParams(): CompanyBranchHistoryParams {
|
|
5
|
+
return {
|
|
6
|
+
startDate: new Date("2023-01-01"),
|
|
7
|
+
endDate: new Date("2023-12-31"),
|
|
8
|
+
companyBranchKey: "CB1"
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static default(): { build: () => CompanyBranchHistory } {
|
|
13
|
+
return {
|
|
14
|
+
build: (): CompanyBranchHistory => {
|
|
15
|
+
return new CompanyBranchHistory(this.defaultParams());
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static withParams(params: Partial<CompanyBranchHistoryParams>): { build: () => CompanyBranchHistory } {
|
|
21
|
+
return {
|
|
22
|
+
build: (): CompanyBranchHistory => {
|
|
23
|
+
const def = this.defaultParams();
|
|
24
|
+
const merged: CompanyBranchHistoryParams = { ...def, ...params };
|
|
25
|
+
return new CompanyBranchHistory(merged);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Compensation, CompensationParams, CompensationType, PeriodType } from "../../data/schedules/compensation";
|
|
2
|
+
|
|
3
|
+
export class CompensationBuilder {
|
|
4
|
+
private params: CompensationParams;
|
|
5
|
+
|
|
6
|
+
private constructor() {
|
|
7
|
+
this.params = CompensationBuilder.defaultParams();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
static defaultParams(): CompensationParams {
|
|
11
|
+
return {
|
|
12
|
+
startDate: new Date("2023-01-01"),
|
|
13
|
+
endDate: new Date("2023-01-31"),
|
|
14
|
+
intervalStart: 480, // 08:00
|
|
15
|
+
intervalEnd: 1020, // 17:00
|
|
16
|
+
compensationType: CompensationType.ABSENCE_FOR_COMPENSATION,
|
|
17
|
+
periodType: PeriodType.ANY_PART_OF_WORKDAY,
|
|
18
|
+
numberOfHours: 8,
|
|
19
|
+
situationId: "situation-123",
|
|
20
|
+
workscheduleId: "workschedule-456",
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static default(): CompensationBuilder {
|
|
25
|
+
return new CompensationBuilder();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
withParams(params: Partial<CompensationParams>): CompensationBuilder {
|
|
29
|
+
this.params = {
|
|
30
|
+
...this.params,
|
|
31
|
+
...params
|
|
32
|
+
};
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
withStartDate(startDate: Date): CompensationBuilder {
|
|
37
|
+
this.params.startDate = startDate;
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
withEndDate(endDate: Date): CompensationBuilder {
|
|
42
|
+
this.params.endDate = endDate;
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
withIntervalStart(intervalStart: number): CompensationBuilder {
|
|
47
|
+
this.params.intervalStart = intervalStart;
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
withIntervalEnd(intervalEnd: number): CompensationBuilder {
|
|
52
|
+
this.params.intervalEnd = intervalEnd;
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
withCompensationType(compensationType: CompensationType): CompensationBuilder {
|
|
57
|
+
this.params.compensationType = compensationType;
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
withPeriodType(periodType: PeriodType): CompensationBuilder {
|
|
62
|
+
this.params.periodType = periodType;
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
withNumberOfHours(numberOfHours: number): CompensationBuilder {
|
|
67
|
+
this.params.numberOfHours = numberOfHours;
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
withSituationId(situationId: string): CompensationBuilder {
|
|
72
|
+
this.params.situationId = situationId;
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
withWorkscheduleId(workscheduleId: string): CompensationBuilder {
|
|
77
|
+
this.params.workscheduleId = workscheduleId;
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
build(): Compensation {
|
|
82
|
+
return new Compensation(this.params);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ContextReference } from "../../../src/data/context/contextReference";
|
|
2
|
+
import { Situation } from "../../../src/data/foundation/situation";
|
|
3
|
+
import { SituationBuilder } from "./situation.builder";
|
|
4
|
+
import { HolidayBuilder } from "./holiday.builder";
|
|
5
|
+
import { TimeEvaluationSituationDefinitionHistory } from "../../data/definition/timeEvaluationSituationDefinitionHistory";
|
|
6
|
+
import { Holiday } from "../../data/foundation/holiday";
|
|
7
|
+
|
|
8
|
+
export class ContextReferenceBuilder {
|
|
9
|
+
private situations: Situation[] = [
|
|
10
|
+
new SituationBuilder().build()
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
private holidays: Holiday[] = [
|
|
14
|
+
new HolidayBuilder().build()
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
static builder(): ContextReferenceBuilder {
|
|
18
|
+
return new ContextReferenceBuilder();
|
|
19
|
+
}
|
|
20
|
+
static default(): ContextReferenceBuilder {
|
|
21
|
+
return new ContextReferenceBuilder();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private timeEvaluationSituationDefinitionHistories: TimeEvaluationSituationDefinitionHistory[] = [];
|
|
25
|
+
|
|
26
|
+
public withSituations(situations: Situation[]): ContextReferenceBuilder {
|
|
27
|
+
this.situations = situations;
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public withHolidays(holidays: Holiday[]): ContextReferenceBuilder {
|
|
32
|
+
this.holidays = holidays;
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static empty(): ContextReference {
|
|
37
|
+
return new ContextReference({
|
|
38
|
+
situations: [],
|
|
39
|
+
holidays: [],
|
|
40
|
+
timeEvaluationSituationDefinitions: [],
|
|
41
|
+
jobPositions: [],
|
|
42
|
+
companyBranches: [],
|
|
43
|
+
workschedules: [],
|
|
44
|
+
workshifts: [],
|
|
45
|
+
workshiftGroups: [],
|
|
46
|
+
workshiftDetails: [],
|
|
47
|
+
syndicates: [],
|
|
48
|
+
employmentRelationships: [],
|
|
49
|
+
costCenters: []
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public build(): ContextReference {
|
|
54
|
+
return new ContextReference({
|
|
55
|
+
situations: this.situations,
|
|
56
|
+
holidays: this.holidays,
|
|
57
|
+
timeEvaluationSituationDefinitions: this.timeEvaluationSituationDefinitionHistories,
|
|
58
|
+
jobPositions: [],
|
|
59
|
+
workschedules: [],
|
|
60
|
+
workshifts: [],
|
|
61
|
+
workshiftGroups: [],
|
|
62
|
+
workshiftDetails: [],
|
|
63
|
+
companyBranches: [],
|
|
64
|
+
syndicates: [],
|
|
65
|
+
employmentRelationships: [],
|
|
66
|
+
costCenters: []
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CostCenterHistory, CostCenterHistoryParams } from "../../data/histories/costCenterHistory";
|
|
2
|
+
|
|
3
|
+
export class CostCenterHistoryBuilder {
|
|
4
|
+
static defaultParams(): CostCenterHistoryParams {
|
|
5
|
+
return {
|
|
6
|
+
startDate: new Date("2023-01-01"),
|
|
7
|
+
endDate: new Date("2023-12-31"),
|
|
8
|
+
costCenterKey: "CC1"
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static default(): { build: () => CostCenterHistory } {
|
|
13
|
+
return {
|
|
14
|
+
build: (): CostCenterHistory => {
|
|
15
|
+
return new CostCenterHistory(this.defaultParams());
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static withParams(params: Partial<CostCenterHistoryParams>): { build: () => CostCenterHistory } {
|
|
21
|
+
return {
|
|
22
|
+
build: (): CostCenterHistory => {
|
|
23
|
+
const def = this.defaultParams();
|
|
24
|
+
const merged: CostCenterHistoryParams = { ...def, ...params };
|
|
25
|
+
return new CostCenterHistory(merged);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Database } from "../../data/dataset/database";
|
|
2
|
+
|
|
3
|
+
export class DatabaseBuilder {
|
|
4
|
+
|
|
5
|
+
static empty(): Database {
|
|
6
|
+
return new Database({
|
|
7
|
+
situations: [],
|
|
8
|
+
holidays: [],
|
|
9
|
+
jobPositions: [],
|
|
10
|
+
companyBranches: [],
|
|
11
|
+
timeEvaluationSituationDefinitions: [],
|
|
12
|
+
syndicates: [],
|
|
13
|
+
workschedules: [],
|
|
14
|
+
workshifts: [],
|
|
15
|
+
workshiftGroups: [],
|
|
16
|
+
workshiftDetails: [],
|
|
17
|
+
employmentRelationships: [],
|
|
18
|
+
costCenters: []
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Dataset, DatasetParams } from "../../data/dataset/dataset";
|
|
2
|
+
import { Contract } from "../../data/contract/contract";
|
|
3
|
+
import { TimeEvaluation } from "../../data/timeEvaluation/timeEvaluation";
|
|
4
|
+
import { TimeEvaluationSituation } from "../../data/timeEvaluation/timeEvaluationSituation";
|
|
5
|
+
import { SchedulesBuilder } from "./schedules.builder";
|
|
6
|
+
import { HistoriesBuilder } from "./historiesBuilder";
|
|
7
|
+
import { TimeEvaluationBuilder } from "./timeEvaluation.builder";
|
|
8
|
+
import { EstimatedHours } from "../../data/timeEvaluation/estimatedHours";
|
|
9
|
+
import { DatabaseBuilder } from "./database.builder";
|
|
10
|
+
import { User } from "../../data/user/user";
|
|
11
|
+
|
|
12
|
+
export class DatasetBuilder {
|
|
13
|
+
static default() {
|
|
14
|
+
return {
|
|
15
|
+
build: (): Dataset => {
|
|
16
|
+
const params: DatasetParams = {
|
|
17
|
+
batchId: "batch-1",
|
|
18
|
+
startDate: new Date(),
|
|
19
|
+
endDate: new Date(),
|
|
20
|
+
contracts: [],
|
|
21
|
+
database: DatabaseBuilder.empty(),
|
|
22
|
+
currentUser: new User({ userName: "test-user" })
|
|
23
|
+
};
|
|
24
|
+
return new Dataset(params);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static withContractWithError() {
|
|
30
|
+
return {
|
|
31
|
+
build: (): Dataset => {
|
|
32
|
+
|
|
33
|
+
const timeEvaluation = TimeEvaluationBuilder.default();
|
|
34
|
+
timeEvaluation.invalidate("Error message");
|
|
35
|
+
|
|
36
|
+
const contract = this.newContract(timeEvaluation);
|
|
37
|
+
const params: DatasetParams = DatasetBuilder.newDatasetParams(contract);
|
|
38
|
+
|
|
39
|
+
return new Dataset(params);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static newDatasetParams(contract: Contract): DatasetParams {
|
|
45
|
+
return {
|
|
46
|
+
batchId: "batch-err",
|
|
47
|
+
startDate: new Date(),
|
|
48
|
+
endDate: new Date(),
|
|
49
|
+
contracts: [contract],
|
|
50
|
+
database: DatabaseBuilder.empty(),
|
|
51
|
+
currentUser: new User({ userName: "test-user" })
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static newContract(timeEvaluation: TimeEvaluation) {
|
|
56
|
+
return {
|
|
57
|
+
id: "c1",
|
|
58
|
+
holidays: [],
|
|
59
|
+
timeEvaluation: [timeEvaluation],
|
|
60
|
+
employee: null,
|
|
61
|
+
histories: [],
|
|
62
|
+
schedules: [],
|
|
63
|
+
hourBankAccounts: [],
|
|
64
|
+
} as unknown as Contract;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static withContractWithSituationChanged() {
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
build: (): Dataset => {
|
|
71
|
+
const situation = new TimeEvaluationSituation({
|
|
72
|
+
situationId: "",
|
|
73
|
+
situationCode: 1,
|
|
74
|
+
numberOfHours: 8
|
|
75
|
+
});
|
|
76
|
+
const timeEvaluation = new TimeEvaluation({
|
|
77
|
+
date: new Date(),
|
|
78
|
+
workscheduleId: "string",
|
|
79
|
+
workscheduleWorkshiftId: "string",
|
|
80
|
+
workshiftId: "string",
|
|
81
|
+
timeEvaluationSituations: [situation],
|
|
82
|
+
clockingEvents: [],
|
|
83
|
+
intervals: [],
|
|
84
|
+
schedules: SchedulesBuilder.default().build(),
|
|
85
|
+
histories: HistoriesBuilder.default().build(),
|
|
86
|
+
hourBankAccounts: [],
|
|
87
|
+
situationDefinitionKey: "string",
|
|
88
|
+
estimatedHours: new EstimatedHours({
|
|
89
|
+
meal: [
|
|
90
|
+
{ dailyHours: 90, nightlyHours: 0 },
|
|
91
|
+
{ dailyHours: 30, nightlyHours: 10 }
|
|
92
|
+
],
|
|
93
|
+
snack: [
|
|
94
|
+
{ dailyHours: 15, nightlyHours: 5 }
|
|
95
|
+
],
|
|
96
|
+
work: [
|
|
97
|
+
{ dailyHours: 120, nightlyHours: 30 },
|
|
98
|
+
{ dailyHours: 60, nightlyHours: 0 }
|
|
99
|
+
]
|
|
100
|
+
}),
|
|
101
|
+
syndicateKey: "string",
|
|
102
|
+
missingClockingEvent: false,
|
|
103
|
+
costCenterKey: "costCenterKey",
|
|
104
|
+
});
|
|
105
|
+
const contract = this.newContract(timeEvaluation);
|
|
106
|
+
const params = DatasetBuilder.newDatasetParams(contract);
|
|
107
|
+
return new Dataset(params);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|