From f36d4e6bfce8e9b5881039b784ae044ef8a9c970 Mon Sep 17 00:00:00 2001 From: Alexandra Date: Wed, 27 Jul 2022 16:41:54 +0200 Subject: [PATCH] AwoDortmund SoziotherapieInvoiceCreation --- .../Invoicing/CustomInvoiceFactory.cs | 6 +- .../Invoicing/SoziotherapieInvoiceCreation.cs | 110 +++++++++++++++--- 2 files changed, 98 insertions(+), 18 deletions(-) diff --git a/ReportImp/AwoDortmund/Invoicing/CustomInvoiceFactory.cs b/ReportImp/AwoDortmund/Invoicing/CustomInvoiceFactory.cs index 83956ce5f..7b279a511 100644 --- a/ReportImp/AwoDortmund/Invoicing/CustomInvoiceFactory.cs +++ b/ReportImp/AwoDortmund/Invoicing/CustomInvoiceFactory.cs @@ -18,16 +18,14 @@ namespace AwoDortmund.Invoicing { var cat = sr.ServiceDescription.Category; - if (!String.IsNullOrEmpty(cat.Name) && cat.Name.ToLower().Contains("soziotherapie")) + if (!String.IsNullOrEmpty(cat.Name) && cat.Name.ToLower().Contains("soziotherapie") + || cat.Name.ToLower().Contains("assistenzleistung nach § 45") || cat.Name.ToLower().Contains("wohngruppenzuschlag nach §38a")) { return new SoziotherapieInvoiceCreation(); } } - } return new DefaultInvoiceCreation(); - } - } } diff --git a/ReportImp/AwoDortmund/Invoicing/SoziotherapieInvoiceCreation.cs b/ReportImp/AwoDortmund/Invoicing/SoziotherapieInvoiceCreation.cs index c5a8d1acc..0e9e497e8 100644 --- a/ReportImp/AwoDortmund/Invoicing/SoziotherapieInvoiceCreation.cs +++ b/ReportImp/AwoDortmund/Invoicing/SoziotherapieInvoiceCreation.cs @@ -27,6 +27,53 @@ namespace AwoDortmund.Invoicing invoice.InvoiceBase.InvoiceTypeText = "Soziotherapie"; } + public override List GenerateServiceInvoices(long costBearerOid, DateTimeSpan invoicePeriod, Dictionary> supportConcepts2ServiceRecords) + { + //bei den Krankenkassen wird je eine Rechnung pro Leistungskategorie benötigt. Der Wohnraumzuschlag ist dabei eine Pauschale... + + var invoiceList = new List(); + var invoiceCounter = 0; + var sortedScs = supportConcepts2ServiceRecords.Keys.OrderBy(s => s.Customer.LastNameFirstName).ToList(); + + foreach (var sc in sortedScs) + { + var serviceRecords = supportConcepts2ServiceRecords[sc]; + if (sc.CostBearerList.Count > 0) + { + var costBearer = DAOFactory.GenericDAO.LoadByID(costBearerOid); + Dictionary> srDict = new Dictionary>(); + + foreach (var sr in serviceRecords) + { + String key = sr.ServiceDescription.CategoryName; + + if (!srDict.ContainsKey(key)) + srDict.Add(key, new List()); + + srDict[key].Add(sr); + } + + srDict.Add("dummyFixAmount", new List()); + + foreach (var catName in srDict.Keys) + { + var list = srDict[catName]; + var invoice = CreateSingleInvoice(invoiceCounter, costBearer, invoicePeriod, sc, list); + + if (invoice != null && invoice.ServiceInvoicePeriodList.Count > 0) + { + invoice.InvoiceBase.InvoiceId = "RechnungSoziotherapie"; + invoiceList.Add(invoice); + invoiceCounter++; + } + } + } + } + + var result = invoiceList.Select(item => MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewDC(item)).ToList(); + return result; + } + //public override ServiceInvoice CreateSingleInvoice(int invoiceCounter, CostBearer costBearer, DateTimeSpan invoicePeriod, CompactSupportConceptDC supportConcept, List serviceRecords) //{ // var invoice = base.CreateSingleInvoice(invoiceCounter, costBearer, invoicePeriod, supportConcept, serviceRecords); @@ -76,21 +123,28 @@ namespace AwoDortmund.Invoicing DateTimeSpan invoicePeriod, List serviceRecords) { - Calculations calc = PluginLoader.FindClass(_SpecificID) ?? Calculations.GetInstance(_SpecificID); - List serviceRecordsInPeriod = serviceRecords.Where( - i => - { - bool valid = i.Start.Value.InBetween(serviceInvoicePeriod.Start.Value, - serviceInvoicePeriod.End.Value, true); + if (ShouldCreateFixedAmounts(serviceInvoicePeriod, supportConceptApprovalPeriod, cb2sc) && serviceRecords.Count == 0) + { + CreateFixedAmounts(serviceInvoicePeriod, supportConceptApprovalPeriod, cb2sc); + } + else + { + Calculations calc = PluginLoader.FindClass(_SpecificID) ?? Calculations.GetInstance(_SpecificID); + List serviceRecordsInPeriod = serviceRecords.Where( + i => + { + bool valid = i.Start.Value.InBetween(serviceInvoicePeriod.Start.Value, + serviceInvoicePeriod.End.Value, true); - if (valid && serviceInvoicePeriod.SupportConceptApprovalPeriod != null && serviceInvoicePeriod.SupportConceptApprovalPeriod.ServiceCategory != null) - valid = serviceInvoicePeriod.SupportConceptApprovalPeriod.ServiceCategory.Oid == - i.ServiceDescription.Category.ServiceCategoryOid; - return valid; - }).ToList(); + if (valid && serviceInvoicePeriod.SupportConceptApprovalPeriod != null && serviceInvoicePeriod.SupportConceptApprovalPeriod.ServiceCategory != null) + valid = serviceInvoicePeriod.SupportConceptApprovalPeriod.ServiceCategory.Oid == + i.ServiceDescription.Category.ServiceCategoryOid; + return valid; + }).ToList(); - var itemList = CreateInvoiceItems(serviceRecordsInPeriod, invoicePeriod, serviceInvoicePeriod.SupportConceptApprovalPeriod, calc); - serviceInvoicePeriod.InvoiceItemList.AddRange(itemList); + var itemList = CreateInvoiceItems(serviceRecordsInPeriod, invoicePeriod, serviceInvoicePeriod.SupportConceptApprovalPeriod, calc); + serviceInvoicePeriod.InvoiceItemList.AddRange(itemList); + } } public override InvoiceItem CreateInvoiceItem(ServiceRecordDC iServiceRecord, SupportConceptApprovalPeriod scap, Calculations calc) @@ -127,7 +181,7 @@ namespace AwoDortmund.Invoicing // ii.ItemDescription = "Soziotherapie 60 min."; //} ii.AmountPerUnit = preisSoziotherapie60min; - ii.ItemDescription = "Soziotherapie"; + ii.ItemDescription = iServiceRecord.ServiceDescription.CategoryName; ii.RateFactor = null; ii.AmountTotal = ii.AmountPerUnit * ii.UnitCount; ii.GrossAmountTotal = ii.AmountTotal; @@ -215,5 +269,33 @@ namespace AwoDortmund.Invoicing { return base.CreateSummaryInvoiceItems(itemList, invoicePeriod, scap, calc, true, true); } + + public override void CreateFixedAmounts(ServiceInvoicePeriod serviceInvoicePeriod, SupportConceptApprovalPeriodDC supportConceptApprovalPeriod, CostBearer2SupportConcept cb2sc) + { + var calc = PluginLoader.FindClass(_SpecificID) ?? Calculations.GetInstance(_SpecificID); + var data = calc.GetFixedBillingData(supportConceptApprovalPeriod, serviceInvoicePeriod.Start, serviceInvoicePeriod.End); + + foreach (var billingData in data) + { + var ii = new InvoiceItem + { + AmountTotal = billingData.AmountTotal, + GrossAmountTotal = billingData.GrossAmountTotal, + ItemPeriodStart = billingData.BillingPeriodStart, + ItemPeriodEnd = billingData.BillingPeriodEnd, + AccountingInterval = billingData.AccountingInterval, + AmountPerUnit = billingData.AmountPerUnit, + UnitCount = billingData.UnitCount + }; + + if (supportConceptApprovalPeriod.ServiceCategory != null) + { + ii.ItemDescription = supportConceptApprovalPeriod.ServiceCategory.Name; + ii.UnitCount = null; + } + serviceInvoicePeriod.InvoiceItemList.Add(ii); + } + } } } +