@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.
Files changed (128) hide show
  1. package/.github/copilot-instructions.md +11 -0
  2. package/.github/workflows/release.yaml +10 -0
  3. package/.gitlab-ci.yml +68 -0
  4. package/CHANGELOG.md +274 -0
  5. package/README.doc.md +658 -0
  6. package/README.md +117 -0
  7. package/assets/favicon.ico +0 -0
  8. package/catalog-info.yaml +19 -0
  9. package/jest.config.js +17 -0
  10. package/package.json +48 -0
  11. package/prompt.md +15 -0
  12. package/run_build_win.bat +1 -0
  13. package/run_link.bat +3 -0
  14. package/run_test.bat +1 -0
  15. package/sonar-project.properties +21 -0
  16. package/src/data/changes/changes.ts +92 -0
  17. package/src/data/context/context.ts +251 -0
  18. package/src/data/context/contextReference.ts +376 -0
  19. package/src/data/contract/contract.ts +272 -0
  20. package/src/data/dataset/database.ts +130 -0
  21. package/src/data/dataset/dataset.ts +275 -0
  22. package/src/data/definition/timeEvaluationSituationDefinitionHistory.ts +1425 -0
  23. package/src/data/employee/employee.ts +434 -0
  24. package/src/data/foundation/companyBranch.ts +66 -0
  25. package/src/data/foundation/costCenter.ts +47 -0
  26. package/src/data/foundation/employer.ts +35 -0
  27. package/src/data/foundation/employmentRelationship.ts +63 -0
  28. package/src/data/foundation/holiday.ts +84 -0
  29. package/src/data/foundation/holidayGroup.ts +47 -0
  30. package/src/data/foundation/jobPosition.ts +73 -0
  31. package/src/data/foundation/person.ts +35 -0
  32. package/src/data/foundation/situation.ts +301 -0
  33. package/src/data/foundation/syndicate.ts +244 -0
  34. package/src/data/foundation/workschedule.ts +688 -0
  35. package/src/data/foundation/workshift.ts +647 -0
  36. package/src/data/foundation/workshiftBase.ts +113 -0
  37. package/src/data/histories/companyBranchHistory.ts +128 -0
  38. package/src/data/histories/costCenterHistory.ts +114 -0
  39. package/src/data/histories/employmentRelationshipHistory.ts +116 -0
  40. package/src/data/histories/histories.ts +419 -0
  41. package/src/data/histories/jobPositionHistory.ts +117 -0
  42. package/src/data/histories/leaveHistory.ts +227 -0
  43. package/src/data/histories/timeEvaluationHistory.ts +191 -0
  44. package/src/data/histories/workshiftHistory.ts +66 -0
  45. package/src/data/hourBank/hourBank.ts +43 -0
  46. package/src/data/hourBank/hourBankAccount.ts +77 -0
  47. package/src/data/log/log.ts +38 -0
  48. package/src/data/schedules/bridge.ts +84 -0
  49. package/src/data/schedules/compensation.ts +332 -0
  50. package/src/data/schedules/overtimeAuthorization.ts +174 -0
  51. package/src/data/schedules/readiness.ts +150 -0
  52. package/src/data/schedules/schedules.ts +398 -0
  53. package/src/data/schedules/workscheduleChange.ts +91 -0
  54. package/src/data/schedules/workshiftChange.ts +76 -0
  55. package/src/data/timeEvaluation/adjustmentReason.ts +46 -0
  56. package/src/data/timeEvaluation/clockingEvent.ts +198 -0
  57. package/src/data/timeEvaluation/estimatedHours.ts +245 -0
  58. package/src/data/timeEvaluation/interval.ts +568 -0
  59. package/src/data/timeEvaluation/separatedHours.ts +134 -0
  60. package/src/data/timeEvaluation/timeEvaluation.ts +1540 -0
  61. package/src/data/timeEvaluation/timeEvaluationSituation.ts +154 -0
  62. package/src/data/user/user.ts +44 -0
  63. package/src/index.ts +60 -0
  64. package/src/test/builder/bridgeBuilder.builder.ts +28 -0
  65. package/src/test/builder/clockingEvent.builder.ts +49 -0
  66. package/src/test/builder/companyBranchHistoryBuilder.ts +29 -0
  67. package/src/test/builder/compensation.builder.ts +84 -0
  68. package/src/test/builder/contextReference.builder.ts +69 -0
  69. package/src/test/builder/costCenterHistoryBuilder.ts +29 -0
  70. package/src/test/builder/database.builder.ts +21 -0
  71. package/src/test/builder/datasetBuilder.ts +111 -0
  72. package/src/test/builder/dateIntervalBuilder.ts +25 -0
  73. package/src/test/builder/employee.builder.ts +91 -0
  74. package/src/test/builder/employmentRelationshipBuilder.ts +35 -0
  75. package/src/test/builder/employmentRelationshipHistoryBuilder.ts +29 -0
  76. package/src/test/builder/historiesBuilder.ts +56 -0
  77. package/src/test/builder/holiday.builder.ts +44 -0
  78. package/src/test/builder/hourBankAccountBuilder.ts +77 -0
  79. package/src/test/builder/hourBankBuilder.ts +32 -0
  80. package/src/test/builder/interval.builder.ts +113 -0
  81. package/src/test/builder/jobPositionHistoryBuilder.ts +29 -0
  82. package/src/test/builder/overtimeAuthorization.builder.ts +42 -0
  83. package/src/test/builder/readinessBuilder.builder.ts +57 -0
  84. package/src/test/builder/schedules.builder.ts +126 -0
  85. package/src/test/builder/situation.builder.ts +59 -0
  86. package/src/test/builder/syndicate.builder.ts +96 -0
  87. package/src/test/builder/syndicateHistoryBuilder.ts +33 -0
  88. package/src/test/builder/timeEvaluation.builder.ts +138 -0
  89. package/src/test/builder/timeEvaluationHistory.builder.ts +49 -0
  90. package/src/test/builder/timeEvaluationSituation.builder.ts +34 -0
  91. package/src/test/builder/workschedule.builder.ts +96 -0
  92. package/src/test/builder/workshift.builder.ts +179 -0
  93. package/src/test/builder/workshiftBuilder.ts +55 -0
  94. package/src/test/data/clockingEvent.spec.ts +56 -0
  95. package/src/test/data/context.spec.ts +176 -0
  96. package/src/test/data/currentUser.spec.ts +11 -0
  97. package/src/test/data/dataset.spec.ts +144 -0
  98. package/src/test/data/employee/employee.spec.ts +20 -0
  99. package/src/test/data/employmentRelationship/employmentRelationship.spec.ts +48 -0
  100. package/src/test/data/estimatedHours/estimatedHours.spec.ts +96 -0
  101. package/src/test/data/histories/costCenterHistory.spec.ts +32 -0
  102. package/src/test/data/histories/histories.spec.ts +306 -0
  103. package/src/test/data/holyday.spec.ts +89 -0
  104. package/src/test/data/hourBank/hourBank.spec.ts +48 -0
  105. package/src/test/data/hourBank/hourBankAccount.spec.ts +32 -0
  106. package/src/test/data/schedules/bridge.spec.ts +13 -0
  107. package/src/test/data/schedules/compesation.spect.ts +89 -0
  108. package/src/test/data/schedules/overtimeAuthorization.spec.ts +52 -0
  109. package/src/test/data/schedules/readiness.spec.ts +64 -0
  110. package/src/test/data/schedules/schedules.spec.ts +134 -0
  111. package/src/test/data/schedules/workscheduleChange.spec.ts +21 -0
  112. package/src/test/data/syndicate/syndicate.spec.ts +51 -0
  113. package/src/test/data/timeEvaluation.spec.ts +1057 -0
  114. package/src/test/data/timeEvaluationDefinition.spec.ts +144 -0
  115. package/src/test/data/workschedule/workschedule.spec.ts +194 -0
  116. package/src/test/data/workshift/workshift.spec.ts +79 -0
  117. package/src/test/utils/date.utils.spec.ts +198 -0
  118. package/src/test/utils/dateIntervalUtils.spec.ts +210 -0
  119. package/src/test/utils/object.utils.spec.ts +83 -0
  120. package/src/utils/dateIntervalUtils.ts +284 -0
  121. package/src/utils/dateUtils.ts +456 -0
  122. package/src/utils/decompressGzipLambda.ts +15 -0
  123. package/src/utils/object.utils.ts +156 -0
  124. package/trivy/vulnerabilities_scan.json +1160 -0
  125. package/tsconfig.json +32 -0
  126. package/tsconfig.spec.json +21 -0
  127. package/tslint.json +92 -0
  128. package/typedoc.json +22 -0
