Vacaciones #64
@ -1,29 +1,29 @@
|
|||||||
package com.primefactorsolutions.model;
|
package com.primefactorsolutions.model;
|
||||||
|
|
||||||
public enum TimeOffRequestType {
|
public enum TimeOffRequestType {
|
||||||
ALL,
|
TODOS,
|
||||||
NEW_YEAR,
|
AÑO_NUEVO,
|
||||||
MONDAY_CARNIVAL,
|
LUNES_CARNAVAL,
|
||||||
TUESDAY_CARNIVAL,
|
MARTES_CARNAVAL,
|
||||||
GOOD_FRIDAY,
|
VIERNES_SANTO,
|
||||||
LABOR_DAY,
|
DIA_DEL_TRABAJADOR,
|
||||||
INDEPENDENCE_DAY,
|
DIA_DE_LA_INDEPENDENCIA,
|
||||||
CHRISTMAS,
|
NAVIDAD,
|
||||||
PRURINATIONAL_STATE_DAY,
|
DIA_DEL_ESTADO_PLURINACIONAL,
|
||||||
CORPUS_CHRISTI,
|
CORPUS_CHRISTI,
|
||||||
ANDEAN_NEW_YEAR,
|
AÑO_NUEVO_ANDINO,
|
||||||
DEPARTMENTAL_ANNIVERSARY,
|
ANIVERSARIO_DEPARTAMENTAL,
|
||||||
ALL_SOULS_DAY,
|
DIA_DE_TODOS_LOS_DIFUNTOS,
|
||||||
|
|
||||||
BIRTHDAY,
|
CUMPLEAÑOS,
|
||||||
MATERNITY,
|
MATERNIDAD,
|
||||||
PATERNITY,
|
PATERNIDAD,
|
||||||
MARRIAGE,
|
MATRIMONIO,
|
||||||
FATHERS_DAY,
|
DIA_DEL_PADRE,
|
||||||
MOTHERS_DAY,
|
DIA_DE_LA_MADRE,
|
||||||
INTERNATIONAL_WOMENS_DAY,
|
DIA_DE_LA_MUJER_INTERNACIONAL,
|
||||||
NATIONAL_WOMENS_DAY,
|
DIA_DE_LA_MUJER_NACIONAL,
|
||||||
HEALTH_PERMIT,
|
PERMISOS_DE_SALUD,
|
||||||
VACATION_CURRENT_MANAGEMENT,
|
VACACION_GESTION_ACTUAL,
|
||||||
VACATION_PREVIOUS_MANAGEMENT,
|
VACACION_GESTION_ANTERIOR,
|
||||||
}
|
}
|
||||||
|
@ -145,9 +145,9 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
.max(Comparator.comparing(TimeOffRequest::getStartDate))
|
.max(Comparator.comparing(TimeOffRequest::getStartDate))
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
||||||
if (category == TimeOffRequestType.HEALTH_PERMIT
|
if (category == TimeOffRequestType.PERMISOS_DE_SALUD
|
||||||
|| category == TimeOffRequestType.VACATION_CURRENT_MANAGEMENT
|
|| category == TimeOffRequestType.VACACION_GESTION_ACTUAL
|
||||||
|| category == TimeOffRequestType.VACATION_PREVIOUS_MANAGEMENT) {
|
|| category == TimeOffRequestType.VACACION_GESTION_ANTERIOR) {
|
||||||
return latestRequest.getState() == TimeOffRequestStatus.VENCIDO
|
return latestRequest.getState() == TimeOffRequestStatus.VENCIDO
|
||||||
|| (latestRequest.getState() == TimeOffRequestStatus.TOMADO && latestRequest.getDaysBalance() > 0);
|
|| (latestRequest.getState() == TimeOffRequestStatus.TOMADO && latestRequest.getDaysBalance() > 0);
|
||||||
} else {
|
} else {
|
||||||
@ -157,13 +157,13 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
|
|
||||||
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.MATERNITY
|
return category != TimeOffRequestType.MATERNIDAD
|
||||||
&& category != TimeOffRequestType.MOTHERS_DAY
|
&& category != TimeOffRequestType.DIA_DE_LA_MADRE
|
||||||
&& category != TimeOffRequestType.INTERNATIONAL_WOMENS_DAY
|
&& category != TimeOffRequestType.DIA_DE_LA_MUJER_INTERNACIONAL
|
||||||
&& category != TimeOffRequestType.NATIONAL_WOMENS_DAY;
|
&& category != TimeOffRequestType.DIA_DE_LA_MUJER_NACIONAL;
|
||||||
} else {
|
} else {
|
||||||
return category != TimeOffRequestType.FATHERS_DAY
|
return category != TimeOffRequestType.DIA_DEL_PADRE
|
||||||
&& category != TimeOffRequestType.PATERNITY;
|
&& category != TimeOffRequestType.PATERNIDAD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
} else if (requestWithBalance.getState() == TimeOffRequestStatus.VENCIDO) {
|
} else if (requestWithBalance.getState() == TimeOffRequestStatus.VENCIDO) {
|
||||||
availableDaysField.setValue(vacation.getDuration());
|
availableDaysField.setValue(vacation.getDuration());
|
||||||
}
|
}
|
||||||
} else if (vacation.getCategory() == TimeOffRequestType.VACATION_CURRENT_MANAGEMENT) {
|
} else if (vacation.getCategory() == TimeOffRequestType.VACACION_GESTION_ACTUAL) {
|
||||||
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);
|
||||||
@ -244,13 +244,13 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
vacation.getDayOfMonth().intValue());
|
vacation.getDayOfMonth().intValue());
|
||||||
endDate = startDate.plusDays(vacation.getExpiration().intValue() - 1);
|
endDate = startDate.plusDays(vacation.getExpiration().intValue() - 1);
|
||||||
} else {
|
} else {
|
||||||
if (vacation.getCategory() == TimeOffRequestType.BIRTHDAY && employee.getBirthday() != null) {
|
if (vacation.getCategory() == TimeOffRequestType.CUMPLEAÑOS && employee.getBirthday() != null) {
|
||||||
startDate = LocalDate.of(
|
startDate = LocalDate.of(
|
||||||
startYear,
|
startYear,
|
||||||
employee.getBirthday().getMonth(),
|
employee.getBirthday().getMonth(),
|
||||||
employee.getBirthday().getDayOfMonth());
|
employee.getBirthday().getDayOfMonth());
|
||||||
endDate = startDate.plusDays(vacation.getExpiration().intValue() - 1);
|
endDate = startDate.plusDays(vacation.getExpiration().intValue() - 1);
|
||||||
} else if (vacation.getCategory() == TimeOffRequestType.HEALTH_PERMIT) {
|
} else if (vacation.getCategory() == TimeOffRequestType.PERMISOS_DE_SALUD) {
|
||||||
startDate = LocalDate.now();
|
startDate = LocalDate.now();
|
||||||
endDate = LocalDate.of(startYear, 12, 31);
|
endDate = LocalDate.of(startYear, 12, 31);
|
||||||
} else {
|
} else {
|
||||||
@ -260,7 +260,7 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
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.HEALTH_PERMIT) {
|
|| vacation.getCategory() == TimeOffRequestType.PERMISOS_DE_SALUD) {
|
||||||
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);
|
||||||
@ -291,7 +291,7 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
|
|
||||||
if (startDate != null && endDate != null) {
|
if (startDate != null && endDate != null) {
|
||||||
double daysToBeTaken = java.time.temporal.ChronoUnit.DAYS.between(startDate, endDate) + 1;
|
double daysToBeTaken = java.time.temporal.ChronoUnit.DAYS.between(startDate, endDate) + 1;
|
||||||
if (vacation.getCategory() == TimeOffRequestType.HEALTH_PERMIT || vacation.getDuration() == 0.5) {
|
if (vacation.getCategory() == TimeOffRequestType.PERMISOS_DE_SALUD || vacation.getDuration() == 0.5) {
|
||||||
daysToBeTakenField.setValue(0.5);
|
daysToBeTakenField.setValue(0.5);
|
||||||
} else {
|
} else {
|
||||||
daysToBeTakenField.setValue(daysToBeTaken);
|
daysToBeTakenField.setValue(daysToBeTaken);
|
||||||
@ -335,7 +335,7 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
List<TimeOffRequest> existingRequests =
|
List<TimeOffRequest> existingRequests =
|
||||||
requestService.findByEmployeeAndCategory(employee.getId(), request.getCategory());
|
requestService.findByEmployeeAndCategory(employee.getId(), request.getCategory());
|
||||||
|
|
||||||
int maxRequests = request.getCategory() == TimeOffRequestType.HEALTH_PERMIT ? 4 : 2;
|
int maxRequests = request.getCategory() == TimeOffRequestType.PERMISOS_DE_SALUD ? 4 : 2;
|
||||||
|
|
||||||
if (existingRequests.size() >= maxRequests) {
|
if (existingRequests.size() >= maxRequests) {
|
||||||
existingRequests.stream()
|
existingRequests.stream()
|
||||||
@ -355,8 +355,8 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
List<TimeOffRequest> requests = requestService.findByEmployeeAndCategory(
|
List<TimeOffRequest> requests = requestService.findByEmployeeAndCategory(
|
||||||
newRequest.getEmployee().getId(), newRequest.getCategory());
|
newRequest.getEmployee().getId(), newRequest.getCategory());
|
||||||
|
|
||||||
if (vacation.getCategory() == TimeOffRequestType.HEALTH_PERMIT
|
if (vacation.getCategory() == TimeOffRequestType.PERMISOS_DE_SALUD
|
||||||
&& vacation.getCategory() == TimeOffRequestType.VACATION_CURRENT_MANAGEMENT) {
|
&& vacation.getCategory() == TimeOffRequestType.VACACION_GESTION_ACTUAL) {
|
||||||
for (TimeOffRequest request : requests) {
|
for (TimeOffRequest request : requests) {
|
||||||
double newBalance = request.getDaysBalance() - newRequest.getDaysToBeTake();
|
double newBalance = request.getDaysBalance() - newRequest.getDaysToBeTake();
|
||||||
request.setDaysBalance(newBalance);
|
request.setDaysBalance(newBalance);
|
||||||
|
@ -170,18 +170,18 @@ public class RequestsListView extends Main {
|
|||||||
|
|
||||||
private Set<TimeOffRequestType> getExcludedCategories() {
|
private Set<TimeOffRequestType> getExcludedCategories() {
|
||||||
return Set.of(
|
return Set.of(
|
||||||
TimeOffRequestType.MATERNITY,
|
TimeOffRequestType.MATERNIDAD,
|
||||||
TimeOffRequestType.PATERNITY,
|
TimeOffRequestType.PATERNIDAD,
|
||||||
TimeOffRequestType.MARRIAGE,
|
TimeOffRequestType.MATRIMONIO,
|
||||||
TimeOffRequestType.FATHERS_DAY,
|
TimeOffRequestType.DIA_DEL_PADRE,
|
||||||
TimeOffRequestType.MOTHERS_DAY
|
TimeOffRequestType.DIA_DE_LA_MADRE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<TimeOffRequestType> getGenderSpecificExclusions() {
|
private Set<TimeOffRequestType> getGenderSpecificExclusions() {
|
||||||
return Set.of(
|
return Set.of(
|
||||||
TimeOffRequestType.INTERNATIONAL_WOMENS_DAY,
|
TimeOffRequestType.DIA_DE_LA_MUJER_INTERNACIONAL,
|
||||||
TimeOffRequestType.NATIONAL_WOMENS_DAY
|
TimeOffRequestType.DIA_DE_LA_MUJER_NACIONAL
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user