59 lines
2.0 KiB
C#
59 lines
2.0 KiB
C#
using BeWo.Data.Entities;
|
|
using BeWo.Service.Plugins;
|
|
using BS.Shared.Extensions;
|
|
using System;
|
|
|
|
namespace MobileEV.Service
|
|
{
|
|
public class CustomSaveInterceptor : SaveInterceptor
|
|
{
|
|
public override void BeforeSaveServiceRecord(ServiceRecord sr)
|
|
{
|
|
|
|
if (sr.CostBearer2SupportConcept != null)
|
|
{
|
|
var costBearer = sr.CostBearer2SupportConcept.CostBearer;
|
|
|
|
if (costBearer.Organisation.Function != null &&
|
|
!costBearer.Organisation.Function.Value.IsNullOrEmpty())
|
|
{
|
|
var function = costBearer.Organisation.Function.Value;
|
|
if (function.Equals("Rundung Selbstzahler wie LWL"))
|
|
{
|
|
if (sr.DurationMinutes <= 7)
|
|
{
|
|
sr.RoundedDuration = 0;
|
|
}
|
|
else
|
|
{
|
|
int rest = Convert.ToInt32(sr.DurationMinutes) % 15;
|
|
|
|
if (rest <= 7)
|
|
{
|
|
sr.RoundedDuration = Convert.ToInt32(sr.DurationMinutes) - rest;
|
|
}
|
|
else
|
|
{
|
|
sr.RoundedDuration = Convert.ToInt32(sr.DurationMinutes) + (15 - rest);
|
|
}
|
|
}
|
|
}
|
|
else if (function.Equals("Rundung wie LWL"))
|
|
{
|
|
var duration = sr.DurationMinutes;
|
|
|
|
if (duration >= 5)
|
|
{
|
|
duration = duration % 10 != 0
|
|
? duration + (10 - (duration % 10))
|
|
: duration;
|
|
}
|
|
|
|
sr.RoundedDuration = (int)Math.Round(duration, 0, MidpointRounding.AwayFromZero);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|