From 3dbdaad1b5a58c0e5dacc77db504eb165f437e26 Mon Sep 17 00:00:00 2001 From: Alexandra Date: Mon, 1 Jun 2026 10:44:14 +0200 Subject: [PATCH] MalteserJohanniterJohanneshaus/Service/CustomServiceRecordStatisticFactory.cs - bei Soziotherapie Faktor auf erbrachte Zeit SupportOID=163414 --- .../MalteserJohanniterJohanneshaus.csproj | 1 + .../CustomServiceRecordStatisticFactory.cs | 104 ++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 ReportImp/MalteserJohanniterJohanneshaus/Service/CustomServiceRecordStatisticFactory.cs diff --git a/ReportImp/MalteserJohanniterJohanneshaus/MalteserJohanniterJohanneshaus.csproj b/ReportImp/MalteserJohanniterJohanneshaus/MalteserJohanniterJohanneshaus.csproj index 8b93dcafe..9ba4ed4bd 100644 --- a/ReportImp/MalteserJohanniterJohanneshaus/MalteserJohanniterJohanneshaus.csproj +++ b/ReportImp/MalteserJohanniterJohanneshaus/MalteserJohanniterJohanneshaus.csproj @@ -153,6 +153,7 @@ + Component diff --git a/ReportImp/MalteserJohanniterJohanneshaus/Service/CustomServiceRecordStatisticFactory.cs b/ReportImp/MalteserJohanniterJohanneshaus/Service/CustomServiceRecordStatisticFactory.cs new file mode 100644 index 000000000..cbb48b370 --- /dev/null +++ b/ReportImp/MalteserJohanniterJohanneshaus/Service/CustomServiceRecordStatisticFactory.cs @@ -0,0 +1,104 @@ +using BeWo.Data.Access; +using BeWo.Data.Entities; +using BeWo.Service.DCEntityMapper; +using BeWo.Service.Plugins; +using BS.Shared.DataContracts; +using DevExpress.Office.Utils; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MalteserJohanniterJohanneshaus.Service +{ + public class CustomServiceRecordStatisticFactory : ServiceRecordStatisticFactory + { + public override SupportConceptStatisticsDC CreateSupportConceptStatisticsImpl(long costBearer2SupportConceptOid, DateTime statisticsDate, long? ignoreServiceRecordOid) + { + var stats = base.CreateSupportConceptStatisticsImpl(costBearer2SupportConceptOid, statisticsDate, ignoreServiceRecordOid); + + try + { + if (stats.PeriodStatistics.Any(p => p.SupportConceptApprovalPeriod.ServiceCategory != null && String.IsNullOrEmpty(p.SupportConceptApprovalPeriod.ServiceCategory.Name) + && p.SupportConceptApprovalPeriod.ServiceCategory.Name == "Soziotherapie")) + { + + decimal factor = 1.2m; + + stats.IstTotalUntilThisMonth *= factor; + stats.MinutesFreePerMonthAverage *= factor; + stats.MinutesFreePerWeekAverage *= factor; + stats.MinutesOutOfApprovedPeriod *= factor; + stats.MinutesProvidedPerMonthAverage *= factor; + stats.MinutesProvidedPerWeekAverage *= factor; + stats.MinutesProvidedThisMonth *= factor; + stats.MinutesProvidedThisWeek *= factor; + stats.MinutesProvidedTotal *= factor; + stats.MinutesProvidedTotalRounded *= factor; + + foreach (var s in stats.PeriodStatistics) + { + s.AmountConsumedThisInterval *= factor; + s.AmountConsumedTotal *= factor; + s.IstTotalUntilThisMonth *= factor; + s.MinutesFreePerWeek *= factor; + s.MinutesOutOfApprovedPeriod *= factor; + s.MinutesProvidedThisMonth *= factor; + s.MinutesProvidedThisWeek *= factor; + s.MinutesProvidedTotal *= factor; + s.MinutesProvidedTotalRounded *= factor; + s.SollTotalUntilThisMonth *= factor; + + SetMinutesFreePerWeek(stats, s); + } + } + + return stats; + } + catch + { + return stats; + } + } + + private void SetMinutesFreePerWeek(SupportConceptStatisticsDC stat, SupportConceptPeriodStatisticsDC ps) + { + try + { + DateTime dtPeriod = stat.DateOfCreation.Date; + if (ps.SupportConceptApprovalPeriod.StartDate.HasValue && ps.SupportConceptApprovalPeriod.EndDate.HasValue) + { + if (ps.SupportConceptApprovalPeriod.StartDate.HasValue && ps.SupportConceptApprovalPeriod.StartDate > dtPeriod) + { + dtPeriod = ps.SupportConceptApprovalPeriod.StartDate.Value; + } + TimeSpan tsPeriod = ps.SupportConceptApprovalPeriod.EndDate.Value.Subtract(dtPeriod); + int daysPeriod = tsPeriod.Days + 1; + if (daysPeriod < 0) + { + daysPeriod = 0; + } + if (daysPeriod != 0) + { + ps.MinutesFreePerWeek = (ps.MinutesApprovedTotal - ps.MinutesProvidedTotalRounded) / (daysPeriod / 7m); + ps.MinutesFreePerWeekStatisticDate = (ps.MinutesApprovedTotal - ps.IstTotalUntilThisMonth - ps.MinutesProvidedThisMonth) / (daysPeriod / 7m); + ps.MinutesFreePerMonth = (ps.MinutesApprovedTotal - ps.MinutesProvidedTotalRounded) / (daysPeriod / 7m) * (365m / 84m); + ps.MinutesFreePerMonthStatisticDate = (ps.MinutesApprovedTotal - ps.IstTotalUntilThisMonth - ps.MinutesProvidedThisMonth) / (daysPeriod / 7m) * (365m / 84m); + } + else // Bewilligung ist abgelaufen + { + ps.MinutesFreePerWeek = ps.MinutesApprovedTotal - ps.MinutesProvidedTotalRounded; + ps.MinutesFreePerWeekStatisticDate = ps.MinutesApprovedTotal - ps.MinutesProvidedTotalRounded; + ps.MinutesFreePerMonth = ps.MinutesApprovedTotal - ps.MinutesProvidedTotalRounded; + ps.MinutesFreePerMonthStatisticDate = ps.MinutesApprovedTotal - ps.MinutesProvidedTotalRounded; + } + } + } + catch (Exception) + { + //Mach nichts. Das ist für den alten Mok bei dem die Felder MinutesFreePerWeekStatisticDate noch nicht in der alten Shared.dll existieren + } + } + } +}