From cb5e83f1bb0775064ec49194252591ff43975e4d Mon Sep 17 00:00:00 2001 From: Alexandra Date: Wed, 17 Dec 2025 17:01:52 +0100 Subject: [PATCH] Service/Plugins/ServiceRecordStatisticFactory.cs - Flexibler Wechsel auf Monatsansicht - Default bleibt Woche --- .../Plugins/ServiceRecordStatisticFactory.cs | 159 ++++++++++-------- 1 file changed, 88 insertions(+), 71 deletions(-) diff --git a/Service/Plugins/ServiceRecordStatisticFactory.cs b/Service/Plugins/ServiceRecordStatisticFactory.cs index a3d883f35..1c868eb61 100644 --- a/Service/Plugins/ServiceRecordStatisticFactory.cs +++ b/Service/Plugins/ServiceRecordStatisticFactory.cs @@ -16,87 +16,104 @@ namespace BeWo.Service.Plugins { public virtual ServiceRecordStatisticsInfoDC GetServiceRecordStatisticInfo(long costBearer2SupportConceptOid, DateTime statisticsDate) { - return null; - //if (costBearer2SupportConceptOid == 1) - //{ - // var dc = new ServiceRecordStatisticsInfoDC(); - // dc.Header = new string[5]; - // dc.Header[0] = "Bewilligungszeitraum:"; - // dc.Header[1] = "Test1:"; - // dc.Header[2] = "Test2:"; - // dc.Header[3] = "Test3:"; - // dc.Header[4] = "Test4:"; - // dc.ForegroundColor = new string[5]; - // dc.ForegroundColor[0] = "#FFFF00"; - // dc.ForegroundColor[1] = "#FF0000"; - // dc.ForegroundColor[2] = "#FF00FF"; - // dc.ForegroundColor[3] = "#00FF00"; - // dc.ForegroundColor[4] = "#0000FF"; + if (!UseFlexibleView()) // AB, 17.12.2025: alter Standard: Kein umswitchen erwünscht -> nur Wochenansicht + { + return null; + } - // dc.PeriodStatisticInfos = new List(); + // Monatsansicht wird nur gewählt, wenn ausschließlich Bewilligungen mit Monatsstunden vorhanden sind + var c2s = DAOFactory.GenericDAO.LoadByID(costBearer2SupportConceptOid); + if (c2s.ApprovalPeriodList.Any(scap => scap.ApprovedBEInterval.HasValue && scap.ApprovedBEInterval.Value == SupportConceptApprovalInterval.Monthly) && + !c2s.ApprovalPeriodList.Any(scap => scap.ApprovedBEInterval.HasValue && scap.ApprovedBEInterval.Value == SupportConceptApprovalInterval.Weekly)) + { + var stats = CreateSupportConceptStatisticsImpl(costBearer2SupportConceptOid, statisticsDate); + var dc = new ServiceRecordStatisticsInfoDC(); + dc.Header = new string[4]; + dc.Header[0] = "Bewilligungszeitraum:"; + dc.Header[1] = "Geleistet diesen Monat/Gesamt:"; + dc.Header[2] = "Bewilligt diesen Monat/Gesamt:"; + dc.Header[3] = "Frei diesen Monat/Gesamt:"; - // var pdc = new ServiceRecordPeriodStatisticsInfoDC(); - // dc.PeriodStatisticInfos.Add(pdc); - // pdc.LeftValues = new string[5]; - // pdc.LeftValues[0] = "Überschrift blablabla"; - // pdc.LeftValues[1] = "456"; - // pdc.LeftValues[2] = "789"; - // pdc.LeftValues[3] = "093"; - // pdc.LeftValues[4] = "56352"; + dc.ForegroundColor = new string[4]; + dc.ForegroundColor[0] = "#FF2B508B"; + dc.ForegroundColor[1] = "#FF2B508B"; + dc.ForegroundColor[2] = "#FF2B508B"; + dc.ForegroundColor[3] = "#FF2B508B"; - // pdc.RightValues = new string[5]; - // pdc.RightValues[0] = ""; - // pdc.RightValues[1] = "45,36"; - // pdc.RightValues[2] = "789,00"; - // pdc.RightValues[3] = "093"; - // pdc.RightValues[4] = "56352"; + dc.PeriodStatisticInfos = new List(); + if (stats != null) + { + if (stats.PeriodStatistics.Count > 1 && !TimeSpanIsEqual(stats)) + dc.PeriodStatisticInfos.Add(CreateMonthTotalStatistics(stats, statisticsDate)); - // pdc.LeftValueColors = new string[5]; - // pdc.LeftValueColors[0] = "#888800"; - // pdc.LeftValueColors[1] = "#880000"; - // pdc.LeftValueColors[2] = "#880088"; - // pdc.LeftValueColors[3] = "#008800"; - // pdc.LeftValueColors[4] = "#000088"; + foreach (var pdc in stats.PeriodStatistics) + { + dc.PeriodStatisticInfos.Add(CreateServiceRecordPeriodMonthStatisticsInfo(stats, pdc, statisticsDate)); + } + } - // pdc.RightValueColors = new string[5]; - // pdc.RightValueColors[0] = "#888800"; - // pdc.RightValueColors[1] = "#880000"; - // pdc.RightValueColors[2] = "#880088"; - // pdc.RightValueColors[3] = "#008800"; - // pdc.RightValueColors[4] = "#000088"; + return dc; + } + else + { + return null; + } + } - // pdc = new ServiceRecordPeriodStatisticsInfoDC(); - // dc.PeriodStatisticInfos.Add(pdc); - // pdc.LeftValues = new string[5]; - // pdc.LeftValues[0] = "xxxx"; - // pdc.LeftValues[1] = "456"; - // pdc.LeftValues[2] = "789"; - // pdc.LeftValues[3] = "093"; - // pdc.LeftValues[4] = "56352"; + private ServiceRecordPeriodStatisticsInfoDC CreateServiceRecordPeriodMonthStatisticsInfo(SupportConceptStatisticsDC stats, SupportConceptPeriodStatisticsDC periodStats, DateTime statisticsDate) + { + var dc = CreateDefaultServiceRecordPeriodStatisticsInfo(4); - // pdc.RightValues = new string[5]; - // pdc.RightValues[0] = "yyyyy"; - // pdc.RightValues[1] = "45,36"; - // pdc.RightValues[2] = "789,00"; - // pdc.RightValues[3] = "093"; - // pdc.RightValues[4] = "56352"; + if (periodStats.SupportConceptApprovalPeriod != null) + { + if (periodStats.SupportConceptApprovalPeriod.ServiceCategory != null) + { + dc.LeftValues[0] = String.Format("{0}: {1:dd.MM.yy} - {2:dd.MM.yy}", + periodStats.SupportConceptApprovalPeriod.ServiceCategory.Name, + periodStats.SupportConceptApprovalPeriod.StartDate, + periodStats.SupportConceptApprovalPeriod.EndDate); + } + else + { + dc.LeftValues[0] = String.Format("{0:dd.MM.yy} - {1:dd.MM.yy}", + periodStats.SupportConceptApprovalPeriod.StartDate, + periodStats.SupportConceptApprovalPeriod.EndDate); + } + } - // pdc.LeftValueColors = new string[5]; - // pdc.LeftValueColors[0] = "#088800"; - // pdc.LeftValueColors[1] = "#080000"; - // pdc.LeftValueColors[2] = "#080088"; - // pdc.LeftValueColors[3] = "#808800"; - // pdc.LeftValueColors[4] = "#800088"; + dc.LeftValues[1] = String.Format("{0:0.00}", periodStats.MinutesProvidedThisMonth / 60); + dc.RightValues[1] = String.Format("{0:0.00}", periodStats.MinutesProvidedTotalRounded / 60); - // pdc.RightValueColors = new string[5]; - // pdc.RightValueColors[0] = "#488800"; - // pdc.RightValueColors[1] = "#480000"; - // pdc.RightValueColors[2] = "#480088"; - // pdc.RightValueColors[3] = "#408800"; - // pdc.RightValueColors[4] = "#400088"; + dc.LeftValues[2] = String.Format("{0:0.00}", periodStats.MinutesApprovedPerMonth / 60); + dc.RightValues[2] = String.Format("{0:0.00}", periodStats.MinutesApprovedTotal / 60); - // return dc; - //} + dc.LeftValues[3] = String.Format("{0:0.00}", (periodStats.MinutesApprovedPerMonth - periodStats.MinutesProvidedThisMonth) / 60); + dc.RightValues[3] = String.Format("{0:0.00}", (periodStats.MinutesApprovedTotal - periodStats.MinutesProvidedTotalRounded) / 60); + + + return dc; + } + + public virtual ServiceRecordPeriodStatisticsInfoDC CreateMonthTotalStatistics(SupportConceptStatisticsDC stats, DateTime statisticsDate) + { + var dc = CreateDefaultServiceRecordPeriodStatisticsInfo(4); + dc.LeftValues[0] = "Gesamt"; + + dc.LeftValues[1] = String.Format("{0:0.00}", stats.MinutesProvidedThisMonth / 60); + dc.RightValues[1] = String.Format("{0:0.00}", stats.MinutesProvidedTotalRounded / 60); + + dc.LeftValues[2] = String.Format("{0:0.00}", stats.MinutesApprovedPerMonth / 60); + dc.RightValues[2] = String.Format("{0:0.00}", stats.MinutesApprovedTotal / 60); + + dc.LeftValues[3] = String.Format("{0:0.00}", (stats.MinutesApprovedPerMonth - stats.MinutesProvidedThisMonth) / 60); + dc.RightValues[3] = String.Format("{0:0.00}", (stats.MinutesApprovedTotal - stats.MinutesProvidedTotalRounded) / 60); + + return dc; + } + + public virtual bool UseFlexibleView() + { + return true; } public virtual SupportConceptStatisticsDC CreateSupportConceptStatistics(long costBearer2SupportConceptOid, DateTime statisticsDate)