@@ -0,0 +1,25 @@
1
+ import { DateInterval } from "../../utils/dateIntervalUtils";
2
+
3
+ /**
4
+ * Builder estático para DateInterval, com valores padrão e métodos de customização.
5
+ */
6
+ export class DateIntervalBuilder {
7
+ public static readonly defaultStart: Date = new Date("2023-01-01T00:00:00.000Z");
8
+ public static readonly defaultEnd: Date = new Date("2023-01-02T00:00:00.000Z");
9
+
10
+ static build(start: Date = DateIntervalBuilder.defaultStart, end: Date = DateIntervalBuilder.defaultEnd): DateInterval {
11
+ return new DateInterval(start, end);
12
+ }
13
+
14
+ static withStart(start: Date): DateInterval {
15
+ return new DateInterval(start, DateIntervalBuilder.defaultEnd);
16
+ }
17
+
18
+ static withEnd(end: Date): DateInterval {
19
+ return new DateInterval(DateIntervalBuilder.defaultStart, end);
20
+ }
21
+
22
+ static withRange(start: Date, end: Date): DateInterval {
23
+ return new DateInterval(start, end);
24
+ }
25
+ }
@@ -0,0 +1,91 @@
1
+ import { Employee } from "../../data/employee/employee";
2
+ import { Employer } from "../../data/foundation/employer";
3
+ import { Person } from "../../data/foundation/person";
4
+
5
+ export class EmployeeBuilder {
6
+
7
+ private id = "id";
8
+ private code = 33;
9
+ private person: Person = new Person({ name: "Lionel Messi" });
10
+ private hireDate = new Date("2023-03-23");
11
+ private dismissalDate: Date | null = null;
12
+ private employmentRelationshipId = "775ee7d1-5d7f-4a1b-b50b-b659a66014b2";
13
+ private employer: Employer = new Employer({ code: 1 });
14
+ private costCenterKey = "02";
15
+ private companyBranchKey = "1_1";
16
+ private jobPositionKey = "1_1";
17
+ private workshiftId = "47971e5f-3d1a-4494-8cf6-328c7dfa5394";
18
+ private workshiftGroupId = "137fa797-595f-45e7-8365-f256e3148016";
19
+
20
+ public withId(id: string): EmployeeBuilder {
21
+ this.id = id;
22
+ return this;
23
+ }
24
+
25
+ public withCode(code: number): EmployeeBuilder {
26
+ this.code = code;
27
+ return this;
28
+ }
29
+
30
+ public withPerson(person: Person): EmployeeBuilder {
31
+ this.person = person;
32
+ return this;
33
+ }
34
+
35
+ public withHireDate(hireDate: Date): EmployeeBuilder {
36
+ this.hireDate = hireDate;
37
+ return this;
38
+ }
39
+
40
+ public withDismissalDate(dismissalDate: Date | null): EmployeeBuilder {
41
+ this.dismissalDate = dismissalDate;
42
+ return this;
43
+ }
44
+
45
+ public withEmploymentRelationshipId(employmentRelationshipId: string): EmployeeBuilder {
46
+ this.employmentRelationshipId = employmentRelationshipId;
47
+ return this;
48
+ }
49
+
50
+ public withEmployer(employer: Employer): EmployeeBuilder {
51
+ this.employer = employer;
52
+ return this;
53
+ }
54
+
55
+ public withCompanyBranchKey(companyBranchKey: string): EmployeeBuilder {
56
+ this.companyBranchKey = companyBranchKey;
57
+ return this;
58
+ }
59
+
60
+ public withJobPositionKey(jobPositionKey: string): EmployeeBuilder {
61
+ this.jobPositionKey = jobPositionKey;
62
+ return this;
63
+ }
64
+
65
+ public withWorkshiftId(workshiftId: string): EmployeeBuilder {
66
+ this.workshiftId = workshiftId;
67
+ return this;
68
+ }
69
+
70
+ public withWorkshiftGroupId(workshiftGroupId: string): EmployeeBuilder {
71
+ this.workshiftGroupId = workshiftGroupId;
72
+ return this;
73
+ }
74
+
75
+ public build(): Employee {
76
+ return new Employee({
77
+ id: this.id,
78
+ code: this.code,
79
+ person: this.person,
80
+ hireDate: this.hireDate,
81
+ dismissalDate: this.dismissalDate,
82
+ employmentRelationshipId: this.employmentRelationshipId,
83
+ employer: this.employer,
84
+ costCenterKey: this.costCenterKey,
85
+ companyBranchKey: this.companyBranchKey,
86
+ jobPositionKey: this.jobPositionKey,
87
+ workshiftId: this.workshiftId,
88
+ workshiftGroupId: this.workshiftGroupId
89
+ });
90
+ }
91
+ }
@@ -0,0 +1,35 @@
1
+ import { EmploymentRelationship } from "../../data/foundation/employmentRelationship";
2
+ import { ContractType } from "../../data/contract/contract";
3
+
4
+ export class EmploymentRelationshipBuilder {
5
+ private _id = "123";
6
+ private _code = "1";
7
+ private _contractType = ContractType.EMPLOYEE;
8
+
9
+ static builder(): EmploymentRelationshipBuilder {
10
+ return new EmploymentRelationshipBuilder();
11
+ }
12
+
13
+ withId(id: string): EmploymentRelationshipBuilder {
14
+ this._id = id;
15
+ return this;
16
+ }
17
+
18
+ withCode(code: string): EmploymentRelationshipBuilder {
19
+ this._code = code;
20
+ return this;
21
+ }
22
+
23
+ withContractType(contractType: ContractType): EmploymentRelationshipBuilder {
24
+ this._contractType = contractType;
25
+ return this;
26
+ }
27
+
28
+ build(): EmploymentRelationship {
29
+ return new EmploymentRelationship({
30
+ id: this._id,
31
+ code: this._code,
32
+ contractType: this._contractType
33
+ });
34
+ }
35
+ }
@@ -0,0 +1,29 @@
1
+ import { EmploymentRelationshipHistory, EmploymentRelationshipHistoryParams } from "../../data/histories/employmentRelationshipHistory";
2
+
3
+ export class EmploymentRelationshipHistoryBuilder {
4
+ static defaultParams(): EmploymentRelationshipHistoryParams {
5
+ return {
6
+ startDate: new Date("2023-01-01"),
7
+ endDate: new Date("2023-12-31"),
8
+ employmentRelationshipId: "123"
9
+ };
10
+ }
11
+
12
+ static default(): { build: () => EmploymentRelationshipHistory } {
13
+ return {
14
+ build: (): EmploymentRelationshipHistory => {
15
+ return new EmploymentRelationshipHistory(this.defaultParams());
16
+ }
17
+ };
18
+ }
19
+
20
+ static withParams(params: Partial<EmploymentRelationshipHistoryParams>): { build: () => EmploymentRelationshipHistory } {
21
+ return {
22
+ build: (): EmploymentRelationshipHistory => {
23
+ const def = this.defaultParams();
24
+ const merged: EmploymentRelationshipHistoryParams = { ...def, ...params };
25
+ return new EmploymentRelationshipHistory(merged);
26
+ }
27
+ };
28
+ }
29
+ }
@@ -0,0 +1,56 @@
1
+ import { Histories, HistoriesParams } from "../../data/histories/histories";
2
+ import { CompanyBranchHistoryBuilder } from "./companyBranchHistoryBuilder";
3
+ import { JobPositionHistoryBuilder } from "./jobPositionHistoryBuilder";
4
+ import { EmploymentRelationshipHistoryBuilder } from "./employmentRelationshipHistoryBuilder";
5
+ import { CostCenterHistoryBuilder } from "./costCenterHistoryBuilder";
6
+
7
+ export class HistoriesBuilder {
8
+ static defaultParams(): HistoriesParams {
9
+ return {
10
+ jobPositionHistories: [
11
+ JobPositionHistoryBuilder.default().build()
12
+ ],
13
+ companyBranchHistories: [
14
+ CompanyBranchHistoryBuilder.default().build()
15
+ ],
16
+ employmentRelationshipHistories: [
17
+ EmploymentRelationshipHistoryBuilder.default().build()],
18
+ timeEvaluationHistories: [],
19
+ workshiftHistories: [],
20
+ leaveHistories: [],
21
+ costCenterHistories: [
22
+ CostCenterHistoryBuilder.default().build()
23
+ ]
24
+ };
25
+ }
26
+
27
+ static default(): { build: () => Histories } {
28
+ return {
29
+ build: (): Histories => {
30
+ return new Histories(this.defaultParams());
31
+ }
32
+ };
33
+ }
34
+
35
+ static withParams(params: Partial<HistoriesParams>): { build: () => Histories } {
36
+ return {
37
+ build: (): Histories => {
38
+ const def = this.defaultParams();
39
+ const merged: HistoriesParams = { ...def, ...params };
40
+ if (params.jobPositionHistories){
41
+ merged.jobPositionHistories = params.jobPositionHistories;
42
+ }
43
+ if (params.companyBranchHistories){
44
+ merged.companyBranchHistories = params.companyBranchHistories;
45
+ }
46
+ if (params.employmentRelationshipHistories) {
47
+ merged.employmentRelationshipHistories = params.employmentRelationshipHistories;
48
+ }
49
+ if (params.costCenterHistories) {
50
+ merged.costCenterHistories = params.costCenterHistories;
51
+ }
52
+ return new Histories(merged);
53
+ }
54
+ };
55
+ }
56
+ }
@@ -0,0 +1,44 @@
1
+ import { Holiday, HolidayParams } from "../../data/foundation/holiday";
2
+ import { HolidayGroup } from "../../data/foundation/holidayGroup";
3
+
4
+ export class HolidayBuilder {
5
+ private key = "holiday-1";
6
+ private date = new Date("2025-01-01");
7
+ private group = new HolidayGroup({
8
+ code: 1
9
+ });
10
+
11
+
12
+ public static builder(): HolidayBuilder {
13
+ return new HolidayBuilder();
14
+ }
15
+
16
+ public static default(): HolidayBuilder {
17
+ return new HolidayBuilder();
18
+ }
19
+
20
+ public withKey(key: string): HolidayBuilder {
21
+ this.key = key;
22
+ return this;
23
+ }
24
+
25
+ public withGroup(group: HolidayGroup): HolidayBuilder {
26
+ this.group = group;
27
+ return this;
28
+ }
29
+
30
+ public withDate(date: Date): HolidayBuilder {
31
+ this.date = date;
32
+ return this;
33
+ }
34
+
35
+ public build(): Holiday {
36
+ const params: HolidayParams = {
37
+ key: this.key,
38
+ date: this.date,
39
+ holidayGroup: this.group
40
+ };
41
+
42
+ return new Holiday(params);
43
+ }
44
+ }
@@ -0,0 +1,77 @@
1
+ import { HourBankAccount } from "../../data/hourBank/hourBankAccount";
2
+ import { HourBank } from "../../data/hourBank/hourBank";
3
+
4
+ export class HourBankAccountBuilder {
5
+ private _hourBank: HourBank;
6
+ private _creationDate: Date;
7
+ private _extinctionDate: Date | null;
8
+
9
+ private constructor() {
10
+ // Valores padrão
11
+ this._hourBank = new HourBank({ code: 1 });
12
+ this._creationDate = new Date("2025-01-01");
13
+ this._extinctionDate = null;
14
+ }
15
+
16
+ /**
17
+ * Cria uma nova instância do builder com valores padrão.
18
+ */
19
+ static builder(): HourBankAccountBuilder {
20
+ return new HourBankAccountBuilder();
21
+ }
22
+
23
+ /**
24
+ * Define o HourBank para o HourBankAccount.
25
+ * @param hourBank Instância de HourBank.
26
+ */
27
+ public withHourBank(hourBank: HourBank): HourBankAccountBuilder {
28
+ this._hourBank = hourBank;
29
+ return this;
30
+ }
31
+
32
+ /**
33
+ * Define a data de criação para o HourBankAccount.
34
+ * @param creationDate Data de criação.
35
+ */
36
+ public withCreationDate(creationDate: Date): HourBankAccountBuilder {
37
+ this._creationDate = creationDate;
38
+ return this;
39
+ }
40
+
41
+ /**
42
+ * Define a data de extinção para o HourBankAccount.
43
+ * @param extinctionDate Data de extinção.
44
+ */
45
+ public withExtinctionDate(extinctionDate: Date | null): HourBankAccountBuilder {
46
+ this._extinctionDate = extinctionDate;
47
+ return this;
48
+ }
49
+
50
+ /**
51
+ * Define múltiplos parâmetros para o HourBankAccount.
52
+ * @param params Parâmetros personalizados.
53
+ */
54
+ public withParams(params: Partial<{ hourBank: HourBank; creationDate: Date; extinctionDate: Date | null }>): HourBankAccountBuilder {
55
+ if (params.hourBank) {
56
+ this._hourBank = params.hourBank;
57
+ }
58
+ if (params.creationDate) {
59
+ this._creationDate = params.creationDate;
60
+ }
61
+ if (params.extinctionDate !== undefined) {
62
+ this._extinctionDate = params.extinctionDate;
63
+ }
64
+ return this;
65
+ }
66
+
67
+ /**
68
+ * Constrói uma instância de HourBankAccount com os valores configurados.
69
+ */
70
+ public build(): HourBankAccount {
71
+ return new HourBankAccount({
72
+ hourBank: this._hourBank,
73
+ creationDate: this._creationDate,
74
+ extinctionDate: this._extinctionDate,
75
+ });
76
+ }
77
+ }
@@ -0,0 +1,32 @@
1
+ import { HourBank, HourBankParams } from "../../data/hourBank/hourBank";
2
+
3
+ export class HourBankBuilder {
4
+ /**
5
+ * Cria uma instância padrão de HourBank.
6
+ */
7
+ static default(): HourBank {
8
+ return new HourBank({
9
+ code: 1, // Valor padrão para o código
10
+ });
11
+ }
12
+
13
+ /**
14
+ * Cria uma instância personalizada de HourBank com código específico.
15
+ * @param code Código personalizado para HourBank.
16
+ */
17
+ static withCode(code: number): HourBank {
18
+ return new HourBank({
19
+ code
20
+ });
21
+ }
22
+
23
+ /**
24
+ * Cria uma instância personalizada de HourBank.
25
+ * @param params Parâmetros personalizados para HourBank.
26
+ */
27
+ static withParams(params: Partial<HourBankParams>): HourBank {
28
+ return new HourBank({
29
+ code: params.code ?? 1, // Usa o valor padrão se não for fornecido
30
+ });
31
+ }
32
+ }
@@ -0,0 +1,113 @@
1
+ import { Interval, IntervalSubTypes, IntervalTypes, IntervalParams, PositionWorkHours } from "../../../src/data/timeEvaluation/interval";
2
+ import { AdjustmentReason } from '../../data/timeEvaluation/adjustmentReason';
3
+
4
+ export class IntervalBuilder {
5
+ private clockingEventStart = new Date("2024-04-02T08:00:00Z");
6
+ private clockingEventEnd = new Date("2024-04-02T12:00:00Z");
7
+ private type = IntervalTypes.WORKING;
8
+ private subType = IntervalSubTypes.ENTER;
9
+ private typeIntervalTolerance = IntervalTypes.TOLERANCE;
10
+ private subTypeIntervalTolerance = IntervalSubTypes.DELAY;
11
+ private situationId = "1";
12
+ private adjustmentReason = new AdjustmentReason({ code: 1001 });
13
+ private justifiedDays = 1;
14
+ private positionWorkingPart = new PositionWorkHours({
15
+ workingHours: 4,
16
+ part: 1,
17
+ });
18
+ private isNightly = false;
19
+ private isOvertimeAuthorized = false;
20
+ private isTolerancePeriod = false;
21
+ private inClockingEventTolerance = false;
22
+
23
+ public withClockingEventStart(date: Date): IntervalBuilder {
24
+ this.clockingEventStart = date;
25
+ return this;
26
+ }
27
+
28
+ public withClockingEventEnd(date: Date): IntervalBuilder {
29
+ this.clockingEventEnd = date;
30
+ return this;
31
+ }
32
+
33
+ public withType(type: IntervalTypes): IntervalBuilder {
34
+ this.type = type;
35
+ return this;
36
+ }
37
+
38
+ public withSubType(subType: IntervalSubTypes): IntervalBuilder {
39
+ this.subType = subType;
40
+ return this;
41
+ }
42
+
43
+ public withTypeIntervalTolerance(type: IntervalTypes): IntervalBuilder {
44
+ this.typeIntervalTolerance = type;
45
+ return this;
46
+ }
47
+
48
+ public withSubTypeIntervalTolerance(subType: IntervalSubTypes): IntervalBuilder {
49
+ this.subTypeIntervalTolerance = subType;
50
+ return this;
51
+ }
52
+
53
+ public withSituationId(id: string): IntervalBuilder {
54
+ this.situationId = id;
55
+ return this;
56
+ }
57
+
58
+ public withAdjustmentReason(adjustmentReason: AdjustmentReason): IntervalBuilder {
59
+ this.adjustmentReason = adjustmentReason;
60
+ return this;
61
+ }
62
+
63
+ public withJustifiedDays(days: number): IntervalBuilder {
64
+ this.justifiedDays = days;
65
+ return this;
66
+ }
67
+
68
+ public withpositionWorkingPart(position: PositionWorkHours): IntervalBuilder {
69
+ this.positionWorkingPart = position;
70
+ return this;
71
+ }
72
+
73
+ public withIsNightly(value: boolean): IntervalBuilder {
74
+ this.isNightly = value;
75
+ return this;
76
+ }
77
+
78
+ public withIsOvertimeAuthorized(value: boolean): IntervalBuilder {
79
+ this.isOvertimeAuthorized = value;
80
+ return this;
81
+ }
82
+
83
+ public withIsTolerancePeriod(value: boolean): IntervalBuilder {
84
+ this.isTolerancePeriod = value;
85
+ return this;
86
+ }
87
+
88
+ public withInClockingEventTolerance(value: boolean): IntervalBuilder {
89
+ this.inClockingEventTolerance = value;
90
+ return this;
91
+ }
92
+
93
+ public build(): Interval {
94
+ const params: IntervalParams = {
95
+ clockingEventStart: this.clockingEventStart,
96
+ clockingEventEnd: this.clockingEventEnd,
97
+ type: this.type,
98
+ subType: this.subType,
99
+ typeIntervalTolerance: this.typeIntervalTolerance,
100
+ subTypeIntervalTolerance: this.subTypeIntervalTolerance,
101
+ situationId: this.situationId,
102
+ adjustmentReason: this.adjustmentReason,
103
+ justifiedDays: this.justifiedDays,
104
+ positionWorkingPart: this.positionWorkingPart,
105
+ isNightly: this.isNightly,
106
+ isOvertimeAuthorized: this.isOvertimeAuthorized,
107
+ isTolerancePeriod: this.isTolerancePeriod,
108
+ inClockingEventTolerance: this.inClockingEventTolerance
109
+ }
110
+
111
+ return new Interval(params);
112
+ }
113
+ }
@@ -0,0 +1,29 @@
1
+ import { JobPositionHistory, JobPositionHistoryParams } from "../../data/histories/jobPositionHistory";
2
+
3
+ export class JobPositionHistoryBuilder {
4
+ static defaultParams(): JobPositionHistoryParams {
5
+ return {
6
+ startDate: new Date("2023-01-01"),
7
+ endDate: new Date("2023-12-31"),
8
+ jobPositionKey: "JP1"
9
+ };
10
+ }
11
+
12
+ static default(): { build: () => JobPositionHistory } {
13
+ return {
14
+ build: (): JobPositionHistory => {
15
+ return new JobPositionHistory(this.defaultParams());
16
+ }
17
+ };
18
+ }
19
+
20
+ static withParams(params: Partial<JobPositionHistoryParams>): { build: () => JobPositionHistory } {
21
+ return {
22
+ build: (): JobPositionHistory => {
23
+ const def = this.defaultParams();
24
+ const merged: JobPositionHistoryParams = { ...def, ...params };
25
+ return new JobPositionHistory(merged);
26
+ }
27
+ };
28
+ }
29
+ }
@@ -0,0 +1,42 @@
1
+ import { OvertimeAuthorization, OvertimeAuthorizationParams } from "../../data/schedules/overtimeAuthorization";
2
+
3
+ export class OvertimeAuthorizationBuilder {
4
+ private startDate: Date = new Date();
5
+ private endDate: Date = new Date();
6
+ private startTime: number = 0;
7
+ private endTime: number = 0;
8
+
9
+ static builder(): OvertimeAuthorizationBuilder {
10
+ return new OvertimeAuthorizationBuilder();
11
+ }
12
+
13
+ withStartDate(startDate: Date): OvertimeAuthorizationBuilder {
14
+ this.startDate = startDate;
15
+ return this;
16
+ }
17
+
18
+ withEndDate(endDate: Date): OvertimeAuthorizationBuilder {
19
+ this.endDate = endDate;
20
+ return this;
21
+ }
22
+
23
+ withStartTime(startTime: number): OvertimeAuthorizationBuilder {
24
+ this.startTime = startTime;
25
+ return this;
26
+ }
27
+
28
+ withEndTime(endTime: number): OvertimeAuthorizationBuilder {
29
+ this.endTime = endTime;
30
+ return this;
31
+ }
32
+
33
+ build(): OvertimeAuthorization {
34
+ const params: OvertimeAuthorizationParams = {
35
+ startDate: this.startDate,
36
+ endDate: this.endDate,
37
+ startTime: this.startTime,
38
+ endTime: this.endTime,
39
+ };
40
+ return new OvertimeAuthorization(params);
41
+ }
42
+ }
@@ -0,0 +1,57 @@
1
+ import { Readiness, ReadinessParams } from '../../data/schedules/readiness';
2
+
3
+ export class ReadinessBuilder {
4
+
5
+ private startDate: Date = new Date();
6
+ private endDate: Date = new Date();
7
+ private startTime: number = 0;
8
+ private endTime: number = 0;
9
+ private continuous: boolean = false;
10
+ private situationId: string = '';
11
+
12
+ static builder(): ReadinessBuilder {
13
+ return new ReadinessBuilder();
14
+ }
15
+
16
+ withStartDate(startDate: Date): ReadinessBuilder {
17
+ this.startDate = startDate;
18
+ return this;
19
+ }
20
+
21
+ withEndDate(endDate: Date): ReadinessBuilder {
22
+ this.endDate = endDate;
23
+ return this;
24
+ }
25
+
26
+ withStartTime(startTime: number): ReadinessBuilder {
27
+ this.startTime = startTime;
28
+ return this;
29
+ }
30
+
31
+ withEndTime(endTime: number): ReadinessBuilder {
32
+ this.endTime = endTime;
33
+ return this;
34
+ }
35
+
36
+ withContinuous(continuous: boolean): ReadinessBuilder {
37
+ this.continuous = continuous;
38
+ return this;
39
+ }
40
+
41
+ withSituationId(situationId: string): ReadinessBuilder {
42
+ this.situationId = situationId;
43
+ return this;
44
+ }
45
+
46
+ build(): Readiness {
47
+ const params: ReadinessParams = {
48
+ startDate: this.startDate,
49
+ endDate: this.endDate,
50
+ startTime: this.startTime,
51
+ endTime: this.endTime,
52
+ continuous: this.continuous,
53
+ situationId: this.situationId
54
+ };
55
+ return new Readiness(params);
56
+ }
57
+ }