CaritasverbandKelheim/Service/CustomGroupDurationCalculator.cs - 3.0

This commit is contained in:
2024-10-29 16:03:28 +01:00
parent d395883589
commit bb47ebada9

View File

@@ -15,28 +15,55 @@ namespace CaritasverbandKelheim.Calculation
public override GroupDurationDC CalculateGroupDuration(int personCount, int employeeCount, decimal totalDuration,
long[] costBearer2SupportConceptArray)
{
if (totalDuration <= 7)
var singleDuration = totalDuration / personCount;
if (singleDuration <= 7)
{
totalDuration = 0; // Runde auf 0 Minuten, da kleiner als 8
singleDuration = 0; // Runde auf 0 Minuten, da kleiner als 8
}
else
{
int rest = Convert.ToInt32(totalDuration) % 15;
int rest = Convert.ToInt32(singleDuration) % 15;
if (rest <= 7)
{
totalDuration = Convert.ToInt32(totalDuration) - rest; // Abgerundet auf das vorherige Vielfache von 15
singleDuration = Convert.ToInt32(singleDuration) - rest; // Abgerundet auf das vorherige Vielfache von 15
}
else
{
totalDuration = Convert.ToInt32(totalDuration) + (15 - rest); // Auf das nächste Vielfache von 15 aufrunden
singleDuration = Convert.ToInt32(singleDuration) + (15 - rest); // Auf das nächste Vielfache von 15 aufrunden
}
}
return new GroupDurationDC()
{
SingleDuration = totalDuration /personCount,
TotalDuration = totalDuration
{
SingleDuration = singleDuration,
TotalDuration = totalDuration
};
}
}
public override void CalculateGroupDuration(ServiceRecordGroup group)
{
foreach (var sr in group.ServiceRecordList)
{
var duration = (decimal)sr.End.Value.Subtract(sr.Start.Value).TotalMinutes / (sr.GroupPersonCount ?? 1);
if (duration <= 7)
{
duration = 0; // Runde auf 0 Minuten, da kleiner als 8
}
else
{
int rest = Convert.ToInt32(duration) % 15;
if (rest <= 7)
{
duration = Convert.ToInt32(duration) - rest; // Abgerundet auf das vorherige Vielfache von 15
}
else
{
duration = Convert.ToInt32(duration) + (15 - rest); // Auf das nächste Vielfache von 15 aufrunden
}
}
sr.RoundedDuration = duration;
}
}
}
}