From bc321d39d1e51e0e25cfe42ce60473e7e90dc42e Mon Sep 17 00:00:00 2001 From: Alexandra Date: Fri, 1 Mar 2024 07:16:59 +0100 Subject: [PATCH] =?UTF-8?q?FeidPartnerReports/Statistics/CustomServiceReco?= =?UTF-8?q?rdStatisticFactory=20-=20=C3=84nderung=20der=20Dokumentation=20?= =?UTF-8?q?und=20Statistik?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FeidPartnerReports.csproj | 2 + .../CustomServiceRecordStatisticFactory.cs | 73 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 ReportImp/FeidPartnerReports/Statistics/CustomServiceRecordStatisticFactory.cs diff --git a/ReportImp/FeidPartnerReports/FeidPartnerReports.csproj b/ReportImp/FeidPartnerReports/FeidPartnerReports.csproj index a80cb081c..e37fbf206 100644 --- a/ReportImp/FeidPartnerReports/FeidPartnerReports.csproj +++ b/ReportImp/FeidPartnerReports/FeidPartnerReports.csproj @@ -112,6 +112,7 @@ CollectiveBillingReport.cs + @@ -121,6 +122,7 @@ ServicesOverviewReport.cs + Component diff --git a/ReportImp/FeidPartnerReports/Statistics/CustomServiceRecordStatisticFactory.cs b/ReportImp/FeidPartnerReports/Statistics/CustomServiceRecordStatisticFactory.cs new file mode 100644 index 000000000..eda0cf0a7 --- /dev/null +++ b/ReportImp/FeidPartnerReports/Statistics/CustomServiceRecordStatisticFactory.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using BeWo.Service.DCEntityMapper; +using BeWo.Service.Plugins; +using BS.Shared; +using BS.Shared.Core; +using BS.Shared.DataContracts; +using BS.Shared.Extensions; +using BS.Shared.Services; + +namespace FeidPartnerReports.Statistics +{ + public class CustomServiceRecordStatisticFactory : ServiceRecordStatisticFactory + { + public override SupportConceptStatisticsDC CreateSupportConceptStatisticsImpl(long costBearer2SupportConceptOid, DateTime statisticsDate, long? ignoreServiceRecordOid) + { + var stat = base.CreateSupportConceptStatisticsImpl(costBearer2SupportConceptOid, statisticsDate, ignoreServiceRecordOid); + + foreach (var item in stat.PeriodStatistics) + { + DateTime start = item.SupportConceptApprovalPeriod.StartDate.Value; + DateTime end = item.SupportConceptApprovalPeriod.EndDate.Value; + DateTime bewStart = item.SupportConceptApprovalPeriod.StartDate.Value; + DateTime bewEnd = item.SupportConceptApprovalPeriod.EndDate.Value; + + + if (statisticsDate < end) + { + end = statisticsDate; + } + + if(bewStart <= DateTime.Now && bewEnd >= DateTime.Now && item.MinutesProvidedThisWeek == 0) + { + item.MinutesProvidedThisWeek = item.MinutesApprovedPerWeek; + stat.MinutesProvidedThisWeek = item.MinutesApprovedPerWeek; + } + //if (item.MinutesProvidedThisMonth == 0) + //{ + // item.MinutesProvidedThisMonth = item.MinutesApprovedPerMonth; + //} + //if (stat.MinutesProvidedThisMonth == 0) + //{ + // stat.MinutesProvidedThisWeek = stat.MinutesApprovedPerMonth; + //} + + while (start < end.Date) + { + if (!EnthaeltEintraege(start, start.AddDays(7), item.ServiceRecords)) + { + //item.MinutesProvidedThisMonth += item.MinutesApprovedPerWeek; + item.MinutesProvidedTotal += item.MinutesApprovedPerWeek; + item.MinutesProvidedTotalRounded += item.MinutesApprovedPerWeek; + stat.MinutesProvidedTotal += item.MinutesApprovedPerWeek; + stat.MinutesProvidedTotalRounded += item.MinutesApprovedPerWeek; + } + start = start.AddDays(7); + } + } + return stat; + } + + private bool EnthaeltEintraege(DateTime start, DateTime end, List serviceRecords) + { + bool vorhandeneEintraege = false; + if (serviceRecords != null && serviceRecords.Count > 0) + { + vorhandeneEintraege = serviceRecords.Any(s => s.Start.Value.Date >= start.Date && s.Start.Value.Date <= end.Date && s.RoundedDuration > 0); + } + return vorhandeneEintraege; + } + } +}