From 2fe9dd226db67fe0363ba1f2ace7659ca1c951d7 Mon Sep 17 00:00:00 2001 From: Marcel Hirschle Date: Wed, 11 Jan 2023 13:22:45 +0100 Subject: [PATCH] =?UTF-8?q?MH:=20AssL=20aus=20Spitzabrechnungen=20entfernt?= =?UTF-8?q?=20f=C3=BCr=20Aidshilfe=20Duisburg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Invoicing/SettlementInvoiceCreation.cs | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/ReportImp/AidsHilfeDuisburg/Invoicing/SettlementInvoiceCreation.cs b/ReportImp/AidsHilfeDuisburg/Invoicing/SettlementInvoiceCreation.cs index d3a126356..3c0654e3d 100644 --- a/ReportImp/AidsHilfeDuisburg/Invoicing/SettlementInvoiceCreation.cs +++ b/ReportImp/AidsHilfeDuisburg/Invoicing/SettlementInvoiceCreation.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using BeWo.Data.Access; using BeWo.Data.Entities; using BeWo.Service.DCEntityMapper; using BeWo.Service.Invoicing; @@ -70,5 +71,67 @@ namespace AidsHilfeDuisburg.Invoicing } } } + + public override List CreateInvoiceItemsForAccountingPeriods(Settlement2DC si, List accountingPeriods, + List costRatePeriods, Calculations calc) + { + Dictionary oid2Scap = new Dictionary(); + List invoiceItems = new List(); + var cb2sc = MapperFactory.SupportConceptCostBearerRelDC_CostBearer2SupportConcept.MapToNewDC(DAOFactory.GenericDAO.GetByID(si.CostBearer2SupportConceptOid.Value)); + foreach (var ap in accountingPeriods) + { + if (ap.ServiceCategory.Name.Contains("Assistenz")) + continue; + + InvoiceItemDC ii = CreateInvoiceItemForAccountingPeriod(ap); + invoiceItems.Add(ii); + + var scap = ap.SupportConceptApprovalPeriod; + SupportConceptApprovalPeriodDC scapHelper = null; + + if (scap != null) + { + if (oid2Scap.ContainsKey(scap.SupportConceptApprovalPeriodOid.Value)) + scapHelper = oid2Scap[scap.SupportConceptApprovalPeriodOid.Value]; + else + { + scapHelper = new SupportConceptApprovalPeriodDC(); + scapHelper.ApprovedBETotal = scap.ApprovedBETotal; + if (!scapHelper.ApprovedBETotal.HasValue) + scapHelper.ApprovedBETotal = calc.GetApprovedBETotal(scap, costRatePeriods); + + oid2Scap[scap.SupportConceptApprovalPeriodOid.Value] = scapHelper; + } + } + + if (!si.ApprovedFLS.HasValue) + { + if (scapHelper.ApprovedBETotal.HasValue && ii.UnitCount.HasValue) + { + if (scapHelper.ApprovedBETotal >= ii.UnitCount.Value) + { + scapHelper.ApprovedBETotal -= ii.UnitCount.Value; + ii.MaxApprovedUnitCount = null; + } + else + { + ii.MaxApprovedUnitCount = scapHelper.ApprovedBETotal; + } + } + + CalculateInvoiceItemAmounts(ii); + } + + if (ii.UnitCount.HasValue) + { + si.RecordedBillableFLSBrutto = (si.RecordedBillableFLSBrutto ?? 0) + ii.UnitCount; + si.RecordedBillableFLSNetto = si.RecordedBillableFLSBrutto ?? 0; + } + + var list = CreateAdditionalInvoiceItems(ap); + invoiceItems.AddRange(list); + } + return invoiceItems; + } } }