Compare commits
No commits in common. "6024b3fdd049a5036d33e19663addc4a26c3131e" and "f7e7dea7cb3bb235389b894c997e7bb6db414d14" have entirely different histories.
6024b3fdd0
...
f7e7dea7cb
@ -21,8 +21,6 @@ import jakarta.annotation.security.PermitAll;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.vaadin.firitin.components.grid.PagingGrid;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@ -111,7 +109,10 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
||||
.filter(this::verificationIsHoliday)
|
||||
.mapToDouble(TimeOffRequest::getAvailableDays)
|
||||
.sum();
|
||||
double totalVacations = calculateVacationDays(employeeService.getEmployee(employeeId));
|
||||
double totalVacations = requests.stream()
|
||||
.filter(req -> req.getCategory().toString().startsWith("VACACION"))
|
||||
.mapToDouble(TimeOffRequest::getAvailableDays)
|
||||
.sum();
|
||||
double totalPersonalDays = requests.stream()
|
||||
.filter(req -> !verificationIsHoliday(req))
|
||||
.filter(req -> !req.getCategory().name().startsWith("VACACION"))
|
||||
@ -128,45 +129,6 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
||||
);
|
||||
}
|
||||
|
||||
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, 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) {
|
||||
Vacation vacation = vacationService.findVacationByCategory(request.getCategory());
|
||||
return vacation.getType() != Vacation.Type.OTHER;
|
||||
|
@ -205,7 +205,8 @@ public class RequestsListView extends Main {
|
||||
boolean hasAnniversaryPassed = entryDate.getMonthValue() < today.getMonthValue()
|
||||
|| (entryDate.getMonthValue() == today.getMonthValue() && entryDate.getDayOfMonth() <= today.getDayOfMonth());
|
||||
|
||||
LocalDate previousVacationYearDate, currentVacationYearDate;
|
||||
LocalDate previousVacationYearDate;
|
||||
LocalDate currentVacationYearDate;
|
||||
|
||||
if (hasAnniversaryPassed) {
|
||||
previousVacationYearDate = LocalDate.of(today.getYear() - 1, entryDate.getMonth(), entryDate.getDayOfMonth());
|
||||
|
Loading…
Reference in New Issue
Block a user