diff --git a/ReportImp/SicherlebenMichaelVoß/Invoicing/CustomSettlementInvoiceCreation.cs b/ReportImp/SicherlebenMichaelVoß/Invoicing/CustomSettlementInvoiceCreation.cs new file mode 100644 index 000000000..3a5a1baf6 --- /dev/null +++ b/ReportImp/SicherlebenMichaelVoß/Invoicing/CustomSettlementInvoiceCreation.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using BeWo.Data.Entities; +using BeWo.Service.Invoicing; +using BeWo.Service.Plugins; +using BS.Shared.Core; +using BS.Shared.DataContracts; + +namespace SicherlebenMichaelVoß +{ + [IDSpecificClass(Identifier = "LWLNEU")] + [IgnoreAutoPlugin] + + internal class CustomSettlementInvoiceCreation : LWLSettlementInvoiceCreation + { + // AB, 17.09.2025: ist nur als Bugfix drin, damit die schnell wieder was tun können, kann nach Serverlieferung raus. + public override List CreateInvoiceItems(Settlement2DC si, IList apList, bool schneideBeiMaxAb) + { + List iiList = new List(); + var apsByHourlyRate = new Dictionary>(); + + foreach (var ap in apList) + { + IList list = null; + String key = String.Format("{0}_{1}", ap.AmountPerUnit, ap.RateFactor); + + if (apsByHourlyRate.ContainsKey(key)) + { + list = apsByHourlyRate[key]; + } + else + { + list = new List(); + apsByHourlyRate[key] = list; + } + + list.Add(ap); + } + + decimal maxApprovedFls = si.ApprovedFLS ?? 0; + decimal totalHours = 0; + foreach (var key in apsByHourlyRate.Keys) + { + IList list = apsByHourlyRate[key]; + var ii = new InvoiceItemDC(); + + decimal minutesTotal = 0; + decimal minutesTotalBudget = 0; + + DateTime start = DateTime.MaxValue; + DateTime end = DateTime.MinValue; + + decimal rf = si.RateFactor ?? 0; + decimal hr = 0; + + foreach (var approvalPeriod in list) + { + minutesTotal += approvalPeriod.RecordedMinutes; + minutesTotalBudget += approvalPeriod.BudgetMinutes; + if (approvalPeriod.PeriodStartDate < start) + start = approvalPeriod.PeriodStartDate; + if (approvalPeriod.PeriodEndDate > end) + end = approvalPeriod.PeriodEndDate; + + hr = approvalPeriod.AmountPerUnit; + if (approvalPeriod.RateFactor.HasValue) + { + rf = approvalPeriod.RateFactor.Value; + } + if (!String.IsNullOrEmpty(approvalPeriod.Notice) && approvalPeriod.Notice == "Fehlkontakte") + { + hr *= 0.8m; + ii.ItemDescription = "Fehlkontakte"; + } + } + ii.ItemPeriodStart = start; + ii.ItemPeriodEnd = end; + ii.RateFactor = rf; + ii.AmountPerUnit = hr; + decimal hours = Math.Round(minutesTotal / 60m, 2, MidpointRounding.AwayFromZero); + hours *= (100 + rf) / 100; + hours = Math.Round(hours, 2, MidpointRounding.AwayFromZero); + + decimal hoursBudget = Math.Round(minutesTotalBudget / 60m, 2, MidpointRounding.AwayFromZero); + hoursBudget *= (100 + rf) / 100; + hoursBudget = Math.Round(hoursBudget, 2, MidpointRounding.AwayFromZero); + totalHours += hoursBudget; + + ii.UnitCount = hours; + ii.UnitCountBudget = hoursBudget; + ii.AmountTotal = Math.Round(hr * hours, 2, MidpointRounding.AwayFromZero); + ii.GrossAmountTotal = ii.AmountTotal; + + iiList.Add(ii); + } + + return iiList.OrderBy(ii => ii.ItemPeriodStart).ToList(); + } + } +} diff --git a/ReportImp/SicherlebenMichaelVoß/SicherlebenMichaelVoß.csproj b/ReportImp/SicherlebenMichaelVoß/SicherlebenMichaelVoß.csproj index 29482b03b..509d6512e 100644 --- a/ReportImp/SicherlebenMichaelVoß/SicherlebenMichaelVoß.csproj +++ b/ReportImp/SicherlebenMichaelVoß/SicherlebenMichaelVoß.csproj @@ -60,6 +60,7 @@ + Component