66 lines
2.1 KiB
C#
66 lines
2.1 KiB
C#
using BeWo.Service.Plugins;
|
|
using BS.Shared.DataContracts;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace KundeXyz.Service
|
|
{
|
|
class CustomVacationService : VacationService
|
|
{
|
|
public override List<FeiertagDC> GetFeiertage(int year, string bundesland)
|
|
{
|
|
var list = base.GetFeiertage(year, bundesland);
|
|
|
|
if (year >= 2024)
|
|
list.Add(new FeiertagDC() { Datum = new DateTime(year, 12, 31), Name = "Silvester" });
|
|
|
|
return list;
|
|
}
|
|
|
|
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 || (endDate.HasValue && endDate.Value.Day == 31 && endDate.Value.Month == 12))
|
|
urlaubstage = (decimal)urlaubstageProJahr;
|
|
else
|
|
urlaubstage = (decimal)urlaubstageProJahr / 365m * restlicheTageImJahr;
|
|
}
|
|
else
|
|
{
|
|
urlaubstage = (decimal)urlaubstageProJahr / 365m * restlicheTageImJahr;
|
|
}
|
|
|
|
// Runden
|
|
urlaubstage = UrlaubstageRunden(urlaubstage);
|
|
|
|
return urlaubstage;
|
|
}
|
|
|
|
public override decimal UrlaubstageRunden(decimal urlaubstage)
|
|
{
|
|
if (urlaubstage - (int)urlaubstage <= 0.5m)
|
|
{
|
|
decimal digits = urlaubstage - (int)urlaubstage;
|
|
urlaubstage = urlaubstage - digits;
|
|
}
|
|
else if (urlaubstage - (int)urlaubstage <= 1.0m)
|
|
{
|
|
urlaubstage = Math.Ceiling(urlaubstage);
|
|
}
|
|
|
|
return urlaubstage;
|
|
}
|
|
|
|
|
|
}
|
|
}
|