From 6646d0e43f24abc90d2cbe8040df79cf010b44ac Mon Sep 17 00:00:00 2001 From: Alexandra Date: Wed, 3 Jun 2026 15:48:49 +0200 Subject: [PATCH] MalteserJohanniterJohanneshaus/Invoicing/AnwesenheitenZeiterfassungRO.cs und InvoiceTSH Teilarbeit SupportOID=162787 --- .../Invoicing/AnwesenheitenZeiterfassungRO.cs | 2 +- .../Invoicing/CollectiveInvoiceTSHCreation.cs | 76 ++++++++++++++++--- 2 files changed, 65 insertions(+), 13 deletions(-) diff --git a/ReportImp/MalteserJohanniterJohanneshaus/Invoicing/AnwesenheitenZeiterfassungRO.cs b/ReportImp/MalteserJohanniterJohanneshaus/Invoicing/AnwesenheitenZeiterfassungRO.cs index d384fa15b..76977b8a3 100644 --- a/ReportImp/MalteserJohanniterJohanneshaus/Invoicing/AnwesenheitenZeiterfassungRO.cs +++ b/ReportImp/MalteserJohanniterJohanneshaus/Invoicing/AnwesenheitenZeiterfassungRO.cs @@ -54,7 +54,7 @@ namespace MalteserJohanniterJohanneshaus.Invoicing var c2aodList = new Dictionary(); var alleHilfeplaene = DAOFactory.GenericDAO.GetAllActive(); - var hpsTsh = alleHilfeplaene.SelectMany(sc => sc.CostBearer2SupportConceptList.Where(c2s => c2s.StartDate < end && c2s.CostBearer.Oid == 1 + var hpsTsh = alleHilfeplaene.SelectMany(sc => sc.CostBearer2SupportConceptList.Where(c2s => c2s.StartDate < end && c2s.Notice.IsNotNullOrEmpty() && c2s.Notice.Contains(kostenstelle))).ToList(); foreach (var c2s in hpsTsh) diff --git a/ReportImp/MalteserJohanniterJohanneshaus/Invoicing/CollectiveInvoiceTSHCreation.cs b/ReportImp/MalteserJohanniterJohanneshaus/Invoicing/CollectiveInvoiceTSHCreation.cs index 64d55200b..2a7bdc76f 100644 --- a/ReportImp/MalteserJohanniterJohanneshaus/Invoicing/CollectiveInvoiceTSHCreation.cs +++ b/ReportImp/MalteserJohanniterJohanneshaus/Invoicing/CollectiveInvoiceTSHCreation.cs @@ -28,47 +28,99 @@ namespace MalteserJohanniterJohanneshaus.Invoicing invoice.InvoiceBase.InvoiceTypeText = "RgTSH"; } - // die haben 2 Standorte für TSH, die über Kostenstellen unter Notiz im Hilfeplan identifiziert werden - // Es werden grundsätzlich volle Tagessätze aus der Verwaltung abgerechnet + // die haben 2 Standorte f�r TSH, die �ber Kostenstellen unter Notiz im Hilfeplan identifiziert werden + // Es werden grunds�tzlich volle Tagess�tze aus der Verwaltung abgerechnet // alle Abwesenheitstage werden nur mit 75 % berechnet public override List GenerateServiceInvoices(long costBearerOid, DateTimeSpan invoicePeriod, Dictionary> supportConcepts2ServiceRecords) { var costBearer = DAOFactory.GenericDAO.LoadByID(costBearerOid); - //FuegeAbgelaufeneHilfeplaeneMitAktuellenBewilligungenHinzu(costBearer, invoicePeriod, supportConcepts2ServiceRecords); var invoiceList = new List(); - ServiceInvoice invoice; - Dictionary> Aulholf = new Dictionary>(); - Dictionary> Hannes = new Dictionary>(); + + bool isLvr = costBearer.Organisation.Name != null && costBearer.Organisation.Name.Contains("LVR"); + + if (isLvr) + { + invoiceList.AddRange(GenerateLvrSammelrechnungen(costBearer, invoicePeriod, supportConcepts2ServiceRecords)); + } + else + { + invoiceList.AddRange(GenerateEinzelrechnungen(costBearer, invoicePeriod, supportConcepts2ServiceRecords)); + } + + var result = invoiceList.Select(item => MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewDC(item)).ToList(); + return result.Count > 1 ? result.OrderBy(i => i.InvoiceBase.CustomerLastName).ToList() : result; + } + + private List GenerateLvrSammelrechnungen(CostBearer costBearer, DateTimeSpan invoicePeriod, + Dictionary> supportConcepts2ServiceRecords) + { + var invoiceList = new List(); + var aulholf = new Dictionary>(); + var hannes = new Dictionary>(); foreach (var sc in supportConcepts2ServiceRecords.Keys) { var c2s = DAOFactory.GenericDAO.LoadByID(sc.CostBearerRelOids[0]); if (c2s.Notice.IsNotNullOrEmpty() && c2s.Notice.Contains("45")) { - Aulholf.Add(sc, supportConcepts2ServiceRecords[sc]); + aulholf.Add(sc, supportConcepts2ServiceRecords[sc]); } else if (c2s.Notice.IsNotNullOrEmpty() && c2s.Notice.Contains("50")) { - Hannes.Add(sc, supportConcepts2ServiceRecords[sc]); + hannes.Add(sc, supportConcepts2ServiceRecords[sc]); } } - invoice = CreateCollectiveBilling2(costBearer, invoicePeriod, Aulholf); + + var invoice = CreateCollectiveBilling2(costBearer, invoicePeriod, aulholf); if (invoice != null) { invoice.InvoiceBase.InvoiceTypeText = "KSt.45"; invoiceList.Add(invoice); } - invoice = CreateCollectiveBilling2(costBearer, invoicePeriod, Hannes); + invoice = CreateCollectiveBilling2(costBearer, invoicePeriod, hannes); if (invoice != null) { invoice.InvoiceBase.InvoiceTypeText = "KSt.50"; invoiceList.Add(invoice); } - var result = invoiceList.Select(item => MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewDC(item)).ToList(); - return result.Count > 1 ? result.OrderBy(i => i.InvoiceBase.CustomerLastName).ToList() : result; + return invoiceList; + } + + private List GenerateEinzelrechnungen(CostBearer costBearer, DateTimeSpan invoicePeriod, + Dictionary> supportConcepts2ServiceRecords) + { + var invoiceList = new List(); + var invoiceCounter = 0; + + foreach (var sc in supportConcepts2ServiceRecords.Keys) + { + var c2s = DAOFactory.GenericDAO.LoadByID(sc.CostBearerRelOids[0]); + string kostenstelle = null; + if (c2s.Notice.IsNotNullOrEmpty() && c2s.Notice.Contains("45")) + { + kostenstelle = "KSt.45"; + } + else if (c2s.Notice.IsNotNullOrEmpty() && c2s.Notice.Contains("50")) + { + kostenstelle = "KSt.50"; + } + + var invoice = CreateSingleInvoice(invoiceCounter, costBearer, invoicePeriod, sc, supportConcepts2ServiceRecords[sc]); + if (invoice != null) + { + if (kostenstelle != null) + { + invoice.InvoiceBase.InvoiceTypeText = kostenstelle; + } + invoiceList.Add(invoice); + invoiceCounter++; + } + } + + return invoiceList; }