Compare commits
No commits in common. "1ab10e286e0194096b08342629743ad176cd5ea6" and "1e22223f2753ff2afb9f7e4c04568888e1ff98c6" have entirely different histories.
1ab10e286e
...
1e22223f27
60
package.json
60
package.json
@ -4,7 +4,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@f0rce/ace-widget": "1.0.2",
|
"@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-component-factory/vcf-pdf-viewer": "2.0.1",
|
||||||
"@vaadin/bundles": "24.5.1",
|
"@vaadin/bundles": "24.5.1",
|
||||||
"@vaadin/common-frontend": "0.0.19",
|
"@vaadin/common-frontend": "0.0.19",
|
||||||
@ -19,30 +19,29 @@
|
|||||||
"@vaadin/vaadin-usage-statistics": "2.1.3",
|
"@vaadin/vaadin-usage-statistics": "2.1.3",
|
||||||
"construct-style-sheets-polyfill": "3.1.0",
|
"construct-style-sheets-polyfill": "3.1.0",
|
||||||
"date-fns": "2.29.3",
|
"date-fns": "2.29.3",
|
||||||
"lit": "3.2.1",
|
"lit": "3.1.4",
|
||||||
"print-js": "1.6.0",
|
"print-js": "1.6.0",
|
||||||
"proj4": "2.12.1",
|
"proj4": "2.12.1",
|
||||||
"react": "18.3.1",
|
"react": "18.3.1",
|
||||||
"react-dom": "18.3.1",
|
"react-dom": "18.3.1",
|
||||||
"react-router-dom": "6.26.2"
|
"react-router-dom": "6.23.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/preset-react": "7.25.7",
|
"@babel/preset-react": "7.24.7",
|
||||||
"@preact/signals-react-transform": "0.4.0",
|
"@rollup/plugin-replace": "5.0.7",
|
||||||
"@rollup/plugin-replace": "6.0.1",
|
"@rollup/pluginutils": "5.1.0",
|
||||||
"@rollup/pluginutils": "5.1.2",
|
"@types/react": "18.3.3",
|
||||||
"@types/react": "18.3.11",
|
"@types/react-dom": "18.3.0",
|
||||||
"@types/react-dom": "18.3.1",
|
"@vitejs/plugin-react": "4.3.1",
|
||||||
"@vitejs/plugin-react": "4.3.3",
|
"async": "3.2.5",
|
||||||
"async": "3.2.6",
|
"glob": "10.4.1",
|
||||||
"glob": "10.4.5",
|
|
||||||
"rollup-plugin-brotli": "3.1.0",
|
"rollup-plugin-brotli": "3.1.0",
|
||||||
"rollup-plugin-visualizer": "5.12.0",
|
"rollup-plugin-visualizer": "5.12.0",
|
||||||
"strip-css-comments": "5.0.0",
|
"strip-css-comments": "5.0.0",
|
||||||
"transform-ast": "2.4.4",
|
"transform-ast": "2.4.4",
|
||||||
"typescript": "5.6.3",
|
"typescript": "5.4.5",
|
||||||
"vite": "5.4.9",
|
"vite": "5.3.3",
|
||||||
"vite-plugin-checker": "0.8.0",
|
"vite-plugin-checker": "0.6.4",
|
||||||
"workbox-build": "7.1.1",
|
"workbox-build": "7.1.1",
|
||||||
"workbox-core": "7.1.0",
|
"workbox-core": "7.1.0",
|
||||||
"workbox-precaching": "7.1.0"
|
"workbox-precaching": "7.1.0"
|
||||||
@ -50,7 +49,7 @@
|
|||||||
"vaadin": {
|
"vaadin": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@f0rce/ace-widget": "1.0.2",
|
"@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-component-factory/vcf-pdf-viewer": "2.0.1",
|
||||||
"@vaadin/bundles": "24.5.1",
|
"@vaadin/bundles": "24.5.1",
|
||||||
"@vaadin/common-frontend": "0.0.19",
|
"@vaadin/common-frontend": "0.0.19",
|
||||||
@ -65,35 +64,34 @@
|
|||||||
"@vaadin/vaadin-usage-statistics": "2.1.3",
|
"@vaadin/vaadin-usage-statistics": "2.1.3",
|
||||||
"construct-style-sheets-polyfill": "3.1.0",
|
"construct-style-sheets-polyfill": "3.1.0",
|
||||||
"date-fns": "2.29.3",
|
"date-fns": "2.29.3",
|
||||||
"lit": "3.2.1",
|
"lit": "3.1.4",
|
||||||
"print-js": "1.6.0",
|
"print-js": "1.6.0",
|
||||||
"proj4": "2.12.1",
|
"proj4": "2.12.1",
|
||||||
"react": "18.3.1",
|
"react": "18.3.1",
|
||||||
"react-dom": "18.3.1",
|
"react-dom": "18.3.1",
|
||||||
"react-router-dom": "6.26.2"
|
"react-router-dom": "6.23.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/preset-react": "7.25.7",
|
"@babel/preset-react": "7.24.7",
|
||||||
"@preact/signals-react-transform": "0.4.0",
|
"@rollup/plugin-replace": "5.0.7",
|
||||||
"@rollup/plugin-replace": "6.0.1",
|
"@rollup/pluginutils": "5.1.0",
|
||||||
"@rollup/pluginutils": "5.1.2",
|
"@types/react": "18.3.3",
|
||||||
"@types/react": "18.3.11",
|
"@types/react-dom": "18.3.0",
|
||||||
"@types/react-dom": "18.3.1",
|
"@vitejs/plugin-react": "4.3.1",
|
||||||
"@vitejs/plugin-react": "4.3.3",
|
"async": "3.2.5",
|
||||||
"async": "3.2.6",
|
"glob": "10.4.1",
|
||||||
"glob": "10.4.5",
|
|
||||||
"rollup-plugin-brotli": "3.1.0",
|
"rollup-plugin-brotli": "3.1.0",
|
||||||
"rollup-plugin-visualizer": "5.12.0",
|
"rollup-plugin-visualizer": "5.12.0",
|
||||||
"strip-css-comments": "5.0.0",
|
"strip-css-comments": "5.0.0",
|
||||||
"transform-ast": "2.4.4",
|
"transform-ast": "2.4.4",
|
||||||
"typescript": "5.6.3",
|
"typescript": "5.4.5",
|
||||||
"vite": "5.4.9",
|
"vite": "5.3.3",
|
||||||
"vite-plugin-checker": "0.8.0",
|
"vite-plugin-checker": "0.6.4",
|
||||||
"workbox-build": "7.1.1",
|
"workbox-build": "7.1.1",
|
||||||
"workbox-core": "7.1.0",
|
"workbox-core": "7.1.0",
|
||||||
"workbox-precaching": "7.1.0"
|
"workbox-precaching": "7.1.0"
|
||||||
},
|
},
|
||||||
"hash": "2dc40a4f634ae025081ca2239cba00b14a35fe94ab78ac0a4dd3023d882081d5"
|
"hash": "1a0f17d48b329307b5862bc57499307d1b89f7d89260121c2b7189f76957c436"
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"@vaadin/bundles": "$@vaadin/bundles",
|
"@vaadin/bundles": "$@vaadin/bundles",
|
||||||
|
@ -2,7 +2,6 @@ package com.primefactorsolutions.model;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import jakarta.validation.constraints.*;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
@ -19,45 +18,30 @@ import java.util.Collection;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class Employee extends BaseEntity implements UserDetails {
|
public class Employee extends BaseEntity implements UserDetails {
|
||||||
|
|
||||||
private String username;
|
private String username;
|
||||||
@NotNull(message = "El nombre no puede estar vacío")
|
|
||||||
@Pattern(regexp = "^[a-zA-Z ]+$", message = "El nombre solo debe contener letras")
|
|
||||||
private String firstName;
|
private String firstName;
|
||||||
@NotNull(message = "El apellido no puede estar vacío")
|
|
||||||
@Pattern(regexp = "^[a-zA-Z ]+$", message = "El apellido solo debe contener letras")
|
|
||||||
private String lastName;
|
private String lastName;
|
||||||
private LocalDate birthday;
|
private LocalDate birthday;
|
||||||
@Pattern(regexp = "^[a-zA-Z ]+$", message = "La ciudad de nacimiento solo debe contener letras")
|
|
||||||
private String birthCity;
|
private String birthCity;
|
||||||
private String age;
|
private String age;
|
||||||
@Size(max = 100, message = "La dirección de residencia no debe exceder 100 caracteres")
|
|
||||||
private String residenceAddress;
|
private String residenceAddress;
|
||||||
@Size(max = 100, message = "La dirección local no debe exceder 100 caracteres")
|
|
||||||
private String localAddress;
|
private String localAddress;
|
||||||
@Pattern(regexp = "^[0-9]+$", message = "El número de teléfono debe contener solo números")
|
|
||||||
private String phoneNumber;
|
private String phoneNumber;
|
||||||
@Email(message = "El correo personal no tiene un formato válido")
|
|
||||||
private String personalEmail;
|
private String personalEmail;
|
||||||
@Pattern(regexp = "^[a-zA-Z ]+$", message = "El cargo solo debe contener letras")
|
|
||||||
private String position;
|
private String position;
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "team_id", nullable = false)
|
@JoinColumn(name = "team_id", nullable = false)
|
||||||
private Team team;
|
private Team team;
|
||||||
@Size(max = 100, message = "El nombre de contacto de emergencia no debe exceder 100 caracteres")
|
|
||||||
private String emergencyCName;
|
private String emergencyCName;
|
||||||
@Size(max = 100, message = "La dirección de contacto de emergencia no debe exceder 100 caracteres")
|
|
||||||
private String emergencyCAddress;
|
private String emergencyCAddress;
|
||||||
@Pattern(regexp = "^[0-9]+$", message = "El teléfono de contacto de emergencia debe contener solo números")
|
|
||||||
private String emergencyCPhone;
|
private String emergencyCPhone;
|
||||||
@Email(message = "El correo de contacto de emergencia no tiene un formato válido")
|
|
||||||
private String emergencyCEmail;
|
private String emergencyCEmail;
|
||||||
@Pattern(regexp = "^[0-9]+$", message = "La cantidad de hijos debe contener solo números")
|
|
||||||
private String numberOfChildren;
|
private String numberOfChildren;
|
||||||
@Pattern(regexp = "^[0-9]+$", message = "El CI debe contener solo números")
|
|
||||||
private String ci;
|
private String ci;
|
||||||
private String issuedIn;
|
private String issuedIn;
|
||||||
@Size(max = 100, message = "El título no debe exceder 100 caracteres")
|
|
||||||
private String pTitle1;
|
private String pTitle1;
|
||||||
private String pTitle2;
|
private String pTitle2;
|
||||||
private String pTitle3;
|
private String pTitle3;
|
||||||
@ -70,36 +54,29 @@ public class Employee extends BaseEntity implements UserDetails {
|
|||||||
private String certification2;
|
private String certification2;
|
||||||
private String certification3;
|
private String certification3;
|
||||||
private String certification4;
|
private String certification4;
|
||||||
@Size(max = 255, message = "El reconocimiento no debe exceder 255 caracteres")
|
|
||||||
private String recognition;
|
private String recognition;
|
||||||
@Size(max = 500, message = "Los logros no deben exceder 500 caracteres")
|
|
||||||
private String achievements;
|
private String achievements;
|
||||||
|
|
||||||
private String language;
|
private String language;
|
||||||
private String languageLevel;
|
private String languageLevel;
|
||||||
@Pattern(regexp = "^[A-Za-z0-9]+$", message = "El código debe contener solo letras y números")
|
|
||||||
private String cod;
|
private String cod;
|
||||||
@Pattern(regexp = "^[a-zA-Z ]+$", message = "El lead manager solo debe contener letras")
|
|
||||||
private String leadManager;
|
private String leadManager;
|
||||||
@Pattern(regexp = "^[a-zA-Z ]+$", message = "El proyecto solo debe contener letras")
|
|
||||||
private String project;
|
private String project;
|
||||||
|
|
||||||
private LocalDate dateOfEntry;
|
private LocalDate dateOfEntry;
|
||||||
private LocalDate dateOfExit;
|
private LocalDate dateOfExit;
|
||||||
@Pattern(regexp = "^[a-zA-Z ]+$", message = "El tipo de contrato solo debe contener letras")
|
|
||||||
private String contractType;
|
private String contractType;
|
||||||
@Pattern(regexp = "^[0-9]+$", message = "La antigüedad debe contener solo números")
|
|
||||||
private String seniority;
|
private String seniority;
|
||||||
@Pattern(regexp = "^[0-9]+(\\.[0-9]{1,2})?$", message = "El salario debe ser un número con hasta dos decimales")
|
|
||||||
private String salary;
|
private String salary;
|
||||||
@Pattern(regexp = "^[a-zA-Z ]+$", message = "El nombre del banco solo debe contener letras")
|
|
||||||
private String bankName;
|
private String bankName;
|
||||||
@Pattern(regexp = "^[0-9]+$", message = "El número de cuenta debe contener solo números")
|
|
||||||
private String accountNumber;
|
private String accountNumber;
|
||||||
|
|
||||||
private String gpss;
|
private String gpss;
|
||||||
private String sss;
|
private String sss;
|
||||||
@Pattern(regexp = "^[a-zA-Z ]+$", message = "Los derechohabientes solo deben contener letras")
|
|
||||||
private String beneficiaries;
|
private String beneficiaries;
|
||||||
|
|
||||||
@Column(columnDefinition = "TEXT")
|
@Column(columnDefinition = "TEXT")
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package com.primefactorsolutions.model;
|
package com.primefactorsolutions.model;
|
||||||
|
|
||||||
public enum TimeOffRequestStatus {
|
public enum TimeOffRequestStatus {
|
||||||
TODOS,
|
ALL,
|
||||||
TOMADO,
|
TAKEN,
|
||||||
SOLICITADO,
|
REQUESTED,
|
||||||
APROBADO,
|
APPROVED,
|
||||||
EN_USO,
|
IN_USE,
|
||||||
EN_REVISION,
|
UNDER_REVIEW,
|
||||||
PENDIENTE,
|
PENDING,
|
||||||
RECHAZADO,
|
REJECTED,
|
||||||
COMPLETADO,
|
COMPLETED,
|
||||||
CANCELADO,
|
CANCELLED,
|
||||||
VENCIDO
|
EXPIRED
|
||||||
}
|
}
|
||||||
|
@ -1,31 +1,29 @@
|
|||||||
package com.primefactorsolutions.model;
|
package com.primefactorsolutions.model;
|
||||||
|
|
||||||
public enum TimeOffRequestType {
|
public enum TimeOffRequestType {
|
||||||
TODOS,
|
ALL,
|
||||||
AÑO_NUEVO,
|
NEW_YEAR,
|
||||||
LUNES_CARNAVAL,
|
MONDAY_CARNIVAL,
|
||||||
MARTES_CARNAVAL,
|
TUESDAY_CARNIVAL,
|
||||||
VIERNES_SANTO,
|
GOOD_FRIDAY,
|
||||||
DIA_DEL_TRABAJADOR,
|
LABOR_DAY,
|
||||||
DIA_DE_LA_INDEPENDENCIA,
|
INDEPENDENCE_DAY,
|
||||||
NAVIDAD,
|
CHRISTMAS,
|
||||||
DIA_DEL_ESTADO_PLURINACIONAL,
|
PRURINATIONAL_STATE_DAY,
|
||||||
CORPUS_CHRISTI,
|
CORPUS_CHRISTI,
|
||||||
AÑO_NUEVO_ANDINO,
|
ANDEAN_NEW_YEAR,
|
||||||
ANIVERSARIO_DEPARTAMENTAL,
|
DEPARTMENTAL_ANNIVERSARY,
|
||||||
DIA_DE_TODOS_LOS_DIFUNTOS,
|
ALL_SOULS_DAY,
|
||||||
|
|
||||||
CUMPLEAÑOS,
|
BIRTHDAY,
|
||||||
MATERNIDAD,
|
MATERNITY,
|
||||||
PATERNIDAD,
|
PATERNITY,
|
||||||
MATRIMONIO,
|
MARRIAGE,
|
||||||
DUELO_1ER_GRADO,
|
FATHERS_DAY,
|
||||||
DUELO_2ER_GRADO,
|
MOTHERS_DAY,
|
||||||
DIA_DEL_PADRE,
|
INTERNATIONAL_WOMENS_DAY,
|
||||||
DIA_DE_LA_MADRE,
|
NATIONAL_WOMENS_DAY,
|
||||||
DIA_DE_LA_MUJER_INTERNACIONAL,
|
HEALTH_PERMIT,
|
||||||
DIA_DE_LA_MUJER_NACIONAL,
|
VACATION_CURRENT_MANAGEMENT,
|
||||||
PERMISOS_DE_SALUD,
|
VACATION_PREVIOUS_MANAGEMENT,
|
||||||
VACACION_GESTION_ACTUAL,
|
|
||||||
VACACION_GESTION_ANTERIOR,
|
|
||||||
}
|
}
|
||||||
|
@ -13,5 +13,4 @@ public interface TimeOffRequestRepository extends JpaRepository<TimeOffRequest,
|
|||||||
List<TimeOffRequest> findByEmployeeId(UUID idEmployee);
|
List<TimeOffRequest> findByEmployeeId(UUID idEmployee);
|
||||||
Optional<TimeOffRequest> findByEmployeeIdAndState(UUID employeeId, TimeOffRequestStatus state);
|
Optional<TimeOffRequest> findByEmployeeIdAndState(UUID employeeId, TimeOffRequestStatus state);
|
||||||
List<TimeOffRequest> findByEmployeeIdAndCategory(UUID employeeId, TimeOffRequestType category);
|
List<TimeOffRequest> findByEmployeeIdAndCategory(UUID employeeId, TimeOffRequestType category);
|
||||||
List<TimeOffRequest> findByState(TimeOffRequestStatus state);
|
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,6 @@ public class TimeOffRequestService {
|
|||||||
timeOffRequestRepository.save(newTimeOffRequest);
|
timeOffRequestRepository.save(newTimeOffRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveAll(final List<TimeOffRequest> requests) {
|
|
||||||
timeOffRequestRepository.saveAll(requests);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteTimeOffRequest(final UUID id) {
|
public void deleteTimeOffRequest(final UUID id) {
|
||||||
timeOffRequestRepository.deleteById(id);
|
timeOffRequestRepository.deleteById(id);
|
||||||
}
|
}
|
||||||
@ -35,10 +31,6 @@ public class TimeOffRequestService {
|
|||||||
return timeOffRequest.orElse(null);
|
return timeOffRequest.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TimeOffRequest> findRequestsByState(final TimeOffRequestStatus state) {
|
|
||||||
return timeOffRequestRepository.findByState(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<TimeOffRequest> findRequestsByEmployeeId(final UUID idEmployee) {
|
public List<TimeOffRequest> findRequestsByEmployeeId(final UUID idEmployee) {
|
||||||
return timeOffRequestRepository.findByEmployeeId(idEmployee);
|
return timeOffRequestRepository.findByEmployeeId(idEmployee);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package com.primefactorsolutions.views;
|
package com.primefactorsolutions.views;
|
||||||
|
|
||||||
import com.primefactorsolutions.model.*;
|
import com.primefactorsolutions.model.Employee;
|
||||||
|
import com.primefactorsolutions.model.Team;
|
||||||
import com.primefactorsolutions.service.EmployeeService;
|
import com.primefactorsolutions.service.EmployeeService;
|
||||||
import com.primefactorsolutions.service.ReportService;
|
import com.primefactorsolutions.service.ReportService;
|
||||||
import com.primefactorsolutions.service.TeamService;
|
|
||||||
import com.primefactorsolutions.service.TimeOffRequestService;
|
|
||||||
import com.vaadin.componentfactory.pdfviewer.PdfViewer;
|
import com.vaadin.componentfactory.pdfviewer.PdfViewer;
|
||||||
import com.vaadin.flow.component.ClickEvent;
|
import com.vaadin.flow.component.ClickEvent;
|
||||||
import com.vaadin.flow.component.Component;
|
import com.vaadin.flow.component.Component;
|
||||||
@ -24,6 +23,9 @@ import com.vaadin.flow.component.textfield.EmailField;
|
|||||||
import com.vaadin.flow.component.textfield.TextField;
|
import com.vaadin.flow.component.textfield.TextField;
|
||||||
import com.vaadin.flow.component.upload.Upload;
|
import com.vaadin.flow.component.upload.Upload;
|
||||||
import com.vaadin.flow.component.upload.receivers.MemoryBuffer;
|
import com.vaadin.flow.component.upload.receivers.MemoryBuffer;
|
||||||
|
import com.vaadin.flow.data.binder.Result;
|
||||||
|
import com.vaadin.flow.data.binder.ValueContext;
|
||||||
|
import com.vaadin.flow.data.converter.Converter;
|
||||||
import com.vaadin.flow.data.value.ValueChangeMode;
|
import com.vaadin.flow.data.value.ValueChangeMode;
|
||||||
import com.vaadin.flow.router.*;
|
import com.vaadin.flow.router.*;
|
||||||
import com.vaadin.flow.server.StreamResource;
|
import com.vaadin.flow.server.StreamResource;
|
||||||
@ -36,8 +38,6 @@ import org.vaadin.firitin.form.BeanValidationForm;
|
|||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.temporal.ChronoUnit;
|
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -51,9 +51,6 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
|||||||
|
|
||||||
private final EmployeeService employeeService;
|
private final EmployeeService employeeService;
|
||||||
private final ReportService reportService;
|
private final ReportService reportService;
|
||||||
private final TimeOffRequestService requestService;
|
|
||||||
private final TeamService teamService;
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: campo usado para registrar al empleado en LDAP. Este campo podria estar en otro form eventualmente.
|
// TODO: campo usado para registrar al empleado en LDAP. Este campo podria estar en otro form eventualmente.
|
||||||
private final TextField username = createTextField("Username: ", 30, true);
|
private final TextField username = createTextField("Username: ", 30, true);
|
||||||
@ -74,7 +71,7 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
|||||||
private final EmailField personalEmail = createEmailField("E-mail");
|
private final EmailField personalEmail = createEmailField("E-mail");
|
||||||
private final TextField cod = createTextField("Codigo de Empleado", 30, false);
|
private final TextField cod = createTextField("Codigo de Empleado", 30, false);
|
||||||
private final TextField position = createTextField("Cargo", 30, false);
|
private final TextField position = createTextField("Cargo", 30, false);
|
||||||
private final ComboBox<Team> team = new ComboBox<>("Equipo");
|
private final TextField team = createTextField("Equipo", 30, false);
|
||||||
private final TextField leadManager = createTextField("Lead/Manager", 30, false);
|
private final TextField leadManager = createTextField("Lead/Manager", 30, false);
|
||||||
private final TextField project = createTextField("Proyecto", 30, false);
|
private final TextField project = createTextField("Proyecto", 30, false);
|
||||||
private final TextField emergencyCName = createTextField("Nombres y Apellidos de Contacto", 50, false);
|
private final TextField emergencyCName = createTextField("Nombres y Apellidos de Contacto", 50, false);
|
||||||
@ -142,19 +139,26 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
|||||||
private final H3 datBanc = new H3("Datos Bancados");
|
private final H3 datBanc = new H3("Datos Bancados");
|
||||||
private final H3 datGest = new H3("Datos Gestora Pública y Seguro Social");
|
private final H3 datGest = new H3("Datos Gestora Pública y Seguro Social");
|
||||||
|
|
||||||
public EmployeeView(final EmployeeService employeeService,
|
public EmployeeView(final EmployeeService employeeService, final ReportService reportService) {
|
||||||
final ReportService reportService,
|
|
||||||
final TeamService teamService,
|
|
||||||
final TimeOffRequestService requestService) {
|
|
||||||
super(Employee.class);
|
super(Employee.class);
|
||||||
this.employeeService = employeeService;
|
this.employeeService = employeeService;
|
||||||
this.reportService = reportService;
|
this.reportService = reportService;
|
||||||
this.requestService = requestService;
|
|
||||||
this.teamService = teamService;
|
|
||||||
saveButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
saveButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||||
|
|
||||||
configureComponents();
|
configureComponents();
|
||||||
addClassName("main-layout");
|
addClassName("main-layout");
|
||||||
|
|
||||||
|
getBinder().setConverter("team", new Converter<Object, Object>() {
|
||||||
|
@Override
|
||||||
|
public Result<Object> convertToModel(final Object o, final ValueContext valueContext) {
|
||||||
|
return Result.ok(new Team((String) o));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object convertToPresentation(final Object o, final ValueContext valueContext) {
|
||||||
|
return ((Team) o).getName();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureComponents() {
|
private void configureComponents() {
|
||||||
@ -162,13 +166,6 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
|||||||
phoneNumber.addValueChangeListener(e -> validatePhoneNumber(phoneNumber, e.getValue()));
|
phoneNumber.addValueChangeListener(e -> validatePhoneNumber(phoneNumber, e.getValue()));
|
||||||
emergencyCPhone.setValueChangeMode(ValueChangeMode.EAGER);
|
emergencyCPhone.setValueChangeMode(ValueChangeMode.EAGER);
|
||||||
emergencyCPhone.addValueChangeListener(e -> validatePhoneNumber(emergencyCPhone, e.getValue()));
|
emergencyCPhone.addValueChangeListener(e -> validatePhoneNumber(emergencyCPhone, e.getValue()));
|
||||||
|
|
||||||
firstName.setValueChangeMode(ValueChangeMode.EAGER);
|
|
||||||
firstName.addValueChangeListener(e -> validateNameField(firstName, e.getValue()));
|
|
||||||
lastName.setValueChangeMode(ValueChangeMode.EAGER);
|
|
||||||
lastName.addValueChangeListener(e -> validateNameField(lastName, e.getValue()));
|
|
||||||
createTeamComboBox();
|
|
||||||
|
|
||||||
configureUpload();
|
configureUpload();
|
||||||
saveButton.setVisible(true);
|
saveButton.setVisible(true);
|
||||||
editButton.setVisible(true);
|
editButton.setVisible(true);
|
||||||
@ -186,15 +183,6 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
|||||||
initDialog();
|
initDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateNameField(final TextField textField, final String value) {
|
|
||||||
if (!value.matches("^[a-zA-ZáéíóúÁÉÍÓÚñÑ\\s]*$")) {
|
|
||||||
textField.setInvalid(true);
|
|
||||||
textField.setErrorMessage("Este campo solo debe contener letras.");
|
|
||||||
} else {
|
|
||||||
textField.setInvalid(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void calculateAge() {
|
private void calculateAge() {
|
||||||
if (birthday.getValue() != null) {
|
if (birthday.getValue() != null) {
|
||||||
int currentYear = java.time.LocalDate.now().getYear();
|
int currentYear = java.time.LocalDate.now().getYear();
|
||||||
@ -265,7 +253,7 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
|||||||
ComboBox<Employee.Status> comboBox = new ComboBox<>("Estado");
|
ComboBox<Employee.Status> comboBox = new ComboBox<>("Estado");
|
||||||
comboBox.setItems(Employee.Status.values());
|
comboBox.setItems(Employee.Status.values());
|
||||||
comboBox.setItemLabelGenerator(Employee.Status::name);
|
comboBox.setItemLabelGenerator(Employee.Status::name);
|
||||||
comboBox.setRequiredIndicatorVisible(true);
|
comboBox.setRequiredIndicatorVisible(true); // Indicador de campo requerido
|
||||||
return comboBox;
|
return comboBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,13 +278,6 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
|||||||
return emailField;
|
return emailField;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createTeamComboBox() {
|
|
||||||
List<Team> teams = teamService.findAllTeams();
|
|
||||||
team.setItems(teams);
|
|
||||||
team.setItemLabelGenerator(Team::getName);
|
|
||||||
team.setWidthFull();
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> ComboBox<T> createComboBox(final String label, final T[] items) {
|
private <T> ComboBox<T> createComboBox(final String label, final T[] items) {
|
||||||
ComboBox<T> comboBox = new ComboBox<>(label);
|
ComboBox<T> comboBox = new ComboBox<>(label);
|
||||||
comboBox.setItems(items);
|
comboBox.setItems(items);
|
||||||
@ -317,26 +298,6 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
|||||||
return !firstName.isEmpty() && !lastName.isEmpty() && status.getValue() != null;
|
return !firstName.isEmpty() && !lastName.isEmpty() && status.getValue() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setVacationDuration(
|
|
||||||
final Employee employee,
|
|
||||||
final TimeOffRequest request,
|
|
||||||
final LocalDate referenceDate) {
|
|
||||||
double yearsOfService = ChronoUnit.YEARS.between(employee.getDateOfEntry(), referenceDate);
|
|
||||||
request.setAvailableDays(calculateAvailableDays(yearsOfService));
|
|
||||||
}
|
|
||||||
|
|
||||||
private double calculateAvailableDays(final double yearsOfService) {
|
|
||||||
if (yearsOfService > 10) {
|
|
||||||
return 30.0;
|
|
||||||
} else if (yearsOfService > 5) {
|
|
||||||
return 20.0;
|
|
||||||
} else if (yearsOfService > 1) {
|
|
||||||
return 15.0;
|
|
||||||
} else {
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveEmployee() {
|
private void saveEmployee() {
|
||||||
if (validateForm()) {
|
if (validateForm()) {
|
||||||
Employee employee = getEntity();
|
Employee employee = getEntity();
|
||||||
@ -357,6 +318,7 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
|||||||
editButton.setVisible(false);
|
editButton.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParameter(final BeforeEvent beforeEvent, final String action) {
|
public void setParameter(final BeforeEvent beforeEvent, final String action) {
|
||||||
final RouteParameters params = beforeEvent.getRouteParameters();
|
final RouteParameters params = beforeEvent.getRouteParameters();
|
||||||
@ -538,3 +500,4 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,11 +143,9 @@ public class MainLayout extends AppLayout {
|
|||||||
SideNavItem timeOff = new SideNavItem("My Time-off", TimeoffView.class,
|
SideNavItem timeOff = new SideNavItem("My Time-off", TimeoffView.class,
|
||||||
LineAwesomeIcon.PLANE_DEPARTURE_SOLID.create());
|
LineAwesomeIcon.PLANE_DEPARTURE_SOLID.create());
|
||||||
timeOff.addItem(new SideNavItem("Vacations", RequestsListView.class,
|
timeOff.addItem(new SideNavItem("Vacations", RequestsListView.class,
|
||||||
LineAwesomeIcon.UMBRELLA_BEACH_SOLID.create()));
|
LineAwesomeIcon.SUN.create()));
|
||||||
timeOff.addItem(new SideNavItem("Add Vacation", RequestRegisterView.class,
|
timeOff.addItem(new SideNavItem("Add Vacation", RequestRegisterView.class,
|
||||||
LineAwesomeIcon.CALENDAR_PLUS.create()));
|
LineAwesomeIcon.SUN.create()));
|
||||||
timeOff.addItem(new SideNavItem("Pending Requests", PendingRequestsListView.class,
|
|
||||||
LineAwesomeIcon.LIST_ALT.create()));
|
|
||||||
SideNavItem timesheet = new SideNavItem("My Timesheet", TimesheetView.class,
|
SideNavItem timesheet = new SideNavItem("My Timesheet", TimesheetView.class,
|
||||||
LineAwesomeIcon.HOURGLASS_START_SOLID.create());
|
LineAwesomeIcon.HOURGLASS_START_SOLID.create());
|
||||||
timesheet.addItem(new SideNavItem("Hours Worked", HoursWorkedView.class,
|
timesheet.addItem(new SideNavItem("Hours Worked", HoursWorkedView.class,
|
||||||
|
@ -1,50 +1,16 @@
|
|||||||
package com.primefactorsolutions.views;
|
package com.primefactorsolutions.views;
|
||||||
|
|
||||||
import com.primefactorsolutions.model.TimeOffRequest;
|
|
||||||
import com.primefactorsolutions.model.TimeOffRequestStatus;
|
|
||||||
import com.primefactorsolutions.service.TimeOffRequestService;
|
|
||||||
import com.vaadin.flow.component.Text;
|
import com.vaadin.flow.component.Text;
|
||||||
import com.vaadin.flow.component.html.Main;
|
import com.vaadin.flow.component.html.Main;
|
||||||
import com.vaadin.flow.router.PageTitle;
|
import com.vaadin.flow.router.PageTitle;
|
||||||
import com.vaadin.flow.router.Route;
|
import com.vaadin.flow.router.Route;
|
||||||
import jakarta.annotation.security.PermitAll;
|
import jakarta.annotation.security.PermitAll;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@PageTitle("Home")
|
@PageTitle("Home")
|
||||||
@Route(value = "", layout = MainLayout.class)
|
@Route(value = "", layout = MainLayout.class)
|
||||||
@PermitAll
|
@PermitAll
|
||||||
public class MainView extends Main {
|
public class MainView extends Main {
|
||||||
|
public MainView() {
|
||||||
private final TimeOffRequestService requestService;
|
add(new Text("Welcome to PFS Intra."));
|
||||||
|
|
||||||
public MainView(final TimeOffRequestService requestService) {
|
|
||||||
this.requestService = requestService;
|
|
||||||
add(new Text("Welcome"));
|
|
||||||
updateRequestStatuses();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateRequestStatuses() {
|
|
||||||
List<TimeOffRequest> requests = requestService.findAllTimeOffRequests();
|
|
||||||
LocalDate now = LocalDate.now();
|
|
||||||
|
|
||||||
for (TimeOffRequest request : requests) {
|
|
||||||
if (request.getState() == TimeOffRequestStatus.APROBADO) {
|
|
||||||
LocalDate expirationDate = request.getExpiration();
|
|
||||||
LocalDate startDate = request.getStartDate();
|
|
||||||
LocalDate endDate = request.getEndDate();
|
|
||||||
|
|
||||||
if (now.isAfter(expirationDate)) {
|
|
||||||
request.setState(TimeOffRequestStatus.VENCIDO);
|
|
||||||
} else if (now.isAfter(endDate) && now.isBefore(expirationDate)) {
|
|
||||||
request.setState(TimeOffRequestStatus.TOMADO);
|
|
||||||
} else if (now.isEqual(startDate) || now.isAfter(startDate) && now.isBefore(endDate)) {
|
|
||||||
request.setState(TimeOffRequestStatus.EN_USO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
requestService.saveAll(requests);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,227 +0,0 @@
|
|||||||
package com.primefactorsolutions.views;
|
|
||||||
|
|
||||||
import com.primefactorsolutions.model.*;
|
|
||||||
import com.primefactorsolutions.service.EmployeeService;
|
|
||||||
import com.primefactorsolutions.service.TeamService;
|
|
||||||
import com.primefactorsolutions.service.TimeOffRequestService;
|
|
||||||
import com.vaadin.flow.component.button.Button;
|
|
||||||
import com.vaadin.flow.component.combobox.ComboBox;
|
|
||||||
import com.vaadin.flow.component.html.Main;
|
|
||||||
import com.vaadin.flow.component.notification.Notification;
|
|
||||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
|
||||||
import com.vaadin.flow.router.PageTitle;
|
|
||||||
import com.vaadin.flow.router.Route;
|
|
||||||
import com.vaadin.flow.spring.annotation.SpringComponent;
|
|
||||||
import jakarta.annotation.security.PermitAll;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
|
||||||
import org.vaadin.firitin.components.grid.PagingGrid;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@SpringComponent
|
|
||||||
@Scope("prototype")
|
|
||||||
@PageTitle("PendingRequests")
|
|
||||||
@Route(value = "/pending-requests", layout = MainLayout.class)
|
|
||||||
@PermitAll
|
|
||||||
public class PendingRequestsListView extends Main {
|
|
||||||
|
|
||||||
private final TimeOffRequestService requestService;
|
|
||||||
private final EmployeeService employeeService;
|
|
||||||
private final TeamService teamService;
|
|
||||||
private final PagingGrid<TimeOffRequest> pendingRequestsGrid = new PagingGrid<>();
|
|
||||||
|
|
||||||
private List<Employee> employees = Collections.emptyList();
|
|
||||||
private ComboBox<Employee> employeeFilter;
|
|
||||||
private ComboBox<Team> teamFilter;
|
|
||||||
private ComboBox<TimeOffRequestType> categoryFilter;
|
|
||||||
private UUID selectedRequestId;
|
|
||||||
|
|
||||||
|
|
||||||
public PendingRequestsListView(final TimeOffRequestService requestService,
|
|
||||||
final EmployeeService employeeService,
|
|
||||||
final TeamService teamService) {
|
|
||||||
this.requestService = requestService;
|
|
||||||
this.employeeService = employeeService;
|
|
||||||
this.teamService = teamService;
|
|
||||||
this.employees = employeeService.findAllEmployees();
|
|
||||||
initializeView();
|
|
||||||
refreshGeneralPendingRequestsGrid(null, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initializeView() {
|
|
||||||
setupFilters();
|
|
||||||
setupPendingRequestsGrid();
|
|
||||||
add(pendingRequestsGrid);
|
|
||||||
add(createActionButtons());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupFilters() {
|
|
||||||
add(createEmployeeFilter());
|
|
||||||
add(createTeamFilter());
|
|
||||||
add(createCategoryFilter());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupPendingRequestsGrid() {
|
|
||||||
pendingRequestsGrid.addColumn(this::getEmployeeFullName).setHeader("Empleado");
|
|
||||||
pendingRequestsGrid.addColumn(this::getTeamName).setHeader("Equipo");
|
|
||||||
pendingRequestsGrid.addColumn(this::getCategory).setHeader("Categoría");
|
|
||||||
|
|
||||||
pendingRequestsGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
|
|
||||||
pendingRequestsGrid.setPageSize(5);
|
|
||||||
pendingRequestsGrid.asSingleSelect().addValueChangeListener(event -> {
|
|
||||||
TimeOffRequest selectedRequest = event.getValue();
|
|
||||||
if (selectedRequest != null) {
|
|
||||||
selectedRequestId = selectedRequest.getId();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private HorizontalLayout createActionButtons() {
|
|
||||||
Button approveButton = createActionButton("Aprobar", TimeOffRequestStatus.APROBADO);
|
|
||||||
Button rejectButton = createActionButton("Rechazar", TimeOffRequestStatus.RECHAZADO);
|
|
||||||
Button closeButton = new Button("Salir", event -> navigateToMainView());
|
|
||||||
return new HorizontalLayout(approveButton, rejectButton, closeButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Button createActionButton(final String caption, final TimeOffRequestStatus status) {
|
|
||||||
return new Button(caption, event -> {
|
|
||||||
if (selectedRequestId != null) {
|
|
||||||
TimeOffRequest request = requestService.findTimeOffRequest(selectedRequestId);
|
|
||||||
request.setState(status);
|
|
||||||
requestService.saveTimeOffRequest(request);
|
|
||||||
refreshGeneralPendingRequestsGrid(null, null, null);
|
|
||||||
} else {
|
|
||||||
Notification.show("Seleccione una solicitud.", 3000, Notification.Position.MIDDLE);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refreshGeneralPendingRequestsGrid(final Employee employee,
|
|
||||||
final Team team,
|
|
||||||
final TimeOffRequestType category) {
|
|
||||||
pendingRequestsGrid.setPagingDataProvider((page, pageSize) -> {
|
|
||||||
int start = (int) (page * pendingRequestsGrid.getPageSize());
|
|
||||||
return fetchFilteredPendingRequests(start, pageSize, employee, team, category);
|
|
||||||
});
|
|
||||||
pendingRequestsGrid.getDataProvider().refreshAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<TimeOffRequest> fetchFilteredPendingRequests(final int start,
|
|
||||||
final int pageSize,
|
|
||||||
final Employee employee,
|
|
||||||
final Team team,
|
|
||||||
final TimeOffRequestType category) {
|
|
||||||
List<TimeOffRequest> filteredPendingRequests
|
|
||||||
= requestService.findRequestsByState(TimeOffRequestStatus.PENDIENTE);
|
|
||||||
|
|
||||||
if (employee != null && !"TODOS".equals(employee.getFirstName())) {
|
|
||||||
filteredPendingRequests = filteredPendingRequests.stream()
|
|
||||||
.filter(emp -> emp.getEmployee().getId().equals(employee.getId()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (team != null && !"TODOS".equals(team.getName())) {
|
|
||||||
filteredPendingRequests = filteredPendingRequests.stream()
|
|
||||||
.filter(emp -> emp.getEmployee().getTeam() != null
|
|
||||||
&& emp.getEmployee().getTeam().getId().equals(team.getId()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (category != null && category != TimeOffRequestType.TODOS) {
|
|
||||||
filteredPendingRequests = filteredPendingRequests.stream()
|
|
||||||
.filter(emp -> emp.getCategory().equals(category))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
int end = Math.min(start + pageSize, filteredPendingRequests.size());
|
|
||||||
return filteredPendingRequests.subList(start, end);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getEmployeeFullName(final TimeOffRequest request) {
|
|
||||||
Employee employee = request.getEmployee();
|
|
||||||
return getEmployeeFullNameLabel(employee);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getEmployeeFullNameLabel(final Employee employee) {
|
|
||||||
return "TODOS".equals(employee.getFirstName())
|
|
||||||
? "TODOS" : employee.getFirstName() + " " + employee.getLastName();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getTeamName(final TimeOffRequest request) {
|
|
||||||
Team team = request.getEmployee().getTeam();
|
|
||||||
return team != null ? team.getName() : "Sin asignar";
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getTeamLabel(final Team team) {
|
|
||||||
return "TODOS".equals(team.getName()) ? "TODOS" : team.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getCategory(final TimeOffRequest request) {
|
|
||||||
return String.valueOf(request.getCategory());
|
|
||||||
}
|
|
||||||
|
|
||||||
private ComboBox<Employee> createEmployeeFilter() {
|
|
||||||
employeeFilter = new ComboBox<>("Empleado");
|
|
||||||
List<Employee> employees = new ArrayList<>(employeeService.findAllEmployees());
|
|
||||||
employees.addFirst(createAllEmployeesOption());
|
|
||||||
employeeFilter.setItems(employees);
|
|
||||||
employeeFilter.setItemLabelGenerator(this::getEmployeeFullNameLabel);
|
|
||||||
employeeFilter.setValue(employees.getFirst());
|
|
||||||
employeeFilter.addValueChangeListener(event ->
|
|
||||||
refreshGeneralPendingRequestsGrid(
|
|
||||||
event.getValue(),
|
|
||||||
teamFilter.getValue(),
|
|
||||||
categoryFilter.getValue()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return employeeFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ComboBox<Team> createTeamFilter() {
|
|
||||||
teamFilter = new ComboBox<>("Equipo");
|
|
||||||
List<Team> teams = new ArrayList<>(teamService.findAllTeams());
|
|
||||||
teams.addFirst(createAllTeamsOption());
|
|
||||||
teamFilter.setItems(teams);
|
|
||||||
teamFilter.setItemLabelGenerator(this::getTeamLabel);
|
|
||||||
teamFilter.setValue(teams.getFirst());
|
|
||||||
teamFilter.addValueChangeListener(event ->
|
|
||||||
refreshGeneralPendingRequestsGrid(
|
|
||||||
employeeFilter.getValue(),
|
|
||||||
event.getValue(),
|
|
||||||
categoryFilter.getValue()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return teamFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ComboBox<TimeOffRequestType> createCategoryFilter() {
|
|
||||||
categoryFilter = new ComboBox<>("Categoría");
|
|
||||||
categoryFilter.setItems(TimeOffRequestType.values());
|
|
||||||
categoryFilter.setValue(TimeOffRequestType.values()[0]);
|
|
||||||
categoryFilter.addValueChangeListener(event ->
|
|
||||||
refreshGeneralPendingRequestsGrid(
|
|
||||||
employeeFilter.getValue(),
|
|
||||||
teamFilter.getValue(),
|
|
||||||
event.getValue()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return categoryFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Employee createAllEmployeesOption() {
|
|
||||||
Employee allEmployeesOption = new Employee();
|
|
||||||
allEmployeesOption.setFirstName("TODOS");
|
|
||||||
return allEmployeesOption;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Team createAllTeamsOption() {
|
|
||||||
Team allTeamsOption = new Team();
|
|
||||||
allTeamsOption.setName("TODOS");
|
|
||||||
return allTeamsOption;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void navigateToMainView() {
|
|
||||||
getUI().ifPresent(ui -> ui.navigate(MainView.class));
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,6 +6,7 @@ import com.primefactorsolutions.service.TimeOffRequestService;
|
|||||||
import com.primefactorsolutions.service.VacationService;
|
import com.primefactorsolutions.service.VacationService;
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.button.Button;
|
||||||
import com.vaadin.flow.component.combobox.ComboBox;
|
import com.vaadin.flow.component.combobox.ComboBox;
|
||||||
|
import com.vaadin.flow.component.grid.Grid;
|
||||||
import com.vaadin.flow.component.html.Div;
|
import com.vaadin.flow.component.html.Div;
|
||||||
import com.vaadin.flow.component.html.H3;
|
import com.vaadin.flow.component.html.H3;
|
||||||
import com.vaadin.flow.component.html.Span;
|
import com.vaadin.flow.component.html.Span;
|
||||||
@ -19,10 +20,8 @@ import com.vaadin.flow.router.Route;
|
|||||||
import com.vaadin.flow.spring.annotation.SpringComponent;
|
import com.vaadin.flow.spring.annotation.SpringComponent;
|
||||||
import jakarta.annotation.security.PermitAll;
|
import jakarta.annotation.security.PermitAll;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.vaadin.firitin.components.grid.PagingGrid;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.Period;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -38,7 +37,7 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
|||||||
private final TimeOffRequestService requestService;
|
private final TimeOffRequestService requestService;
|
||||||
private final EmployeeService employeeService;
|
private final EmployeeService employeeService;
|
||||||
private final VacationService vacationService;
|
private final VacationService vacationService;
|
||||||
private final PagingGrid<TimeOffRequest> requestGrid = new PagingGrid<>(TimeOffRequest.class);
|
private final Grid<TimeOffRequest> requestGrid = new Grid<>(TimeOffRequest.class);
|
||||||
private List<TimeOffRequest> requests = Collections.emptyList();
|
private List<TimeOffRequest> requests = Collections.emptyList();
|
||||||
private ComboBox<TimeOffRequestType> categoryFilter;
|
private ComboBox<TimeOffRequestType> categoryFilter;
|
||||||
private ComboBox<TimeOffRequestStatus> stateFilter;
|
private ComboBox<TimeOffRequestStatus> stateFilter;
|
||||||
@ -67,7 +66,7 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ComboBox<TimeOffRequestType> createCategoryFilter() {
|
private ComboBox<TimeOffRequestType> createCategoryFilter() {
|
||||||
categoryFilter = new ComboBox<>("Categoría");
|
categoryFilter = new ComboBox<>("Category");
|
||||||
categoryFilter.setItems(TimeOffRequestType.values());
|
categoryFilter.setItems(TimeOffRequestType.values());
|
||||||
categoryFilter.setValue(TimeOffRequestType.values()[0]);
|
categoryFilter.setValue(TimeOffRequestType.values()[0]);
|
||||||
categoryFilter.addValueChangeListener(event -> refreshRequestGrid(event.getValue(), stateFilter.getValue()));
|
categoryFilter.addValueChangeListener(event -> refreshRequestGrid(event.getValue(), stateFilter.getValue()));
|
||||||
@ -75,7 +74,7 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ComboBox<TimeOffRequestStatus> createStateFilter() {
|
private ComboBox<TimeOffRequestStatus> createStateFilter() {
|
||||||
stateFilter = new ComboBox<>("Estado de la solicitud");
|
stateFilter = new ComboBox<>("State");
|
||||||
stateFilter.setItems(TimeOffRequestStatus.values());
|
stateFilter.setItems(TimeOffRequestStatus.values());
|
||||||
stateFilter.setValue(TimeOffRequestStatus.values()[0]);
|
stateFilter.setValue(TimeOffRequestStatus.values()[0]);
|
||||||
stateFilter.addValueChangeListener(event -> refreshRequestGrid(categoryFilter.getValue(), event.getValue()));
|
stateFilter.addValueChangeListener(event -> refreshRequestGrid(categoryFilter.getValue(), event.getValue()));
|
||||||
@ -88,16 +87,10 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
|||||||
"state",
|
"state",
|
||||||
"startDate",
|
"startDate",
|
||||||
"endDate",
|
"endDate",
|
||||||
"daysToBeTake");
|
"daysToBeTake",
|
||||||
|
"daysBalance"
|
||||||
requestGrid.getColumnByKey("category").setHeader("Categoría");
|
);
|
||||||
requestGrid.getColumnByKey("state").setHeader("Estado");
|
requestGrid.setAllRowsVisible(true);
|
||||||
requestGrid.getColumnByKey("startDate").setHeader("Fecha de Inicio");
|
|
||||||
requestGrid.getColumnByKey("endDate").setHeader("Fecha de Fin");
|
|
||||||
requestGrid.getColumnByKey("daysToBeTake").setHeader("Días a Tomar");
|
|
||||||
|
|
||||||
requestGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
|
|
||||||
requestGrid.setPageSize(5);
|
|
||||||
requestGrid.asSingleSelect().addValueChangeListener(event -> {
|
requestGrid.asSingleSelect().addValueChangeListener(event -> {
|
||||||
TimeOffRequest selectedRequest = event.getValue();
|
TimeOffRequest selectedRequest = event.getValue();
|
||||||
if (selectedRequest != null) {
|
if (selectedRequest != null) {
|
||||||
@ -111,101 +104,46 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
|||||||
.filter(this::verificationIsHoliday)
|
.filter(this::verificationIsHoliday)
|
||||||
.mapToDouble(TimeOffRequest::getAvailableDays)
|
.mapToDouble(TimeOffRequest::getAvailableDays)
|
||||||
.sum();
|
.sum();
|
||||||
double totalVacations = calculateVacationDays(employeeService.getEmployee(employeeId));
|
double totalVacations = requests.stream()
|
||||||
double totalPersonalDays = requests.stream()
|
.filter(req -> req.getCategory().toString().startsWith("VACATION"))
|
||||||
.filter(req -> !verificationIsHoliday(req))
|
.mapToDouble(TimeOffRequest::getAvailableDays)
|
||||||
.filter(req -> !req.getCategory().name().startsWith("VACACION"))
|
.sum();
|
||||||
|
double totalPersonalDays = requests.stream()
|
||||||
|
.filter(req -> !verificationIsHoliday(req)) // Solo los de tipo OTHER
|
||||||
.mapToDouble(TimeOffRequest::getAvailableDays)
|
.mapToDouble(TimeOffRequest::getAvailableDays)
|
||||||
.sum();
|
.sum();
|
||||||
|
|
||||||
double totalAvailableDays = totalHoliday + totalVacations + totalPersonalDays;
|
double totalAvailableDays = totalHoliday + totalVacations + totalPersonalDays;
|
||||||
|
|
||||||
return new VerticalLayout(
|
return new VerticalLayout(
|
||||||
new Span("Total feriados: " + totalHoliday),
|
new Span("TOTAL HOLIDAYS: " + totalHoliday),
|
||||||
new Span("Total vacaciones: " + totalVacations),
|
new Span("TOTAL VACATIONS: " + totalVacations),
|
||||||
new Span("Total días personales: " + totalPersonalDays),
|
new Span("TOTAL PERSONAL DAYS: " + totalPersonalDays),
|
||||||
new Span("Total general: " + totalAvailableDays)
|
new Span("TOTAL GENERAL: " + totalAvailableDays)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double calculateVacationDays(final Employee employee) {
|
|
||||||
if (employee.getDateOfEntry() != null) {
|
|
||||||
LocalDate entryDate = employee.getDateOfEntry();
|
|
||||||
LocalDate today = LocalDate.now();
|
|
||||||
|
|
||||||
boolean hasAnniversaryPassed = entryDate.getMonthValue() < today.getMonthValue()
|
|
||||||
|| (entryDate.getMonthValue() == today.getMonthValue() && entryDate.getDayOfMonth()
|
|
||||||
<= today.getDayOfMonth());
|
|
||||||
|
|
||||||
LocalDate previousVacationYearDate;
|
|
||||||
LocalDate currentVacationYearDate;
|
|
||||||
|
|
||||||
if (hasAnniversaryPassed) {
|
|
||||||
previousVacationYearDate = LocalDate.of(
|
|
||||||
today.getYear() - 1,
|
|
||||||
entryDate.getMonth(),
|
|
||||||
entryDate.getDayOfMonth()
|
|
||||||
);
|
|
||||||
currentVacationYearDate = LocalDate.of(
|
|
||||||
today.getYear(),
|
|
||||||
entryDate.getMonth(),
|
|
||||||
entryDate.getDayOfMonth()
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
previousVacationYearDate = LocalDate.of(
|
|
||||||
today.getYear() - 2,
|
|
||||||
entryDate.getMonth(),
|
|
||||||
entryDate.getDayOfMonth()
|
|
||||||
);
|
|
||||||
currentVacationYearDate = LocalDate.of(
|
|
||||||
today.getYear() - 1,
|
|
||||||
entryDate.getMonth(),
|
|
||||||
entryDate.getDayOfMonth()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return calculateVacationDaysSinceEntry(entryDate, previousVacationYearDate)
|
|
||||||
+ calculateVacationDaysSinceEntry(entryDate, currentVacationYearDate);
|
|
||||||
} else {
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private double calculateVacationDaysSinceEntry(final LocalDate dateOfEntry, final LocalDate date) {
|
|
||||||
int yearsOfService = dateOfEntry != null ? Period.between(dateOfEntry, date).getYears() : 0;
|
|
||||||
if (yearsOfService > 10) {
|
|
||||||
return 30;
|
|
||||||
}
|
|
||||||
if (yearsOfService > 5) {
|
|
||||||
return 20;
|
|
||||||
}
|
|
||||||
if (yearsOfService > 1) {
|
|
||||||
return 15;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Boolean verificationIsHoliday(final TimeOffRequest request) {
|
private Boolean verificationIsHoliday(final TimeOffRequest request) {
|
||||||
Vacation vacation = vacationService.findVacationByCategory(request.getCategory());
|
Vacation vacation = vacationService.findVacationByCategory(request.getCategory());
|
||||||
return vacation.getType() != Vacation.Type.OTHER;
|
return vacation.getType() != Vacation.Type.OTHER;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HorizontalLayout createActionButtons() {
|
private HorizontalLayout createActionButtons() {
|
||||||
Button viewButton = createButton("Ver", () -> navigateToViewRequest(request));
|
Button viewButton = new Button("View", event -> {
|
||||||
Button editButton = createButton("Editar", () -> navigateToEditRequest(request));
|
|
||||||
Button closeButton = new Button("Salir", event -> navigateToRequestsListView());
|
|
||||||
|
|
||||||
return new HorizontalLayout(viewButton, editButton, closeButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Button createButton(final String caption, final Runnable action) {
|
|
||||||
return new Button(caption, event -> {
|
|
||||||
if (request != null) {
|
if (request != null) {
|
||||||
action.run();
|
navigateToViewRequest(request);
|
||||||
} else {
|
} else {
|
||||||
Notification.show("Seleccione una solicitud.", 3000, Notification.Position.MIDDLE);
|
Notification.show("Please select a request to view.", 3000, Notification.Position.MIDDLE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Button editButton = new Button("Edit", event -> {
|
||||||
|
if (request != null) {
|
||||||
|
navigateToEditRequest(request);
|
||||||
|
} else {
|
||||||
|
Notification.show("Please select a request to view.", 3000, Notification.Position.MIDDLE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Button closeButton = new Button("Close", event -> navigateToRequestsListView());
|
||||||
|
return new HorizontalLayout(viewButton, editButton, closeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void navigateToRequestsListView() {
|
private void navigateToRequestsListView() {
|
||||||
@ -225,30 +163,38 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void refreshRequestGrid(final TimeOffRequestType category, final TimeOffRequestStatus state) {
|
private void refreshRequestGrid(final TimeOffRequestType category, final TimeOffRequestStatus state) {
|
||||||
requestGrid.setPagingDataProvider((page, pageSize) -> {
|
List<TimeOffRequest> filteredRequests = allFiltersAreNull(category, state)
|
||||||
int start = (int) (page * requestGrid.getPageSize());
|
? requestService.findRequestsByEmployeeId(employeeId)
|
||||||
return fetchFilteredTimeOffRequests(start, pageSize, category, state);
|
: fetchFilteredTimeOffRequests(category, state);
|
||||||
});
|
for (TimeOffRequest request : filteredRequests) {
|
||||||
requestGrid.getDataProvider().refreshAll();
|
if (request.getExpiration().isBefore(LocalDate.now())) {
|
||||||
|
request.setState(TimeOffRequestStatus.EXPIRED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (TimeOffRequest request : filteredRequests) {
|
||||||
|
requestService.saveTimeOffRequest(request);
|
||||||
|
}
|
||||||
|
requestGrid.setItems(filteredRequests);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<TimeOffRequest> fetchFilteredTimeOffRequests(final int start,
|
private boolean allFiltersAreNull(final TimeOffRequestType category, final TimeOffRequestStatus state) {
|
||||||
final int pageSize,
|
return category == null && state == null;
|
||||||
final TimeOffRequestType category,
|
}
|
||||||
|
|
||||||
|
private List<TimeOffRequest> fetchFilteredTimeOffRequests(final TimeOffRequestType category,
|
||||||
final TimeOffRequestStatus state) {
|
final TimeOffRequestStatus state) {
|
||||||
requests = requestService.findRequestsByEmployeeId(employeeId);
|
requests = requestService.findRequestsByEmployeeId(employeeId);
|
||||||
if (category != null && !"TODOS".equals(category.name())) {
|
if (category != null && !"ALL".equals(category.name())) {
|
||||||
requests = requests.stream()
|
requests = requests.stream()
|
||||||
.filter(req -> req.getCategory().equals(category))
|
.filter(req -> req.getCategory().equals(category))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
if (state != null && !"TODOS".equals(state.name())) {
|
if (state != null && !"ALL".equals(state.name())) {
|
||||||
requests = requests.stream()
|
requests = requests.stream()
|
||||||
.filter(req -> req.getState().equals(state))
|
.filter(req -> req.getState().equals(state))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
int end = Math.min(start + pageSize, requests.size());
|
return requests;
|
||||||
return requests.subList(start, end);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -262,7 +208,7 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setViewTitle(final String employeeName, final String employeeTeam) {
|
private void setViewTitle(final String employeeName, final String employeeTeam) {
|
||||||
addComponentAsFirst(new H3("Nombre del empleado: " + employeeName));
|
addComponentAsFirst(new H3("Name: " + employeeName));
|
||||||
addComponentAtIndex(1, new H3("Equipo: " + employeeTeam));
|
addComponentAtIndex(1, new H3("Team: " + employeeTeam));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,13 +32,13 @@ import java.util.UUID;
|
|||||||
@Route(value = "/requests/new", layout = MainLayout.class)
|
@Route(value = "/requests/new", layout = MainLayout.class)
|
||||||
public class RequestRegisterView extends VerticalLayout {
|
public class RequestRegisterView extends VerticalLayout {
|
||||||
|
|
||||||
private final ComboBox<Employee> employeeComboBox = new ComboBox<>("Empleado");
|
private final ComboBox<Employee> employeeComboBox = new ComboBox<>("Employee");
|
||||||
private final ComboBox<TimeOffRequestType> categoryComboBox = new ComboBox<>("Categoría");
|
private final ComboBox<TimeOffRequestType> categoryComboBox = new ComboBox<>("Category");
|
||||||
private final NumberField availableDaysField = new NumberField("Días disponibles");
|
private final NumberField availableDaysField = new NumberField("Available Days");
|
||||||
private final DatePicker startDatePicker = new DatePicker("Fecha de inicio");
|
private final DatePicker startDatePicker = new DatePicker("Start Date");
|
||||||
private final DatePicker endDatePicker = new DatePicker("Fecha final");
|
private final DatePicker endDatePicker = new DatePicker("End Date");
|
||||||
private final NumberField daysToBeTakenField = new NumberField("Días a tomar");
|
private final NumberField daysToBeTakenField = new NumberField("Days To Be Taken");
|
||||||
private final NumberField balanceDaysField = new NumberField("Días de saldo");
|
private final NumberField balanceDaysField = new NumberField("Balance Days");
|
||||||
|
|
||||||
private final TimeOffRequestService requestService;
|
private final TimeOffRequestService requestService;
|
||||||
private final EmployeeService employeeService;
|
private final EmployeeService employeeService;
|
||||||
@ -59,24 +59,11 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
this.employeeService = employeeService;
|
this.employeeService = employeeService;
|
||||||
this.vacationService = vacationService;
|
this.vacationService = vacationService;
|
||||||
this.binder = new Binder<>(TimeOffRequest.class);
|
this.binder = new Binder<>(TimeOffRequest.class);
|
||||||
initializeView();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initializeView() {
|
|
||||||
configureFormFields();
|
configureFormFields();
|
||||||
configureButtons();
|
configureButtons();
|
||||||
configureBinder();
|
configureBinder();
|
||||||
setupFormLayout();
|
setupFormLayout();
|
||||||
configureInitialFieldStates();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void configureInitialFieldStates() {
|
|
||||||
categoryComboBox.setEnabled(false);
|
|
||||||
startDatePicker.setEnabled(false);
|
|
||||||
endDatePicker.setEnabled(false);
|
|
||||||
availableDaysField.setReadOnly(true);
|
|
||||||
daysToBeTakenField.setReadOnly(true);
|
|
||||||
balanceDaysField.setReadOnly(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureFormFields() {
|
private void configureFormFields() {
|
||||||
@ -84,75 +71,66 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
employeeComboBox.setItemLabelGenerator(emp -> emp.getFirstName() + " " + emp.getLastName());
|
employeeComboBox.setItemLabelGenerator(emp -> emp.getFirstName() + " " + emp.getLastName());
|
||||||
employeeComboBox.addValueChangeListener(event -> {
|
employeeComboBox.addValueChangeListener(event -> {
|
||||||
employee = event.getValue();
|
employee = event.getValue();
|
||||||
System.out.println("Clearing form..." + employee);
|
handleEmployeeSelection(employee);
|
||||||
|
|
||||||
handleEmployeeSelection(event.getValue());
|
|
||||||
});
|
|
||||||
categoryComboBox.addValueChangeListener(event -> {
|
|
||||||
onCategoryChange(event.getValue());
|
|
||||||
handleCategorySelection(event.getValue());
|
|
||||||
});
|
});
|
||||||
|
categoryComboBox.setEnabled(false);
|
||||||
|
startDatePicker.setEnabled(false);
|
||||||
|
endDatePicker.setEnabled(false);
|
||||||
|
categoryComboBox.addValueChangeListener(event -> handleCategorySelection(event.getValue()));
|
||||||
startDatePicker.addValueChangeListener(event -> updateDatePickerMinValues());
|
startDatePicker.addValueChangeListener(event -> updateDatePickerMinValues());
|
||||||
endDatePicker.addValueChangeListener(event -> calculateDays());
|
endDatePicker.addValueChangeListener(event -> calculateDays());
|
||||||
|
availableDaysField.setReadOnly(true);
|
||||||
|
daysToBeTakenField.setReadOnly(true);
|
||||||
|
balanceDaysField.setReadOnly(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureBinder() {
|
private void configureBinder() {
|
||||||
binder.forField(employeeComboBox)
|
binder.forField(employeeComboBox)
|
||||||
|
.asRequired("Employee is required")
|
||||||
.bind(TimeOffRequest::getEmployee, TimeOffRequest::setEmployee);
|
.bind(TimeOffRequest::getEmployee, TimeOffRequest::setEmployee);
|
||||||
|
|
||||||
binder.forField(categoryComboBox)
|
binder.forField(categoryComboBox)
|
||||||
|
.asRequired("Category is required")
|
||||||
.bind(TimeOffRequest::getCategory, TimeOffRequest::setCategory);
|
.bind(TimeOffRequest::getCategory, TimeOffRequest::setCategory);
|
||||||
|
|
||||||
binder.forField(availableDaysField)
|
binder.forField(availableDaysField)
|
||||||
.bind(TimeOffRequest::getAvailableDays, TimeOffRequest::setAvailableDays);
|
.bind(TimeOffRequest::getAvailableDays, TimeOffRequest::setAvailableDays);
|
||||||
|
|
||||||
binder.forField(startDatePicker)
|
binder.forField(startDatePicker)
|
||||||
|
.asRequired("Start date is required")
|
||||||
.bind(TimeOffRequest::getStartDate, TimeOffRequest::setStartDate);
|
.bind(TimeOffRequest::getStartDate, TimeOffRequest::setStartDate);
|
||||||
|
|
||||||
binder.forField(endDatePicker)
|
binder.forField(endDatePicker)
|
||||||
|
.asRequired("End date is required")
|
||||||
.bind(TimeOffRequest::getEndDate, TimeOffRequest::setEndDate);
|
.bind(TimeOffRequest::getEndDate, TimeOffRequest::setEndDate);
|
||||||
|
|
||||||
binder.forField(daysToBeTakenField)
|
binder.forField(daysToBeTakenField)
|
||||||
.bind(TimeOffRequest::getDaysToBeTake, TimeOffRequest::setDaysToBeTake);
|
.bind(TimeOffRequest::getDaysToBeTake, TimeOffRequest::setDaysToBeTake);
|
||||||
|
|
||||||
binder.forField(balanceDaysField)
|
binder.forField(balanceDaysField)
|
||||||
.bind(TimeOffRequest::getDaysBalance, TimeOffRequest::setDaysBalance);
|
.bind(TimeOffRequest::getDaysBalance, TimeOffRequest::setDaysBalance);
|
||||||
|
|
||||||
binder.setBean(new TimeOffRequest());
|
binder.setBean(new TimeOffRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleEmployeeSelection(final Employee selectedEmployee) {
|
private void handleEmployeeSelection(final Employee selectedEmployee) {
|
||||||
|
clearForm();
|
||||||
if (selectedEmployee != null) {
|
if (selectedEmployee != null) {
|
||||||
categoryComboBox.clear();
|
|
||||||
availableDaysField.clear();
|
|
||||||
startDatePicker.clear();
|
|
||||||
endDatePicker.clear();
|
|
||||||
daysToBeTakenField.clear();
|
|
||||||
balanceDaysField.clear();
|
|
||||||
categoryComboBox.setEnabled(true);
|
categoryComboBox.setEnabled(true);
|
||||||
startDatePicker.setEnabled(false);
|
|
||||||
endDatePicker.setEnabled(false);
|
|
||||||
filterCategories(selectedEmployee);
|
filterCategories(selectedEmployee);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void filterCategories(final Employee employee) {
|
private void filterCategories(final Employee employee) {
|
||||||
categoryComboBox.clear();
|
|
||||||
List<TimeOffRequest> employeeRequests = requestService.findRequestsByEmployeeId(employee.getId());
|
List<TimeOffRequest> employeeRequests = requestService.findRequestsByEmployeeId(employee.getId());
|
||||||
List<TimeOffRequestType> allCategories = Arrays.asList(TimeOffRequestType.values());
|
List<TimeOffRequestType> allCategories = Arrays.asList(TimeOffRequestType.values());
|
||||||
List<TimeOffRequestType> availableCategories = allCategories.stream()
|
List<TimeOffRequestType> availableCategories = allCategories.stream()
|
||||||
.filter(category -> isCategoryAvailable(employeeRequests, category))
|
.filter(category -> isCategoryAvailable(employeeRequests, category))
|
||||||
.filter(category -> isCategoryAllowedByGender(category, employee.getGender()))
|
.filter(category -> isCategoryAllowedByGender(category, employee.getGender()))
|
||||||
.filter(category -> category != TimeOffRequestType.VACACION_GESTION_ANTERIOR
|
|
||||||
&& category != TimeOffRequestType.TODOS)
|
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
categoryComboBox.setItems(availableCategories);
|
categoryComboBox.setItems(availableCategories);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onCategoryChange(final TimeOffRequestType selectedCategory) {
|
|
||||||
if (selectedCategory == TimeOffRequestType.VACACION_GESTION_ACTUAL) {
|
|
||||||
startDatePicker.setEnabled(true);
|
|
||||||
endDatePicker.setEnabled(true);
|
|
||||||
} else {
|
|
||||||
startDatePicker.setEnabled(true);
|
|
||||||
endDatePicker.setEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isCategoryAvailable(final List<TimeOffRequest> employeeRequests,
|
private boolean isCategoryAvailable(final List<TimeOffRequest> employeeRequests,
|
||||||
final TimeOffRequestType category) {
|
final TimeOffRequestType category) {
|
||||||
List<TimeOffRequest> requestsByCategory = employeeRequests.stream()
|
List<TimeOffRequest> requestsByCategory = employeeRequests.stream()
|
||||||
@ -167,31 +145,32 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
.max(Comparator.comparing(TimeOffRequest::getStartDate))
|
.max(Comparator.comparing(TimeOffRequest::getStartDate))
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
||||||
if (category == TimeOffRequestType.PERMISOS_DE_SALUD
|
if (category == TimeOffRequestType.HEALTH_PERMIT
|
||||||
|| category == TimeOffRequestType.VACACION_GESTION_ACTUAL
|
|| category == TimeOffRequestType.VACATION_CURRENT_MANAGEMENT
|
||||||
|| category == TimeOffRequestType.VACACION_GESTION_ANTERIOR) {
|
|| category == TimeOffRequestType.VACATION_PREVIOUS_MANAGEMENT) {
|
||||||
return latestRequest.getState() == TimeOffRequestStatus.VENCIDO
|
return latestRequest.getState() == TimeOffRequestStatus.EXPIRED
|
||||||
|| (latestRequest.getState() == TimeOffRequestStatus.TOMADO && latestRequest.getDaysBalance() > 0);
|
|| (latestRequest.getState() == TimeOffRequestStatus.TAKEN && latestRequest.getDaysBalance() > 0);
|
||||||
} else {
|
} else {
|
||||||
return latestRequest.getState() == TimeOffRequestStatus.VENCIDO;
|
return latestRequest.getState() == TimeOffRequestStatus.EXPIRED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCategoryAllowedByGender(final TimeOffRequestType category, final Employee.Gender gender) {
|
private boolean isCategoryAllowedByGender(final TimeOffRequestType category, final Employee.Gender gender) {
|
||||||
if (gender == Employee.Gender.MALE) {
|
if (gender == Employee.Gender.MALE) {
|
||||||
return category != TimeOffRequestType.MATERNIDAD
|
return category != TimeOffRequestType.MATERNITY
|
||||||
&& category != TimeOffRequestType.DIA_DE_LA_MADRE
|
&& category != TimeOffRequestType.MOTHERS_DAY
|
||||||
&& category != TimeOffRequestType.DIA_DE_LA_MUJER_INTERNACIONAL
|
&& category != TimeOffRequestType.INTERNATIONAL_WOMENS_DAY
|
||||||
&& category != TimeOffRequestType.DIA_DE_LA_MUJER_NACIONAL;
|
&& category != TimeOffRequestType.NATIONAL_WOMENS_DAY;
|
||||||
} else {
|
} else {
|
||||||
return category != TimeOffRequestType.DIA_DEL_PADRE
|
return category != TimeOffRequestType.FATHERS_DAY
|
||||||
&& category != TimeOffRequestType.PATERNIDAD;
|
&& category != TimeOffRequestType.PATERNITY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleCategorySelection(final TimeOffRequestType selectedCategory) {
|
private void handleCategorySelection(final TimeOffRequestType selectedCategory) {
|
||||||
if (selectedCategory != null) {
|
if (selectedCategory != null) {
|
||||||
updateAvailableDays(selectedCategory);
|
updateAvailableDays(selectedCategory);
|
||||||
|
startDatePicker.setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,16 +181,16 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
if (vacation != null) {
|
if (vacation != null) {
|
||||||
TimeOffRequest requestWithBalance = requests.stream()
|
TimeOffRequest requestWithBalance = requests.stream()
|
||||||
.filter(request -> request.getDaysBalance() > 0
|
.filter(request -> request.getDaysBalance() > 0
|
||||||
&& request.getState() != TimeOffRequestStatus.VENCIDO)
|
&& request.getState() != TimeOffRequestStatus.EXPIRED)
|
||||||
.max(Comparator.comparing(TimeOffRequest::getStartDate))
|
.max(Comparator.comparing(TimeOffRequest::getStartDate))
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
if (requestWithBalance != null) {
|
if (requestWithBalance != null) {
|
||||||
if (requestWithBalance.getState() == TimeOffRequestStatus.TOMADO) {
|
if (requestWithBalance.getState() == TimeOffRequestStatus.TAKEN) {
|
||||||
availableDaysField.setValue(requestWithBalance.getDaysBalance());
|
availableDaysField.setValue(requestWithBalance.getDaysBalance());
|
||||||
} else if (requestWithBalance.getState() == TimeOffRequestStatus.VENCIDO) {
|
} else if (requestWithBalance.getState() == TimeOffRequestStatus.EXPIRED) {
|
||||||
availableDaysField.setValue(vacation.getDuration());
|
availableDaysField.setValue(vacation.getDuration());
|
||||||
}
|
}
|
||||||
} else if (vacation.getCategory() == TimeOffRequestType.VACACION_GESTION_ACTUAL) {
|
} else if (vacation.getCategory() == TimeOffRequestType.VACATION_CURRENT_MANAGEMENT) {
|
||||||
LocalDate dateOfEntry = employeeComboBox.getValue().getDateOfEntry();
|
LocalDate dateOfEntry = employeeComboBox.getValue().getDateOfEntry();
|
||||||
LocalDate currentDate = LocalDate.now();
|
LocalDate currentDate = LocalDate.now();
|
||||||
long yearsOfService = ChronoUnit.YEARS.between(dateOfEntry, currentDate);
|
long yearsOfService = ChronoUnit.YEARS.between(dateOfEntry, currentDate);
|
||||||
@ -239,137 +218,97 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
List<TimeOffRequest> previousRequests
|
List<TimeOffRequest> previousRequests
|
||||||
= requestService.findByEmployeeAndCategory(employeeId, vacation.getCategory());
|
= requestService.findByEmployeeAndCategory(employeeId, vacation.getCategory());
|
||||||
|
|
||||||
int startYear = calculateStartYear(previousRequests);
|
int startYear;
|
||||||
|
|
||||||
startDate = determineStartDate(vacation, startYear);
|
|
||||||
|
|
||||||
if (startDate.isBefore(LocalDate.now())) {
|
|
||||||
startDate = determineStartDate(vacation, startYear + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (startDate != null) {
|
|
||||||
endDate = startDate.plusDays(vacation.getExpiration().intValue() - 1);
|
|
||||||
} else {
|
|
||||||
startDate = LocalDate.now();
|
|
||||||
}
|
|
||||||
|
|
||||||
setPickerValues(vacation, startDate);
|
|
||||||
setPickerLimits(startDate, endDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int calculateStartYear(final List<TimeOffRequest> previousRequests) {
|
|
||||||
if (previousRequests.isEmpty()) {
|
if (previousRequests.isEmpty()) {
|
||||||
return LocalDate.now().getYear();
|
startYear = LocalDate.now().getYear();
|
||||||
}
|
} else {
|
||||||
|
|
||||||
int lastRequestYear = previousRequests.stream()
|
int lastRequestYear = previousRequests.stream()
|
||||||
.max(Comparator.comparing(TimeOffRequest::getStartDate))
|
.max(Comparator.comparing(TimeOffRequest::getStartDate))
|
||||||
.map(request -> request.getStartDate().getYear())
|
.map(request -> request.getStartDate().getYear())
|
||||||
.orElse(LocalDate.now().getYear());
|
.orElse(LocalDate.now().getYear());
|
||||||
|
|
||||||
|
int proposedYear = lastRequestYear + 1;
|
||||||
int currentYear = LocalDate.now().getYear();
|
int currentYear = LocalDate.now().getYear();
|
||||||
return Math.max(lastRequestYear + 1, currentYear);
|
|
||||||
|
if (proposedYear < currentYear) {
|
||||||
|
startYear = currentYear;
|
||||||
|
} else {
|
||||||
|
startYear = proposedYear;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private LocalDate determineStartDate(final Vacation vacation, final int startYear) {
|
|
||||||
if (vacation.getMonthOfYear() != null && vacation.getDayOfMonth() != null) {
|
if (vacation.getMonthOfYear() != null && vacation.getDayOfMonth() != null) {
|
||||||
return LocalDate.of(startYear, vacation.getMonthOfYear().intValue(), vacation.getDayOfMonth().intValue());
|
startDate = LocalDate.of(
|
||||||
|
startYear,
|
||||||
|
vacation.getMonthOfYear().intValue(),
|
||||||
|
vacation.getDayOfMonth().intValue());
|
||||||
|
endDate = startDate.plusDays(vacation.getExpiration().intValue() - 1);
|
||||||
|
} else {
|
||||||
|
if (vacation.getCategory() == TimeOffRequestType.BIRTHDAY && employee.getBirthday() != null) {
|
||||||
|
startDate = LocalDate.of(
|
||||||
|
startYear,
|
||||||
|
employee.getBirthday().getMonth(),
|
||||||
|
employee.getBirthday().getDayOfMonth());
|
||||||
|
endDate = startDate.plusDays(vacation.getExpiration().intValue() - 1);
|
||||||
|
} else if (vacation.getCategory() == TimeOffRequestType.HEALTH_PERMIT) {
|
||||||
|
startDate = LocalDate.now();
|
||||||
|
endDate = LocalDate.of(startYear, 12, 31);
|
||||||
|
} else {
|
||||||
|
startDate = LocalDate.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vacation.getCategory() == TimeOffRequestType.CUMPLEAÑOS && employee.getBirthday() != null) {
|
|
||||||
return LocalDate.of(startYear, employee.getBirthday().getMonth(), employee.getBirthday().getDayOfMonth());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vacation.getCategory() == TimeOffRequestType.PERMISOS_DE_SALUD) {
|
|
||||||
return LocalDate.now();
|
|
||||||
}
|
|
||||||
|
|
||||||
return LocalDate.now();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setPickerValues(final Vacation vacation, final LocalDate startDate) {
|
|
||||||
startDatePicker.setValue(startDate);
|
startDatePicker.setValue(startDate);
|
||||||
|
|
||||||
if ((vacation.getDuration() != null && vacation.getDuration() == 0.5)
|
if ((vacation.getDuration() != null && vacation.getDuration() == 0.5)
|
||||||
|| vacation.getCategory() == TimeOffRequestType.PERMISOS_DE_SALUD) {
|
|| vacation.getCategory() == TimeOffRequestType.HEALTH_PERMIT) {
|
||||||
endDatePicker.setValue(startDate);
|
endDatePicker.setValue(startDate);
|
||||||
} else {
|
} else {
|
||||||
int durationDays = (vacation.getDuration() != null ? vacation.getDuration().intValue() - 1 : 0);
|
int durationDays = (vacation.getDuration() != null ? vacation.getDuration().intValue() - 1 : 0);
|
||||||
endDatePicker.setValue(startDate.plusDays(durationDays));
|
endDatePicker.setValue(startDate.plusDays(durationDays));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void setPickerLimits(final LocalDate startDate, final LocalDate endDate) {
|
|
||||||
startDatePicker.setMin(startDate);
|
startDatePicker.setMin(startDate);
|
||||||
startDatePicker.setMax(endDate);
|
startDatePicker.setMax(endDate);
|
||||||
endDatePicker.setMin(startDate);
|
endDatePicker.setMin(startDate);
|
||||||
endDatePicker.setMax(endDate);
|
endDatePicker.setMax(endDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void updateDatePickerMinValues() {
|
private void updateDatePickerMinValues() {
|
||||||
LocalDate startDate = startDatePicker.getValue();
|
LocalDate startDate = startDatePicker.getValue();
|
||||||
if (availableDaysField.getValue() != null) {
|
if (vacation.getDuration() == 0.5) {
|
||||||
if (availableDaysField.getValue() == 0.5) {
|
|
||||||
endDatePicker.setValue(startDate.plusDays(0));
|
endDatePicker.setValue(startDate.plusDays(0));
|
||||||
} else {
|
} else {
|
||||||
endDatePicker.setValue(startDate.plusDays(availableDaysField.getValue().intValue() - 1));
|
endDatePicker.setValue(startDate.plusDays(vacation.getDuration().intValue() - 1));
|
||||||
}
|
}
|
||||||
calculateDays();
|
calculateDays();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void calculateDays() {
|
private void calculateDays() {
|
||||||
LocalDate startDate = startDatePicker.getValue();
|
LocalDate startDate = startDatePicker.getValue();
|
||||||
LocalDate endDate = endDatePicker.getValue();
|
LocalDate endDate = endDatePicker.getValue();
|
||||||
Double availableDays = availableDaysField.getValue();
|
Double availableDays = availableDaysField.getValue();
|
||||||
|
|
||||||
if (areDatesValid(startDate, endDate)) {
|
if (startDate != null && endDate != null) {
|
||||||
double daysToBeTaken = calculateDaysBetween(startDate, endDate);
|
double daysToBeTaken = java.time.temporal.ChronoUnit.DAYS.between(startDate, endDate) + 1;
|
||||||
setDaysToBeTakenField(daysToBeTaken);
|
if (vacation.getCategory() == TimeOffRequestType.HEALTH_PERMIT || vacation.getDuration() == 0.5) {
|
||||||
|
|
||||||
double balanceDays = calculateBalanceDays(availableDays, daysToBeTakenField.getValue());
|
|
||||||
balanceDaysField.setValue(balanceDays);
|
|
||||||
|
|
||||||
if (balanceDays < 0) {
|
|
||||||
clearFields();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean areDatesValid(final LocalDate startDate, final LocalDate endDate) {
|
|
||||||
return startDate != null && endDate != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private double calculateDaysBetween(final LocalDate startDate, final LocalDate endDate) {
|
|
||||||
return java.time.temporal.ChronoUnit.DAYS.between(startDate, endDate) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setDaysToBeTakenField(final double daysToBeTaken) {
|
|
||||||
if (vacation.getCategory() == TimeOffRequestType.PERMISOS_DE_SALUD) {
|
|
||||||
daysToBeTakenField.setValue(0.5);
|
daysToBeTakenField.setValue(0.5);
|
||||||
} else {
|
} else {
|
||||||
daysToBeTakenField.setValue(daysToBeTaken);
|
daysToBeTakenField.setValue(daysToBeTaken);
|
||||||
}
|
}
|
||||||
|
double balanceDays = availableDays - daysToBeTakenField.getValue();
|
||||||
|
balanceDaysField.setValue(balanceDays);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double calculateBalanceDays(final double availableDays, final double daysToBeTaken) {
|
|
||||||
return availableDays - daysToBeTaken;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void clearFields() {
|
|
||||||
daysToBeTakenField.clear();
|
|
||||||
balanceDaysField.clear();
|
|
||||||
endDatePicker.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureButtons() {
|
private void configureButtons() {
|
||||||
saveButton = new Button("Guardar", event -> saveRequest());
|
saveButton = new Button("Save", event -> saveRequest());
|
||||||
closeButton = new Button("Salir", event -> closeForm());
|
closeButton = new Button("Close", event -> closeForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupFormLayout() {
|
private void setupFormLayout() {
|
||||||
add(
|
add(
|
||||||
new H3("Añadir solicitud de vacaciones"),
|
new H3("Add Vacation Request"),
|
||||||
employeeComboBox,
|
employeeComboBox,
|
||||||
categoryComboBox,
|
categoryComboBox,
|
||||||
availableDaysField,
|
availableDaysField,
|
||||||
@ -382,71 +321,59 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void saveRequest() {
|
private void saveRequest() {
|
||||||
if (!binder.validate().isOk()) {
|
if (binder.validate().isOk()) {
|
||||||
Notification.show("Rellene correctamente todos los campos obligatorios.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!validateForm()) {
|
|
||||||
Notification.show("Por favor, complete los campos antes de guardar");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TimeOffRequest request = prepareRequest();
|
|
||||||
|
|
||||||
if (request.getCategory() == TimeOffRequestType.VACACION_GESTION_ACTUAL) {
|
|
||||||
handleVacationRequest(request);
|
|
||||||
} else {
|
|
||||||
handleExistingRequests(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
requestService.saveTimeOffRequest(request);
|
|
||||||
Notification.show("Solicitud guardada correctamente.");
|
|
||||||
closeForm();
|
|
||||||
}
|
|
||||||
|
|
||||||
private TimeOffRequest prepareRequest() {
|
|
||||||
TimeOffRequest request = binder.getBean();
|
TimeOffRequest request = binder.getBean();
|
||||||
request.setStartDate(startDatePicker.getValue());
|
request.setStartDate(startDatePicker.getValue());
|
||||||
request.setAvailableDays(availableDaysField.getValue());
|
request.setAvailableDays(availableDaysField.getValue());
|
||||||
request.setExpiration(endDate != null ? endDate : endDatePicker.getValue());
|
if (endDate == null) {
|
||||||
request.setState(TimeOffRequestStatus.PENDIENTE);
|
request.setExpiration(endDatePicker.getValue());
|
||||||
return request;
|
} else {
|
||||||
|
request.setExpiration(endDate);
|
||||||
}
|
}
|
||||||
|
request.setState(TimeOffRequestStatus.REQUESTED);
|
||||||
|
|
||||||
private void handleExistingRequests(final TimeOffRequest request) {
|
|
||||||
List<TimeOffRequest> existingRequests =
|
List<TimeOffRequest> existingRequests =
|
||||||
requestService.findByEmployeeAndCategory(employee.getId(), request.getCategory());
|
requestService.findByEmployeeAndCategory(employee.getId(), request.getCategory());
|
||||||
|
|
||||||
int maxRequests = request.getCategory() == TimeOffRequestType.PERMISOS_DE_SALUD ? 4 : 2;
|
int maxRequests = request.getCategory() == TimeOffRequestType.HEALTH_PERMIT ? 4 : 2;
|
||||||
|
|
||||||
if (existingRequests.size() >= maxRequests) {
|
if (existingRequests.size() >= maxRequests) {
|
||||||
existingRequests.stream()
|
existingRequests.stream()
|
||||||
.min(Comparator.comparing(TimeOffRequest::getStartDate))
|
.min(Comparator.comparing(TimeOffRequest::getStartDate))
|
||||||
.ifPresent(oldestRequest -> requestService.deleteTimeOffRequest(oldestRequest.getId()));
|
.ifPresent(oldestRequest -> requestService.deleteTimeOffRequest(oldestRequest.getId()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void handleVacationRequest(final TimeOffRequest request) {
|
requestService.saveTimeOffRequest(request);
|
||||||
List<TimeOffRequest> existingRequests = requestService.findByEmployeeAndCategory(
|
Notification.show("Request saved successfully.");
|
||||||
employee.getId(),
|
closeForm();
|
||||||
TimeOffRequestType.VACACION_GESTION_ACTUAL
|
} else {
|
||||||
);
|
Notification.show("Please fill all required fields correctly.");
|
||||||
if (!existingRequests.isEmpty()) {
|
|
||||||
TimeOffRequest existingRequest = existingRequests.getFirst();
|
|
||||||
existingRequest.setCategory(TimeOffRequestType.VACACION_GESTION_ANTERIOR);
|
|
||||||
requestService.saveTimeOffRequest(existingRequest);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean validateForm() {
|
private void updateBalanceForCategory(final TimeOffRequest newRequest) {
|
||||||
return employeeComboBox.getValue() != null
|
List<TimeOffRequest> requests = requestService.findByEmployeeAndCategory(
|
||||||
&& categoryComboBox.getValue() != null
|
newRequest.getEmployee().getId(), newRequest.getCategory());
|
||||||
&& startDatePicker.getValue() != null
|
|
||||||
&& endDatePicker.getValue() != null;
|
if (vacation.getCategory() == TimeOffRequestType.HEALTH_PERMIT
|
||||||
|
&& vacation.getCategory() == TimeOffRequestType.VACATION_CURRENT_MANAGEMENT) {
|
||||||
|
for (TimeOffRequest request : requests) {
|
||||||
|
double newBalance = request.getDaysBalance() - newRequest.getDaysToBeTake();
|
||||||
|
request.setDaysBalance(newBalance);
|
||||||
|
requestService.saveTimeOffRequest(request);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void closeForm() {
|
private void closeForm() {
|
||||||
getUI().ifPresent(ui -> ui.navigate(RequestsListView.class));
|
getUI().ifPresent(ui -> ui.navigate(RequestsListView.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void clearForm() {
|
||||||
|
availableDaysField.clear();
|
||||||
|
startDatePicker.clear();
|
||||||
|
endDatePicker.clear();
|
||||||
|
daysToBeTakenField.clear();
|
||||||
|
balanceDaysField.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,12 +27,12 @@ import java.util.UUID;
|
|||||||
@Route(value = "/requests/:requestId?/:action?", layout = MainLayout.class)
|
@Route(value = "/requests/:requestId?/:action?", layout = MainLayout.class)
|
||||||
public class RequestView extends BeanValidationForm<TimeOffRequest> implements HasUrlParameter<String> {
|
public class RequestView extends BeanValidationForm<TimeOffRequest> implements HasUrlParameter<String> {
|
||||||
|
|
||||||
private final ComboBox<TimeOffRequestStatus> state = new ComboBox<>("Estado de la solicitud");
|
private final ComboBox<TimeOffRequestStatus> state = new ComboBox<>("State");
|
||||||
private final DatePicker expiration = new DatePicker("Vencimiento");
|
private final DatePicker expiration = new DatePicker("Expiration");
|
||||||
private final DatePicker startDate = new DatePicker("Fecha de inicio");
|
private final DatePicker startDate = new DatePicker("Start Date");
|
||||||
private final DatePicker endDate = new DatePicker("Fecha de fin");
|
private final DatePicker endDate = new DatePicker("End Date");
|
||||||
private final NumberField availableDays = new NumberField("Días disponibles");
|
private final NumberField availableDays = new NumberField("Available Days");
|
||||||
private final NumberField daysToBeTake = new NumberField("Días a tomar");
|
private final NumberField daysToBeTake = new NumberField("Days To Be Take");
|
||||||
|
|
||||||
private final TimeOffRequestService requestService;
|
private final TimeOffRequestService requestService;
|
||||||
private final EmployeeService employeeService;
|
private final EmployeeService employeeService;
|
||||||
@ -85,13 +85,13 @@ public class RequestView extends BeanValidationForm<TimeOffRequest> implements H
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected Button createSaveButton() {
|
protected Button createSaveButton() {
|
||||||
saveButton = new Button("Guardar");
|
saveButton = new Button("Save");
|
||||||
saveButton.addClickListener(event -> saveRequest());
|
saveButton.addClickListener(event -> saveRequest());
|
||||||
return saveButton;
|
return saveButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Button createCloseButton() {
|
protected Button createCloseButton() {
|
||||||
Button closeButton = new Button("Salir");
|
Button closeButton = new Button("Close");
|
||||||
closeButton.addClickListener(event -> closeForm());
|
closeButton.addClickListener(event -> closeForm());
|
||||||
return closeButton;
|
return closeButton;
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ public class RequestView extends BeanValidationForm<TimeOffRequest> implements H
|
|||||||
TimeOffRequest request = getEntity();
|
TimeOffRequest request = getEntity();
|
||||||
setRequestFieldValues(request);
|
setRequestFieldValues(request);
|
||||||
requestService.saveTimeOffRequest(request);
|
requestService.saveTimeOffRequest(request);
|
||||||
Notification.show("Solicitud guardada correctamente.");
|
Notification.show("Request saved successfully.");
|
||||||
closeForm();
|
closeForm();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -147,14 +147,14 @@ public class RequestView extends BeanValidationForm<TimeOffRequest> implements H
|
|||||||
}
|
}
|
||||||
|
|
||||||
private H3 createEmployeeHeader() {
|
private H3 createEmployeeHeader() {
|
||||||
return new H3("Empleado: " + employee.getFirstName() + " " + employee.getLastName());
|
return new H3("Employee: " + employee.getFirstName() + " " + employee.getLastName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private H3 createTeamHeader() {
|
private H3 createTeamHeader() {
|
||||||
return new H3("Equipo: " + employee.getTeam().getName());
|
return new H3("Team: " + employee.getTeam().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private H3 createCategoryHeader() {
|
private H3 createCategoryHeader() {
|
||||||
return new H3("Categoría: " + request.getCategory());
|
return new H3("Category: " + request.getCategory());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,6 @@ import jakarta.annotation.security.PermitAll;
|
|||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.vaadin.firitin.components.grid.PagingGrid;
|
import org.vaadin.firitin.components.grid.PagingGrid;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.Period;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -70,10 +68,10 @@ public class RequestsListView extends Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupRequestGrid() {
|
private void setupRequestGrid() {
|
||||||
requestGrid.addColumn(this::getEmployeeFullName).setHeader("Empleado");
|
requestGrid.addColumn(this::getEmployeeFullName).setHeader("Employee");
|
||||||
requestGrid.addColumn(this::getTeamName).setHeader("Equipo");
|
requestGrid.addColumn(this::getTeamName).setHeader("Team");
|
||||||
requestGrid.addColumn(this::getEmployeeStatus).setHeader("Estado del empleado");
|
requestGrid.addColumn(this::getEmployeeStatus).setHeader("Employee State");
|
||||||
requestGrid.addColumn(this::getGeneralTotal).setHeader("Total general");
|
requestGrid.addColumn(this::getGeneralTotal).setHeader("General Total");
|
||||||
|
|
||||||
requestGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
|
requestGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
|
||||||
requestGrid.setPageSize(5);
|
requestGrid.setPageSize(5);
|
||||||
@ -86,14 +84,14 @@ public class RequestsListView extends Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private HorizontalLayout createActionButtons() {
|
private HorizontalLayout createActionButtons() {
|
||||||
Button viewButton = new Button("Ver", event -> {
|
Button viewButton = new Button("View", event -> {
|
||||||
if (selectedEmployeeId != null) {
|
if (selectedEmployeeId != null) {
|
||||||
navigateToTimeOffRequestView(selectedEmployeeId);
|
navigateToTimeOffRequestView(selectedEmployeeId);
|
||||||
} else {
|
} else {
|
||||||
Notification.show("Seleccione una solicitud.", 3000, Notification.Position.MIDDLE);
|
Notification.show("Please select a request to view.", 3000, Notification.Position.MIDDLE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Button closeButton = new Button("Salir", event -> navigateToMainView());
|
Button closeButton = new Button("Close", event -> navigateToMainView());
|
||||||
return new HorizontalLayout(viewButton, closeButton);
|
return new HorizontalLayout(viewButton, closeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,24 +112,24 @@ public class RequestsListView extends Main {
|
|||||||
final Status state) {
|
final Status state) {
|
||||||
List<Employee> filteredEmployees = employeeService.findAllEmployees();
|
List<Employee> filteredEmployees = employeeService.findAllEmployees();
|
||||||
|
|
||||||
if (employee != null && !"TODOS".equals(employee.getFirstName())) {
|
if (employee != null && !"ALL".equals(employee.getFirstName())) {
|
||||||
filteredEmployees = filteredEmployees.stream()
|
filteredEmployees = filteredEmployees.stream()
|
||||||
.filter(emp -> emp.getId().equals(employee.getId()))
|
.filter(emp -> emp.getId().equals(employee.getId()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (team != null && !"TODOS".equals(team.getName())) {
|
if (team != null && !"ALL".equals(team.getName())) {
|
||||||
filteredEmployees = filteredEmployees.stream()
|
filteredEmployees = filteredEmployees.stream()
|
||||||
.filter(emp -> emp.getTeam() != null && emp.getTeam().getId().equals(team.getId()))
|
.filter(emp -> emp.getTeam() != null && emp.getTeam().getId().equals(team.getId()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state != null && state != Status.TODOS) {
|
if (state != null && state != Status.ALL) {
|
||||||
filteredEmployees = filteredEmployees.stream()
|
filteredEmployees = filteredEmployees.stream()
|
||||||
.filter(emp -> {
|
.filter(emp -> {
|
||||||
Optional<TimeOffRequest> request = requestService
|
Optional<TimeOffRequest> request = requestService
|
||||||
.findByEmployeeAndState(emp.getId(), TimeOffRequestStatus.EN_USO);
|
.findByEmployeeAndState(emp.getId(), TimeOffRequestStatus.TAKEN);
|
||||||
return state == Status.EN_DESCANSO ? request.isPresent() : request.isEmpty();
|
return state == Status.IDLE ? request.isPresent() : request.isEmpty();
|
||||||
})
|
})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
@ -141,160 +139,54 @@ public class RequestsListView extends Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getEmployeeFullName(final Employee employee) {
|
private String getEmployeeFullName(final Employee employee) {
|
||||||
return "TODOS".equals(employee.getFirstName())
|
return "ALL".equals(employee.getFirstName()) ? "ALL" : employee.getFirstName() + " " + employee.getLastName();
|
||||||
? "TODOS" : employee.getFirstName() + " " + employee.getLastName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTeamName(final Employee employee) {
|
private String getTeamName(final Employee employee) {
|
||||||
Team team = employee.getTeam();
|
Team team = employee.getTeam();
|
||||||
return team != null ? team.getName() : "Sin asignar";
|
return team != null ? team.getName() : "Unassigned";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTeamLabel(final Team team) {
|
private String getTeamLabel(final Team team) {
|
||||||
return "TODOS".equals(team.getName()) ? "TODOS" : team.getName();
|
return "ALL".equals(team.getName()) ? "ALL" : team.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getEmployeeStatus(final Employee employee) {
|
private String getEmployeeStatus(final Employee employee) {
|
||||||
Optional<TimeOffRequest> activeRequest = requestService
|
Optional<TimeOffRequest> activeRequest = requestService
|
||||||
.findByEmployeeAndState(employee.getId(), TimeOffRequestStatus.EN_USO);
|
.findByEmployeeAndState(employee.getId(), TimeOffRequestStatus.TAKEN);
|
||||||
return activeRequest.isPresent() ? "EN_DESCANSO" : "ACTIVO";
|
return activeRequest.isPresent() ? "IDLE" : "ACTIVE";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getGeneralTotal(final Employee employee) {
|
private String getGeneralTotal(final Employee employee) {
|
||||||
List<TimeOffRequest> employeeRequests = requestService.findRequestsByEmployeeId(employee.getId());
|
List<TimeOffRequest> employeeRequests = requestService.findRequestsByEmployeeId(employee.getId());
|
||||||
List<Vacation> vacations = vacationService.findVacations();
|
List<Vacation> vacations = vacationService.findVacations();
|
||||||
double totalUtilized = calculateTotalUtilized(employeeRequests);
|
double totalUtilized = employeeRequests.stream()
|
||||||
double totalVacations = calculateVacationDays(employee);
|
.filter(Objects::nonNull)
|
||||||
double totalAvailable = calculateTotalAvailable(vacations, employeeRequests, employee);
|
.mapToDouble(request -> {
|
||||||
|
Double daysBalance = request.getAvailableDays();
|
||||||
double generalTotal = totalAvailable + totalVacations - totalUtilized;
|
return daysBalance != null ? daysBalance : 0.0;
|
||||||
|
})
|
||||||
|
.sum();
|
||||||
|
double totalUnused = employeeRequests.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.mapToDouble(request -> {
|
||||||
|
Double daysBalance = request.getDaysBalance();
|
||||||
|
return daysBalance != null ? daysBalance : 0.0;
|
||||||
|
})
|
||||||
|
.sum();
|
||||||
|
double totalAvailable = vacations.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.mapToDouble(request -> {
|
||||||
|
Double daysBalance = request.getDuration();
|
||||||
|
return daysBalance != null ? daysBalance : 0.0;
|
||||||
|
})
|
||||||
|
.sum();
|
||||||
|
double generalTotal = (totalAvailable - totalUtilized) + totalUnused;
|
||||||
return String.valueOf(generalTotal);
|
return String.valueOf(generalTotal);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<TimeOffRequestType> getExcludedCategories() {
|
|
||||||
return Set.of(
|
|
||||||
TimeOffRequestType.MATERNIDAD,
|
|
||||||
TimeOffRequestType.PATERNIDAD,
|
|
||||||
TimeOffRequestType.MATRIMONIO,
|
|
||||||
TimeOffRequestType.DUELO_1ER_GRADO,
|
|
||||||
TimeOffRequestType.DUELO_2ER_GRADO,
|
|
||||||
TimeOffRequestType.DIA_DEL_PADRE,
|
|
||||||
TimeOffRequestType.DIA_DE_LA_MADRE
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Set<TimeOffRequestType> getGenderSpecificExclusions() {
|
|
||||||
return Set.of(
|
|
||||||
TimeOffRequestType.DIA_DE_LA_MUJER_INTERNACIONAL,
|
|
||||||
TimeOffRequestType.DIA_DE_LA_MUJER_NACIONAL
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private double calculateTotalUtilized(final List<TimeOffRequest> employeeRequests) {
|
|
||||||
return employeeRequests.stream()
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.mapToDouble(request -> request.getDaysToBeTake() != null ? request.getDaysToBeTake() : 0.0)
|
|
||||||
.sum();
|
|
||||||
}
|
|
||||||
|
|
||||||
private double calculateVacationDays(final Employee employee) {
|
|
||||||
if (employee.getDateOfEntry() != null) {
|
|
||||||
LocalDate entryDate = employee.getDateOfEntry();
|
|
||||||
LocalDate today = LocalDate.now();
|
|
||||||
|
|
||||||
boolean hasAnniversaryPassed = entryDate.getMonthValue() < today.getMonthValue()
|
|
||||||
|| (entryDate.getMonthValue() == today.getMonthValue() && entryDate.getDayOfMonth()
|
|
||||||
<= today.getDayOfMonth());
|
|
||||||
|
|
||||||
LocalDate previousVacationYearDate;
|
|
||||||
LocalDate currentVacationYearDate;
|
|
||||||
|
|
||||||
if (hasAnniversaryPassed) {
|
|
||||||
previousVacationYearDate = LocalDate.of(
|
|
||||||
today.getYear() - 1,
|
|
||||||
entryDate.getMonth(),
|
|
||||||
entryDate.getDayOfMonth()
|
|
||||||
);
|
|
||||||
currentVacationYearDate = LocalDate.of(
|
|
||||||
today.getYear(),
|
|
||||||
entryDate.getMonth(),
|
|
||||||
entryDate.getDayOfMonth()
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
previousVacationYearDate = LocalDate.of(
|
|
||||||
today.getYear() - 2,
|
|
||||||
entryDate.getMonth(),
|
|
||||||
entryDate.getDayOfMonth()
|
|
||||||
);
|
|
||||||
currentVacationYearDate = LocalDate.of(
|
|
||||||
today.getYear() - 1,
|
|
||||||
entryDate.getMonth(),
|
|
||||||
entryDate.getDayOfMonth()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return calculateVacationDaysSinceEntry(entryDate, previousVacationYearDate)
|
|
||||||
+ calculateVacationDaysSinceEntry(entryDate, currentVacationYearDate);
|
|
||||||
} else {
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private double calculateTotalAvailable(final List<Vacation> vacations, final List<TimeOffRequest> employeeRequests,
|
|
||||||
final Employee employee) {
|
|
||||||
Set<TimeOffRequestType> excludedCategories = getExcludedCategories();
|
|
||||||
Set<TimeOffRequestType> genderSpecificExclusions = getGenderSpecificExclusions();
|
|
||||||
Set<TimeOffRequestType> employeeRequestCategories = employeeRequests.stream()
|
|
||||||
.map(TimeOffRequest::getCategory)
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
|
|
||||||
return vacations.stream()
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.filter(vacation -> shouldIncludeVacation(
|
|
||||||
vacation,
|
|
||||||
excludedCategories,
|
|
||||||
genderSpecificExclusions,
|
|
||||||
employee, employeeRequestCategories
|
|
||||||
))
|
|
||||||
.mapToDouble(vacation -> vacation.getDuration() != null ? vacation.getDuration() : 0.0)
|
|
||||||
.sum();
|
|
||||||
}
|
|
||||||
|
|
||||||
private double calculateVacationDaysSinceEntry(final LocalDate dateOfEntry, final LocalDate date) {
|
|
||||||
int yearsOfService = dateOfEntry != null ? Period.between(dateOfEntry, date).getYears() : 0;
|
|
||||||
if (yearsOfService > 10) {
|
|
||||||
return 30;
|
|
||||||
}
|
|
||||||
if (yearsOfService > 5) {
|
|
||||||
return 20;
|
|
||||||
}
|
|
||||||
if (yearsOfService > 1) {
|
|
||||||
return 15;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean shouldIncludeVacation(final Vacation vacation,
|
|
||||||
final Set<TimeOffRequestType> excludedCategories,
|
|
||||||
final Set<TimeOffRequestType> genderSpecificExclusions,
|
|
||||||
final Employee employee,
|
|
||||||
final Set<TimeOffRequestType> employeeRequestCategories) {
|
|
||||||
if (excludedCategories.contains(vacation.getCategory())
|
|
||||||
&& !employeeRequestCategories.contains(vacation.getCategory())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isFemale(employee) && genderSpecificExclusions.contains(vacation.getCategory())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isFemale(final Employee employee) {
|
|
||||||
return employee.getGender() == Employee.Gender.FEMALE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ComboBox<Employee> createEmployeeFilter() {
|
private ComboBox<Employee> createEmployeeFilter() {
|
||||||
employeeFilter = new ComboBox<>("Empleado");
|
employeeFilter = new ComboBox<>("Employee");
|
||||||
List<Employee> employees = new ArrayList<>(employeeService.findAllEmployees());
|
List<Employee> employees = new ArrayList<>(employeeService.findAllEmployees());
|
||||||
employees.addFirst(createAllEmployeesOption());
|
employees.addFirst(createAllEmployeesOption());
|
||||||
employeeFilter.setItems(employees);
|
employeeFilter.setItems(employees);
|
||||||
@ -311,7 +203,7 @@ public class RequestsListView extends Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ComboBox<Team> createTeamFilter() {
|
private ComboBox<Team> createTeamFilter() {
|
||||||
teamFilter = new ComboBox<>("Equipo");
|
teamFilter = new ComboBox<>("Team");
|
||||||
List<Team> teams = new ArrayList<>(teamService.findAllTeams());
|
List<Team> teams = new ArrayList<>(teamService.findAllTeams());
|
||||||
teams.addFirst(createAllTeamsOption());
|
teams.addFirst(createAllTeamsOption());
|
||||||
teamFilter.setItems(teams);
|
teamFilter.setItems(teams);
|
||||||
@ -328,7 +220,7 @@ public class RequestsListView extends Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ComboBox<Status> createStateFilter() {
|
private ComboBox<Status> createStateFilter() {
|
||||||
stateFilter = new ComboBox<>("Estado del empleado");
|
stateFilter = new ComboBox<>("Employee State");
|
||||||
stateFilter.setItems(Status.values());
|
stateFilter.setItems(Status.values());
|
||||||
stateFilter.setValue(Status.values()[0]);
|
stateFilter.setValue(Status.values()[0]);
|
||||||
stateFilter.addValueChangeListener(event ->
|
stateFilter.addValueChangeListener(event ->
|
||||||
@ -342,20 +234,20 @@ public class RequestsListView extends Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private enum Status {
|
private enum Status {
|
||||||
TODOS,
|
ALL,
|
||||||
EN_DESCANSO,
|
IDLE,
|
||||||
ACTIVO
|
ACTIVE
|
||||||
}
|
}
|
||||||
|
|
||||||
private Employee createAllEmployeesOption() {
|
private Employee createAllEmployeesOption() {
|
||||||
Employee allEmployeesOption = new Employee();
|
Employee allEmployeesOption = new Employee();
|
||||||
allEmployeesOption.setFirstName("TODOS");
|
allEmployeesOption.setFirstName("ALL");
|
||||||
return allEmployeesOption;
|
return allEmployeesOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Team createAllTeamsOption() {
|
private Team createAllTeamsOption() {
|
||||||
Team allTeamsOption = new Team();
|
Team allTeamsOption = new Team();
|
||||||
allTeamsOption.setName("TODOS");
|
allTeamsOption.setName("ALL");
|
||||||
return allTeamsOption;
|
return allTeamsOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,35 +16,33 @@ INSERT INTO team (id, version, name) VALUES ('c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3
|
|||||||
INSERT INTO team (id, version, name) VALUES ('8f6b61e7-efb2-4de7-b8ed-7438c9d8babe', 1, 'GHI');
|
INSERT INTO team (id, version, name) VALUES ('8f6b61e7-efb2-4de7-b8ed-7438c9d8babe', 1, 'GHI');
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('123e4567-e89b-12d3-a456-426614174000', 1, 'AÑO_NUEVO', 1, 1, 1, 1, 'FIXED');
|
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('123e4567-e89b-12d3-a456-426614174000', 1, 'NEW_YEAR', 1, 1, 1, 1, 'FIXED');
|
||||||
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('223e4567-e89b-12d3-a456-426614174001', 1, 'LUNES_CARNAVAL', 2, 12, 1, 1, 'FIXED');
|
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('223e4567-e89b-12d3-a456-426614174001', 1, 'MONDAY_CARNIVAL', 2, 12, 1, 1, 'FIXED');
|
||||||
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('323e4567-e89b-12d3-a456-426614174002', 1, 'MARTES_CARNAVAL', 2, 13, 1, 1, 'FIXED');
|
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('323e4567-e89b-12d3-a456-426614174002', 1, 'TUESDAY_CARNIVAL', 2, 13, 1, 1, 'FIXED');
|
||||||
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('423e4567-e89b-12d3-a456-426614174003', 1, 'VIERNES_SANTO', 3, 29, 1, 1, 'FIXED');
|
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('423e4567-e89b-12d3-a456-426614174003', 1, 'GOOD_FRIDAY', 3, 29, 1, 1, 'FIXED');
|
||||||
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('523e4567-e89b-12d3-a456-426614174004', 1, 'DIA_DEL_TRABAJADOR', 5, 1, 1, 1, 'FIXED');
|
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('523e4567-e89b-12d3-a456-426614174004', 1, 'LABOR_DAY', 5, 1, 1, 1, 'FIXED');
|
||||||
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('623e4567-e89b-12d3-a456-426614174005', 1, 'DIA_DE_LA_INDEPENDENCIA', 8, 6, 1, 1, 'FIXED');
|
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('623e4567-e89b-12d3-a456-426614174005', 1, 'INDEPENDENCE_DAY', 8, 6, 1, 1, 'FIXED');
|
||||||
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('723e4567-e89b-12d3-a456-426614174006', 1, 'NAVIDAD', 12, 25, 1, 1, 'FIXED');
|
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('723e4567-e89b-12d3-a456-426614174006', 1, 'CHRISTMAS', 12, 25, 1, 1, 'FIXED');
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('823e4567-e89b-12d3-a456-426614174007', 1, 'DIA_DEL_ESTADO_PLURINACIONAL', 1, 21, 1, 30, 'MOVABLE');
|
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('823e4567-e89b-12d3-a456-426614174007', 1, 'PRURINATIONAL_STATE_DAY', 1, 21, 1, 30, 'MOVABLE');
|
||||||
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('923e4567-e89b-12d3-a456-426614174008', 1, 'CORPUS_CHRISTI', 5, 30, 1, 30, 'MOVABLE');
|
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('923e4567-e89b-12d3-a456-426614174008', 1, 'CORPUS_CHRISTI', 5, 30, 1, 30, 'MOVABLE');
|
||||||
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('a23e4567-e89b-12d3-a456-426614174009', 1, 'AÑO_NUEVO_ANDINO', 6, 21, 1, 30, 'MOVABLE');
|
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('a23e4567-e89b-12d3-a456-426614174009', 1, 'ANDEAN_NEW_YEAR', 6, 21, 1, 30, 'MOVABLE');
|
||||||
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('b23e4567-e89b-12d3-a456-42661417400a', 1, 'ANIVERSARIO_DEPARTAMENTAL', 9, 14, 1, 30, 'MOVABLE');
|
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('b23e4567-e89b-12d3-a456-42661417400a', 1, 'DEPARTMENTAL_ANNIVERSARY', 9, 14, 1, 30, 'MOVABLE');
|
||||||
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400b', 1, 'DIA_DE_TODOS_LOS_DIFUNTOS', 11, 2, 1, 30, 'MOVABLE');
|
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400b', 1, 'ALL_SOULS_DAY', 11, 2, 1, 30, 'MOVABLE');
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO vacation (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400c', 1, 'CUMPLEAÑOS', 0.5, 365, 'OTHER');
|
INSERT INTO vacation (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400c', 1, 'BIRTHDAY', 0.5, 365, 'OTHER');
|
||||||
INSERT INTO vacation (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400d', 1, 'MATERNIDAD', 90, 90, 'OTHER');
|
INSERT INTO vacation (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400d', 1, 'MATERNITY', 90, 90, 'OTHER');
|
||||||
INSERT INTO vacation (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400e', 1, 'PATERNIDAD', 3, 3, 'OTHER');
|
INSERT INTO vacation (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400e', 1, 'PATERNITY', 3, 3, 'OTHER');
|
||||||
INSERT INTO vacation (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400f', 1, 'MATRIMONIO', 3, 3, 'OTHER');
|
INSERT INTO vacation (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400f', 1, 'MARRIAGE', 3, 3, 'OTHER');
|
||||||
INSERT INTO vacation (id, version, category, duration, expiration, type) VALUES ('550e8400-e29b-41d4-a716-446655440000', 1, 'DUELO_1ER_GRADO', 3, 3, 'OTHER');
|
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401a', 1, 'FATHERS_DAY', 3, 19, 0.5, 30, 'OTHER');
|
||||||
INSERT INTO vacation (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400a', 1, 'DUELO_2ER_GRADO', 2, 2, 'OTHER');
|
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401b', 1, 'MOTHERS_DAY', 5, 27, 0.5, 30, 'OTHER');
|
||||||
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401a', 1, 'DIA_DEL_PADRE', 3, 19, 0.5, 30, 'OTHER');
|
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401c', 1, 'INTERNATIONAL_WOMENS_DAY', 3, 8, 0.5, 30, 'OTHER');
|
||||||
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401b', 1, 'DIA_DE_LA_MADRE', 5, 27, 0.5, 30, 'OTHER');
|
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401d', 1, 'NATIONAL_WOMENS_DAY', 10, 11, 0.5, 30, 'OTHER');
|
||||||
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401c', 1, 'DIA_DE_LA_MUJER_INTERNACIONAL', 3, 8, 0.5, 30, 'OTHER');
|
INSERT INTO vacation (id, version, category, duration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401e', 1, 'HEALTH_PERMIT', 2, 'OTHER');
|
||||||
INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401d', 1, 'DIA_DE_LA_MUJER_NACIONAL', 10, 11, 0.5, 30, 'OTHER');
|
INSERT INTO vacation (id, version, category, expiration, type) VALUES ('490e5fbe-895b-42f8-b914-95437f7b39c0', 1, 'VACATION_CURRENT_MANAGEMENT', 730, 'OTHER');
|
||||||
INSERT INTO vacation (id, version, category, duration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401e', 1, 'PERMISOS_DE_SALUD', 2, 'OTHER');
|
INSERT INTO vacation (id, version, category, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-4266141740ff', 1, 'VACATION_PREVIOUS_MANAGEMENT', 730, 'OTHER');
|
||||||
INSERT INTO vacation (id, version, category, expiration, type) VALUES ('490e5fbe-895b-42f8-b914-95437f7b39c0', 1, 'VACACION_GESTION_ACTUAL', 360, 'OTHER');
|
|
||||||
INSERT INTO vacation (id, version, category, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-4266141740ff', 1, 'VACACION_GESTION_ANTERIOR', 360, 'OTHER');
|
|
||||||
|
|
||||||
|
|
||||||
insert into employee (id, version, username, first_name, last_name, status, team_id, gender, birthday, date_of_entry) values ('5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 1, 'bob', 'Bob', 'Test', 'ACTIVE','b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 'MALE', '2024-02-20', '2013-10-22');
|
insert into employee (id, version, username, first_name, last_name, status, team_id, gender, birthday, date_of_entry) values ('5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 1, 'bob', 'Bob', 'Test', 'ACTIVE','b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 'MALE', '2024-02-20', '2013-10-22');
|
||||||
@ -68,25 +66,25 @@ insert into employee (id, version, username, first_name, last_name, status, team
|
|||||||
|
|
||||||
|
|
||||||
insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
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-e341-4e7a-b8a6-cab0982bd8c1', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'PATERNIDAD', 'VENCIDO', 3, '2024-10-03', '2024-10-01', '2024-10-03', 3, 0);
|
values ('9d6f12ba-e341-4e7a-b8a6-cab0982bd8c1', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'PATERNITY', 'TAKEN', 3, '2024-10-03', '2024-10-01', '2024-10-03', 3, 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)
|
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 ('9a6f12ba-e111-4e7a-b8a6-caa0982bd8a1', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'AÑO_NUEVO', 'VENCIDO', 1, '2024-01-01', '2024-01-01', '2024-01-01', 1, 0);
|
values ('9a6f12ba-e111-4e7a-b8a6-caa0982bd8a1', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'NEW_YEAR', 'EXPIRED', 1, '2024-01-01', '2024-01-01', '2024-01-01', 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)
|
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 ('9b6f12ba-e222-4e7a-b8a6-caa0982bd8b2', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'LUNES_CARNAVAL', 'APROBADO', 1, '2025-02-12', '2025-02-12', '2025-02-12', 1, 0);
|
values ('9b6f12ba-e222-4e7a-b8a6-caa0982bd8b2', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'MONDAY_CARNIVAL', 'APPROVED', 1, '2025-02-12', '2025-02-12', '2025-02-12', 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)
|
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 ('9c6f12ba-e333-4e7a-b8a6-caa0982bd8c3', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'MARTES_CARNAVAL', 'EN_REVISION', 1, '2025-02-13', '2025-02-13', '2025-02-13', 1, 0);
|
values ('9c6f12ba-e333-4e7a-b8a6-caa0982bd8c3', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'TUESDAY_CARNIVAL', 'UNDER_REVIEW', 1, '2025-02-13', '2025-02-13', '2025-02-13', 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)
|
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);
|
values ('9d6f12ba-e444-4e7a-b8a6-caa0982bd8d4', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'GOOD_FRIDAY', 'COMPLETED', 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)
|
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_ACTUAL', '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', 'VACATION_CURRENT_MANAGEMENT', 'APPROVED', 30, '2026-11-01', '2024-11-01', '2024-11-30', 30, 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)
|
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);
|
values ('8c653f2a-f9a3-4d67-b3b6-12ad98fe0983', 1, 'f6ab3c6d-7078-45f6-9b22-4e37637bfec6', 'LABOR_DAY', 'REQUESTED', 1, '2025-05-01', '2024-05-01', '2024-05-01', 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)
|
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 ('fb9d9d75-b2ab-4ea4-b8b3-0a8f89e5c123', 1, '2e2293b1-3f9a-4f3d-abc8-32639b0a5e15', 'DIA_DE_LA_INDEPENDENCIA', 'APROBADO', 1, '2024-08-06', '2024-08-06', '2024-08-06', 1, 0);
|
values ('fb9d9d75-b2ab-4ea4-b8b3-0a8f89e5c123', 1, '2e2293b1-3f9a-4f3d-abc8-32639b0a5e15', 'INDEPENDENCE_DAY', 'IN_USE', 1, '2025-08-06', '2024-08-06', '2024-08-06', 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)
|
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 ('6fdc47a8-127b-41c4-8d12-7fc12098ab12', 1, 'b2436b82-7b9f-4f0d-9463-f2c3173a45c3', 'DIA_DE_TODOS_LOS_DIFUNTOS', 'PENDIENTE', 1, '2025-12-01', '2025-11-02', '2025-11-02', 1, 0);
|
values ('6fdc47a8-127b-41c4-8d12-7fc12098ab12', 1, 'b2436b82-7b9f-4f0d-9463-f2c3173a45c3', 'ALL_SOULS_DAY', 'PENDING', 1, '2025-12-01', '2025-11-02', '2025-11-02', 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)
|
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 ('12ec8b74-983d-4a17-b67e-134f45ae904c', 1, '5c1a7b82-832d-4f24-8377-54b77b91b6a8', 'AÑO_NUEVO', 'PENDIENTE', 1, '2025-01-01', '2025-01-01', '2025-01-01', 1, 0);
|
values ('12ec8b74-983d-4a17-b67e-134f45ae904c', 1, '5c1a7b82-832d-4f24-8377-54b77b91b6a8', 'NEW_YEAR', 'PENDING', 1, '2025-01-01', '2025-01-01', '2025-01-01', 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)
|
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 ('89bc4b2a-943f-487c-a9f3-bacf78145e67', 1, 'cba3efb7-32bc-44be-9fdc-fc5e4f211254', 'LUNES_CARNAVAL', 'APROBADO', 1, '2024-02-12', '2024-02-12', '2024-02-12', 1, 0);
|
values ('89bc4b2a-943f-487c-a9f3-bacf78145e67', 1, 'cba3efb7-32bc-44be-9fdc-fc5e4f211254', 'MONDAY_CARNIVAL', 'APPROVED', 1, '2025-02-12', '2024-02-12', '2024-02-12', 1, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user