237 lines
8.4 KiB
C#
237 lines
8.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Service.Dienstplanung;
|
|
|
|
|
|
namespace SKMAachen
|
|
{
|
|
public class CustomMitarbeiterstundenkontoBerechnung : MitarbeiterstundenkontoBerechnung
|
|
{
|
|
public override bool ShouldCreateDayDetails()
|
|
{
|
|
return true;
|
|
}
|
|
public override bool SollPauseBerechnen()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public override MitarbeiterstundenkontoRO.DayDetail CreateDayDetail(DateTime date, MitarbeiterstundenkontoRO.EmployeeDetail ed)
|
|
{
|
|
var dd = base.CreateDayDetail(date, ed);
|
|
if (date.Date < new DateTime(2023, 10, 17))
|
|
{
|
|
dd.MaxHoursUntilBreak = 6;
|
|
dd.MaxHoursUntilBreak2 = 9;
|
|
dd.BreakMinutes = 30;
|
|
dd.BreakMinutes2 = 15;
|
|
}
|
|
else
|
|
{
|
|
dd.MaxHoursUntilBreak = null;
|
|
dd.MaxHoursUntilBreak2 = null;
|
|
dd.BreakMinutes = null;
|
|
dd.BreakMinutes2 = null;
|
|
}
|
|
|
|
return dd;
|
|
}
|
|
|
|
public override bool AddServiceRecordToDuration(StundenkontoServiceRecord item)
|
|
{
|
|
if (item.ServiceDescription != null && item.ServiceDescription.Category != null)
|
|
{
|
|
if (item.Start.Date < new DateTime(2023, 10, 17))
|
|
{
|
|
if (item.ServiceDescription.Category.Name == "Arbeitszeit")
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!item.ServiceDescription.Name.Contains("Pause"))
|
|
{
|
|
if (item.ServiceDescription.Category.Name.Contains("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.Contains("Arbeitszeit"))
|
|
{
|
|
if (item.Start.Date < new DateTime(2023, 10, 17))
|
|
arbeitszeit += duration;
|
|
else
|
|
{
|
|
if (!item.ServiceDescription.Name.Contains("Pause"))
|
|
arbeitszeit += duration;
|
|
//else
|
|
// 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 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.MinutesTotal = 0;
|
|
dd.SpecialHours = 0;
|
|
dd.PauseInMinuten = 0;
|
|
|
|
foreach (var sr in recordsAll)
|
|
{
|
|
if (sr.Start >= berichtStart && sr.Start < berichtEnde && sr.Start.Day == dd.Date.Day)
|
|
{
|
|
decimal duration = GetDuration(sr);
|
|
|
|
if (sr.Start.Date > new DateTime(2023, 10, 16))
|
|
{
|
|
if (sr.ServiceDescription.Name.Contains("Pause"))
|
|
{
|
|
dd.PauseInMinuten += (decimal)sr.DurationMinutes;
|
|
|
|
}
|
|
else if (sr.ServiceDescription.Category.Name.Contains("Arbeitszeit"))
|
|
{
|
|
dd.MinutesTotal += (decimal)sr.DurationMinutes;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (sr.ServiceDescription.Category.Name.Contains("Arbeitszeit"))
|
|
dd.MinutesTotal += (decimal)sr.DurationMinutes;
|
|
}
|
|
|
|
if (sr.ServiceDescription.Name != "Arbeitszeit" &&
|
|
sr.ServiceDescription.Category.IsBillable)
|
|
{
|
|
dd.SpecialHours += (decimal)sr.DurationMinutes;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (dd.PauseInMinuten > 0)
|
|
{
|
|
dd.MinutesTotal -= dd.PauseInMinuten;
|
|
if (dd.MinutesTotal < 0)
|
|
{
|
|
dd.MinutesTotal = 0;
|
|
}
|
|
}
|
|
}
|
|
return list;
|
|
}
|
|
|
|
private decimal GetDuration(StundenkontoServiceRecord sr)
|
|
{
|
|
decimal duration = 0;
|
|
|
|
if (sr.GroupRoundedDuration.HasValue)
|
|
{
|
|
duration = sr.GroupRoundedDuration.Value;
|
|
}
|
|
else
|
|
{
|
|
duration = sr.RoundedDuration;
|
|
}
|
|
|
|
return duration;
|
|
}
|
|
public override decimal BerechnePauseMinuten(IList<StundenkontoServiceRecord> srListAlle)
|
|
{
|
|
var srList = srListAlle.Where(s => s.ServiceDescription.Category.Name == "Arbeitszeit");
|
|
decimal pausenZeit = 0;
|
|
|
|
List<StundenkontoServiceRecord> pausen = new List<StundenkontoServiceRecord>();
|
|
List<StundenkontoServiceRecord> nichtpausen = new List<StundenkontoServiceRecord>();
|
|
|
|
foreach (var sr in srList)
|
|
{
|
|
if (sr.Start.Date > new DateTime(2023, 10, 16))
|
|
{
|
|
if (sr.ServiceDescription.Name == "Pause")
|
|
{
|
|
pausen.Add(sr);
|
|
}
|
|
else
|
|
{
|
|
nichtpausen.Add(sr);
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach (var pause in pausen)
|
|
{
|
|
pausenZeit += pause.RoundedDuration;
|
|
}
|
|
return pausenZeit;
|
|
}
|
|
|
|
public override bool IsUrlaubAbsenceTime(AbsenceTime absenceTime)
|
|
{
|
|
return !String.IsNullOrEmpty(absenceTime.AbsenceReason.Description) &&
|
|
(absenceTime.AbsenceReason.Description.ToLower().IndexOf("urlaub") >= 0 || absenceTime.AbsenceReason.Description.ToLower().IndexOf("regenerationstag") >= 0);
|
|
}
|
|
}
|
|
}
|