From 53eadc9755570ac6446fc4eb579b62692cb3dbf0 Mon Sep 17 00:00:00 2001 From: Rene Evertz Date: Fri, 31 Jan 2025 10:45:42 +0100 Subject: [PATCH] SoziotherapieInvoiceCreation default --- DakotaSender/Program.cs | 2 + .../DiakonieKKKleve/DiakonieKKKleve.csproj | 1 - .../Invoicing/DiakoneKKKleveInvoiceFactory.cs | 2 +- ...koneKKKleveSoziotherapieInvoiceCreation.cs | 336 ------------------ .../Invoicing/SoziotherapieInvoiceCreation.cs | 256 ------------- .../OwnSoftTest5Mrd/OwnSoftTest5Mrd.csproj | 1 - Service/Invoicing/InvoiceFactory.cs | 2 +- .../Invoicing/SoziotherapieInvoiceCreation.cs | 273 ++++++++++++++ Service/Service.csproj | 1 + 9 files changed, 278 insertions(+), 596 deletions(-) delete mode 100644 ReportImp/DiakonieKKKleve/Invoicing/DiakoneKKKleveSoziotherapieInvoiceCreation.cs delete mode 100644 ReportImp/OwnSoftTest5Mrd/Invoicing/SoziotherapieInvoiceCreation.cs create mode 100644 Service/Invoicing/SoziotherapieInvoiceCreation.cs diff --git a/DakotaSender/Program.cs b/DakotaSender/Program.cs index 38a8914c4..c604b474d 100644 --- a/DakotaSender/Program.cs +++ b/DakotaSender/Program.cs @@ -67,6 +67,8 @@ namespace DakotaSender PrintSeperator(); } + + PrintLine(); } internal static void PrintTitle() diff --git a/ReportImp/DiakonieKKKleve/DiakonieKKKleve.csproj b/ReportImp/DiakonieKKKleve/DiakonieKKKleve.csproj index d951f97c6..1069454e5 100644 --- a/ReportImp/DiakonieKKKleve/DiakonieKKKleve.csproj +++ b/ReportImp/DiakonieKKKleve/DiakonieKKKleve.csproj @@ -126,7 +126,6 @@ - diff --git a/ReportImp/DiakonieKKKleve/Invoicing/DiakoneKKKleveInvoiceFactory.cs b/ReportImp/DiakonieKKKleve/Invoicing/DiakoneKKKleveInvoiceFactory.cs index 01cd3ffcd..1924af9c6 100644 --- a/ReportImp/DiakonieKKKleve/Invoicing/DiakoneKKKleveInvoiceFactory.cs +++ b/ReportImp/DiakonieKKKleve/Invoicing/DiakoneKKKleveInvoiceFactory.cs @@ -49,7 +49,7 @@ namespace DiakonieKKKleve.Invoicing } if (!String.IsNullOrEmpty(sd.Name) && sd.Name.Contains("Therapie")) { - var ic = new DiakoneKKKleveSoziotherapieInvoiceCreation(); + var ic = new SoziotherapieInvoiceCreation(); if (specificId == "FinanzauswertungOhnePauschale") { ic.ErstelleHausbesuchspauschale = false; diff --git a/ReportImp/DiakonieKKKleve/Invoicing/DiakoneKKKleveSoziotherapieInvoiceCreation.cs b/ReportImp/DiakonieKKKleve/Invoicing/DiakoneKKKleveSoziotherapieInvoiceCreation.cs deleted file mode 100644 index 127f82061..000000000 --- a/ReportImp/DiakonieKKKleve/Invoicing/DiakoneKKKleveSoziotherapieInvoiceCreation.cs +++ /dev/null @@ -1,336 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using BeWo.Data.Access; -using BeWo.Data.Entities; -using BeWo.Service.DCEntityMapper; -using BeWo.Service.Invoicing; -using BS.Shared; -using BS.Shared.Core; -using BS.Shared.DataContracts; -using BS.Shared.DataContracts.Compact; -using BS.Shared.Extensions; -using BS.Shared.Services; - -namespace DiakonieKKKleve.Invoicing -{ - public class DiakoneKKKleveSoziotherapieInvoiceCreation : InvoiceCreation - { - public DiakoneKKKleveSoziotherapieInvoiceCreation() : base() - { - //Wichtig für Finanzauswertung. Hier sollen entweder nur die normalen Therapieeinheiten oder nur die Hausbesuchspauschale berechnet werden - ErstelleTherapieeinheiten = true; - ErstelleHausbesuchspauschale = true; - } - - - public bool ErstelleTherapieeinheiten { get; set; } - - public bool ErstelleHausbesuchspauschale { get; set; } - - public override void SetInvoiceId(ServiceInvoice invoice) - { - invoice.InvoiceBase.InvoiceId = "RechnungSoziotherapie"; - invoice.InvoiceBase.InvoiceTypeText = "Soziotherapie"; - } - - public override ServiceInvoice CreateSingleInvoice(int invoiceCounter, CostBearer costBearer, DateTimeSpan invoicePeriod, CompactSupportConceptDC supportConcept, List serviceRecords) - { - var invoice = base.CreateSingleInvoice(invoiceCounter, costBearer, invoicePeriod, supportConcept, serviceRecords); - - if (invoicePeriod != null) - { - SetAmountEquityContribution(invoice); - } - - return invoice; - } - - public override void SetAmountEquityContribution(ServiceInvoice invoice) - { - decimal equity = 0; - - IList EquityInvoiceList = DAOFactory.SearchDAO.GetInvoiceBaseByTypeAndSupportConceptOid(InvoiceType.CustomerEquity, invoice.InvoiceBase.SupportConceptOid.Value); - - EquityInvoiceList = EquityInvoiceList.Where(i => - { - if (i.AccountingPeriodEnd >= invoice.InvoiceBase.AccountingPeriodStart && i.AccountingPeriodStart <= invoice.InvoiceBase.AccountingPeriodEnd) - { - return true; - } - return false; - - }).ToList(); - - foreach (InvoiceBase iEquityInvoice in EquityInvoiceList) - { - foreach (InvoiceItem item in iEquityInvoice.InvoiceItems) - { - if (item.AmountTotal != null) - { - equity += item.AmountTotal.Value; - } - } - } - - invoice.AmountEquityContribution = equity; - } - - public override InvoiceItem CreateInvoiceItem(ServiceRecordDC iServiceRecord, SupportConceptApprovalPeriod scap, BS.Shared.Services.Calculations calc) - { - var ii = base.CreateInvoiceItem(iServiceRecord, scap, calc); - - - - - //if (iServiceRecord.CostBearer.Name.Contains("Techniker Krankenkasse")) - // { - // ii.RateFactor = null; - // ii.AmountTotal = ii.AmountPerUnit * ii.UnitCount; - // ii.GrossAmountTotal = ii.AmountTotal; - //} - - if (ii.ItemDescription.ToLower().Contains("probe")) - { - ii.UnitDescription = "GPos: 2001607"; - } - else if (ii.ItemDescription.ToLower().Contains("gruppentherapie") || (iServiceRecord != null && iServiceRecord.GroupPersonCount.HasValue && iServiceRecord.GroupPersonCount.Value > 1)) - { - //Setze Pauschale für Gruppentherapie - var preisGruppe = GetGruppenPreis(scap.CostBearer2SupportConcept, iServiceRecord.Start.Value); - ii.AmountPerUnit = preisGruppe; - ii.AmountTotal = preisGruppe; - ii.UnitCount = 1; - ii.UnitDescription = "GPos: 2002672"; - } - else if (ii.ItemDescription.ToLower().Contains("video")) - { - if (iServiceRecord.RoundedDuration <= 30 || ii.ItemDescription.ToLower().Contains("30")) - { - ii.UnitDescription = "GPos: 2001616"; - } - else if (iServiceRecord.RoundedDuration > 30 || ii.ItemDescription.ToLower().Contains("60")) - { - ii.UnitDescription = "GPos: 2001615"; - } - } - else if (ii.ItemDescription.ToLower().Contains("telefon")) - { - if (iServiceRecord.RoundedDuration <= 30) - { - ii.UnitDescription = "GPos: 2001618"; - } - else if (iServiceRecord.RoundedDuration > 30) - { - ii.UnitDescription = "GPos: 2001617"; - } - } - else - { - if (iServiceRecord.RoundedDuration <= 30) - { - ii.UnitDescription = "GPos: 2001612"; - } - else if (iServiceRecord.RoundedDuration > 30) - { - ii.UnitDescription = "GPos: 2001610"; - } - } - - return ii; - } - - public virtual InvoiceItem CreateInvoiceItemFactor(ServiceRecordDC iServiceRecord, SupportConceptApprovalPeriod scap, BS.Shared.Services.Calculations calc) - { - var ii = base.CreateInvoiceItem(iServiceRecord, scap, calc); - - //if (iServiceRecord.CostBearer.Name.Contains("Techniker Krankenkasse")) - // { - // ii.UnitCount = ii.UnitCount * ii.RateFactor / 100; - // ii.AmountTotal = ii.AmountPerUnit * ii.UnitCount; - // ii.GrossAmountTotal = ii.AmountTotal; - // ii.RateFactor = null; - // ii.UnitDescription = "Mittelbare Leistung (Verwaltung)"; - //} - - return ii; - } - - public override IList CreateInvoiceItems(List serviceRecordsInPeriod, DateTimeSpan invoicePeriod, SupportConceptApprovalPeriod scap, - BS.Shared.Services.Calculations calc) - { - var list = new List(); - //if (scap.CostBearer2SupportConcept.CostBearer.Organisation.Name.Contains("Techniker Krankenkasse")) - //{ - // list = (List)CreateInvoiceItemsTKK(serviceRecordsInPeriod, invoicePeriod, scap, calc); - //} - //else - //{ - if (ErstelleTherapieeinheiten) - { - list = (List)base.CreateInvoiceItems(serviceRecordsInPeriod, invoicePeriod, scap, calc); - } - - if (ErstelleHausbesuchspauschale) - { - var ii = CreateHausbesuchspauschale(serviceRecordsInPeriod, invoicePeriod, scap); - list.AddRange(ii); - } - - return list; - } - - //public virtual IList CreateInvoiceItemsTKK(List serviceRecordsInPeriod, DateTimeSpan invoicePeriod, SupportConceptApprovalPeriod scap, Calculations calc) - //{ - // var list = new List(); - // foreach (ServiceRecordDC iServiceRecord in serviceRecordsInPeriod) - // { - // if (iServiceRecord.ServiceDescription.Category.IsBillable) - // { - // if (!iServiceRecord.AlreadyAccounted) - // { - // InvoiceItem invoiceItem = CreateInvoiceItem(iServiceRecord, scap, calc); - // if (invoiceItem != null) - // { - // list.Add(invoiceItem); - // } - // InvoiceItem invoiceItemFactor = CreateInvoiceItemFactor(iServiceRecord, scap, calc); - // if (invoiceItemFactor != null) - // { - // list.Add(invoiceItemFactor); - // } - // } - // iServiceRecord.AlreadyAccounted = true; - // } - // } - - // return CreateSummaryInvoiceItems(list, invoicePeriod, scap, calc); - //} - - public virtual IList CreateHausbesuchspauschale(List serviceRecordsInPeriod, DateTimeSpan invoicePeriod, SupportConceptApprovalPeriod scap) - { - //Dictionary differentDays = new Dictionary(); - IList items = new List(); - decimal hausbesuchspauschale = GetHausbesuchspauschale(scap.CostBearer2SupportConcept, invoicePeriod.StartDate); - - //if (invoicePeriod.StartDateTime >= new DateTime(2022, 4, 1)) - //{ - // hausbesuchspauschale = 8.02m; - //} - - int countHausbesuch = 0; - - foreach (var sr in serviceRecordsInPeriod) - { - if (!sr.ServiceDescription.Name.ToLower().Contains("telefon") && !sr.ServiceDescription.Name.ToLower().Contains("gruppe") && !sr.ServiceDescription.Name.ToLower().Contains("praxis")) - { - countHausbesuch++; - } - } - - if (countHausbesuch > 0) - { - var desc = DAOFactory.GenericDAO.GetAllActive(); - CostRatePeriodDC crp = null; - List crpDcs; - - // foreach (var ServiceDescription in desc) - // { - //if (scap.CostBearer2SupportConcept.CostBearer.Organisation.Name.Contains("Barmer")) - //{ - // if (ServiceDescription.Name.Contains("Hausbesuchpauschale") && ServiceDescription.Name.Contains("Barmer")) - // { - // crpDcs = MapperFactory.CostRatePeriodDC_CostRatePeriod.MapToNewDCs(ServiceDescription.CostRatePeriods); - // crp = crpDcs.GetCostRatePeriodForDate(CostRatePeriodType.AmountOfMoney, invoicePeriod.StartDate); - // } - //} - //else - //{ - // if (ServiceDescription.Name.Contains("Hausbesuchpauschale") && !ServiceDescription.Name.Contains("Barmer")) - // { - // crpDcs = MapperFactory.CostRatePeriodDC_CostRatePeriod.MapToNewDCs(ServiceDescription.CostRatePeriods); - // crp = crpDcs.GetCostRatePeriodForDate(CostRatePeriodType.AmountOfMoney, invoicePeriod.StartDate); - // } - //} - - // if (crp != null && crp.CostRateValue.HasValue) - // { - // hausbesuchspauschale = crp.CostRateValue ?? 0; - // } - - // foreach (var oscap in scap.CostBearer2SupportConcept.ApprovalPeriodList) - // { - // if (!String.IsNullOrEmpty(oscap.ServiceCategory.Name) && oscap.ServiceCategory.Name.Contains("Hausbesuchspauschale")) - // hausbesuchspauschale = oscap.ApprovedFixedAmount ?? hausbesuchspauschale; - //} - // } - var invoiceItem = new InvoiceItem(); - - //decimal anzahlHausbesuche = differentDays.Count; - decimal anzahlHausbesuche = countHausbesuch; - - - invoiceItem.AmountPerUnit = hausbesuchspauschale; - invoiceItem.UnitCount = anzahlHausbesuche; - invoiceItem.AmountTotal = anzahlHausbesuche * hausbesuchspauschale; - invoiceItem.ItemPeriodStart = invoicePeriod.StartDate; - invoiceItem.ItemPeriodEnd = invoicePeriod.EndDate; - invoiceItem.RateFactor = null; - invoiceItem.GrossAmountTotal = invoiceItem.AmountTotal; - invoiceItem.ItemDescription = "Hausbesuchspauschale"; - invoiceItem.UnitDescription = "GPos: 2009690"; - if (scap != null) - invoiceItem.SupportConceptApprovalPeriodOid = scap.Oid; - - items.Add(invoiceItem); - } - - return items; - } - private decimal GetHausbesuchspauschale(CostBearer2SupportConcept c2s, DateTime dt) - { - String preisName = "Hausbesuchspauschale Primärkassen"; - - if (c2s.CostBearer.Organisation.Function != null) - { - if (c2s.CostBearer.Organisation.Function.Value.Contains("Ersatzkasse")) - { - preisName = "Hausbesuchspauschale Ersatzkassen"; - } - } - - return base.GetPreis(preisName, dt); - } - - private decimal GetGruppenPreis(CostBearer2SupportConcept c2s, DateTime dt) - { - String preisName = "Gruppentherapie Primärkassen"; - - if (c2s.CostBearer.Organisation.Function != null) - { - if (c2s.CostBearer.Organisation.Function.Value.Contains("Ersatzkasse")) - { - preisName = "Gruppentherapie Ersatzkassen"; - } - } - - return base.GetPreis(preisName, dt); - } - - public override IList CreateSummaryInvoiceItems(IList itemList, DateTimeSpan invoicePeriod, SupportConceptApprovalPeriod scap, BS.Shared.Services.Calculations calc, bool summaryPerMonth, bool addRateFactorToUnitCount) - { - return base.CreateSummaryInvoiceItems(itemList, invoicePeriod, scap, calc, true, true); - } - - public override string GetSummaryItemKey(SupportConceptApprovalPeriod scap, InvoiceItem iitem, bool summaryPerMonth) - { - String key = String.Format("{0}_{1}_{2}", iitem.AmountPerUnit, iitem.RateFactor, iitem.UnitDescription); - if (summaryPerMonth) - { - key = String.Format("{0}_{1}_{2:yyyyMM}_{3}", iitem.AmountPerUnit, iitem.RateFactor, iitem.ItemPeriodStart, iitem.UnitDescription); - } - - return key; - } - } -} diff --git a/ReportImp/OwnSoftTest5Mrd/Invoicing/SoziotherapieInvoiceCreation.cs b/ReportImp/OwnSoftTest5Mrd/Invoicing/SoziotherapieInvoiceCreation.cs deleted file mode 100644 index 395ddfad5..000000000 --- a/ReportImp/OwnSoftTest5Mrd/Invoicing/SoziotherapieInvoiceCreation.cs +++ /dev/null @@ -1,256 +0,0 @@ -using System; -using System.Collections.Generic; -using BeWo.Data.Entities; -using BeWo.Service.Invoicing; -using BS.Shared.Core; -using BS.Shared.DataContracts; -using BS.Shared.DataContracts.Compact; -using BS.Shared.Extensions; -using BS.Shared.Services; - -namespace OwnSoftTest5Mrd.Invoicing -{ - public class SoziotherapieInvoiceCreation : InvoiceCreation - { - public override void SetInvoiceId(ServiceInvoice invoice) - { - invoice.InvoiceBase.InvoiceId = "RechnungSoziotherapie"; - invoice.InvoiceBase.InvoiceTypeText = "Soziotherapie"; - } - - public override ServiceInvoice CreateSingleInvoice(int invoiceCounter, CostBearer costBearer, DateTimeSpan invoicePeriod, CompactSupportConceptDC supportConcept, List serviceRecords) - { - var invoice = new ServiceInvoice(); - - var supportConceptList = new List { supportConcept }; - - SetSenderInformation(invoice); - SetInvoiceBaseData(invoiceCounter, invoice, costBearer, invoicePeriod, supportConceptList); - SetSingleInvoiceBaseData(invoiceCounter, invoice, costBearer, invoicePeriod, supportConcept); - - SetRecipientInformation(invoice, costBearer); - - SetServiceInvoicePeriods(invoice, invoice.InvoiceBase.CostBearer2SupportConcept, invoicePeriod, serviceRecords); - - SetServiceInvoicePeriodAmounts(invoice); - - if (invoicePeriod == null) - { - SetAmountAdvancePayments(invoice); - SetAmountEquityContribution(invoice); - } - - base.CreateSingleInvoice(invoiceCounter, costBearer, invoicePeriod, supportConcept, serviceRecords); - return invoice; - } - - public override IList CreateInvoiceItems(List serviceRecordsInPeriod, DateTimeSpan invoicePeriod, SupportConceptApprovalPeriod scap, Calculations calc) - { - var list = base.CreateInvoiceItems(serviceRecordsInPeriod, invoicePeriod, scap, calc); - var ii = CreateHausbesuchspauschale(serviceRecordsInPeriod, invoicePeriod, scap); - list.AddRange(ii); - - return list; - } - - public override InvoiceItem CreateInvoiceItem(ServiceRecordDC iServiceRecord, SupportConceptApprovalPeriod scap, Calculations calc) - { - var ii = base.CreateInvoiceItem(iServiceRecord, scap, calc); - ii.ItemDescription = iServiceRecord.ServiceDescription.Name; - - if (ii.ItemDescription.ToLower().Contains("gruppe")) - { - if (iServiceRecord.RoundedDuration <= 45) - ii.UnitDescription = "GPos: 2002678"; - else if (iServiceRecord.RoundedDuration <= 60) - ii.UnitDescription = "GPos: 2002677"; - else - ii.UnitDescription = "GPos: 2002672"; // 90 min, 2-5 Personen - ii.AmountPerUnit = GetGruppenPreis(scap.CostBearer2SupportConcept, iServiceRecord.Start.Value); - ii.AmountTotal = ii.AmountPerUnit * ii.UnitCount; - ii.GrossAmountTotal = ii.AmountTotal; - } - else - { - ii.AmountPerUnit = GetEinzelPreis(scap.CostBearer2SupportConcept, iServiceRecord.Start.Value); - ii.AmountTotal = ii.AmountPerUnit * ii.UnitCount; - ii.GrossAmountTotal = ii.AmountTotal; - - if (ii.ItemDescription.ToLower().Contains("video")) - { - if (iServiceRecord.RoundedDuration <= 30) - { - ii.UnitDescription = "GPos: 2001616"; - } - else - { - ii.UnitDescription = "GPos: 2001615"; - } - } - else if (ii.ItemDescription.ToLower().Contains("telefonat")) - { - if (iServiceRecord.RoundedDuration <= 30) - { - ii.UnitDescription = "GPos: 2001618"; - } - else - { - ii.UnitDescription = "GPos: 2001617"; - } - } - else if (ii.ItemDescription.ToLower().Contains("aufsuchende einheit")) - { - if (iServiceRecord.RoundedDuration <= 10) - { - ii.UnitDescription = "GPos: 2001613 / 2009690"; - } - else if (iServiceRecord.RoundedDuration <= 30) - { - ii.UnitDescription = "GPos: 2001612 / 2009690"; - } - else if (iServiceRecord.RoundedDuration <= 45) - { - ii.UnitDescription = "GPos: 2001611 / 2009690"; - } - else - { - ii.UnitDescription = "GPos: 2001610 / 2009690"; - } - } - else if (ii.ItemDescription.ToLower().Contains("aufsuchende probatorik")) - { - ii.UnitDescription = "GPos: 2001607 / 2009690"; - } - else if (ii.ItemDescription.ToLower().Contains("büroprobatorik")) - { - ii.UnitDescription = "GPos: 2001607"; - } - else if (ii.ItemDescription.ToLower().Contains("büroeinheit")) - { - if (iServiceRecord.RoundedDuration <= 10) - { - ii.UnitDescription = "GPos: 2001613"; - } - else if (iServiceRecord.RoundedDuration <= 30) - { - ii.UnitDescription = "GPos: 2001612"; - } - else if (iServiceRecord.RoundedDuration <= 45) - { - ii.UnitDescription = "GPos: 2001611"; - } - else - { - ii.UnitDescription = "GPos: 2001610"; - } - } - } - - return ii; - } - - public virtual IList CreateHausbesuchspauschale(List serviceRecordsInPeriod, DateTimeSpan invoicePeriod, SupportConceptApprovalPeriod scap) - { - IList items = new List(); - decimal hausbesuchspauschale = 8.53m; - if (scap != null && invoicePeriod != null) - { - hausbesuchspauschale = GetHausbesuchspauschale(scap.CostBearer2SupportConcept, invoicePeriod.StartDate); - } - int countHausbesuch = 0; - foreach (var sr in serviceRecordsInPeriod) - { - if (sr.ServiceDescription != null && sr.ServiceDescription.Name != null && sr.ServiceDescription.Name.ToLower().Contains("aufsuchend")) - { - countHausbesuch++; - } - } - - if (countHausbesuch > 0) - { - var invoiceItem = new InvoiceItem(); - - decimal anzahlHausbesuche = countHausbesuch; - - invoiceItem.AmountPerUnit = hausbesuchspauschale; - invoiceItem.UnitCount = anzahlHausbesuche; - invoiceItem.AmountTotal = anzahlHausbesuche * hausbesuchspauschale; - if (invoicePeriod != null) - { - invoiceItem.ItemPeriodStart = invoicePeriod.StartDate; - invoiceItem.ItemPeriodEnd = invoicePeriod.EndDate; - } - invoiceItem.RateFactor = null; - invoiceItem.GrossAmountTotal = invoiceItem.AmountTotal; - invoiceItem.ItemDescription = "Hausbesuchspauschale"; - invoiceItem.UnitDescription = "GPos: 2009690"; - if (scap != null) - invoiceItem.SupportConceptApprovalPeriodOid = scap.Oid; - - items.Add(invoiceItem); - } - return items; - } - - private decimal GetHausbesuchspauschale(CostBearer2SupportConcept c2s, DateTime dt) - { - String preisName = "Hausbesuchspauschale Primärkasse"; - - if (c2s.CostBearer.Organisation.Function != null) - { - if (c2s.CostBearer.Organisation.Function.Value.Contains("Ersatzkasse")) - { - preisName = "Hausbesuchspauschale Ersatzkasse"; - } - } - - return base.GetPreis(preisName, dt); - } - - private decimal GetGruppenPreis(CostBearer2SupportConcept c2s, DateTime dt) - { - String preisName = "Gruppenstunde Primärkasse"; - - if (c2s.CostBearer.Organisation.Function != null) - { - if (c2s.CostBearer.Organisation.Function.Value.Contains("Ersatzkasse")) - { - preisName = "Gruppenstunde Ersatzkasse"; - } - } - - return base.GetPreis(preisName, dt); - } - - private decimal GetEinzelPreis(CostBearer2SupportConcept c2s, DateTime dt) - { - String preisName = "Einzelstunde Primärkasse"; - - if (c2s.CostBearer.Organisation.Function != null) - { - if (c2s.CostBearer.Organisation.Function.Value.Contains("Ersatzkasse")) - { - preisName = "Einzelstunde Ersatzkasse"; - } - } - - return base.GetPreis(preisName, dt); - } - - public override IList CreateSummaryInvoiceItems(IList itemList, DateTimeSpan invoicePeriod, SupportConceptApprovalPeriod scap, Calculations calc, bool summaryPerMonth, bool addRateFactorToUnitCount) - { - return base.CreateSummaryInvoiceItems(itemList, invoicePeriod, scap, calc, true, true); - } - - public override string GetSummaryItemKey(SupportConceptApprovalPeriod scap, InvoiceItem iitem, bool summaryPerMonth) - { - String key = String.Format("{0}_{1}_{2}", iitem.AmountPerUnit, iitem.RateFactor, iitem.ItemDescription); - if (summaryPerMonth) - { - key = String.Format("{0}_{1}_{2:yyyyMM}_{3}", iitem.AmountPerUnit, iitem.RateFactor, iitem.ItemPeriodStart, iitem.ItemDescription); - } - - return key; - } - } -} diff --git a/ReportImp/OwnSoftTest5Mrd/OwnSoftTest5Mrd.csproj b/ReportImp/OwnSoftTest5Mrd/OwnSoftTest5Mrd.csproj index 7a956fb65..b99b74f03 100644 --- a/ReportImp/OwnSoftTest5Mrd/OwnSoftTest5Mrd.csproj +++ b/ReportImp/OwnSoftTest5Mrd/OwnSoftTest5Mrd.csproj @@ -58,7 +58,6 @@ - Component diff --git a/Service/Invoicing/InvoiceFactory.cs b/Service/Invoicing/InvoiceFactory.cs index 6ea3e21eb..65c82412d 100644 --- a/Service/Invoicing/InvoiceFactory.cs +++ b/Service/Invoicing/InvoiceFactory.cs @@ -21,7 +21,7 @@ namespace BeWo.Service.Invoicing return new SbdDefaultInvoiceCreation(); } - return InvoiceCreation.GetInstance(specificId, tenant); + return InvoiceCreation.GetInstance(specificId, tenant); } public virtual SettlementInvoiceCreation CreateSettlementInvoiceCreator(string costbearerId, string tenant, CostBearer2SupportConcept lCb2Sc) diff --git a/Service/Invoicing/SoziotherapieInvoiceCreation.cs b/Service/Invoicing/SoziotherapieInvoiceCreation.cs new file mode 100644 index 000000000..895de7d84 --- /dev/null +++ b/Service/Invoicing/SoziotherapieInvoiceCreation.cs @@ -0,0 +1,273 @@ +using BeWo.Data.Access; +using BeWo.Data.Entities; +using BS.Shared; +using BS.Shared.Core; +using BS.Shared.DataContracts; +using BS.Shared.DataContracts.Compact; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeWo.Service.Invoicing +{ + public class SoziotherapieInvoiceCreation : InvoiceCreation + { + public SoziotherapieInvoiceCreation() : base() + { + //Wichtig für Finanzauswertung. Hier sollen entweder nur die normalen Therapieeinheiten oder nur die Hausbesuchspauschale berechnet werden + ErstelleTherapieeinheiten = true; + ErstelleHausbesuchspauschale = true; + } + + public bool ErstelleTherapieeinheiten { get; set; } + public bool ErstelleHausbesuchspauschale { get; set; } + + public override void SetInvoiceId(ServiceInvoice invoice) + { + invoice.InvoiceBase.InvoiceId = "RechnungSoziotherapie"; + invoice.InvoiceBase.InvoiceTypeText = "Soziotherapie"; + } + + public override ServiceInvoice CreateSingleInvoice(int invoiceCounter, CostBearer costBearer, DateTimeSpan invoicePeriod, CompactSupportConceptDC supportConcept, List serviceRecords) + { + var invoice = base.CreateSingleInvoice(invoiceCounter, costBearer, invoicePeriod, supportConcept, serviceRecords); + + if (invoicePeriod != null) + { + SetAmountEquityContribution(invoice); + } + + return invoice; + } + + public override void SetAmountEquityContribution(ServiceInvoice invoice) + { + decimal equity = 0; + + IList EquityInvoiceList = DAOFactory.SearchDAO.GetInvoiceBaseByTypeAndSupportConceptOid(InvoiceType.CustomerEquity, invoice.InvoiceBase.SupportConceptOid.Value); + + EquityInvoiceList = EquityInvoiceList.Where(i => + { + if (i.AccountingPeriodEnd >= invoice.InvoiceBase.AccountingPeriodStart && i.AccountingPeriodStart <= invoice.InvoiceBase.AccountingPeriodEnd) + { + return true; + } + return false; + + }).ToList(); + + foreach (InvoiceBase iEquityInvoice in EquityInvoiceList) + { + foreach (InvoiceItem item in iEquityInvoice.InvoiceItems) + { + if (item.AmountTotal != null) + { + equity += item.AmountTotal.Value; + } + } + } + + invoice.AmountEquityContribution = equity; + } + + public override InvoiceItem CreateInvoiceItem(ServiceRecordDC iServiceRecord, SupportConceptApprovalPeriod scap, BS.Shared.Services.Calculations calc) + { + var ii = base.CreateInvoiceItem(iServiceRecord, scap, calc); + + if (ii.ItemDescription.ToLower().Contains("probe")) + { + ii.UnitDescription = "GPos: 2001607"; + } + else if (ii.ItemDescription.ToLower().Contains("gruppentherapie") || (iServiceRecord != null && iServiceRecord.GroupPersonCount.HasValue && iServiceRecord.GroupPersonCount.Value > 1)) + { + //Setze Pauschale für Gruppentherapie + var preisGruppe = GetGruppenPreis(scap.CostBearer2SupportConcept, iServiceRecord.Start.Value); + ii.AmountPerUnit = preisGruppe; + ii.AmountTotal = preisGruppe; + ii.UnitCount = 1; + ii.UnitDescription = "GPos: 2002672"; + } + else if (ii.ItemDescription.ToLower().Contains("video")) + { + if (iServiceRecord.RoundedDuration <= 30 || ii.ItemDescription.ToLower().Contains("30")) + { + ii.UnitDescription = "GPos: 2001616"; + } + else if (iServiceRecord.RoundedDuration > 30 || ii.ItemDescription.ToLower().Contains("60")) + { + ii.UnitDescription = "GPos: 2001615"; + } + } + else if (ii.ItemDescription.ToLower().Contains("telefon")) + { + if (iServiceRecord.RoundedDuration <= 30) + { + ii.UnitDescription = "GPos: 2001618"; + } + else if (iServiceRecord.RoundedDuration > 30) + { + ii.UnitDescription = "GPos: 2001617"; + } + } + else + { + if (iServiceRecord.RoundedDuration <= 30) + { + ii.UnitDescription = "GPos: 2001612"; + } + else if (iServiceRecord.RoundedDuration > 30) + { + ii.UnitDescription = "GPos: 2001610"; + } + } + + return ii; + } + + public virtual InvoiceItem CreateInvoiceItemFactor(ServiceRecordDC iServiceRecord, SupportConceptApprovalPeriod scap, BS.Shared.Services.Calculations calc) + { + return CreateInvoiceItem(iServiceRecord, scap, calc); + } + + public override IList CreateInvoiceItems(List serviceRecordsInPeriod, DateTimeSpan invoicePeriod, SupportConceptApprovalPeriod scap, + BS.Shared.Services.Calculations calc) + { + var list = new List(); + + if (ErstelleTherapieeinheiten) + { + list = (List)base.CreateInvoiceItems(serviceRecordsInPeriod, invoicePeriod, scap, calc); + } + + if (ErstelleHausbesuchspauschale) + { + var ii = CreateHausbesuchspauschale(serviceRecordsInPeriod, invoicePeriod, scap); + list.AddRange(ii); + } + + return list; + } + + public virtual IList CreateHausbesuchspauschale(List serviceRecordsInPeriod, DateTimeSpan invoicePeriod, SupportConceptApprovalPeriod scap) + { + IList items = new List(); + decimal hausbesuchspauschale = GetHausbesuchspauschale(scap.CostBearer2SupportConcept, invoicePeriod.StartDate); + + int countHausbesuch = 0; + + foreach (var sr in serviceRecordsInPeriod) + { + if (!sr.ServiceDescription.Name.ToLower().Contains("telefon") && !sr.ServiceDescription.Name.ToLower().Contains("gruppe") && !sr.ServiceDescription.Name.ToLower().Contains("praxis")) + { + countHausbesuch++; + } + } + + if (countHausbesuch > 0) + { + var desc = DAOFactory.GenericDAO.GetAllActive(); + CostRatePeriodDC crp = null; + List crpDcs; + + var invoiceItem = new InvoiceItem(); + + decimal anzahlHausbesuche = countHausbesuch; + + invoiceItem.AmountPerUnit = hausbesuchspauschale; + invoiceItem.UnitCount = anzahlHausbesuche; + invoiceItem.AmountTotal = anzahlHausbesuche * hausbesuchspauschale; + invoiceItem.ItemPeriodStart = invoicePeriod.StartDate; + invoiceItem.ItemPeriodEnd = invoicePeriod.EndDate; + invoiceItem.RateFactor = null; + invoiceItem.GrossAmountTotal = invoiceItem.AmountTotal; + invoiceItem.ItemDescription = "Hausbesuchspauschale"; + invoiceItem.UnitDescription = "GPos: 2009690"; + if (scap != null) + invoiceItem.SupportConceptApprovalPeriodOid = scap.Oid; + + items.Add(invoiceItem); + } + + return items; + } + private decimal GetHausbesuchspauschale(CostBearer2SupportConcept c2s, DateTime dt) + { + String preisName = "Hausbesuchspauschale Primärkassen"; + + if (c2s.CostBearer.Organisation.Function != null) + { + if (c2s.CostBearer.Organisation.Function.Value.Contains("Ersatzkasse")) + { + preisName = "Hausbesuchspauschale Ersatzkassen"; + } + } + + return base.GetPreis(preisName, dt); + } + + private decimal GetGruppenPreis(CostBearer2SupportConcept c2s, DateTime dt) + { + String preisName = "Gruppentherapie Primärkassen"; + + if (c2s.CostBearer.Organisation.Function != null) + { + if (c2s.CostBearer.Organisation.Function.Value.Contains("Ersatzkasse")) + { + preisName = "Gruppentherapie Ersatzkassen"; + } + } + + return base.GetPreis(preisName, dt); + } + + public override IList CreateSummaryInvoiceItems(IList itemList, DateTimeSpan invoicePeriod, SupportConceptApprovalPeriod scap, BS.Shared.Services.Calculations calc, bool summaryPerMonth, bool addRateFactorToUnitCount) + { + var newlist = new List(); + + var rateToItem = new Dictionary(); + foreach (InvoiceItem iitem in itemList) + { + InvoiceItem item; + + var key = String.Format("{0}_{1}_{2:yyyyMMdd}_{3}", iitem.AmountPerUnit, iitem.RateFactor, iitem.ItemPeriodStart, iitem.UnitDescription); + + if (rateToItem.ContainsKey(key)) + { + item = rateToItem[key]; + } + else + { + item = new InvoiceItem(); + newlist.Add(item); + + item.AmountPerUnit = iitem.AmountPerUnit; + item.ItemPeriodStart = iitem.ItemPeriodStart.Value.Date; + item.ItemPeriodEnd = iitem.ItemPeriodEnd.Value.Date; + + item.RateFactor = iitem.RateFactor; + + item.AccountingInterval = iitem.AccountingInterval; + item.ItemDescription = iitem.ItemDescription; + item.UnitDescription = iitem.UnitDescription; + item.SupportConceptApprovalPeriodOid = scap.Oid; + item.ServiceRecord = iitem.ServiceRecord; + + rateToItem[key] = item; + } + + + if (!item.UnitCount.HasValue) + { + item.UnitCount = 0; + } + item.UnitCount += iitem.UnitCount ?? 0; + } + + BerechneSummaryItemsSummen(newlist, addRateFactorToUnitCount); + + return newlist; + } + } +} diff --git a/Service/Service.csproj b/Service/Service.csproj index dbb4aaf0d..8da0c85a9 100644 --- a/Service/Service.csproj +++ b/Service/Service.csproj @@ -420,6 +420,7 @@ +