93 lines
3.0 KiB
C#
93 lines
3.0 KiB
C#
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Service.Plugins;
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
namespace FizHof.Service
|
|
{
|
|
public class CustomVacationService : VacationService
|
|
{
|
|
public override string Bundesland { get => "Bayern"; }
|
|
public override List<FeiertagDC> GetFeiertage(int year, String bundesland)
|
|
{
|
|
List<FeiertagDC> list = base.GetFeiertage(year, bundesland);
|
|
|
|
|
|
if (year < 2020)
|
|
{
|
|
list.Remove(list.First(f => f.Datum == new DateTime(year, 1, 6)));
|
|
|
|
}
|
|
|
|
list.Remove(list.First(f => f.Datum == new DateTime(year, 8, 15)));
|
|
|
|
if (year >= 2020)
|
|
{
|
|
list.Remove(list.First(f => f.Datum == new DateTime(year, 12, 24)));
|
|
}
|
|
else if (year == 2019)
|
|
{
|
|
list.Add(new FeiertagDC { Datum = new DateTime(year, 12, 31), Name = "Silvester" });
|
|
}
|
|
|
|
if (year >= 2023)
|
|
{
|
|
list.Add(new FeiertagDC { Datum = CalculateBussUndBettag(year), Name = "Buß- und Bettag" });
|
|
list.Add(new FeiertagDC { Datum = new DateTime(year, 12, 24), Name = "Heiligabend" });
|
|
list.Add(new FeiertagDC { Datum = new DateTime(year, 12, 31), Name = "Silvester" });
|
|
}
|
|
|
|
return list;
|
|
}
|
|
|
|
private static DateTime CalculateBussUndBettag(int year)
|
|
{
|
|
DateTime firstAdventSunday = CalculateFirstAdventSunday(year);
|
|
DateTime bußUndBettag = firstAdventSunday.AddDays(-11); // Mittwoch vor dem 23. November
|
|
|
|
return bußUndBettag;
|
|
}
|
|
|
|
private static DateTime CalculateFirstAdventSunday(int year)
|
|
{
|
|
DateTime christmas = new DateTime(year, 12, 25);
|
|
int daysUntilSunday = ((int)christmas.DayOfWeek + 7 - (int)DayOfWeek.Sunday) % 7;
|
|
DateTime firstAdventSunday = christmas.AddDays(-daysUntilSunday - 21); // 4 Wochen vor dem 1. Advent
|
|
|
|
return firstAdventSunday;
|
|
}
|
|
|
|
public override DateTime GetExpirationDate(int year)
|
|
{
|
|
return new DateTime(year, 12, 31);
|
|
}
|
|
|
|
public override decimal UrlaubstageRunden(decimal urlaubstage)
|
|
{
|
|
if (urlaubstage - (int)urlaubstage <= 0.1m)
|
|
{
|
|
urlaubstage = Math.Round(urlaubstage, MidpointRounding.AwayFromZero);
|
|
}
|
|
else if (urlaubstage - (int)urlaubstage > 0.25m && urlaubstage - (int)urlaubstage <= 0.75m)
|
|
{
|
|
decimal digits = urlaubstage - (int)urlaubstage;
|
|
urlaubstage = urlaubstage - digits + 0.5m;
|
|
}
|
|
else if (urlaubstage - (int)urlaubstage <= 1.0m)
|
|
{
|
|
urlaubstage = Math.Ceiling(urlaubstage);
|
|
}
|
|
|
|
return urlaubstage;
|
|
}
|
|
}
|
|
}
|