MH: BeWoNordeifel Rundung LWL wie bei LVR

This commit is contained in:
2025-04-29 16:01:11 +02:00
parent 6f1f6f58fa
commit 7a414a03fb
4 changed files with 105 additions and 0 deletions

View File

@@ -55,6 +55,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Calculation\CustomCalculations.cs" />
<Compile Include="Calculation\CustomLWLCalculations.cs" />
<Compile Include="Calculation\CustomServiceRecordDurationCalculator.cs" />
<Compile Include="FLSGroupReport.cs">
<SubType>Component</SubType>
</Compile>

View File

@@ -0,0 +1,19 @@
using BS.Shared;
using BS.Shared.Extensions;
using BS.Shared.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeWoNordeifel.Calculation
{
public class CustomCalculations : Calculations
{
public override int GetRoundedDuration(BS.Shared.DataContracts.Compact.CompactOrganisationDC org, DateTime date, decimal durationInMinutes)
{
return base.GetRoundedDuration(org, date, durationInMinutes);
}
}
}

View File

@@ -0,0 +1,27 @@
using BS.Shared.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeWoNordeifel.Calculation
{
public class CustomLWLCalculations : LWLCalculations
{
// Wie LVR
public override int GetRoundedDuration(int minuteInterval, decimal durationInMinutes)
{
decimal lRoundedDuration = durationInMinutes;
if (minuteInterval > 0)
{
lRoundedDuration = durationInMinutes % minuteInterval != 0
? durationInMinutes + (minuteInterval - (durationInMinutes % minuteInterval))
: durationInMinutes;
}
return (int)Math.Round(lRoundedDuration, 0, MidpointRounding.AwayFromZero);
}
}
}

View File

@@ -0,0 +1,56 @@
using BeWo.Data.Entities;
using BeWo.Service.DCEntityMapper;
using BeWo.Service.Plugins;
using BS.Shared.DataContracts;
using BS.Shared.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeWoNordeifel.Calculation
{
public class CustomServiceRecordDurationCalculator : ServiceRecordDurationCalculator
{
public override void CalculateRoundedDuration(ServiceRecordDC newServiceRecord)
{
//Wird nur für die Validierung benötigt
if (newServiceRecord.ServiceDescription.Category != null &&
newServiceRecord.ServiceDescription.Category.IsBillable && newServiceRecord.CostBearer != null)
{
var duration = (decimal)newServiceRecord.End.Value.Subtract(newServiceRecord.Start.Value).TotalMinutes;
Calculations calc = new CustomCalculations();
var roundedDuration = calc.GetRoundedDuration(newServiceRecord.CostBearer, newServiceRecord.Start.Value, duration);
newServiceRecord.RoundedDuration = roundedDuration;
}
else
{
newServiceRecord.RoundedDuration = (decimal)newServiceRecord.End.Value.Subtract(newServiceRecord.Start.Value).TotalMinutes;
}
}
public override void CalculateRoundedDuration(ServiceRecord newServiceRecord)
{
if (newServiceRecord.ServiceDescription.ServiceCategory != null &&
newServiceRecord.ServiceDescription.ServiceCategory.IsBillable && newServiceRecord.CostBearer2SupportConcept != null)
{
var duration = (decimal)newServiceRecord.End.Value.Subtract(newServiceRecord.Start.Value).TotalMinutes;
Calculations calc = new CustomCalculations();
var org = MapperFactory.CompactOrganisationDC_Organisation.MapToNewDC(
newServiceRecord.CostBearer2SupportConcept.CostBearer.Organisation);
var roundedDuration = calc.GetRoundedDuration(org, newServiceRecord.Start.Value, duration);
newServiceRecord.RoundedDuration = roundedDuration;
}
else
{
newServiceRecord.RoundedDuration = (decimal)newServiceRecord.End.Value.Subtract(newServiceRecord.Start.Value).TotalMinutes;
}
}
}
}