116 lines
3.2 KiB
C#
116 lines
3.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Service.Plugins;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.Extensions;
|
|
|
|
|
|
namespace PassgenauUG
|
|
{
|
|
public class CustomMitarbeiterstundenkontoBerechnung : MitarbeiterstundenkontoBerechnung
|
|
{
|
|
public VacationService VacationService = new VacationService();
|
|
|
|
public bool BerechneFerienTage { get; set; }
|
|
|
|
public override List<DateTime> GetFeiertage(int year)
|
|
{
|
|
var list = base.GetFeiertage(year);
|
|
|
|
if (year != 2017)
|
|
{
|
|
list.Add(new DateTime(year, 10, 31)); // , "Reformationstag"));
|
|
}
|
|
DateTime osterSonntag = GetOsterSonntag(year);
|
|
|
|
list.Remove(osterSonntag.AddDays(60)); // Fronleichnam
|
|
return list;
|
|
}
|
|
|
|
protected override void StarteBerechnung(DateTime berichtsAnfang, DateTime berichtsEnde, MitarbeiterstundenkontoRO.EmployeeDetail empDetail)
|
|
{
|
|
|
|
BerechneFerienTage = false;
|
|
foreach (var team in empDetail.Teams)
|
|
{
|
|
if (team.Name.Contains("Schulbegleitung") && team.Name.Contains("Alle"))
|
|
{
|
|
BerechneFerienTage = true;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
//public override decimal GetArbeitstageImBereich(DateTime von, DateTime bis, Employee emp)
|
|
//{
|
|
|
|
// DateTime start = von;
|
|
// DateTime end = bis;
|
|
|
|
// TimeSpan ts = end.Subtract(start);
|
|
|
|
// var maxDays = (decimal)ts.TotalDays;
|
|
|
|
// while (start < end)
|
|
// {
|
|
// int arbeitstageProWoche = 5;
|
|
|
|
// var c = GetContractForDate(emp, start, start);
|
|
|
|
// if (c != null && c.WeeklyDays.HasValue && c.WeeklyDays > 0)
|
|
// {
|
|
// arbeitstageProWoche = c.WeeklyDays.Value;
|
|
// }
|
|
|
|
|
|
// if (arbeitstageProWoche <= 5 && (start.DayOfWeek == DayOfWeek.Saturday || start.DayOfWeek == DayOfWeek.Sunday))
|
|
// {
|
|
// maxDays -= 1;
|
|
// }
|
|
// else if (arbeitstageProWoche == 6 && start.DayOfWeek == DayOfWeek.Sunday)
|
|
// {
|
|
// maxDays -= 1;
|
|
// }
|
|
// else if (berechneFerienTage && IstFerienTag(start))
|
|
// {
|
|
// maxDays -= 1;
|
|
|
|
// }
|
|
// else
|
|
// {
|
|
|
|
// maxDays -= GetFeiertagsFaktor(start);
|
|
// //if (IstFeiertag(start))
|
|
// // maxDays--;
|
|
// }
|
|
// start = start.AddDays(1);
|
|
// }
|
|
// return maxDays;
|
|
|
|
//}
|
|
|
|
public override decimal GetFeiertagsFaktor(DateTime start)
|
|
{
|
|
if (BerechneFerienTage)
|
|
{
|
|
if (GetFerienTag(start) != null)
|
|
{
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
return base.GetFeiertagsFaktor(start);
|
|
}
|
|
|
|
public FerienDC GetFerienTag(DateTime start)
|
|
{
|
|
return VacationService.GetFerien(start, "Niedersachsen");
|
|
|
|
}
|
|
}
|
|
}
|