Repository: urlaubsverwaltung/urlaubsverwaltung (java)

Issue:
Abwesenheitsstatistik zeigt trotzdem halbe Tage
Hi,

wir haben Heiligabend und Silvester auf "ganztägig" gesetzt:

![grafik](https://github.com/urlaubsverwaltung/urlaubsverwaltung/assets/19844709/f5b3e93c-a66e-4102-93db-bcae88b5e637)


Die Abwesenheitsstatistik zeigt trotzdem:

![grafik](https://github.com/urlaubsverwaltung/urlaubsverwaltung/assets/19844709/e3da68c5-26cf-47b0-82ae-3850623eb9c7)

Der CSV Export ist auch davon betroffen.

Vielen Dank!


Pull request description:
Public holidays can have a daylength of zero...
... if they are configure via public holidays christmas eve and new years

closes #4496 

<!--

Thanks for contributing to the Urlaubsverwaltung.
Please review the following notes before submitting you pull request.

Please look for other issues or pull requests which already work on this topic. Is somebody already on it? Do you need to synchronize?

# Security Vulnerabilities

🛑 STOP! 🛑 If your contribution fixes a security vulnerability, please do not submit it.
Instead, please open a report of a security vulnerability via
[Report a security vulnerability](https://github.com/urlaubsverwaltung/urlaubsverwaltung/security/advisories/new)


# Describing Your Changes

If, having reviewed the notes above, you're ready to submit your pull request, please
provide a brief description of the proposed changes.

If they:
 🐞 fix a bug, please describe the broken behaviour and how the changes fix it.
    Please label with 'type: bug' and 'status: new'
    
 🎁 make an enhancement, please describe the new functionality and why you believe it's useful.
    Please label with 'type: enhancement' and 'status: new'
 
If your pull request relates to any existing issues,
please reference them by using the issue number prefixed with #.

-->


Patch:
diff --git a/src/main/java/org/synyx/urlaubsverwaltung/workingtime/WorkingTimeCalendarServiceImpl.java b/src/main/java/org/synyx/urlaubsverwaltung/workingtime/WorkingTimeCalendarServiceImpl.java
index 2c8817747..be71fb4e1 100644
--- a/src/main/java/org/synyx/urlaubsverwaltung/workingtime/WorkingTimeCalendarServiceImpl.java
+++ b/src/main/java/org/synyx/urlaubsverwaltung/workingtime/WorkingTimeCalendarServiceImpl.java
@@ -119,11 +119,16 @@ class WorkingTimeCalendarServiceImpl implements WorkingTimeCalendarService {
                         morningType = WorkingTimeCalendarEntryType.PUBLIC_HOLIDAY;
                         noon = DayLength.NOON;
                         noonType = WorkingTimeCalendarEntryType.WORKDAY;
-                    } else {
+                    } else if (publicHoliday.dayLength().isNoon()) {
                         morning = DayLength.MORNING;
                         morningType = WorkingTimeCalendarEntryType.WORKDAY;
                         noon = DayLength.ZERO;
                         noonType = WorkingTimeCalendarEntryType.PUBLIC_HOLIDAY;
+                    } else {
+                        morning = DayLength.MORNING;
+                        morningType = WorkingTimeCalendarEntryType.WORKDAY;
+                        noon = DayLength.NOON;
+                        noonType = WorkingTimeCalendarEntryType.WORKDAY;
                     }
                 } else {
                     if (configuredWorkingTimeForDayOfWeek.isMorning()) {
@@ -158,11 +163,11 @@ class WorkingTimeCalendarServiceImpl implements WorkingTimeCalendarService {
         DayLength calculatedDayLength = configuredWorkingTimeForDayOfWeek;
         if (morning.isMorning() && noon.isNoon()) {
             calculatedDayLength = DayLength.FULL;
-        } else if(morning == DayLength.ZERO && noon == DayLength.ZERO){
+        } else if (morning == DayLength.ZERO && noon == DayLength.ZERO) {
             calculatedDayLength = DayLength.ZERO;
-        } else if(morning == DayLength.ZERO && noon.isNoon()) {
+        } else if (morning == DayLength.ZERO && noon.isNoon()) {
             calculatedDayLength = DayLength.NOON;
-        } else if(morning.isMorning() && noon == DayLength.ZERO){
+        } else if (morning.isMorning() && noon == DayLength.ZERO) {
             calculatedDayLength = DayLength.MORNING;
         }
 


Test patch:
diff --git a/src/test/java/org/synyx/urlaubsverwaltung/workingtime/WorkingTimeCalendarServiceTest.java b/src/test/java/org/synyx/urlaubsverwaltung/workingtime/WorkDaysCountServiceTest.java
similarity index 99%
rename from src/test/java/org/synyx/urlaubsverwaltung/workingtime/WorkingTimeCalendarServiceTest.java
rename to src/test/java/org/synyx/urlaubsverwaltung/workingtime/WorkDaysCountServiceTest.java
index 8ce1f789b..de99bb52b 100644
--- a/src/test/java/org/synyx/urlaubsverwaltung/workingtime/WorkingTimeCalendarServiceTest.java
+++ b/src/test/java/org/synyx/urlaubsverwaltung/workingtime/WorkDaysCountServiceTest.java
@@ -40,7 +40,7 @@ import static org.synyx.urlaubsverwaltung.period.DayLength.NOON;
 import static org.synyx.urlaubsverwaltung.workingtime.FederalState.GERMANY_BADEN_WUERTTEMBERG;
 
 @ExtendWith(MockitoExtension.class)
-class WorkingTimeCalendarServiceTest {
+class WorkDaysCountServiceTest {
 
     private WorkDaysCountService sut;
 
diff --git a/src/test/java/org/synyx/urlaubsverwaltung/workingtime/WorkingTimeCalendarServiceImplTest.java b/src/test/java/org/synyx/urlaubsverwaltung/workingtime/WorkingTimeCalendarServiceImplTest.java
index b57da67d0..61f818df9 100644
--- a/src/test/java/org/synyx/urlaubsverwaltung/workingtime/WorkingTimeCalendarServiceImplTest.java
+++ b/src/test/java/org/synyx/urlaubsverwaltung/workingtime/WorkingTimeCalendarServiceImplTest.java
@@ -34,6 +34,7 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 import static org.synyx.urlaubsverwaltung.period.DayLength.FULL;
 import static org.synyx.urlaubsverwaltung.period.DayLength.MORNING;
+import static org.synyx.urlaubsverwaltung.period.DayLength.ZERO;
 import static org.synyx.urlaubsverwaltung.workingtime.FederalState.GERMANY_BADEN_WUERTTEMBERG;
 import static org.synyx.urlaubsverwaltung.workingtime.FederalState.GERMANY_BERLIN;
 import static org.synyx.urlaubsverwaltung.workingtime.FederalState.SWITZERLAND_GENF;
@@ -390,4 +391,41 @@ class WorkingTimeCalendarServiceImplTest {
             assertThat(workingTimeCalendar.workingTime(date)).isEmpty();
         }
     }
+
+    @Test
+    void ensureToHandlePublicHolidaysWithZeroDayLengthToFullWorkday() {
+        final Person person = new Person();
+        person.setId(1L);
+
+        final List<Person> persons = List.of(person);
+
+        final WorkingTimeEntity workingTimeEntity = new WorkingTimeEntity();
+        workingTimeEntity.setValidFrom(LocalDate.of(2024, JANUARY, 1));
+        workingTimeEntity.setPerson(person);
+        workingTimeEntity.setMonday(FULL);
+        workingTimeEntity.setTuesday(FULL);
+        workingTimeEntity.setWednesday(FULL);
+        workingTimeEntity.setThursday(FULL);
+        workingTimeEntity.setFriday(FULL);
+        workingTimeEntity.setSaturday(FULL);
+        workingTimeEntity.setSunday(FULL);
+        workingTimeEntity.setFederalStateOverride(GERMANY_BADEN_WUERTTEMBERG);
+        when(workingTimeRepository.findByPersonIsInOrderByValidFromDesc(persons)).thenReturn(List.of(workingTimeEntity));
+
+        final Settings settings = new Settings();
+        final WorkingTimeSettings workingTimeSettings = new WorkingTimeSettings();
+        workingTimeSettings.setWorkingDurationForChristmasEve(FULL);
+        settings.setWorkingTimeSettings(workingTimeSettings);
+        when(settingsService.getSettings()).thenReturn(settings);
+
+        when(publicHolidaysService.getPublicHoliday(LocalDate.of(2024, DECEMBER, 24), GERMANY_BADEN_WUERTTEMBERG, workingTimeSettings))
+            .thenReturn(Optional.of(new PublicHoliday(LocalDate.of(2024, DECEMBER, 24), ZERO, "")));
+
+        final Map<Person, WorkingTimeCalendar> actual = sut.getWorkingTimesByPersons(persons, new DateRange(LocalDate.of(2024, 12, 24), LocalDate.of(2024, 12, 24)));
+        assertThat(actual)
+            .hasSize(1)
+            .containsKeys(person);
+
+        assertThat(actual.get(person).workingTime(LocalDate.of(2024, DECEMBER, 24))).hasValue(BigDecimal.ONE);
+    }
 }