Files
BeWoPlaner/ReportImp/MobileEV/Service/CustomSaveInterceptor.cs
2024-06-25 09:31:21 +02:00

42 lines
1.5 KiB
C#

using BeWo.Data.Entities;
using BeWo.Service.Plugins;
using BS.Shared.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MobileEV.Service
{
public class CustomSaveInterceptor : SaveInterceptor
{
public override void BeforeSaveServiceRecord(ServiceRecord sr)
{
if (sr.CostBearer2SupportConcept != null && sr.CostBearer2SupportConcept.CostBearer.Organisation.Function != null && !sr.CostBearer2SupportConcept.CostBearer.Organisation.Function.Value.IsNullOrEmpty() && sr.CostBearer2SupportConcept.CostBearer.Organisation.Function.Value == "Rundung Selbstzahler wie LWL")
{
// Nach LWL-Regeln runden
if (sr.DurationMinutes <= 7)
{
sr.RoundedDuration = 0; // Runde auf 0 Minuten, da kleiner als 8
}
else
{
int rest = Convert.ToInt32(sr.DurationMinutes) % 15;
if (rest <= 7)
{
sr.RoundedDuration = Convert.ToInt32(sr.DurationMinutes) - rest; // Abgerundet auf das vorherige Vielfache von 15
}
else
{
sr.RoundedDuration = Convert.ToInt32(sr.DurationMinutes) + (15 - rest); // Auf das nächste Vielfache von 15 aufrunden
}
}
}
}
}
}