Files
BeWoPlaner/ReportImp/MalteserJohanniterJohanneshaus/CustomMitarbeiterstundenkontoBerechnung.cs

57 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using BeWo.Data.Entities;
using BeWo.Report.ReportObjects;
using BeWo.Service.Dienstplanung;
namespace MalteserJohanniterJohanneshaus
{
public class CustomMitarbeiterstundenkontoBerechnung : MitarbeiterstundenkontoBerechnung
{
public override bool ShouldCreateDayDetails()
{
return true;
}
public override IList<MitarbeiterstundenkontoRO.DayDetail> CreateDayDetails(DateTime berichtStart, DateTime berichtEnde, MitarbeiterstundenkontoRO.EmployeeDetail ed, IList<StundenkontoServiceRecord> recordsAll)
{
var list = base.CreateDayDetails(berichtStart, berichtEnde, ed, recordsAll);
foreach (var dd in list)
{
dd.SpecialHours = 0;
foreach (var sr in recordsAll)
{
if (sr.Start >= berichtStart && sr.Start < berichtEnde && sr.Start.Day == dd.Date.Day)
{
if (sr.ServiceDescription.Name != "Arbeitszeit" &&
sr.ServiceDescription.Category.IsBillable)
{
if (sr.GroupRoundedDuration.HasValue)
{
dd.SpecialHours += sr.GroupRoundedDuration.Value;
}
else
{
decimal prozent = 100;
if (sr.ServiceDescription.ProzentStundenkonto.HasValue)
{
prozent = sr.ServiceDescription.ProzentStundenkonto.Value;
}
else if (sr.ServiceDescription.Category.ProzentStundenkonto.HasValue)
{
prozent = sr.ServiceDescription.Category.ProzentStundenkonto.Value;
}
dd.SpecialHours += (decimal)sr.DurationMinutes * (prozent / 100);
}
}
}
}
}
return list;
}
}
}