49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
using System;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Service.Plugins;
|
|
using BS.Shared.DataContracts;
|
|
|
|
namespace SpzRatingen
|
|
{
|
|
public class CustomDurationCalculator : ServiceRecordDurationCalculator
|
|
{
|
|
public override void CalculateRoundedDuration(ServiceRecord sr)
|
|
{
|
|
if (sr.CostBearer2SupportConcept != null && sr.ServiceDescription.ServiceCategory != null &&
|
|
sr.ServiceDescription.ServiceCategory.IsBillable && sr.ServiceDescription.ServiceCategory.Name == "Soziotherapie")
|
|
{
|
|
var durationInMinutes = (decimal)sr.End.Value.Subtract(sr.Start.Value).TotalMinutes;
|
|
|
|
decimal lRoundedDuration = durationInMinutes;
|
|
lRoundedDuration = durationInMinutes % 25 != 0
|
|
? durationInMinutes + (25 - (durationInMinutes % 25))
|
|
: durationInMinutes;
|
|
|
|
sr.RoundedDuration = (int)Math.Round(lRoundedDuration, 0, MidpointRounding.AwayFromZero);
|
|
}
|
|
else
|
|
{
|
|
base.CalculateRoundedDuration(sr);
|
|
}
|
|
}
|
|
|
|
public override void CalculateRoundedDuration(ServiceRecordDC sr)
|
|
{
|
|
if (sr.ServiceDescription.Category != null && sr.ServiceDescription.Category.IsBillable && sr.ServiceDescription.Category.Name == "Soziotherapie")
|
|
{
|
|
var durationInMinutes = (decimal)sr.End.Value.Subtract(sr.Start.Value).TotalMinutes;
|
|
|
|
decimal lRoundedDuration = durationInMinutes;
|
|
lRoundedDuration = durationInMinutes % 25 != 0
|
|
? durationInMinutes + (25 - (durationInMinutes % 25))
|
|
: durationInMinutes;
|
|
|
|
sr.RoundedDuration = (int)Math.Round(lRoundedDuration, 0, MidpointRounding.AwayFromZero);
|
|
}
|
|
else
|
|
{
|
|
base.CalculateRoundedDuration(sr);
|
|
}
|
|
}
|
|
}
|
|
} |