Correccion registro solicitud vacaciones actual y anterior
All checks were successful
PR Builder / Build-PR (pull_request) Successful in 0s
All checks were successful
PR Builder / Build-PR (pull_request) Successful in 0s
This commit is contained in:
parent
88e80a7dcc
commit
9fdf1c08b5
@ -19,6 +19,8 @@ public enum TimeOffRequestType {
|
|||||||
MATERNIDAD,
|
MATERNIDAD,
|
||||||
PATERNIDAD,
|
PATERNIDAD,
|
||||||
MATRIMONIO,
|
MATRIMONIO,
|
||||||
|
DUELO_1ER_GRADO,
|
||||||
|
DUELO_2ER_GRADO,
|
||||||
DIA_DEL_PADRE,
|
DIA_DEL_PADRE,
|
||||||
DIA_DE_LA_MADRE,
|
DIA_DE_LA_MADRE,
|
||||||
DIA_DE_LA_MUJER_INTERNACIONAL,
|
DIA_DE_LA_MUJER_INTERNACIONAL,
|
||||||
|
@ -29,7 +29,6 @@ import com.vaadin.flow.router.*;
|
|||||||
import com.vaadin.flow.server.StreamResource;
|
import com.vaadin.flow.server.StreamResource;
|
||||||
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.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.vaadin.firitin.components.datepicker.VDatePicker;
|
import org.vaadin.firitin.components.datepicker.VDatePicker;
|
||||||
import org.vaadin.firitin.form.BeanValidationForm;
|
import org.vaadin.firitin.form.BeanValidationForm;
|
||||||
|
@ -142,7 +142,7 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
|||||||
return new HorizontalLayout(viewButton, editButton, closeButton);
|
return new HorizontalLayout(viewButton, editButton, closeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Button createButton(String caption, Runnable action) {
|
private Button createButton(final String caption, final Runnable action) {
|
||||||
return new Button(caption, event -> {
|
return new Button(caption, event -> {
|
||||||
if (request != null) {
|
if (request != null) {
|
||||||
action.run();
|
action.run();
|
||||||
|
@ -393,9 +393,14 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TimeOffRequest request = prepareRequest();
|
TimeOffRequest request = prepareRequest();
|
||||||
handleExistingRequests(request);
|
|
||||||
requestService.saveTimeOffRequest(request);
|
|
||||||
|
|
||||||
|
if (request.getCategory() == TimeOffRequestType.VACACION_GESTION_ACTUAL) {
|
||||||
|
handleVacationRequest(request);
|
||||||
|
} else {
|
||||||
|
handleExistingRequests(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
requestService.saveTimeOffRequest(request);
|
||||||
Notification.show("Solicitud guardada correctamente.");
|
Notification.show("Solicitud guardada correctamente.");
|
||||||
closeForm();
|
closeForm();
|
||||||
}
|
}
|
||||||
@ -422,6 +427,15 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleVacationRequest(final TimeOffRequest request) {
|
||||||
|
List<TimeOffRequest> existingRequests = requestService.findByEmployeeAndCategory(employee.getId(), TimeOffRequestType.VACACION_GESTION_ACTUAL);
|
||||||
|
if (!existingRequests.isEmpty()) {
|
||||||
|
TimeOffRequest existingRequest = existingRequests.getFirst();
|
||||||
|
existingRequest.setCategory(TimeOffRequestType.VACACION_GESTION_ANTERIOR);
|
||||||
|
requestService.saveTimeOffRequest(existingRequest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean validateForm() {
|
private boolean validateForm() {
|
||||||
return employeeComboBox.getValue() != null
|
return employeeComboBox.getValue() != null
|
||||||
&& categoryComboBox.getValue() != null
|
&& categoryComboBox.getValue() != null
|
||||||
|
@ -174,6 +174,8 @@ public class RequestsListView extends Main {
|
|||||||
TimeOffRequestType.MATERNIDAD,
|
TimeOffRequestType.MATERNIDAD,
|
||||||
TimeOffRequestType.PATERNIDAD,
|
TimeOffRequestType.PATERNIDAD,
|
||||||
TimeOffRequestType.MATRIMONIO,
|
TimeOffRequestType.MATRIMONIO,
|
||||||
|
TimeOffRequestType.DUELO_1ER_GRADO,
|
||||||
|
TimeOffRequestType.DUELO_2ER_GRADO,
|
||||||
TimeOffRequestType.DIA_DEL_PADRE,
|
TimeOffRequestType.DIA_DEL_PADRE,
|
||||||
TimeOffRequestType.DIA_DE_LA_MADRE
|
TimeOffRequestType.DIA_DE_LA_MADRE
|
||||||
);
|
);
|
||||||
|
@ -36,13 +36,15 @@ INSERT INTO vacation (id, version, category, duration, expiration, type) VALUES
|
|||||||
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, 'MATERNIDAD', 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, 'PATERNIDAD', 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, 'MATRIMONIO', 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, 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-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-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-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-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-42661417401c', 1, 'DIA_DE_LA_MUJER_INTERNACIONAL', 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-42661417401c', 1, 'DIA_DE_LA_MUJER_INTERNACIONAL', 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-42661417401d', 1, 'DIA_DE_LA_MUJER_NACIONAL', 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-42661417401d', 1, 'DIA_DE_LA_MUJER_NACIONAL', 10, 11, 0.5, 30, '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, duration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401e', 1, 'PERMISOS_DE_SALUD', 2, 'OTHER');
|
||||||
INSERT INTO vacation (id, version, category, expiration, type) VALUES ('490e5fbe-895b-42f8-b914-95437f7b39c0', 1, 'VACACION_GESTION_ACTUAL', 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', 730, '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');
|
||||||
@ -76,7 +78,7 @@ values ('9c6f12ba-e333-4e7a-b8a6-caa0982bd8c3', 1, '5c6f11fe-c341-4be7-a9a6-bba0
|
|||||||
insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
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', 'VIERNES_SANTO', 'APROBADO', 1, '2024-03-29', '2024-03-29', '2024-03-29', 1, 0);
|
||||||
insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
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, '2026-11-01', '2024-11-01', '2024-11-30', 30, 0);
|
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);
|
||||||
|
|
||||||
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', 'DIA_DEL_TRABAJADOR', 'APROBADO', 1, '2024-05-01', '2024-05-01', '2024-05-01', 1, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user