From 80a76162efd1b85bff30b92b1e943dfc28e570c1 Mon Sep 17 00:00:00 2001 From: Marcel Hirschle Date: Wed, 10 May 2023 12:32:59 +0200 Subject: [PATCH] =?UTF-8?q?MH:=20Autismus=20K=C3=B6ln=20Bonn=20Spitzabrech?= =?UTF-8?q?nung=20Rundung?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AutismusKoelnBonn.csproj | 1 + .../Invoicing/CustomInvoiceFactory.cs | 6 ++- .../CustomSettlementInvoiceCreation.cs | 52 +++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 ReportImp/AutismusKoelnBonn/Invoicing/CustomSettlementInvoiceCreation.cs diff --git a/ReportImp/AutismusKoelnBonn/AutismusKoelnBonn.csproj b/ReportImp/AutismusKoelnBonn/AutismusKoelnBonn.csproj index 5db34c1d1..381f97bbd 100644 --- a/ReportImp/AutismusKoelnBonn/AutismusKoelnBonn.csproj +++ b/ReportImp/AutismusKoelnBonn/AutismusKoelnBonn.csproj @@ -56,6 +56,7 @@ + diff --git a/ReportImp/AutismusKoelnBonn/Invoicing/CustomInvoiceFactory.cs b/ReportImp/AutismusKoelnBonn/Invoicing/CustomInvoiceFactory.cs index 5fe8971e7..7b0499d80 100644 --- a/ReportImp/AutismusKoelnBonn/Invoicing/CustomInvoiceFactory.cs +++ b/ReportImp/AutismusKoelnBonn/Invoicing/CustomInvoiceFactory.cs @@ -37,5 +37,9 @@ namespace AutismusKoelnBonn.Invoicing return new InvoiceCreation(); } - } + public override SettlementInvoiceCreation CreateSettlementInvoiceCreator(string costbearerId, string tenant, CostBearer2SupportConcept lCb2Sc) + { + return new CustomSettlementInvoiceCreation(); + } + } } diff --git a/ReportImp/AutismusKoelnBonn/Invoicing/CustomSettlementInvoiceCreation.cs b/ReportImp/AutismusKoelnBonn/Invoicing/CustomSettlementInvoiceCreation.cs new file mode 100644 index 000000000..dfbd470a5 --- /dev/null +++ b/ReportImp/AutismusKoelnBonn/Invoicing/CustomSettlementInvoiceCreation.cs @@ -0,0 +1,52 @@ +using BeWo.Service.Invoicing; +using BS.Shared.DataContracts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AutismusKoelnBonn.Invoicing +{ + public class CustomSettlementInvoiceCreation : SettlementInvoiceCreation + { + // Änderung: Rundung von AmountTotal + public override void CalculateInvoiceItemAmounts(Settlement2DC si) + { + decimal maxApprovedFls = si.ApprovedFLS ?? 0; + + foreach (var ii in si.InvoiceItems) + { + if (ii.UnitCount.HasValue) + { + var unitCountBudget = Math.Round(ii.UnitCountBudget ?? ii.UnitCount ?? 0, 2, MidpointRounding.AwayFromZero); + if (maxApprovedFls < unitCountBudget) + unitCountBudget = maxApprovedFls; + + maxApprovedFls -= unitCountBudget; + + if (unitCountBudget < ii.UnitCount) + { + ii.UnitCount = unitCountBudget; + } + if (ii.AmountPerUnit.HasValue) + { + // ÄNDERUNG NACHFOLGENDE ZEILE + ii.AmountTotal = Math.Round(ii.UnitCount.Value, 2, MidpointRounding.AwayFromZero) * ii.AmountPerUnit.Value; + if (ii.RateFactor.HasValue && ii.RateFactor.Value != 0) + ii.GrossAmountTotal = Math.Round(ii.AmountTotal.Value * ((100m + ii.RateFactor.Value) / 100m), 2, + MidpointRounding.AwayFromZero); + else + ii.GrossAmountTotal = ii.AmountTotal; + + } + if (ii.MaxApprovedUnitCount < ii.UnitCount) + { + ii.MaxApprovedUnitCount = ii.UnitCount; + } + } + } + + } + } +}