146 lines
4.7 KiB
C#
146 lines
4.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.Remoting.Metadata.W3cXsd2001;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Service.Dienstplanung;
|
|
|
|
|
|
namespace BUGeVReports
|
|
{
|
|
public class CustomMitarbeiterstundenkontoBerechnung : MitarbeiterstundenkontoBerechnung
|
|
{
|
|
private const int ANZ_WOCHENTAGE = 5;
|
|
|
|
public override bool ShouldCreateDayDetails()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public override MitarbeiterstundenkontoRO.DayDetail CreateDayDetail(DateTime date, MitarbeiterstundenkontoRO.EmployeeDetail ed)
|
|
{
|
|
var dd = base.CreateDayDetail(date, ed);
|
|
dd.MaxHoursUntilBreak = 6;
|
|
dd.MaxHoursUntilBreak2 = 9;
|
|
dd.BreakMinutes = 30;
|
|
dd.BreakMinutes2 = 15;
|
|
|
|
return dd;
|
|
}
|
|
|
|
public override bool AddServiceRecordToDuration(StundenkontoServiceRecord item)
|
|
{
|
|
if (item.ServiceDescription != null && item.ServiceDescription.Category != null)
|
|
{
|
|
if (item.ServiceDescription.Category.Name == "Arbeitszeit")
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
protected override ServiceRecordSummary BerechneStunden(MitarbeiterstundenkontoRO.EmployeeDetail empDetail, IList<StundenkontoServiceRecord> groupFilteredRecords, DateTime berichtsAnfang,
|
|
DateTime berichtsEnde)
|
|
{
|
|
decimal flsGesamt = 0;
|
|
decimal arbeitszeit = 0;
|
|
|
|
var sum = new ServiceRecordSummary();
|
|
sum.RecordsImBerichtszeitraum = new List<StundenkontoServiceRecord>();
|
|
//base.CorrectOverlappingTimes(groupFilteredRecords);
|
|
|
|
foreach (var item in groupFilteredRecords)
|
|
{
|
|
if (!IsServiceRecordFehlzeit(item))
|
|
{
|
|
if (item.Start >= berichtsAnfang && item.Start < berichtsEnde)
|
|
{
|
|
//if (AddServiceRecordToDuration(item))
|
|
//{
|
|
decimal duration = 0;
|
|
|
|
if (item.GroupRoundedDuration.HasValue)
|
|
{
|
|
duration = item.GroupRoundedDuration.Value;
|
|
}
|
|
else
|
|
{
|
|
duration = item.RoundedDuration;
|
|
}
|
|
|
|
if (item.ServiceDescription != null &&
|
|
item.ServiceDescription.Category != null)
|
|
{
|
|
if (item.ServiceDescription.Category.Name == "Arbeitszeit")
|
|
{
|
|
arbeitszeit += duration;
|
|
}
|
|
else if (item.ServiceDescription.Category.IsBillable)
|
|
{
|
|
flsGesamt += duration;
|
|
}
|
|
|
|
}
|
|
sum.RecordsImBerichtszeitraum.Add(item);
|
|
}
|
|
}
|
|
}
|
|
|
|
sum.IstAbrechenbar = flsGesamt;
|
|
sum.IstNichtAbrechenbar = arbeitszeit - flsGesamt;
|
|
|
|
return sum;
|
|
}
|
|
public override decimal GetArbeitstageImBereich(DateTime von, DateTime bis, Employee emp)
|
|
{
|
|
DateTime start = von;
|
|
DateTime end = bis;
|
|
|
|
if (BerechneSollNurBisZumAktuellenTag())
|
|
{
|
|
if (end > DateTime.Now.Date.AddDays(1))
|
|
{
|
|
end = DateTime.Now.Date.AddDays(1);
|
|
}
|
|
}
|
|
|
|
TimeSpan ts = end.Subtract(start);
|
|
|
|
var maxDays = (decimal)ts.TotalDays;
|
|
|
|
while (start < end)
|
|
{
|
|
int arbeitstageProWoche = ANZ_WOCHENTAGE;
|
|
|
|
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 (!BerechneFeiertageAlsArbeitszeit())
|
|
{
|
|
maxDays -= GetFeiertagsFaktor(start);
|
|
}
|
|
}
|
|
start = start.AddDays(1);
|
|
}
|
|
return maxDays;
|
|
|
|
}
|
|
}
|
|
}
|