2024-02-05 09:02:21 +01:00
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 )
{
2024-06-25 09:31:21 +02:00
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" )
2024-02-05 09:02:21 +01:00
{
// 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
}
}
}
}
}
}