diff --git a/Service/Invoicing/LWLBeWo67SettlementInvoiceCreation.cs b/Service/Invoicing/LWLBeWo67SettlementInvoiceCreation.cs index 916e41e33..bd1506b51 100644 --- a/Service/Invoicing/LWLBeWo67SettlementInvoiceCreation.cs +++ b/Service/Invoicing/LWLBeWo67SettlementInvoiceCreation.cs @@ -149,7 +149,7 @@ namespace BeWo.Service.Invoicing } - private List CreateInvoiceItems(Settlement2DC si, IList apList) + public virtual List CreateInvoiceItems(Settlement2DC si, IList apList) { List iiList = new List(); @@ -204,9 +204,15 @@ namespace BeWo.Service.Invoicing } if (rf > 0) { - decimal totalAmount = 0; + // 28.10.2024 Änderung von Summe der pauschalen Leistungen zu Stundensatz x Faktor und Zwischenrundung + decimal totalAmountFW = 0; + decimal totalAmountAF = 0; + int rfFahrzeit = (int)Math.Min(20, rf); + decimal rfAusfall = rf - rfFahrzeit; DateTime? start = DateTime.MaxValue; DateTime? end = DateTime.MinValue; + decimal hours = 0; + decimal hr = 0; foreach (var iii in iiList) { @@ -214,21 +220,20 @@ namespace BeWo.Service.Invoicing start = iii.ItemPeriodStart; if (iii.ItemPeriodEnd > end) end = iii.ItemPeriodEnd; - totalAmount += iii.GrossAmountTotal ?? 0; + hours = iii.UnitCount.Value; + hr = iii.AmountPerUnit.Value; + totalAmountFW += Math.Round(Math.Round(hr * rfFahrzeit / 100, 2, MidpointRounding.AwayFromZero) * hours, 2, MidpointRounding.AwayFromZero); + totalAmountAF += Math.Round(Math.Round(hr * rfAusfall / 100, 2, MidpointRounding.AwayFromZero) * hours, 2, MidpointRounding.AwayFromZero); } //zzgl. Fahr+Wegezeiten (20 %) var ii = new InvoiceItemDC(); - - int rfFahrzeit = (int)Math.Min(20, rf); - rf -= rfFahrzeit; - ii.ItemPeriodStart = start; ii.ItemPeriodEnd = end; ii.RateFactor = rfFahrzeit; - ii.AmountPerUnit = (totalAmount * rfFahrzeit) / 100; + ii.AmountPerUnit = totalAmountFW; ii.UnitCount = 1; - ii.AmountTotal = Math.Round(ii.AmountPerUnit.Value * ii.UnitCount.Value, 2, MidpointRounding.AwayFromZero); + ii.AmountTotal = totalAmountFW; ii.GrossAmountTotal = ii.AmountTotal; ii.ItemDescription = "Fahrt- und Wegezeiten"; iiList.Add(ii); @@ -241,9 +246,9 @@ namespace BeWo.Service.Invoicing ii.ItemPeriodStart = start; ii.ItemPeriodEnd = end; ii.RateFactor = rf; - ii.AmountPerUnit = (totalAmount * rf) / 100; + ii.AmountPerUnit = totalAmountAF; ii.UnitCount = 1; - ii.AmountTotal = Math.Round(ii.AmountPerUnit.Value * ii.UnitCount.Value, 2, MidpointRounding.AwayFromZero); + ii.AmountTotal = totalAmountAF; ii.GrossAmountTotal = ii.AmountTotal; ii.ItemDescription = "Ausfallzeiten Fehlkontakte"; @@ -251,7 +256,6 @@ namespace BeWo.Service.Invoicing } } - return iiList.OrderBy(ii => ii.ItemPeriodStart).ToList(); } @@ -286,5 +290,4 @@ namespace BeWo.Service.Invoicing approvalPeriod.ApprovedAmountTotal = Math.Round(approvalPeriod.ApprovedTotal * approvalPeriod.AmountPerUnit, 2, MidpointRounding.AwayFromZero); } } - }