Vacaciones #79
@ -1,36 +1,35 @@
|
|||||||
package com.primefactorsolutions.model;
|
package com.primefactorsolutions.model;
|
||||||
|
|
||||||
public enum DocumentType {
|
public enum DocumentType {
|
||||||
All,
|
TODOS,
|
||||||
ID_CARD,
|
CARNET_DE_IDENTIDAD,
|
||||||
PAY_STUB,
|
RECIBOS_DE_PAGO,
|
||||||
PAY_SLIPS,
|
CONTRATO_DE_TRABAJO,
|
||||||
EMPLOYMENT_CONTRACT,
|
CERTIFICADO_DE_TRABAJO,
|
||||||
WORK_CERTIFICATES,
|
|
||||||
NDA,
|
NDA,
|
||||||
MEMORANDUMS,
|
MEMORÁNDUMS,
|
||||||
CONTRACT_APPROVAL_MTEPS,
|
APROBACIÓN_DE_CONTRATO_MTEPS,
|
||||||
BACKGROUND_CHECK_CERTIFICATE,
|
CERTIFICADO_DE_ANTECEDENTES,
|
||||||
PRE_EMPLOYMENT_EVALUATION,
|
EVALUACIÓN_PRE_EMPLEO,
|
||||||
INSURANCE_REGISTRATION_FORM,
|
FORMULARIO_DE_INSCRIPCIÓN_AL_SEGURO,
|
||||||
INSURANCE_CANCELLATION_FORM,
|
FORMULARIO_DE_CANCELACIÓN_DE_SEGURO,
|
||||||
PROFESSIONAL_DEGREE_1,
|
TÍTULO_PROFESIONAL_1,
|
||||||
PROFESSIONAL_CERTIFICATE_1,
|
CERTIFICACIÓN_PROFESIONAL_1,
|
||||||
PROFESSIONAL_DEGREE_2,
|
TÍTULO_PROFESIONAL_2,
|
||||||
PROFESSIONAL_CERTIFICATE_2,
|
CERTIFICACIÓN_PROFECIONAL_2,
|
||||||
PROFESSIONAL_DEGREE_3,
|
TÍTULO_PROFESIONAL_3,
|
||||||
PROFESSIONAL_CERTIFICATE_3,
|
CERTIFICACIÓN_PROFECIONAL_3,
|
||||||
GENERAL_LABOR_REGULATIONS,
|
NORMATIVA_LABORAL_GENERAL,
|
||||||
REMOTE_WORK_GUIDELINES,
|
NORMAS_DE_TRABAJO_REMOTO,
|
||||||
SAFETY_REGULATIONS,
|
NORMAS_DE_SEGURIDAD,
|
||||||
HUMAN_RESOURCES_GUIDELINES,
|
INSTRUCTIVOS_DE_RECURSOS_HUMANOS,
|
||||||
ADMINISTRATION_FUNCTIONS_MANUAL,
|
MANUAL_DE_FUNCIONES_DE_ADMINISTRACIÓN,
|
||||||
ENGINEERING_FUNCTIONS_MANUAL,
|
MANUAL_DE_FUNCIONES_DE_INGENIERÍA,
|
||||||
GENERAL_LABOR_LAW,
|
LEY_GENERAL_DEL_TRABAJO,
|
||||||
SUPREME_DECREE,
|
DECRETOS_SUPREMOS,
|
||||||
REGULATORY_RESOLUTION,
|
RESOLUCIONES_O_DISPOSICIONES_REGLAMENTARIAS,
|
||||||
COMPLEMENTARY_REGULATION,
|
NORMATIVA_COMPLEMENTARIA,
|
||||||
HEALTH_SAFETY_LAW,
|
LEY_GRAL_DE_HIGIENE_SALUD_SEGURIDAD_OCUPACIONAL_Y_BIENESTAR,
|
||||||
INTERNSHIP_RULES,
|
NORMATIVA_REGLAMENTARIA_PARA_DESARROLLO_DE_PASANTÍAS,
|
||||||
OTHER
|
OTROS
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,9 @@ import java.io.InputStream;
|
|||||||
@PageTitle("Document")
|
@PageTitle("Document")
|
||||||
@Route(value = "/documents/:documentId?/:action?", layout = MainLayout.class)
|
@Route(value = "/documents/:documentId?/:action?", layout = MainLayout.class)
|
||||||
public class DocumentView extends BeanValidationForm<Document> implements HasUrlParameter<String> {
|
public class DocumentView extends BeanValidationForm<Document> implements HasUrlParameter<String> {
|
||||||
private final TextField fileName = new TextField("Document Name");
|
private final TextField fileName = new TextField("Nombre del documento");
|
||||||
private final ComboBox<DocumentType> documentType = new ComboBox<>("Document Type");
|
private final ComboBox<DocumentType> documentType = new ComboBox<>("Tipo de documento");
|
||||||
private final ComboBox<Employee> employeeComboBox = new ComboBox<>("Employee");
|
private final ComboBox<Employee> employeeComboBox = new ComboBox<>("Empleado");
|
||||||
private final MemoryBuffer buffer = new MemoryBuffer();
|
private final MemoryBuffer buffer = new MemoryBuffer();
|
||||||
private final Upload uploadButton = new Upload(buffer);
|
private final Upload uploadButton = new Upload(buffer);
|
||||||
private final DocumentService documentService;
|
private final DocumentService documentService;
|
||||||
@ -68,19 +68,19 @@ public class DocumentView extends BeanValidationForm<Document> implements HasUrl
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected Button createSaveButton() {
|
protected Button createSaveButton() {
|
||||||
saveButton = new Button("Save");
|
saveButton = new Button("Guardar");
|
||||||
saveButton.addClickListener(event -> saveDocument());
|
saveButton.addClickListener(event -> saveDocument());
|
||||||
return saveButton;
|
return saveButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Button createCloseButton() {
|
protected Button createCloseButton() {
|
||||||
Button closeButton = new Button("Close");
|
Button closeButton = new Button("Salir");
|
||||||
closeButton.addClickListener(event -> closeForm());
|
closeButton.addClickListener(event -> closeForm());
|
||||||
return closeButton;
|
return closeButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Button createViewDocumentButton() {
|
protected Button createViewDocumentButton() {
|
||||||
viewDocumentButton = new Button("View Document");
|
viewDocumentButton = new Button("Ver documento");
|
||||||
viewDocumentButton.setEnabled(false);
|
viewDocumentButton.setEnabled(false);
|
||||||
viewDocumentButton.addClickListener(event -> viewDocument());
|
viewDocumentButton.addClickListener(event -> viewDocument());
|
||||||
return viewDocumentButton;
|
return viewDocumentButton;
|
||||||
@ -130,7 +130,7 @@ public class DocumentView extends BeanValidationForm<Document> implements HasUrl
|
|||||||
ui.getPage().open(registration.getResourceUri().toString());
|
ui.getPage().open(registration.getResourceUri().toString());
|
||||||
});
|
});
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Notification.show("Error reading file.");
|
Notification.show("Error al leer el archivo.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,10 +148,10 @@ public class DocumentView extends BeanValidationForm<Document> implements HasUrl
|
|||||||
setDocumentCreator(document);
|
setDocumentCreator(document);
|
||||||
|
|
||||||
documentService.saveDocument(document);
|
documentService.saveDocument(document);
|
||||||
Notification.show("File saved successfully.");
|
Notification.show("Archivo guardado correctamente.");
|
||||||
clearForm();
|
clearForm();
|
||||||
} else {
|
} else {
|
||||||
Notification.show("Save failed: Please complete all fields and upload a file.");
|
Notification.show("Error al guardar: Por favor, complete todos los campos y cargue un archivo.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ public class DocumentView extends BeanValidationForm<Document> implements HasUrl
|
|||||||
try {
|
try {
|
||||||
return buffer.getInputStream().readAllBytes();
|
return buffer.getInputStream().readAllBytes();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Notification.show("Error reading file data.");
|
Notification.show("Error al leer los datos del archivo.");
|
||||||
return new byte[0];
|
return new byte[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,13 +220,13 @@ public class DocumentView extends BeanValidationForm<Document> implements HasUrl
|
|||||||
uploadButton.setAcceptedFileTypes(".pdf");
|
uploadButton.setAcceptedFileTypes(".pdf");
|
||||||
uploadButton.addSucceededListener(event -> {
|
uploadButton.addSucceededListener(event -> {
|
||||||
fileUploaded = true;
|
fileUploaded = true;
|
||||||
Notification.show("File uploaded successfully.");
|
Notification.show("Archivo cargado correctamente.");
|
||||||
viewDocumentButton.setEnabled(true);
|
viewDocumentButton.setEnabled(true);
|
||||||
updateSaveButtonState();
|
updateSaveButtonState();
|
||||||
});
|
});
|
||||||
uploadButton.getElement().addEventListener("file-remove", event -> {
|
uploadButton.getElement().addEventListener("file-remove", event -> {
|
||||||
fileUploaded = false;
|
fileUploaded = false;
|
||||||
Notification.show("File removed.");
|
Notification.show("Archivo eliminado.");
|
||||||
viewDocumentButton.setEnabled(false);
|
viewDocumentButton.setEnabled(false);
|
||||||
updateSaveButtonState();
|
updateSaveButtonState();
|
||||||
});
|
});
|
||||||
|
@ -47,7 +47,7 @@ public class DocumentsListView extends BaseView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initializeView() {
|
private void initializeView() {
|
||||||
getCurrentPageLayout().add(createActionButton("Add Document", this::navigateToAddDocumentView));
|
getCurrentPageLayout().add(createActionButton("Añadir documento", this::navigateToAddDocumentView));
|
||||||
|
|
||||||
final HorizontalLayout hl = new HorizontalLayout();
|
final HorizontalLayout hl = new HorizontalLayout();
|
||||||
hl.add(createDocumentTypeFilter());
|
hl.add(createDocumentTypeFilter());
|
||||||
@ -61,7 +61,10 @@ public class DocumentsListView extends BaseView {
|
|||||||
|
|
||||||
private void configureDocumentGrid() {
|
private void configureDocumentGrid() {
|
||||||
documentGrid.setColumns("fileName", "documentType", "creator");
|
documentGrid.setColumns("fileName", "documentType", "creator");
|
||||||
documentGrid.addComponentColumn(this::createEmployeeSpan).setHeader("Employee");
|
documentGrid.getColumnByKey("fileName").setHeader("Nombre archivo");
|
||||||
|
documentGrid.getColumnByKey("documentType").setHeader("Tipo");
|
||||||
|
documentGrid.getColumnByKey("creator").setHeader("Creador");
|
||||||
|
documentGrid.addComponentColumn(this::createEmployeeSpan).setHeader("Empleado");
|
||||||
addActionColumns();
|
addActionColumns();
|
||||||
configurePagination();
|
configurePagination();
|
||||||
}
|
}
|
||||||
@ -73,9 +76,9 @@ public class DocumentsListView extends BaseView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addActionColumns() {
|
private void addActionColumns() {
|
||||||
addDocumentActionColumn("View", this::navigateToDocumentView);
|
addDocumentActionColumn("Ver", this::navigateToDocumentView);
|
||||||
addDocumentActionColumn("Edit", this::navigateToEditDocumentView);
|
addDocumentActionColumn("Editar", this::navigateToEditDocumentView);
|
||||||
addDocumentActionColumn("Download", this::downloadDocument);
|
addDocumentActionColumn("Descargar", this::downloadDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addDocumentActionColumn(final String label, final DocumentActionHandler handler) {
|
private void addDocumentActionColumn(final String label, final DocumentActionHandler handler) {
|
||||||
@ -89,7 +92,7 @@ public class DocumentsListView extends BaseView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ComboBox<DocumentType> createDocumentTypeFilter() {
|
private ComboBox<DocumentType> createDocumentTypeFilter() {
|
||||||
documentTypeFilter = new ComboBox<>("Document Type");
|
documentTypeFilter = new ComboBox<>("Tipo de documento");
|
||||||
documentTypeFilter.setItems(DocumentType.values());
|
documentTypeFilter.setItems(DocumentType.values());
|
||||||
documentTypeFilter.setValue(DocumentType.values()[0]);
|
documentTypeFilter.setValue(DocumentType.values()[0]);
|
||||||
documentTypeFilter.addValueChangeListener(event -> {
|
documentTypeFilter.addValueChangeListener(event -> {
|
||||||
@ -99,7 +102,7 @@ public class DocumentsListView extends BaseView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ComboBox<Employee> createEmployeeFilter() {
|
private ComboBox<Employee> createEmployeeFilter() {
|
||||||
employeeFilter = new ComboBox<>("Employee");
|
employeeFilter = new ComboBox<>("Empleado");
|
||||||
List<Employee> employees = employeeService.findAllEmployees();
|
List<Employee> employees = employeeService.findAllEmployees();
|
||||||
employees.addFirst(createAllEmployeesOption());
|
employees.addFirst(createAllEmployeesOption());
|
||||||
employeeFilter.setItems(employees);
|
employeeFilter.setItems(employees);
|
||||||
@ -113,12 +116,12 @@ public class DocumentsListView extends BaseView {
|
|||||||
|
|
||||||
private Employee createAllEmployeesOption() {
|
private Employee createAllEmployeesOption() {
|
||||||
Employee allEmployeesOption = new Employee();
|
Employee allEmployeesOption = new Employee();
|
||||||
allEmployeesOption.setFirstName("All");
|
allEmployeesOption.setFirstName("TODOS");
|
||||||
return allEmployeesOption;
|
return allEmployeesOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getEmployeeLabel(final Employee employee) {
|
private String getEmployeeLabel(final Employee employee) {
|
||||||
return employee.getFirstName().equals("All") ? "All" : employee.getFirstName() + " " + employee.getLastName();
|
return employee.getFirstName().equals("TODOS") ? "TODOS" : employee.getFirstName() + " " + employee.getLastName();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void navigateToEditDocumentView(final Document document) {
|
private void navigateToEditDocumentView(final Document document) {
|
||||||
|
@ -246,7 +246,8 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
|||||||
private double calculateHolidayUtilizedDays(final int year) {
|
private double calculateHolidayUtilizedDays(final int year) {
|
||||||
return requests.stream()
|
return requests.stream()
|
||||||
.filter(this::verificationIsHoliday)
|
.filter(this::verificationIsHoliday)
|
||||||
.filter(req -> req.getState() == TimeOffRequestStatus.TOMADO || req.getState() == TimeOffRequestStatus.APROBADO)
|
.filter(req -> req.getState() == TimeOffRequestStatus.TOMADO
|
||||||
|
|| req.getState() == TimeOffRequestStatus.APROBADO)
|
||||||
.filter(req -> getStartDateYear(req) == year)
|
.filter(req -> getStartDateYear(req) == year)
|
||||||
.mapToDouble(TimeOffRequest::getDaysToBeTake)
|
.mapToDouble(TimeOffRequest::getDaysToBeTake)
|
||||||
.sum();
|
.sum();
|
||||||
@ -255,7 +256,8 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
|||||||
private double calculatePersonalDaysUtilized(final boolean isMale, final int year) {
|
private double calculatePersonalDaysUtilized(final boolean isMale, final int year) {
|
||||||
return requests.stream()
|
return requests.stream()
|
||||||
.filter(req -> !verificationIsHoliday(req))
|
.filter(req -> !verificationIsHoliday(req))
|
||||||
.filter(req -> req.getState() == TimeOffRequestStatus.TOMADO || req.getState() == TimeOffRequestStatus.APROBADO)
|
.filter(req -> req.getState() == TimeOffRequestStatus.TOMADO
|
||||||
|
|| req.getState() == TimeOffRequestStatus.APROBADO)
|
||||||
.filter(req -> !getStandardExclusions().contains(req.getCategory()))
|
.filter(req -> !getStandardExclusions().contains(req.getCategory()))
|
||||||
.filter(req -> !(isMale && getMaleSpecificExclusions().contains(req.getCategory())))
|
.filter(req -> !(isMale && getMaleSpecificExclusions().contains(req.getCategory())))
|
||||||
.filter(req -> !req.getCategory().name().startsWith("VACACION"))
|
.filter(req -> !req.getCategory().name().startsWith("VACACION"))
|
||||||
|
@ -94,7 +94,8 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
});
|
});
|
||||||
startDatePicker.addValueChangeListener(event -> {
|
startDatePicker.addValueChangeListener(event -> {
|
||||||
LocalDate selectedDate = event.getValue();
|
LocalDate selectedDate = event.getValue();
|
||||||
if (selectedDate != null && (selectedDate.getDayOfWeek().getValue() == 6 || selectedDate.getDayOfWeek().getValue() == 7)) {
|
if (selectedDate != null && (selectedDate.getDayOfWeek().getValue() == 6
|
||||||
|
|| selectedDate.getDayOfWeek().getValue() == 7)) {
|
||||||
startDatePicker.setValue(selectedDate.minusDays(1));
|
startDatePicker.setValue(selectedDate.minusDays(1));
|
||||||
}
|
}
|
||||||
updateDatePickerMinValues();
|
updateDatePickerMinValues();
|
||||||
@ -104,7 +105,8 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
endDatePicker.setMin(startDatePicker.getValue());
|
endDatePicker.setMin(startDatePicker.getValue());
|
||||||
}
|
}
|
||||||
LocalDate selectedDate = event.getValue();
|
LocalDate selectedDate = event.getValue();
|
||||||
if (selectedDate != null && (selectedDate.getDayOfWeek().getValue() == 6 || selectedDate.getDayOfWeek().getValue() == 7)) {
|
if (selectedDate != null && (selectedDate.getDayOfWeek().getValue() == 6
|
||||||
|
|| selectedDate.getDayOfWeek().getValue() == 7)) {
|
||||||
endDatePicker.setValue(selectedDate.minusDays(1));
|
endDatePicker.setValue(selectedDate.minusDays(1));
|
||||||
}
|
}
|
||||||
calculateDays();
|
calculateDays();
|
||||||
@ -424,7 +426,7 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
return startDate != null && endDate != null;
|
return startDate != null && endDate != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long countWorkDaysBetween(LocalDate startDate, LocalDate endDate) {
|
private long countWorkDaysBetween(final LocalDate startDate, final LocalDate endDate) {
|
||||||
return startDate.datesUntil(endDate.plusDays(1))
|
return startDate.datesUntil(endDate.plusDays(1))
|
||||||
.filter(date -> date.getDayOfWeek() != DayOfWeek.SATURDAY && date.getDayOfWeek() != DayOfWeek.SUNDAY)
|
.filter(date -> date.getDayOfWeek() != DayOfWeek.SATURDAY && date.getDayOfWeek() != DayOfWeek.SUNDAY)
|
||||||
.count();
|
.count();
|
||||||
@ -506,7 +508,9 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
Notification.show("Solicitud guardada correctamente.");
|
Notification.show("Solicitud guardada correctamente.");
|
||||||
closeForm();
|
closeForm();
|
||||||
} else {
|
} else {
|
||||||
Notification.show("La fecha de inicio debe encontrarse dentro del rango de 15 días a 3 meses de anticipación.");
|
Notification.show(
|
||||||
|
"La fecha de inicio debe encontrarse dentro del rango de 15 días a 3 meses de anticipación."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +217,8 @@ public class RequestsListView extends BaseView {
|
|||||||
int currentYear = LocalDate.now().getYear();
|
int currentYear = LocalDate.now().getYear();
|
||||||
return employeeRequests.stream()
|
return employeeRequests.stream()
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.filter(request -> request.getState() == TimeOffRequestStatus.APROBADO || request.getState() == TimeOffRequestStatus.TOMADO)
|
.filter(request -> request.getState() == TimeOffRequestStatus.APROBADO
|
||||||
|
|| request.getState() == TimeOffRequestStatus.TOMADO)
|
||||||
.filter(request -> request.getCategory() != TimeOffRequestType.PERMISOS_DE_SALUD)
|
.filter(request -> request.getCategory() != TimeOffRequestType.PERMISOS_DE_SALUD)
|
||||||
.filter(request -> request.getCategory() != TimeOffRequestType.VACACION_GESTION_ACTUAL)
|
.filter(request -> request.getCategory() != TimeOffRequestType.VACACION_GESTION_ACTUAL)
|
||||||
.filter(request -> request.getCategory() != TimeOffRequestType.VACACION_GESTION_ANTERIOR)
|
.filter(request -> request.getCategory() != TimeOffRequestType.VACACION_GESTION_ANTERIOR)
|
||||||
|
Loading…
Reference in New Issue
Block a user