diff --git a/ReportImp/AlzeyTeilhabe/StundenzettelSoziotherapie.cs b/ReportImp/AlzeyTeilhabe/StundenzettelSoziotherapie.cs index 26fca503b..e80c2b0a8 100644 --- a/ReportImp/AlzeyTeilhabe/StundenzettelSoziotherapie.cs +++ b/ReportImp/AlzeyTeilhabe/StundenzettelSoziotherapie.cs @@ -35,9 +35,25 @@ namespace AlzeyTeilhabe if (pRO.Services != null) { - decimal stundensatz = GetStundensatz(pRO); pRO.RateFactor = stundensatz; + ServiceCategoryDC sc = null; // Kategorie ist nur Soziotherapie. Die wird für den Stundensatz benötigt + List serviceDescriptions = new List(); // Alle dokumentierten Leistungen werden benötigt, da je nach Leistung eine andere Fahrtpauschale anfällt. Die richtige wird unten dann aus dieser Liste gesucht + + // Für Stundensätze Sozio-Kategorie + Alle Leistungen raussuchen + if (pRO.Services.Count > 0) + { + sc = MapperFactory.ServiceCategoryDC_ServiceCategory.MapToNewDC(DAOFactory.SearchDAO.FindServiceCategoryByName(pRO.Services[0].ServiceCategory)); + + foreach (var service in pRO.Services) + { + if(!serviceDescriptions.Any(s => s.Name == service.ServiceDescription)) + { + var sr = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDC(DAOFactory.GenericDAO.GetByID(service.ServiceRecordOid)); + serviceDescriptions.Add(sr.ServiceDescription); + } + } + } List servicesBillable = new List(); var gesamtpreis = 0.0m; @@ -45,16 +61,26 @@ namespace AlzeyTeilhabe { if (s.IsBillable) { - var sr = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDC(DAOFactory.GenericDAO.GetByID(s.ServiceRecordOid)); + // Stundensatz ist der von Soziotherapie + if (sc != null) + { + var crp = sc.CostRatePeriods.GetCostRatePeriodForDate(CostRatePeriodType.AmountOfMoney, s.StartDate); + if (crp.CostRateValue.HasValue) + { + stundensatz = crp.CostRateValue.Value; + pRO.RateFactor = stundensatz; + } + } + // Ist aber eine Leistung mit Stundensatz dokumentiert, wird der genommen + var desc = serviceDescriptions.FirstOrDefault(sd => sd.Name == s.ServiceDescription); + var crpValue = desc != null ? desc.CostRatePeriods.GetCostRatePeriodForDate(CostRatePeriodType.AmountOfMoney, s.StartDate) : null; - var crpValue = sr.ServiceDescription.CostRatePeriods.GetCostRatePeriodForDate(CostRatePeriodType.AmountOfMoney, s.StartDate); - - //var crp = sr.ServiceDescription.CostRatePeriods.Count > 0 ? sr.ServiceDescription.CostRatePeriods.FirstOrDefault(c => c.EndDate == null) : null; if (crpValue != null && crpValue.CostRateValue.HasValue) stundensatz = crpValue.CostRateValue.Value; else stundensatz = pRO.RateFactor; + // Preise etc. setzen ServicesOverviewRO.CreateSignatureString(s); //s.Notice4 = string.Format("{0:00}", (s.EndDate - s.StartDate).TotalHours) + ":"+ string.Format("{0:00}", (s.EndDate - s.StartDate).TotalMinutes % 60);