@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,64 @@
1
+ import { ReadinessBuilder } from "../../builder/readinessBuilder.builder";
2
+ import { Context } from "../../../data/context/context";
3
+
4
+ describe("Readiness", () => {
5
+ it("deve criar uma instância de Readiness com valores válidos", () => {
6
+ const startDate = new Date("2025-01-01");
7
+ const endDate = new Date("2025-01-02");
8
+ const startTime = 8;
9
+ const endTime = 17;
10
+ const continuous = true;
11
+ const situationId = "situation123";
12
+ const readiness = ReadinessBuilder.builder()
13
+ .withStartDate(startDate)
14
+ .withEndDate(endDate)
15
+ .withStartTime(startTime)
16
+ .withEndTime(endTime)
17
+ .withContinuous(continuous)
18
+ .withSituationId(situationId)
19
+ .build();
20
+
21
+ expect(readiness.startDate).toEqual(startDate);
22
+ expect(readiness.endDate).toEqual(endDate);
23
+ expect(readiness.startTime).toEqual(startTime);
24
+ expect(readiness.endTime).toEqual(endTime);
25
+ expect(readiness.continuous).toEqual(continuous);
26
+ });
27
+
28
+ it('testContext', () => {
29
+
30
+ let inputRule = '{"version":"1.0.0","input":{"batchId":"3bdd63de-38aa-455d-80e0-bcfad17ef924","processType":"EVALUATE","startDate":"2024-10-14","endDate":"2024-10-14","contracts":[{"id":"50591a71-844c-4bf1-ac58-cd4d0fa8385e","holidaysKeys":["2_2024-10-12"],"timeEvaluation":[{"date":"2024-10-14","workscheduleId":"ceba8a2e-a7bf-480c-8e4d-be6a3995b6a3","workscheduleWorkshiftId":"ceba8a2e-a7bf-480c-8e4d-be6a3995b6a3","workshiftId":"47971e5f-3d1a-4494-8cf6-328c7dfa5394","timeEvaluationSituations":[{"situationId":"e75ba021-148e-4f36-bb3e-13e024cc1908","situationCode":20,"numberOfHours":510}],"clockingEvents":[{"clockingEventDate":"2024-10-14","clockingEventTime":480,"functionCode":0,"originType":"ELECTRONIC","useType":"CLOCKING"},{"clockingEventDate":"2024-10-14","clockingEventTime":720,"functionCode":0,"originType":"ELECTRONIC","useType":"CLOCKING"},{"clockingEventDate":"2024-10-14","clockingEventTime":810,"functionCode":0,"originType":"ELECTRONIC","useType":"CLOCKING"},{"clockingEventDate":"2024-10-14","clockingEventTime":1080,"functionCode":0,"originType":"ELECTRONIC","useType":"CLOCKING"}],"intervals":[{"clockingEventStart":"2024-10-14T08:00:00","clockingEventEnd":"2024-10-14T12:00:00","type":"OVERTIME","subType":"COMPENSATED","situationCode":0,"situationReasonCode":0,"justifiedSituationCode":0,"justifiedDays":0,"positionWorkingPart":{"workingHours":1,"part":1},"isNightly":false,"isOvertimeAuthorized":false,"isTolerancePeriod":false,"inClockingEventTolerance":false},{"clockingEventStart":"2024-10-14T13:30:00","clockingEventEnd":"2024-10-14T18:00:00","type":"OVERTIME","subType":"COMPENSATED","situationCode":0,"situationReasonCode":0,"justifiedSituationCode":0,"justifiedDays":0,"positionWorkingPart":{"workingHours":1,"part":1},"isNightly":false,"isOvertimeAuthorized":false,"isTolerancePeriod":false,"inClockingEventTolerance":false}],"situationDefinitionKey":"3_2023-01-30_null","estimatedHours":{"meal":[],"snack":[],"work":[]},"syndicateKey":"1","missingClockingEvent":false}],"employee":{"id":"50591a71-844c-4bf1-ac58-cd4d0fa8385e","code":33,"person":{"name":"Lionel Messi"},"hireDate":"2023-03-23","employmentRelationshipId":"775ee7d1-5d7f-4a1b-b50b-b659a66014b2","employer":{"code":1},"costCenterCode":"02","jobPositionCode":"1","companyBranchCode":1,"workshiftCode":1,"workshiftGroupCode":5},"histories":{"jobPositionHistories":[{"startDate":"2010-01-01","jobPositionKey":"1_1"}],"companyBranchHistories":[{"startDate":"2024-01-20","companyBranchKey":"1_1"}],"employmentRelationshipHistories":[{"startDate":"2010-01-01","employmentRelationshipId":"775ee7d1-5d7f-4a1b-b50b-b659a66014b2"}],"timeEvaluationHistories":[{"startDate":"2024-04-24","type":"NORMAL","situationDefinitionKey":["3_2023-01-30_null"]}],"workshiftHistories":[{"startDate":"2024-07-13","workshiftId":"47971e5f-3d1a-4494-8cf6-328c7dfa5394","workshiftGroupsCode":5}],"leaveHistories":[]},"schedules":{"bridges":[],"workscheduleChanges":[{"date":"2024-01-11","workscheduleId":"459d7c62-bfb2-425c-b9c0-d98fdfce30df"},{"date":"2023-11-22","workscheduleId":"9850ad40-0d5f-495f-85ea-843f11b3b427"}],"workshiftChanges":[],"readinesses":[{"startDate":"2024-01-20","endDate":"2024-01-20","startTime":480,"endTime":1080,"continuous":false,"situationId":"8b0d4bd7-bda6-4cf3-809a-e27b4ec50d03"},{"startDate":"2024-01-20","endDate":"2024-01-20","startTime":1081,"endTime":1439,"continuous":false,"situationId":"54e601cf-0a62-4170-b32e-ab34a274ffcc"},{"startDate":"2024-03-02","endDate":"2024-03-02","startTime":1200,"endTime":1342,"continuous":false,"situationId":"54e601cf-0a62-4170-b32e-ab34a274ffcc"}]},"hourBankAccounts":[{"hourBank":{"code":8},"creationDate":"2024-04-24"},{"hourBank":{"code":1},"creationDate":"2024-12-01"}]}],"database":{"situations":[{"id":"209c328d-3fe8-446a-b690-846d75ef5ed5","code":1,"type":"WORKING","exception":false,"complementarySituationId":"209c328d-3fe8-446a-b690-846d75ef5ed5","daytime":true},{"id":"8b0d4bd7-bda6-4cf3-809a-e27b4ec50d03","code":2,"type":"PRECAUTIONREADINESS","exception":true,"complementarySituationId":"54e601cf-0a62-4170-b32e-ab34a274ffcc","daytime":true},{"id":"489eab83-47ed-42ee-ab76-a1702bd13e79","code":9,"type":"VACATION","exception":false,"complementarySituationId":"489eab83-47ed-42ee-ab76-a1702bd13e79","daytime":true},{"id":"54e601cf-0a62-4170-b32e-ab34a274ffcc","code":10,"type":"PRECAUTIONREADINESS","exception":true,"complementarySituationId":"8b0d4bd7-bda6-4cf3-809a-e27b4ec50d03","daytime":false},{"id":"4be78b2c-cae5-46f8-93ae-850a1c85013a","code":11,"type":"WORKING","exception":true,"complementarySituationId":"4be78b2c-cae5-46f8-93ae-850a1c85013a","daytime":true},{"id":"848ec42d-b2df-4c4d-94f4-151f381e4a54","code":12,"type":"WORKING","exception":false,"complementarySituationId":"848ec42d-b2df-4c4d-94f4-151f381e4a54","daytime":true},{"id":"74072aa1-e4b0-4f2a-8573-72b7ad9f1cf5","code":17,"type":"ABSENCES","exception":true,"complementarySituationId":"74072aa1-e4b0-4f2a-8573-72b7ad9f1cf5","daytime":true},{"id":"e75ba021-148e-4f36-bb3e-13e024cc1908","code":20,"type":"WORKING","exception":true,"complementarySituationId":"2a2fae76-cf7e-498b-9107-0166f6e906ef","daytime":true},{"id":"2a2fae76-cf7e-498b-9107-0166f6e906ef","code":21,"type":"WORKING","exception":true,"complementarySituationId":"e75ba021-148e-4f36-bb3e-13e024cc1908","daytime":false},{"id":"aa1506e9-edd3-44bd-893c-56d00d3c6ca3","code":51,"type":"WORKING","exception":false,"complementarySituationId":"aa1506e9-edd3-44bd-893c-56d00d3c6ca3","daytime":false},{"id":"950ba6cd-528d-42cc-aa07-9f15561735f9","code":999,"type":"TIMEEVALUATIONSITUATION","exception":true,"complementarySituationId":"950ba6cd-528d-42cc-aa07-9f15561735f9","daytime":true}],"holidays":[{"key":"2_2024-10-12","date":"2024-10-12","holidayGroup":{"code":2}}],"timeEvaluationSituationDefinitions":[{"code":3,"startDate":"2023-01-30","workSituationId":"209c328d-3fe8-446a-b690-846d75ef5ed5","nightShiftWorkPremiumId":"aa1506e9-edd3-44bd-893c-56d00d3c6ca3","invalidEventsSituationId":"950ba6cd-528d-42cc-aa07-9f15561735f9","vacationPaidLeaveSituationId":"489eab83-47ed-42ee-ab76-a1702bd13e79","dailyRestViolationSituationId":"848ec42d-b2df-4c4d-94f4-151f381e4a54","workBreakViolationSituationId":"4be78b2c-cae5-46f8-93ae-850a1c85013a","absenceSituationId":"74072aa1-e4b0-4f2a-8573-72b7ad9f1cf5","tardinessSituationId":"74072aa1-e4b0-4f2a-8573-72b7ad9f1cf5","intermediateLeaveSituationId":"74072aa1-e4b0-4f2a-8573-72b7ad9f1cf5","earlyLeaveSituationId":"74072aa1-e4b0-4f2a-8573-72b7ad9f1cf5","absenceSituationOnRelayScheduleHolidaysId":"74072aa1-e4b0-4f2a-8573-72b7ad9f1cf5","percentageNextDay":true,"normalOvertimeSeparationLimit":0,"separateOvertimeAfterConvertingNightShiftHours":false,"overtimeBeforeId":"e75ba021-148e-4f36-bb3e-13e024cc1908","overtimeEntryId":"e75ba021-148e-4f36-bb3e-13e024cc1908","overtimeDuringMealId":"e75ba021-148e-4f36-bb3e-13e024cc1908","leaveOvertimeId":"e75ba021-148e-4f36-bb3e-13e024cc1908","overtimeAfterId":"2a2fae76-cf7e-498b-9107-0166f6e906ef","overtimeSeparationLimitDuringRest":0,"overtimeDuringRestId":"2a2fae76-cf7e-498b-9107-0166f6e906ef","overtimeSeparationLimitDuringCompensatedDays":0,"overtimeOnCompensatedDaysId":"2a2fae76-cf7e-498b-9107-0166f6e906ef","overtimeSeparationLimitDuringHoliday":0,"overtimeDuringHolidayId":"2a2fae76-cf7e-498b-9107-0166f6e906ef","overtimeSeparationLimitDuringDayOff":0,"overtimeDuringDayOffId":"2a2fae76-cf7e-498b-9107-0166f6e906ef"}],"jobPositions":[{"key":"1_1","code":1,"structureCode":1}],"workschedules":[{"id":"9850ad40-0d5f-495f-85ea-843f11b3b427","code":7,"workload":480,"type":"RIGID","definitionType":"NORMAL","clockingRegisters":[{"sequence":1,"clockingEvent":480,"toleranceBefore":480,"toleranceAfter":480,"mobilityBefore":0,"mobilityAfter":0,"clockingEventScheduleType":"MANDATORY","usingType":"MANDATORY_ENTRY_OR_EXIT"},{"sequence":2,"clockingEvent":720,"toleranceBefore":720,"toleranceAfter":720,"mobilityBefore":0,"mobilityAfter":0,"intervalType":"RIGID","clockingEventScheduleType":"GENERATED","usingType":"GENERATED_PRE_ASSIGNED_MEAL"},{"sequence":3,"clockingEvent":780,"toleranceBefore":780,"toleranceAfter":780,"mobilityBefore":0,"mobilityAfter":0,"intervalType":"RIGID","clockingEventScheduleType":"GENERATED","usingType":"GENERATED_PRE_ASSIGNED_MEAL"},{"sequence":4,"clockingEvent":1020,"toleranceBefore":1020,"toleranceAfter":1020,"mobilityBefore":0,"mobilityAfter":0,"clockingEventScheduleType":"MANDATORY","usingType":"MANDATORY_ENTRY_OR_EXIT"}],"clockingEvent":{"workStartEndOvertimeTolerance":0,"mealOvertimeTolerance":0,"overtimeDailyTotalTolerance":0,"absenceDailyTotalTolerance":0,"workStartEndAbsenceTolerance":0,"mealAbsenceTolerance":0}},{"id":"ceba8a2e-a7bf-480c-8e4d-be6a3995b6a3","code":11,"workload":0,"type":"RIGID","definitionType":"OFFSET","clockingRegisters":[],"clockingEvent":{"workStartEndOvertimeTolerance":0,"mealOvertimeTolerance":0,"overtimeDailyTotalTolerance":0,"absenceDailyTotalTolerance":0,"workStartEndAbsenceTolerance":0,"mealAbsenceTolerance":0}},{"id":"459d7c62-bfb2-425c-b9c0-d98fdfce30df","code":1001,"workload":510,"type":"RIGID","definitionType":"NORMAL","clockingRegisters":[{"sequence":1,"clockingEvent":480,"toleranceBefore":475,"toleranceAfter":485,"mobilityBefore":0,"mobilityAfter":0,"clockingEventScheduleType":"MANDATORY","usingType":"MANDATORY_ENTRY_OR_EXIT"},{"sequence":2,"clockingEvent":720,"toleranceBefore":715,"toleranceAfter":725,"mobilityBefore":0,"mobilityAfter":0,"intervalType":"RIGID","clockingEventScheduleType":"MANDATORY","usingType":"MANDATORY_MEAL"},{"sequence":3,"clockingEvent":810,"toleranceBefore":805,"toleranceAfter":815,"mobilityBefore":0,"mobilityAfter":0,"intervalType":"RIGID","clockingEventScheduleType":"MANDATORY","usingType":"MANDATORY_MEAL"},{"sequence":4,"clockingEvent":1080,"toleranceBefore":1075,"toleranceAfter":1085,"mobilityBefore":0,"mobilityAfter":0,"clockingEventScheduleType":"MANDATORY","usingType":"MANDATORY_ENTRY_OR_EXIT"}],"clockingEvent":{"workStartEndOvertimeTolerance":0,"mealOvertimeTolerance":0,"overtimeDailyTotalTolerance":10,"absenceDailyTotalTolerance":10,"workStartEndAbsenceTolerance":0,"mealAbsenceTolerance":0}}],"workshifts":[{"id":"47971e5f-3d1a-4494-8cf6-328c7dfa5394","code":1,"type":"PERMANENT","rotationWorkShift":true,"extensionNightHours":true,"dsrMinutes":440,"weekMinutes":2640,"monthMinutes":13200,"timeShiftType":"GENERAL","workshiftGroups":[{"code":1,"baseDate":"2022-08-01"},{"code":2,"baseDate":"2022-08-08"},{"code":3,"baseDate":"2022-08-15"},{"code":4,"baseDate":"1901-01-08"},{"code":4,"baseDate":"2022-08-22"},{"code":5,"baseDate":"2023-03-22"},{"code":5,"baseDate":"2022-08-29"},{"code":6,"baseDate":"2022-09-05"}],"workshiftDetails":[{"holidayGroup":{"code":2},"holidayType":"OWN","startDate":"2022-08-12"}]}],"companyBranches":[{"key":"1_1","code":1}],"syndicates":[{"key":"1","code":1,"nightStartHour":1320,"nightEndHour":300,"minimumInterval4to6Hours":30,"minimumInterval6Hours":90,"minimumWorkDuration6Hours":361}],"employmentRelationships":[{"id":"775ee7d1-5d7f-4a1b-b50b-b659a66014b2","code":"1","contractType":"EMPLOYEE"}]},"currentUser":{"userName":"admin@allanalves.com.br"}}}';
31
+
32
+ const context = new Context({ body: inputRule });
33
+ const contracts = context.contracts[0];
34
+ const readinessesInContract = contracts?.schedules?.readinesses;
35
+ const readinessInTimeEvaluation = contracts.timeEvaluation[0].readinesses;
36
+
37
+ expect(readinessesInContract.length).toBe(3);
38
+
39
+ expect(readinessesInContract[0].startDate).toEqual(new Date("2024-01-20"));
40
+ expect(readinessesInContract[0].endDate).toEqual(new Date("2024-01-20"));
41
+ expect(readinessesInContract[0].startTime).toEqual(480);
42
+ expect(readinessesInContract[0].endTime).toEqual(1080);
43
+ expect(readinessesInContract[0].continuous).toEqual(false);
44
+ expect(readinessesInContract[0].situation.code).toEqual(2);
45
+
46
+ expect(readinessesInContract[1].startDate).toEqual(new Date("2024-01-20"));
47
+ expect(readinessesInContract[1].endDate).toEqual(new Date("2024-01-20"));
48
+ expect(readinessesInContract[1].startTime).toEqual(1081);
49
+ expect(readinessesInContract[1].endTime).toEqual(1439);
50
+ expect(readinessesInContract[1].continuous).toEqual(false);
51
+ expect(readinessesInContract[1].situation.code).toEqual(10);
52
+
53
+ expect(readinessesInContract[2].startDate).toEqual(new Date("2024-03-02"));
54
+ expect(readinessesInContract[2].endDate).toEqual(new Date("2024-03-02"));
55
+ expect(readinessesInContract[2].startTime).toEqual(1200);
56
+ expect(readinessesInContract[2].endTime).toEqual(1342);
57
+ expect(readinessesInContract[2].continuous).toEqual(false);
58
+ expect(readinessesInContract[2].situation.code).toEqual(10);
59
+
60
+ expect(readinessInTimeEvaluation).toStrictEqual([]);
61
+
62
+ });
63
+
64
+ });
@@ -0,0 +1,134 @@
1
+ import { SchedulesBuilder } from "../../builder/schedules.builder";
2
+ import { DateUtils } from "../../../utils/dateUtils";
3
+ import { BridgeBuilder } from "../../builder/bridgeBuilder.builder";
4
+ import { Schedules } from "../../../data/schedules/schedules";
5
+ import { CompensationType, PeriodType } from '../../../data/schedules/compensation';
6
+
7
+ describe("Schedules", () => {
8
+ it("should return all bridges", () => {
9
+ const schedules = SchedulesBuilder.default().build();
10
+ expect(schedules.bridges.length).toBe(2);
11
+ });
12
+
13
+ it("should return all readiness", () => {
14
+ const schedules = SchedulesBuilder.default().build();
15
+ expect(schedules.readinesses.length).toBe(2);
16
+ });
17
+
18
+ it("should default", () => {
19
+ const schedules = Schedules.default();
20
+ expect(schedules.bridges.length).toBe(0);
21
+ });
22
+ });
23
+
24
+ describe("Bridge", () => {
25
+ it("should find a bridge by date", () => {
26
+ const schedules = SchedulesBuilder.default().build();
27
+
28
+ const foundBridge = schedules.findBridgeByDate(new Date("2023-01-01"));
29
+ expect(foundBridge).toBeDefined();
30
+ expect(DateUtils.equals(foundBridge!.originDate, new Date("2023-01-01"))).toBe(true);
31
+ });
32
+
33
+ it("should not find a bridge by date", () => {
34
+ const schedules = SchedulesBuilder.default().build();
35
+
36
+ const foundBridge = schedules.findBridgeByDate(new Date("2023-03-01"));
37
+ expect(foundBridge).toBeUndefined();
38
+ });
39
+
40
+ it("should return the correct origin and destination dates", () => {
41
+ const originDate = new Date("2023-01-01");
42
+ const destinationDate = new Date("2023-01-02");
43
+ const bridgeFinder = new BridgeBuilder()
44
+ .withOriginDate(originDate)
45
+ .withDestinationDate(destinationDate)
46
+ .build();
47
+
48
+ const schedule = new SchedulesBuilder().withBridges([bridgeFinder]).build();
49
+ let bridge = schedule.bridges[0];
50
+
51
+ expect(DateUtils.equals(bridge.originDate, originDate)).toBe(true);
52
+ expect(DateUtils.equals(bridge.destinationDate, destinationDate)).toBe(true);
53
+ });
54
+
55
+ });
56
+
57
+ describe("Readiness", () => {
58
+ it("should find a readiness by date", () => {
59
+ const schedules = SchedulesBuilder.default().build();
60
+
61
+ const foundReadiness = schedules.findReadinessByDate(new Date("2023-01-01"));
62
+ expect(foundReadiness).toBeDefined();
63
+ expect(DateUtils.equals(foundReadiness[0].startDate, new Date("2023-01-01"))).toBe(true);
64
+ });
65
+
66
+ it("should not find a readiness by date", () => {
67
+ const schedules = SchedulesBuilder.default().build();
68
+
69
+ const foundReadiness = schedules.findReadinessByDate(new Date("2023-03-01"));
70
+ expect(foundReadiness).toStrictEqual([]);
71
+ });
72
+ });
73
+
74
+ describe("OvertimeAuthorization", () => {
75
+ it("should find a overtimeAuthorization by date", () => {
76
+ const schedules = SchedulesBuilder.default().build();
77
+
78
+ const foundOvertimeAuthorization = schedules.findOvertimeAuthorizationByDate(new Date("2023-01-01"));
79
+ expect(foundOvertimeAuthorization).toBeDefined();
80
+ expect(DateUtils.equals(foundOvertimeAuthorization[0]!.startDate, new Date("2023-01-01"))).toBe(true);
81
+ });
82
+
83
+ it("should not find a overtimeAuthorization by date", () => {
84
+ const schedules = SchedulesBuilder.default().build();
85
+
86
+ const foundOvertimeAuthorization = schedules.findOvertimeAuthorizationByDate(new Date("2023-01-20"));
87
+ expect(foundOvertimeAuthorization).toStrictEqual([]);
88
+ });
89
+
90
+ it("shuld return all overtime authorizations", () => {
91
+ const schedules = SchedulesBuilder.default().build();
92
+ expect(schedules.overtimeAuthorizations.length).toBe(2);
93
+ });
94
+
95
+ it("should find a overtimeAuthorizations by date", () => {
96
+ const schedules = SchedulesBuilder.default().build();
97
+
98
+ const foundOvertimeAuthorizations = schedules.findOvertimeAuthorizationByDate(new Date("2023-01-01"));
99
+
100
+ expect(foundOvertimeAuthorizations).toBeDefined();
101
+
102
+ expect(DateUtils.equals(foundOvertimeAuthorizations[0].startDate, new Date("2023-01-01"))).toBe(true);
103
+ expect(DateUtils.equals(foundOvertimeAuthorizations[0].endDate, new Date("2023-01-02"))).toBe(true);
104
+ expect(foundOvertimeAuthorizations[0].startTime).toBe(9);
105
+ expect(foundOvertimeAuthorizations[0].endTime).toBe(17);
106
+ });
107
+
108
+ it("should not find a overtimeAuthorizations by date", () => {
109
+ const schedules = SchedulesBuilder.default().build();
110
+
111
+ const foundReadiness = schedules.findOvertimeAuthorizationByDate(new Date("2025-04-22"));
112
+ expect(foundReadiness).toStrictEqual([]);
113
+ });
114
+ });
115
+
116
+ describe("compensations", () => {
117
+ it("should return all compensations", () => {
118
+ const schedules = SchedulesBuilder.default().build();
119
+ expect(schedules.compensations.length).toBe(2);
120
+ });
121
+
122
+ it("should return compensations with correct properties", () => {
123
+ const schedules = SchedulesBuilder.default().build();
124
+ const compensation = schedules.compensations[0];
125
+
126
+ expect(compensation.startDate).toEqual(new Date("2023-01-01"));
127
+ expect(compensation.endDate).toEqual(new Date("2023-01-31"));
128
+ expect(compensation.intervalStart).toBe(480); // 08:00
129
+ expect(compensation.intervalEnd).toBe(1020); // 17:00
130
+ expect(compensation.compensationType).toBe(CompensationType.ABSENCE_FOR_COMPENSATION);
131
+ expect(compensation.periodType).toBe(PeriodType.ANY_PART_OF_WORKDAY);
132
+ expect(compensation.numberOfHours).toBe(8);
133
+ });
134
+ });
@@ -0,0 +1,21 @@
1
+ import { Context } from '../../../data/context/context';
2
+
3
+ describe("WorkscheduleChange", () => {
4
+
5
+ it('WorkscheduleChange', () => {
6
+ const inputRule = '{"version":"1.0.0","input":{"batchId":"6af937d6-0ae9-4744-9cad-ff834de71baa","processType":"EVALUATE","startDate":"2023-07-31","endDate":"2023-07-31","contracts":[{"id":"50591a71-844c-4bf1-ac58-cd4d0fa8385e","holidaysKeys":[],"timeEvaluation":[{"date":"2023-07-31","workscheduleId":"e7875638-42b4-479d-a825-10fa3b13fbae","workscheduleWorkshiftId":"e7875638-42b4-479d-a825-10fa3b13fbae","workshiftId":"47971e5f-3d1a-4494-8cf6-328c7dfa5394","timeEvaluationSituations":[{"situationId":"209c328d-3fe8-446a-b690-846d75ef5ed5","situationCode":1,"numberOfHours":105},{"situationId":"6f3d297a-8977-4b27-a2ca-e5cb5f1489b7","situationCode":5,"numberOfHours":360},{"situationId":"acaf9c07-9521-422b-9325-1af1f36fd589","situationCode":8,"numberOfHours":30}],"clockingEvents":[{"clockingEventDate":"2023-07-31","clockingEventTime":1110,"functionCode":0,"originType":"TYPED","useType":"CLOCKING"}],"intervals":[{"clockingEventStart":"2023-07-31T08:00:00","clockingEventEnd":"2023-07-31T09:00:00","type":"ABSENCE","subType":"DELAY","situationCode":0,"situationReasonCode":0,"justifiedDays":0,"positionWorkingPart":{"workingHours":1,"part":1},"isNightly":false,"isOvertimeAuthorized":false,"isTolerancePeriod":false,"inClockingEventTolerance":false},{"clockingEventStart":"2023-07-31T09:30:00","clockingEventEnd":"2023-07-31T12:00:00","type":"ABSENCE","subType":"DELAY","situationCode":0,"situationReasonCode":0,"justifiedDays":0,"positionWorkingPart":{"workingHours":1,"part":1},"isNightly":false,"isOvertimeAuthorized":false,"isTolerancePeriod":false,"inClockingEventTolerance":false},{"clockingEventStart":"2023-07-31T13:30:00","clockingEventEnd":"2023-07-31T16:00:00","type":"ABSENCE","subType":"DELAY","situationCode":0,"situationReasonCode":0,"justifiedDays":0,"positionWorkingPart":{"workingHours":1,"part":2},"isNightly":false,"isOvertimeAuthorized":false,"isTolerancePeriod":false,"inClockingEventTolerance":false},{"clockingEventStart":"2023-07-31T16:15:00","clockingEventEnd":"2023-07-31T18:00:00","type":"WORKING","situationCode":0,"situationReasonCode":0,"justifiedDays":0,"positionWorkingPart":{"workingHours":1,"part":2},"isNightly":false,"isOvertimeAuthorized":false,"isTolerancePeriod":false,"inClockingEventTolerance":false},{"clockingEventStart":"2023-07-31T18:00:00","clockingEventEnd":"2023-07-31T18:30:00","type":"OVERTIME","subType":"CHECKOUT","situationCode":0,"situationReasonCode":0,"justifiedDays":0,"positionWorkingPart":{"workingHours":1,"part":2},"isNightly":false,"isOvertimeAuthorized":false,"isTolerancePeriod":false,"inClockingEventTolerance":false}],"situationDefinitionKey":"1_2022-08-01_null","estimatedHours":{"meal":[{"dailyHours":90,"nightlyHours":0}],"snack":[{"dailyHours":30,"nightlyHours":0},{"dailyHours":15,"nightlyHours":0}],"work":[{"dailyHours":60,"nightlyHours":0},{"dailyHours":150,"nightlyHours":0},{"dailyHours":150,"nightlyHours":0},{"dailyHours":105,"nightlyHours":0}]},"syndicateKey":"1","missingClockingEvent":true,"costCenterKey":"01"}],"employee":{"id":"50591a71-844c-4bf1-ac58-cd4d0fa8385e","code":33,"person":{"name":"Lionel Messi"},"hireDate":"2023-03-23","employmentRelationshipId":"775ee7d1-5d7f-4a1b-b50b-b659a66014b2","employer":{"code":1},"costCenterKey":"02","jobPositionCode":"1","companyBranchCode":1,"workshiftCode":1,"workshiftGroupCode":5},"histories":{"jobPositionHistories":[{"startDate":"2010-01-01","jobPositionKey":"1_1"}],"companyBranchHistories":[{"startDate":"2010-01-01","companyBranchKey":"1_1"}],"employmentRelationshipHistories":[{"startDate":"2010-01-01","employmentRelationshipId":"775ee7d1-5d7f-4a1b-b50b-b659a66014b2"}],"timeEvaluationHistories":[{"startDate":"2023-03-23","type":"NORMAL","situationDefinitionKey":["1_2022-08-01_null"]}],"workshiftHistories":[{"startDate":"2010-01-01","workshiftId":"47971e5f-3d1a-4494-8cf6-328c7dfa5394","workshiftGroupsCode":1}],"costCenterHistories":[{"startDate":"2010-01-01","endDate":"2023-07-31","costCenterKey":"01"},{"startDate":"2023-08-01","costCenterKey":"02"}]},"schedules":{"bridges":[],"workscheduleChanges":[{"date":"2023-07-31","workscheduleId":"e7875638-42b4-479d-a825-10fa3b13fbae"}],"workshiftChanges":[]},"hourBankAccounts":[{"hourBank":{"code":8},"creationDate":"2024-04-24"},{"hourBank":{"code":1},"creationDate":"2024-12-01"}]}],"database":{"situations":[{"id":"209c328d-3fe8-446a-b690-846d75ef5ed5","code":1,"type":"WORKING","exception":false,"complementarySituationId":"209c328d-3fe8-446a-b690-846d75ef5ed5","daytime":true},{"id":"6774bc30-d9db-4d52-ade2-9d3e5059e0ab","code":3,"type":"OVERTIME","exception":true,"complementarySituationId":"acaf9c07-9521-422b-9325-1af1f36fd589","daytime":false},{"id":"6f3d297a-8977-4b27-a2ca-e5cb5f1489b7","code":5,"type":"ABSENCES","exception":true,"complementarySituationId":"6f3d297a-8977-4b27-a2ca-e5cb5f1489b7","daytime":true},{"id":"a6e0401f-42f2-4dc8-ad48-c48682029689","code":6,"type":"WORKING","exception":true,"complementarySituationId":"a6e0401f-42f2-4dc8-ad48-c48682029689","daytime":false},{"id":"acaf9c07-9521-422b-9325-1af1f36fd589","code":8,"type":"OVERTIME","exception":true,"complementarySituationId":"6774bc30-d9db-4d52-ade2-9d3e5059e0ab","daytime":true},{"id":"489eab83-47ed-42ee-ab76-a1702bd13e79","code":9,"type":"VACATION","exception":false,"complementarySituationId":"489eab83-47ed-42ee-ab76-a1702bd13e79","daytime":true},{"id":"4be78b2c-cae5-46f8-93ae-850a1c85013a","code":11,"type":"WORKING","exception":true,"complementarySituationId":"4be78b2c-cae5-46f8-93ae-850a1c85013a","daytime":true},{"id":"848ec42d-b2df-4c4d-94f4-151f381e4a54","code":12,"type":"WORKING","exception":false,"complementarySituationId":"848ec42d-b2df-4c4d-94f4-151f381e4a54","daytime":true},{"id":"8cb7c936-a263-4845-979e-9c69d663b4a2","code":15,"type":"WORKING","exception":false,"complementarySituationId":"e63bd904-4cc8-4bc0-9e2d-b087f6fc0f81","daytime":true},{"id":"e63bd904-4cc8-4bc0-9e2d-b087f6fc0f81","code":16,"type":"WORKING","exception":false,"complementarySituationId":"8cb7c936-a263-4845-979e-9c69d663b4a2","daytime":false},{"id":"e75ba021-148e-4f36-bb3e-13e024cc1908","code":20,"type":"WORKING","exception":true,"complementarySituationId":"2a2fae76-cf7e-498b-9107-0166f6e906ef","daytime":true},{"id":"2a2fae76-cf7e-498b-9107-0166f6e906ef","code":21,"type":"WORKING","exception":true,"complementarySituationId":"e75ba021-148e-4f36-bb3e-13e024cc1908","daytime":false},{"id":"950ba6cd-528d-42cc-aa07-9f15561735f9","code":999,"type":"TIMEEVALUATIONSITUATION","exception":true,"complementarySituationId":"950ba6cd-528d-42cc-aa07-9f15561735f9","daytime":true}],"holidays":[],"timeEvaluationSituationDefinitions":[{"code":1,"startDate":"2022-08-01","workSituationId":"209c328d-3fe8-446a-b690-846d75ef5ed5","nightShiftWorkPremiumId":"2a2fae76-cf7e-498b-9107-0166f6e906ef","invalidEventsSituationId":"950ba6cd-528d-42cc-aa07-9f15561735f9","vacationPaidLeaveSituationId":"489eab83-47ed-42ee-ab76-a1702bd13e79","dailyRestViolationSituationId":"848ec42d-b2df-4c4d-94f4-151f381e4a54","workBreakViolationSituationId":"4be78b2c-cae5-46f8-93ae-850a1c85013a","absenceSituationId":"6f3d297a-8977-4b27-a2ca-e5cb5f1489b7","tardinessSituationId":"6f3d297a-8977-4b27-a2ca-e5cb5f1489b7","intermediateLeaveSituationId":"6f3d297a-8977-4b27-a2ca-e5cb5f1489b7","earlyLeaveSituationId":"6f3d297a-8977-4b27-a2ca-e5cb5f1489b7","absenceSituationOnRelayScheduleHolidaysId":"6f3d297a-8977-4b27-a2ca-e5cb5f1489b7","percentageNextDay":false,"normalOvertimeSeparationLimit":10,"separateOvertimeAfterConvertingNightShiftHours":false,"unauthorizedOvertimeId":"acaf9c07-9521-422b-9325-1af1f36fd589","overtimeBeforeId":"6774bc30-d9db-4d52-ade2-9d3e5059e0ab","overtimeEntryId":"6774bc30-d9db-4d52-ade2-9d3e5059e0ab","overtimeDuringMealId":"6774bc30-d9db-4d52-ade2-9d3e5059e0ab","leaveOvertimeId":"6774bc30-d9db-4d52-ade2-9d3e5059e0ab","overtimeAfterId":"a6e0401f-42f2-4dc8-ad48-c48682029689","overtimeSeparationLimitDuringRest":10,"overtimeDuringRestId":"a6e0401f-42f2-4dc8-ad48-c48682029689","overtimeSeparationLimitDuringCompensatedDays":10,"overtimeOnCompensatedDaysId":"a6e0401f-42f2-4dc8-ad48-c48682029689","overtimeSeparationLimitDuringHoliday":10,"overtimeDuringHolidayId":"a6e0401f-42f2-4dc8-ad48-c48682029689","overtimeSeparationLimitDuringDayOff":10,"overtimeDuringDayOffId":"a6e0401f-42f2-4dc8-ad48-c48682029689","overtimeSituationOnRelayScheduleHolidaysId":"6774bc30-d9db-4d52-ade2-9d3e5059e0ab","nightShiftOvertimePremiumSituationId":"a6e0401f-42f2-4dc8-ad48-c48682029689","overtimeSeparationBeforeId":"8cb7c936-a263-4845-979e-9c69d663b4a2","overtimeSeparationEntryId":"8cb7c936-a263-4845-979e-9c69d663b4a2","overtimeSeparationDuringMealId":"8cb7c936-a263-4845-979e-9c69d663b4a2","overtimeSeparationLeaveId":"8cb7c936-a263-4845-979e-9c69d663b4a2","overtimeSeparationAfterId":"8cb7c936-a263-4845-979e-9c69d663b4a2","overtimeSeparationDuringRestId":"8cb7c936-a263-4845-979e-9c69d663b4a2","overtimeSeparationDuringCompensatedDaysId":"8cb7c936-a263-4845-979e-9c69d663b4a2","overtimeSeparationDuringHolidayId":"8cb7c936-a263-4845-979e-9c69d663b4a2","overtimeSeparationDuringDayOffId":"8cb7c936-a263-4845-979e-9c69d663b4a2"}],"jobPositions":[{"key":"1_1","code":1,"structureCode":1}],"workschedules":[{"id":"e7875638-42b4-479d-a825-10fa3b13fbae","code":1,"workload":465,"type":"RIGID","definitionType":"NORMAL","clockingRegisters":[{"sequence":1,"clockingEvent":480,"toleranceBefore":480,"toleranceAfter":480,"mobilityBefore":0,"mobilityAfter":0,"clockingEventScheduleType":"MANDATORY","usingType":"MANDATORY_ENTRY_OR_EXIT"},{"sequence":2,"clockingEvent":540,"toleranceBefore":540,"toleranceAfter":540,"mobilityBefore":0,"mobilityAfter":0,"intervalType":"RIGID","clockingEventScheduleType":"NOM_MANDATORY","usingType":"NON_MANDATORY_SNACK"},{"sequence":3,"clockingEvent":570,"toleranceBefore":570,"toleranceAfter":570,"mobilityBefore":0,"mobilityAfter":0,"intervalType":"RIGID","clockingEventScheduleType":"NOM_MANDATORY","usingType":"NON_MANDATORY_SNACK"},{"sequence":4,"clockingEvent":720,"toleranceBefore":720,"toleranceAfter":720,"mobilityBefore":0,"mobilityAfter":0,"intervalType":"RIGID","clockingEventScheduleType":"MANDATORY","usingType":"MANDATORY_MEAL"},{"sequence":5,"clockingEvent":810,"toleranceBefore":810,"toleranceAfter":810,"mobilityBefore":0,"mobilityAfter":0,"intervalType":"RIGID","clockingEventScheduleType":"MANDATORY","usingType":"MANDATORY_MEAL"},{"sequence":6,"clockingEvent":960,"toleranceBefore":960,"toleranceAfter":960,"mobilityBefore":0,"mobilityAfter":0,"intervalType":"RIGID","clockingEventScheduleType":"NOM_MANDATORY","usingType":"NON_MANDATORY_SNACK"},{"sequence":7,"clockingEvent":975,"toleranceBefore":975,"toleranceAfter":975,"mobilityBefore":0,"mobilityAfter":0,"intervalType":"RIGID","clockingEventScheduleType":"NOM_MANDATORY","usingType":"NON_MANDATORY_SNACK"},{"sequence":8,"clockingEvent":1080,"toleranceBefore":1080,"toleranceAfter":1080,"mobilityBefore":0,"mobilityAfter":0,"clockingEventScheduleType":"MANDATORY","usingType":"MANDATORY_ENTRY_OR_EXIT"}],"clockingEvent":{"workStartEndOvertimeTolerance":10,"mealOvertimeTolerance":11,"overtimeDailyTotalTolerance":12,"absenceDailyTotalTolerance":15,"workStartEndAbsenceTolerance":0,"mealAbsenceTolerance":0}}],"workshifts":[{"id":"47971e5f-3d1a-4494-8cf6-328c7dfa5394","code":1,"type":"PERMANENT","rotationWorkShift":true,"extensionNightHours":true,"dsrMinutes":440,"weekMinutes":2640,"monthMinutes":13200,"timeShiftType":"GENERAL","workshiftGroups":[{"code":1,"baseDate":"2022-08-01"},{"code":2,"baseDate":"2022-08-08"},{"code":3,"baseDate":"2022-08-15"},{"code":4,"baseDate":"1901-01-08"},{"code":4,"baseDate":"2022-08-22"},{"code":5,"baseDate":"2023-03-22"},{"code":5,"baseDate":"2022-08-29"},{"code":6,"baseDate":"2022-09-05"}],"workshiftDetails":[{"holidayGroup":{"code":2},"holidayType":"OWN","startDate":"2022-08-12"}]}],"companyBranches":[{"key":"1_1","code":1}],"syndicates":[{"key":"1","code":1,"nightStartHour":1320,"nightEndHour":300,"minimumInterval4to6Hours":30,"minimumInterval6Hours":90,"minimumWorkDuration6Hours":361}],"employmentRelationships":[{"id":"775ee7d1-5d7f-4a1b-b50b-b659a66014b2","code":"1","contractType":"EMPLOYEE"}],"costCenters":[{"code":"01"},{"code":"02"}]},"currentUser":{"userName":"admin@allanalves.com.br"}}}';
7
+
8
+ const context = new Context({body: inputRule});
9
+ const contract = context.contracts[0];
10
+ const workscheduleChange = contract.schedules.workscheduleChanges[0];
11
+
12
+ expect(workscheduleChange.date).toEqual(new Date("2023-07-31"));
13
+ expect(workscheduleChange.workschedule.code).toBe(1);
14
+ expect(workscheduleChange.workschedule.workload).toBe(465);
15
+ expect(workscheduleChange.workschedule.type).toBe("RIGID");
16
+
17
+ });
18
+
19
+ });
20
+
21
+
@@ -0,0 +1,51 @@
1
+ import { Syndicate } from "../../../data/foundation/syndicate";
2
+ import { SyndicateBuilder } from "../../builder/syndicate.builder";
3
+
4
+ describe("Syndicate", () => {
5
+ it("Deve criar uma instância de Syndicate corretamente com valores padrão", () => {
6
+ const syndicate = new SyndicateBuilder().build();
7
+
8
+ expect(syndicate.code).toBe(1);
9
+ expect(syndicate.nightStartHour).toBe(22 * 60);
10
+ expect(syndicate.nightEndHour).toBe(5 * 60);
11
+ expect(syndicate.minimumInterval4to6Hours).toBe(9 * 60);
12
+ expect(syndicate.minimumInterval6Hours).toBe(1 * 60);
13
+ expect(syndicate.minimumWorkDuration6Hours).toBe(1 * 60);
14
+ expect(syndicate.minimumWorkDuration6Hours).toBe(1 * 60);
15
+ expect(syndicate.minimumWorkDuration6Hours).toBe(1 * 60);
16
+ expect(syndicate.maxDailyWorkTime).toBe(1 * 480);
17
+ expect(syndicate.maxContinuousDrivingTime).toBe(1 * 540);
18
+ expect(syndicate.minContinuousRestTime).toBe(1 * 60);
19
+ expect(syndicate.allowDailyRestFractionation).toBe(false);
20
+ expect(syndicate.calculateWeeklyRest).toBe(false);
21
+ });
22
+
23
+ it("Deve criar uma instância de Syndicate com valores personalizados", () => {
24
+ const syndicate = new SyndicateBuilder()
25
+ .withKey("custom-key")
26
+ .withCode(99)
27
+ .withNightStartHour(21 * 60)
28
+ .withNightEndHour(6 * 60)
29
+ .withMinimumInterval4to6Hours(10 * 60)
30
+ .withMinimumInterval6Hours(2 * 60)
31
+ .withMinimumWorkDuration6Hours(2 * 60)
32
+ .withMaxDailyWorkTime(2 * 480)
33
+ .withMaxContinuousDrivingTime(2 * 540)
34
+ .withMinContinuousRestTime(2 * 60)
35
+ .withAllowDailyRestFractionation(true)
36
+ .withCalculateWeeklyRest(true)
37
+ .build();
38
+
39
+ expect(syndicate.code).toBe(99);
40
+ expect(syndicate.nightStartHour).toBe(21 * 60);
41
+ expect(syndicate.nightEndHour).toBe(6 * 60);
42
+ expect(syndicate.minimumInterval4to6Hours).toBe(10 * 60);
43
+ expect(syndicate.minimumInterval6Hours).toBe(2 * 60);
44
+ expect(syndicate.minimumWorkDuration6Hours).toBe(2 * 60);
45
+ expect(syndicate.maxDailyWorkTime).toBe(2 * 480);
46
+ expect(syndicate.maxContinuousDrivingTime).toBe(2 * 540);
47
+ expect(syndicate.minContinuousRestTime).toBe(2 * 60);
48
+ expect(syndicate.allowDailyRestFractionation).toBe(true);
49
+ expect(syndicate.calculateWeeklyRest).toBe(true);
50
+ });
51
+ });