From 06fdb8a78933f2085fbab0991aa95446fb56bd0e Mon Sep 17 00:00:00 2001 From: Marcel Hirschle Date: Fri, 5 May 2023 14:53:18 +0200 Subject: [PATCH] MH: RRP Urlaubskonto --- .../RomanRogerPuth/RomanRogerPuth.csproj | 1 + .../Service/CustomVacationService.cs | 64 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 ReportImp/RomanRogerPuth/Service/CustomVacationService.cs diff --git a/ReportImp/RomanRogerPuth/RomanRogerPuth.csproj b/ReportImp/RomanRogerPuth/RomanRogerPuth.csproj index fa51ffae3..af4e6d9de 100644 --- a/ReportImp/RomanRogerPuth/RomanRogerPuth.csproj +++ b/ReportImp/RomanRogerPuth/RomanRogerPuth.csproj @@ -59,6 +59,7 @@ Mitarbeiterauslastung.cs + diff --git a/ReportImp/RomanRogerPuth/Service/CustomVacationService.cs b/ReportImp/RomanRogerPuth/Service/CustomVacationService.cs new file mode 100644 index 000000000..5b83b4b37 --- /dev/null +++ b/ReportImp/RomanRogerPuth/Service/CustomVacationService.cs @@ -0,0 +1,64 @@ +using BeWo.Service.Plugins; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RomanRogerPuth.Service +{ + public class CustomVacationService : VacationService + { + public override decimal CalcCorrectNumberOfLeaveDaysForSpecialContractSituation(DateTime entryDate, DateTime? endDate, int anzahlArbeitstage, int restlicheTageImJahr, decimal? urlaubstageProJahr) + { + decimal urlaubstage = 0; + if (urlaubstageProJahr == null) + urlaubstageProJahr = 0m; + + if (entryDate.Day == 1 && entryDate.Month == 1 || entryDate.Day == 2 && entryDate.Month == 1) //Erster Tag im Jahr + { + //Prüfen, ob Enddatum Ende des Jahres oder früher ist + if (endDate == null) + urlaubstage = (decimal)urlaubstageProJahr; + + else if (endDate.Value.Day == 31 && endDate.Value.Month == 12) + urlaubstage = (decimal)urlaubstageProJahr; + + else + { + if (anzahlArbeitstage < 5) // weniger als 5 Tage + urlaubstage = (decimal)urlaubstageProJahr / 5m * anzahlArbeitstage; + else + { + if (anzahlArbeitstage == 5) // 5 Tage + urlaubstage = (decimal)urlaubstageProJahr / 365m * restlicheTageImJahr; + else if (anzahlArbeitstage == 6) // 6 Tage + urlaubstage = (decimal)urlaubstageProJahr / 365m * restlicheTageImJahr; + } + } + + } + else // Mitten im Jahr + { + urlaubstage = (decimal)urlaubstageProJahr / 365m * restlicheTageImJahr; + } + + // Runden + if (urlaubstage - (int)urlaubstage <= 0.1m) + { + urlaubstage = Math.Round(urlaubstage, MidpointRounding.AwayFromZero); + } + else if (urlaubstage - (int)urlaubstage <= 0.5m) + { + decimal digits = urlaubstage - (int)urlaubstage; + urlaubstage = urlaubstage - digits + 0.5m; + } + else if (urlaubstage - (int)urlaubstage <= 1.0m) + { + urlaubstage = Math.Ceiling(urlaubstage); + } + + return urlaubstage; + } + } +}