From 97b9e515bfafeef2b84d1c2ba153c89e3edd685b Mon Sep 17 00:00:00 2001 From: ricardo051199 Date: Thu, 14 Nov 2024 22:19:43 -0400 Subject: [PATCH 1/3] correcciones --- package.json | 56 +++++++++---------- .../TimeOffRequestRepository.java | 1 + .../service/TimeOffRequestService.java | 10 +++- .../views/RequestRegisterView.java | 2 +- src/main/resources/data.sql | 2 +- 5 files changed, 39 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index 18cb231..209a580 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "type": "module", "dependencies": { "@f0rce/ace-widget": "1.0.2", - "@polymer/polymer": "3.5.1", + "@polymer/polymer": "3.5.2", "@vaadin-component-factory/vcf-pdf-viewer": "2.0.1", "@vaadin/bundles": "24.5.1", "@vaadin/common-frontend": "0.0.19", @@ -19,30 +19,30 @@ "@vaadin/vaadin-usage-statistics": "2.1.3", "construct-style-sheets-polyfill": "3.1.0", "date-fns": "2.29.3", - "lit": "3.1.4", + "lit": "3.2.1", "print-js": "1.6.0", "proj4": "2.12.1", "react": "18.3.1", "react-dom": "18.3.1", - "react-router-dom": "6.23.1" + "react-router-dom": "6.26.2" }, "devDependencies": { - "@babel/preset-react": "7.24.7", + "@babel/preset-react": "7.25.7", "@preact/signals-react-transform": "0.4.0", - "@rollup/plugin-replace": "5.0.7", - "@rollup/pluginutils": "5.1.0", - "@types/react": "18.3.3", - "@types/react-dom": "18.3.0", - "@vitejs/plugin-react": "4.3.1", - "async": "3.2.5", - "glob": "10.4.1", + "@rollup/plugin-replace": "6.0.1", + "@rollup/pluginutils": "5.1.2", + "@types/react": "18.3.11", + "@types/react-dom": "18.3.1", + "@vitejs/plugin-react": "4.3.3", + "async": "3.2.6", + "glob": "10.4.5", "rollup-plugin-brotli": "3.1.0", "rollup-plugin-visualizer": "5.12.0", "strip-css-comments": "5.0.0", "transform-ast": "2.4.4", - "typescript": "5.4.5", - "vite": "5.3.3", - "vite-plugin-checker": "0.6.4", + "typescript": "5.6.3", + "vite": "5.4.9", + "vite-plugin-checker": "0.8.0", "workbox-build": "7.1.1", "workbox-core": "7.1.0", "workbox-precaching": "7.1.0" @@ -50,7 +50,7 @@ "vaadin": { "dependencies": { "@f0rce/ace-widget": "1.0.2", - "@polymer/polymer": "3.5.1", + "@polymer/polymer": "3.5.2", "@vaadin-component-factory/vcf-pdf-viewer": "2.0.1", "@vaadin/bundles": "24.5.1", "@vaadin/common-frontend": "0.0.19", @@ -65,30 +65,30 @@ "@vaadin/vaadin-usage-statistics": "2.1.3", "construct-style-sheets-polyfill": "3.1.0", "date-fns": "2.29.3", - "lit": "3.1.4", + "lit": "3.2.1", "print-js": "1.6.0", "proj4": "2.12.1", "react": "18.3.1", "react-dom": "18.3.1", - "react-router-dom": "6.23.1" + "react-router-dom": "6.26.2" }, "devDependencies": { - "@babel/preset-react": "7.24.7", + "@babel/preset-react": "7.25.7", "@preact/signals-react-transform": "0.4.0", - "@rollup/plugin-replace": "5.0.7", - "@rollup/pluginutils": "5.1.0", - "@types/react": "18.3.3", - "@types/react-dom": "18.3.0", - "@vitejs/plugin-react": "4.3.1", - "async": "3.2.5", - "glob": "10.4.1", + "@rollup/plugin-replace": "6.0.1", + "@rollup/pluginutils": "5.1.2", + "@types/react": "18.3.11", + "@types/react-dom": "18.3.1", + "@vitejs/plugin-react": "4.3.3", + "async": "3.2.6", + "glob": "10.4.5", "rollup-plugin-brotli": "3.1.0", "rollup-plugin-visualizer": "5.12.0", "strip-css-comments": "5.0.0", "transform-ast": "2.4.4", - "typescript": "5.4.5", - "vite": "5.3.3", - "vite-plugin-checker": "0.6.4", + "typescript": "5.6.3", + "vite": "5.4.9", + "vite-plugin-checker": "0.8.0", "workbox-build": "7.1.1", "workbox-core": "7.1.0", "workbox-precaching": "7.1.0" diff --git a/src/main/java/com/primefactorsolutions/repositories/TimeOffRequestRepository.java b/src/main/java/com/primefactorsolutions/repositories/TimeOffRequestRepository.java index f58ae50..0fcb604 100644 --- a/src/main/java/com/primefactorsolutions/repositories/TimeOffRequestRepository.java +++ b/src/main/java/com/primefactorsolutions/repositories/TimeOffRequestRepository.java @@ -14,4 +14,5 @@ public interface TimeOffRequestRepository extends JpaRepository findByEmployeeIdAndState(UUID employeeId, TimeOffRequestStatus state); List findByEmployeeIdAndCategory(UUID employeeId, TimeOffRequestType category); List findByState(TimeOffRequestStatus state); + void deleteByEmployeeIdAndCategory(UUID employeeId, TimeOffRequestType category); } diff --git a/src/main/java/com/primefactorsolutions/service/TimeOffRequestService.java b/src/main/java/com/primefactorsolutions/service/TimeOffRequestService.java index e652266..748fcbc 100644 --- a/src/main/java/com/primefactorsolutions/service/TimeOffRequestService.java +++ b/src/main/java/com/primefactorsolutions/service/TimeOffRequestService.java @@ -19,6 +19,10 @@ public class TimeOffRequestService { timeOffRequestRepository.save(newTimeOffRequest); } + public void deleteTimeOffRequestByEmployeeAndCategory(final UUID employeeId, final TimeOffRequestType category) { + timeOffRequestRepository.deleteByEmployeeIdAndCategory(employeeId, category); + } + public void saveAll(final List requests) { timeOffRequestRepository.saveAll(requests); } @@ -57,10 +61,12 @@ public class TimeOffRequestService { LocalDate now = LocalDate.now(); LocalDate startOfYear = LocalDate.of(now.getYear(), 1, 1); - requests.removeIf(request -> request.getCategory() == TimeOffRequestType.VACACION_GESTION_ANTERIOR); - for (TimeOffRequest request : requests) { if (request.getCategory() == TimeOffRequestType.VACACION_GESTION_ACTUAL && now.isEqual(startOfYear)) { + deleteTimeOffRequestByEmployeeAndCategory( + request.getEmployee().getId(), + TimeOffRequestType.VACACION_GESTION_ANTERIOR + ); request.setCategory(TimeOffRequestType.VACACION_GESTION_ANTERIOR); } diff --git a/src/main/java/com/primefactorsolutions/views/RequestRegisterView.java b/src/main/java/com/primefactorsolutions/views/RequestRegisterView.java index 4d15629..6551bd3 100644 --- a/src/main/java/com/primefactorsolutions/views/RequestRegisterView.java +++ b/src/main/java/com/primefactorsolutions/views/RequestRegisterView.java @@ -136,7 +136,7 @@ public class RequestRegisterView extends VerticalLayout { .filter(category -> isCategoryAvailable(employeeRequests, category)) .filter(category -> isCategoryAllowedByGender(category, employee.getGender())) .filter(category -> category != TimeOffRequestType.TODOS) - .filter(category -> shouldIncludeVacationGestionActual(employeeRequests, category)) // Nueva condiciĆ³n + .filter(category -> shouldIncludeVacationGestionActual(employeeRequests, category)) .toList(); categoryComboBox.setItems(availableCategories); diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index aeee7ec..5cb7a98 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -78,7 +78,7 @@ values ('9c6f12ba-e333-4e7a-b8a6-caa0982bd8c3', 1, '5c6f11fe-c341-4be7-a9a6-bba0 insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance) values ('9d6f12ba-e444-4e7a-b8a6-caa0982bd8d4', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'VIERNES_SANTO', 'APROBADO', 1, '2024-03-29', '2024-03-29', '2024-03-29', 1, 0); insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance) -values ('9e6f12ba-e555-4e7a-b8a6-caa0982bd8e5', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'VACACION_GESTION_ANTERIOR', 'APROBADO', 30, '2024-11-01', '2022-11-01', '2022-11-30', 30, 0); +values ('9e6f12ba-e555-4e7a-b8a6-caa0982bd8e5', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'VACACION_GESTION_ANTERIOR', 'APROBADO', 20, '2024-11-01', '2022-11-01', '2022-11-30', 20, 0); insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance) values ('8c653f2a-f9a3-4d67-b3b6-12ad98fe0983', 1, 'f6ab3c6d-7078-45f6-9b22-4e37637bfec6', 'DIA_DEL_TRABAJADOR', 'APROBADO', 1, '2024-05-01', '2024-05-01', '2024-05-01', 1, 0); -- 2.34.1 From 305a5c53f3462da1c4e164b045c1aa42596fe33c Mon Sep 17 00:00:00 2001 From: ricardo051199 Date: Thu, 14 Nov 2024 22:31:29 -0400 Subject: [PATCH 2/3] correcciones --- .../views/RequestEmployeeView.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/primefactorsolutions/views/RequestEmployeeView.java b/src/main/java/com/primefactorsolutions/views/RequestEmployeeView.java index 6737dc5..58b4ab6 100644 --- a/src/main/java/com/primefactorsolutions/views/RequestEmployeeView.java +++ b/src/main/java/com/primefactorsolutions/views/RequestEmployeeView.java @@ -244,22 +244,21 @@ public class RequestEmployeeView extends Div implements HasUrlParameter private double calculateHolidayUtilizedDays(final int year) { return requests.stream() .filter(this::verificationIsHoliday) + .filter(this::verificationIsHoliday) + .filter(req -> req.getState() == TimeOffRequestStatus.APROBADO) + .filter(req -> req.getState() == TimeOffRequestStatus.EN_USO) + .filter(req -> req.getState() == TimeOffRequestStatus.TOMADO) .filter(req -> getStartDateYear(req) == year) .mapToDouble(TimeOffRequest::getDaysToBeTake) .sum(); } - private double calculateVacationUtilizedDays(final int year) { - return requests.stream() - .filter(req -> req.getCategory().name().startsWith("VACACION")) - .filter(req -> getStartDateYear(req) == year || getStartDateYear(req) == year - 1) - .mapToDouble(TimeOffRequest::getDaysBalance) - .sum(); - } - private double calculatePersonalDaysUtilized(final boolean isMale, final int year) { return requests.stream() .filter(req -> !verificationIsHoliday(req)) + .filter(req -> req.getState() == TimeOffRequestStatus.APROBADO) + .filter(req -> req.getState() == TimeOffRequestStatus.EN_USO) + .filter(req -> req.getState() == TimeOffRequestStatus.TOMADO) .filter(req -> !getStandardExclusions().contains(req.getCategory())) .filter(req -> !(isMale && getMaleSpecificExclusions().contains(req.getCategory()))) .filter(req -> !req.getCategory().name().startsWith("VACACION")) -- 2.34.1 From 005f0235fa104caa96e16d7de7f25ff226762da1 Mon Sep 17 00:00:00 2001 From: ricardo051199 Date: Thu, 14 Nov 2024 22:42:42 -0400 Subject: [PATCH 3/3] correcciones vacacion gestion anterior --- package.json | 56 +++++++++---------- .../views/RequestRegisterView.java | 11 ++++ 2 files changed, 39 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index 209a580..18cb231 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "type": "module", "dependencies": { "@f0rce/ace-widget": "1.0.2", - "@polymer/polymer": "3.5.2", + "@polymer/polymer": "3.5.1", "@vaadin-component-factory/vcf-pdf-viewer": "2.0.1", "@vaadin/bundles": "24.5.1", "@vaadin/common-frontend": "0.0.19", @@ -19,30 +19,30 @@ "@vaadin/vaadin-usage-statistics": "2.1.3", "construct-style-sheets-polyfill": "3.1.0", "date-fns": "2.29.3", - "lit": "3.2.1", + "lit": "3.1.4", "print-js": "1.6.0", "proj4": "2.12.1", "react": "18.3.1", "react-dom": "18.3.1", - "react-router-dom": "6.26.2" + "react-router-dom": "6.23.1" }, "devDependencies": { - "@babel/preset-react": "7.25.7", + "@babel/preset-react": "7.24.7", "@preact/signals-react-transform": "0.4.0", - "@rollup/plugin-replace": "6.0.1", - "@rollup/pluginutils": "5.1.2", - "@types/react": "18.3.11", - "@types/react-dom": "18.3.1", - "@vitejs/plugin-react": "4.3.3", - "async": "3.2.6", - "glob": "10.4.5", + "@rollup/plugin-replace": "5.0.7", + "@rollup/pluginutils": "5.1.0", + "@types/react": "18.3.3", + "@types/react-dom": "18.3.0", + "@vitejs/plugin-react": "4.3.1", + "async": "3.2.5", + "glob": "10.4.1", "rollup-plugin-brotli": "3.1.0", "rollup-plugin-visualizer": "5.12.0", "strip-css-comments": "5.0.0", "transform-ast": "2.4.4", - "typescript": "5.6.3", - "vite": "5.4.9", - "vite-plugin-checker": "0.8.0", + "typescript": "5.4.5", + "vite": "5.3.3", + "vite-plugin-checker": "0.6.4", "workbox-build": "7.1.1", "workbox-core": "7.1.0", "workbox-precaching": "7.1.0" @@ -50,7 +50,7 @@ "vaadin": { "dependencies": { "@f0rce/ace-widget": "1.0.2", - "@polymer/polymer": "3.5.2", + "@polymer/polymer": "3.5.1", "@vaadin-component-factory/vcf-pdf-viewer": "2.0.1", "@vaadin/bundles": "24.5.1", "@vaadin/common-frontend": "0.0.19", @@ -65,30 +65,30 @@ "@vaadin/vaadin-usage-statistics": "2.1.3", "construct-style-sheets-polyfill": "3.1.0", "date-fns": "2.29.3", - "lit": "3.2.1", + "lit": "3.1.4", "print-js": "1.6.0", "proj4": "2.12.1", "react": "18.3.1", "react-dom": "18.3.1", - "react-router-dom": "6.26.2" + "react-router-dom": "6.23.1" }, "devDependencies": { - "@babel/preset-react": "7.25.7", + "@babel/preset-react": "7.24.7", "@preact/signals-react-transform": "0.4.0", - "@rollup/plugin-replace": "6.0.1", - "@rollup/pluginutils": "5.1.2", - "@types/react": "18.3.11", - "@types/react-dom": "18.3.1", - "@vitejs/plugin-react": "4.3.3", - "async": "3.2.6", - "glob": "10.4.5", + "@rollup/plugin-replace": "5.0.7", + "@rollup/pluginutils": "5.1.0", + "@types/react": "18.3.3", + "@types/react-dom": "18.3.0", + "@vitejs/plugin-react": "4.3.1", + "async": "3.2.5", + "glob": "10.4.1", "rollup-plugin-brotli": "3.1.0", "rollup-plugin-visualizer": "5.12.0", "strip-css-comments": "5.0.0", "transform-ast": "2.4.4", - "typescript": "5.6.3", - "vite": "5.4.9", - "vite-plugin-checker": "0.8.0", + "typescript": "5.4.5", + "vite": "5.3.3", + "vite-plugin-checker": "0.6.4", "workbox-build": "7.1.1", "workbox-core": "7.1.0", "workbox-precaching": "7.1.0" diff --git a/src/main/java/com/primefactorsolutions/views/RequestRegisterView.java b/src/main/java/com/primefactorsolutions/views/RequestRegisterView.java index 6551bd3..4d56f10 100644 --- a/src/main/java/com/primefactorsolutions/views/RequestRegisterView.java +++ b/src/main/java/com/primefactorsolutions/views/RequestRegisterView.java @@ -137,6 +137,7 @@ public class RequestRegisterView extends VerticalLayout { .filter(category -> isCategoryAllowedByGender(category, employee.getGender())) .filter(category -> category != TimeOffRequestType.TODOS) .filter(category -> shouldIncludeVacationGestionActual(employeeRequests, category)) + .filter(category -> shouldIncludeVacationGestionAnterior(employeeRequests, category)) .toList(); categoryComboBox.setItems(availableCategories); @@ -154,6 +155,16 @@ public class RequestRegisterView extends VerticalLayout { && request.getState() == TimeOffRequestStatus.TOMADO); } + private boolean shouldIncludeVacationGestionAnterior(final List employeeRequests, + final TimeOffRequestType category) { + if (category != TimeOffRequestType.VACACION_GESTION_ANTERIOR) { + return true; + } + return employeeRequests.stream() + .noneMatch(request -> request.getCategory() == TimeOffRequestType.VACACION_GESTION_ANTERIOR + && request.getDaysBalance() == 0); + } + private void onCategoryChange(final TimeOffRequestType selectedCategory) { if (selectedCategory == TimeOffRequestType.VACACION_GESTION_ACTUAL || selectedCategory == TimeOffRequestType.VACACION_GESTION_ANTERIOR) { -- 2.34.1