diff --git a/ReportImp/SKMAachen/CustomMitarbeiterstundenkontoBerechnung.cs b/ReportImp/SKMAachen/CustomMitarbeiterstundenkontoBerechnung.cs index 4cde86cbe..a81621112 100644 --- a/ReportImp/SKMAachen/CustomMitarbeiterstundenkontoBerechnung.cs +++ b/ReportImp/SKMAachen/CustomMitarbeiterstundenkontoBerechnung.cs @@ -13,11 +13,15 @@ namespace SKMAachen { 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, 09, 20)) //17.10. + if (date.Date < new DateTime(2023, 10, 17)) { dd.MaxHoursUntilBreak = 6; dd.MaxHoursUntilBreak2 = 9; @@ -39,7 +43,7 @@ namespace SKMAachen { if (item.ServiceDescription != null && item.ServiceDescription.ServiceCategory != null) { - if (item.Start.HasValue && item.Start.Value.Date < new DateTime(2023, 09, 20)) //17.10. + if (item.Start.HasValue && item.Start.Value.Date < new DateTime(2023, 10, 17)) { if (item.ServiceDescription.ServiceCategory.Name == "Arbeitszeit") { @@ -48,13 +52,16 @@ namespace SKMAachen } else { - if (item.ServiceDescription.ServiceCategory.Name == "Arbeitszeit" && !item.ServiceDescription.Name.Contains("Pause")) + if (!item.ServiceDescription.Name.Contains("Pause")) { - return true; + if (item.ServiceDescription.ServiceCategory.Name.Contains("Arbeitszeit")) + { + return true; + } } } - - + + } return false; } @@ -91,14 +98,16 @@ namespace SKMAachen if (item.ServiceDescription != null && item.ServiceDescription.ServiceCategory != null) { - if (item.ServiceDescription.ServiceCategory.Name == "Arbeitszeit") + if (item.ServiceDescription.ServiceCategory.Name.Contains("Arbeitszeit")) { - if (item.Start.HasValue && item.Start.Value.Date < new DateTime(2023, 09, 20)) //17.10. + if (item.Start.HasValue && item.Start.Value.Date < new DateTime(2023, 10, 17)) arbeitszeit += duration; else { if (!item.ServiceDescription.Name.Contains("Pause")) - arbeitszeit += duration; + arbeitszeit += duration; + else + arbeitszeit -= duration; } } else if (item.ServiceDescription.ServiceCategory.IsBillable) @@ -119,5 +128,102 @@ namespace SKMAachen return sum; } + public override IList CreateDayDetails(DateTime berichtStart, DateTime berichtEnde, MitarbeiterstundenkontoRO.EmployeeDetail ed, IList 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.HasValue && sr.Start >= berichtStart && sr.Start < berichtEnde && sr.End.HasValue && sr.Start.Value.Day == dd.Date.Day) + { + decimal duration = GetDuration(sr); + + if (sr.Start.HasValue && sr.Start.Value.Date > new DateTime(2023, 10, 16)) + { + if (sr.ServiceDescription.Name.Contains("Pause")) + { + dd.PauseInMinuten += (decimal)sr.DurationMinutes; + + } + else if (sr.ServiceDescription.ServiceCategory.Name.Contains("Arbeitszeit")) + { + dd.MinutesTotal += (decimal)sr.DurationMinutes; + } + } + else + { + if (sr.ServiceDescription.ServiceCategory.Name.Contains("Arbeitszeit")) + dd.MinutesTotal += (decimal)sr.DurationMinutes; + } + + if (sr.ServiceDescription.Name != "Arbeitszeit" && + sr.ServiceDescription.ServiceCategory.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(ServiceRecord sr) + { + decimal duration = 0; + + if (sr.GroupRoundedDuration.HasValue) + { + duration = sr.GroupRoundedDuration.Value; + } + else + { + duration = sr.RoundedDuration; + } + + return duration; + } + public override decimal BerechnePauseMinuten(IList srListAlle) + { + var srList = srListAlle.Where(s => s.ServiceDescription.ServiceCategory.Name == "Arbeitszeit"); + decimal pausenZeit = 0; + + List pausen = new List(); + List nichtpausen = new List(); + + foreach (var sr in srList) + { + if (sr.Start.HasValue && sr.Start.Value.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; + } } }