From 948e6cd1b24b0205b58268c095bdcf4c693776a1 Mon Sep 17 00:00:00 2001 From: Kojo Date: Mon, 25 Nov 2024 17:12:43 +0100 Subject: [PATCH] =?UTF-8?q?MobileEV:=20Anpassung=20der=20Rundungslogik=20(?= =?UTF-8?q?f=C3=BCr=20Landkreis=20B=C3=B6rde=20wie=20LWL)=20=C3=BCber=20Fu?= =?UTF-8?q?nktion=20bei=20der=20Organisation=20(statt=20ID=20vom=20Costbea?= =?UTF-8?q?rer)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Calculations/CustomCalculations.cs | 24 ------- ReportImp/MobileEV/MobileEV.csproj | 1 - .../MobileEV/Service/CustomSaveInterceptor.cs | 63 ++++++++++++------- 3 files changed, 40 insertions(+), 48 deletions(-) delete mode 100644 ReportImp/MobileEV/Calculations/CustomCalculations.cs diff --git a/ReportImp/MobileEV/Calculations/CustomCalculations.cs b/ReportImp/MobileEV/Calculations/CustomCalculations.cs deleted file mode 100644 index 8b9b7720f..000000000 --- a/ReportImp/MobileEV/Calculations/CustomCalculations.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using BS.Shared.Core; -using BS.Shared.Services; - -namespace MobileEV -{ - [IDSpecificClass(Identifier = "RundungWieLWL")] - public class CustomCalculations : Calculations - { - public override int GetRoundedDuration(int minuteInterval, decimal durationInMinutes) - { - decimal lRoundedDuration = durationInMinutes; - - if (minuteInterval > 0 && durationInMinutes >= 5) - { - lRoundedDuration = durationInMinutes % minuteInterval != 0 - ? durationInMinutes + (minuteInterval - (durationInMinutes % minuteInterval)) - : durationInMinutes; - } - - return (int)Math.Round(lRoundedDuration, 0, MidpointRounding.AwayFromZero); - } - } -} \ No newline at end of file diff --git a/ReportImp/MobileEV/MobileEV.csproj b/ReportImp/MobileEV/MobileEV.csproj index f9f73a331..426b36c1c 100644 --- a/ReportImp/MobileEV/MobileEV.csproj +++ b/ReportImp/MobileEV/MobileEV.csproj @@ -55,7 +55,6 @@ - diff --git a/ReportImp/MobileEV/Service/CustomSaveInterceptor.cs b/ReportImp/MobileEV/Service/CustomSaveInterceptor.cs index 4f0deeb4a..5169befc8 100644 --- a/ReportImp/MobileEV/Service/CustomSaveInterceptor.cs +++ b/ReportImp/MobileEV/Service/CustomSaveInterceptor.cs @@ -2,10 +2,6 @@ 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 { @@ -14,28 +10,49 @@ namespace MobileEV.Service 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 (sr.CostBearer2SupportConcept != null) + { + var costBearer = sr.CostBearer2SupportConcept.CostBearer; - if (rest <= 7) + if (costBearer.Organisation.Function != null && + !costBearer.Organisation.Function.Value.IsNullOrEmpty()) + { + var function = costBearer.Organisation.Function.Value; + if (function.Equals("Rundung Selbstzahler wie LWL")) { - sr.RoundedDuration = Convert.ToInt32(sr.DurationMinutes) - rest; // Abgerundet auf das vorherige Vielfache von 15 + 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 - { - sr.RoundedDuration = Convert.ToInt32(sr.DurationMinutes) + (15 - rest); // Auf das nächste Vielfache von 15 aufrunden - } - } - } + 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); + } + } + } } } }