MH: Mittelpunkt Teamstundenkonto mehrere Teams

This commit is contained in:
2024-10-18 13:57:41 +02:00
parent 151ca8e6bb
commit ff6aa95639

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using BeWo.Report;
using BeWo.Report.ReportObjects;
@@ -27,12 +28,23 @@ namespace Mittelpunkt
decimal feiertag = 0;
decimal nacht = 0;
// Prüfen, wie oft der MA in allen Teams vorkommt und Stunden da durch teilen, da die Stunden sonst mehrfach gezählt werden
Dictionary<long, int> employeeZuVorkommenInTeams = new Dictionary<long, int>();
foreach (var team in pRO.TeamDetailList)
{
foreach (var emp in team.EmployeeDetailList)
{
if (employeeZuVorkommenInTeams.ContainsKey(emp.Employee.Oid.Value))
employeeZuVorkommenInTeams[emp.Employee.Oid.Value]++;
else
employeeZuVorkommenInTeams.Add(emp.Employee.Oid.Value, 1);
}
}
foreach (var team in pRO.TeamDetailList)
{
foreach (var emp in team.EmployeeDetailList)
{
emp.Custom4 = emp.Days.Sum(d => d.SpecialHours);
nacht += emp.Days.Sum(d => d.SpecialHours);
foreach (var day in emp.Days)
{
// Custom1 Samstagsarbeit 13-21 Uhr
@@ -47,19 +59,29 @@ namespace Mittelpunkt
var saturdayStart = new DateTime(saturday.Year, saturday.Month, saturday.Day, 13, 0, 0);
var saturdayEnd = new DateTime(saturday.Year, saturday.Month, saturday.Day, 21, 0, 0);
emp.Custom1 += Math.Round((decimal)d1.GetIntersectingMinutes(unroundedEnd, saturdayStart, saturdayEnd) / 60, 2, MidpointRounding.AwayFromZero);
samstag += Math.Round((decimal)d1.GetIntersectingMinutes(unroundedEnd, saturdayStart, saturdayEnd) / 60, 2, MidpointRounding.AwayFromZero);
emp.Custom1 += Math.Round((decimal)d1.GetIntersectingMinutes(unroundedEnd, saturdayStart, saturdayEnd) / 60, 2, MidpointRounding.AwayFromZero) / employeeZuVorkommenInTeams[emp.Employee.Oid.Value];
samstag += Math.Round((decimal)d1.GetIntersectingMinutes(unroundedEnd, saturdayStart, saturdayEnd) / 60, 2, MidpointRounding.AwayFromZero) / employeeZuVorkommenInTeams[emp.Employee.Oid.Value];
}
}
// Custom2 Sonntagsarbeit
emp.Custom2 += day.HoursSunday;
sonntag += day.HoursSunday;
//// Custom2 Sonntagsarbeit
//emp.Custom2 += day.HoursSunday;
//sonntag += day.HoursSunday;
// Custom3 Feiertagsarbeit
emp.Custom3 += day.HoursHoliday;
feiertag += day.HoursHoliday;
//// Custom3 Feiertagsarbeit
//emp.Custom3 += day.HoursHoliday;
//feiertag += day.HoursHoliday;
}
// Custom2 Sonntagsarbeit
emp.Custom2 = emp.Days.Sum(d => d.HoursSunday) / employeeZuVorkommenInTeams[emp.Employee.Oid.Value];
sonntag += emp.Custom2;
// Custom3 Feiertagsarbeit
emp.Custom3 = emp.Days.Sum(d => d.HoursHoliday) / employeeZuVorkommenInTeams[emp.Employee.Oid.Value];
feiertag += emp.Custom3;
// Custom4 Nachtarbeit
emp.Custom4 = emp.Days.Sum(d => d.SpecialHours) / employeeZuVorkommenInTeams[emp.Employee.Oid.Value];
nacht += emp.Custom4;
}
}