MH: RRP Urlaubskonto

This commit is contained in:
2023-05-05 14:53:18 +02:00
parent 53daf6f069
commit 06fdb8a789
2 changed files with 65 additions and 0 deletions

View File

@@ -59,6 +59,7 @@
<DependentUpon>Mitarbeiterauslastung.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Service\CustomVacationService.cs" />
<Compile Include="Translation\TranslationDictionary.cs" />
</ItemGroup>
<ItemGroup>

View File

@@ -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;
}
}
}