236 lines
7.7 KiB
C#
236 lines
7.7 KiB
C#
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 AufEigenenFuessenStehen.Invoicing
|
|
{
|
|
public class SoziotherapieInvoiceCreation : InvoiceCreation
|
|
{
|
|
public override ServiceInvoice CreateSingleInvoice(int invoiceCounter, CostBearer costBearer, DateTimeSpan invoicePeriod, CompactSupportConceptDC supportConcept, List<ServiceRecordDC> serviceRecords)
|
|
{
|
|
var invoice = new ServiceInvoice();
|
|
var supportConceptList = new List<CompactSupportConceptDC> { 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);
|
|
|
|
// Spitzabrechnung
|
|
if (invoicePeriod == null)
|
|
{
|
|
SetAmountAdvancePayments(invoice);
|
|
SetAmountEquityContribution(invoice);
|
|
}
|
|
|
|
return invoice;
|
|
}
|
|
|
|
public override IList<InvoiceItem> CreateInvoiceItems(List<ServiceRecordDC> 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)
|
|
{
|
|
// Es gibt 4 verschiedene Preise - jeweils für Einzel- bzw. Gruppenstunde
|
|
// sowie für Primär- und Ersatzkasse
|
|
// zusätzlich verschiedene GPos-Nummern für jede Leistung - dort häufig noch nach Dauer (<= 30 min und > 30min) unterschieden
|
|
|
|
var ii = base.CreateInvoiceItem(iServiceRecord, scap, calc);
|
|
ii.ItemDescription = iServiceRecord.ServiceDescription.Name;
|
|
|
|
// 2 Preise, einmal für Funktion Primärkasse und einmal für Funktion Ersatzkasse
|
|
if (ii.ItemDescription.ToLower().Contains("gruppe"))
|
|
{
|
|
if (iServiceRecord.RoundedDuration <= 45)
|
|
{
|
|
ii.UnitDescription = "GPos: 2002678"; // 2 bis 5 Teilnehmer
|
|
}
|
|
else if (iServiceRecord.RoundedDuration <= 60)
|
|
{
|
|
ii.UnitDescription = "GPos: 2002677"; // 2 bis 5 Teilnehmer
|
|
}
|
|
else
|
|
{
|
|
ii.UnitDescription = "GPos: 2002672"; // 2 bis 5 Teilnehmer - 90 Min
|
|
}
|
|
|
|
var preisGruppe = GetGruppenPreis(scap.CostBearer2SupportConcept, iServiceRecord.Start.Value);
|
|
ii.AmountPerUnit = preisGruppe;
|
|
ii.AmountTotal = ii.AmountPerUnit * ii.UnitCount;
|
|
ii.GrossAmountTotal = ii.AmountTotal;
|
|
}
|
|
else
|
|
{
|
|
var preisEinzel = GetEinzelPreis(scap.CostBearer2SupportConcept, iServiceRecord.Start.Value);
|
|
ii.AmountPerUnit = preisEinzel;
|
|
ii.AmountTotal = ii.AmountPerUnit * ii.UnitCount;
|
|
ii.GrossAmountTotal = ii.AmountTotal;
|
|
|
|
if (ii.ItemDescription.ToLower().Contains("probatorik"))
|
|
{
|
|
ii.UnitDescription = "GPos: 2001607";
|
|
}
|
|
else if (ii.ItemDescription.ToLower().Contains("video"))
|
|
{
|
|
if (iServiceRecord.RoundedDuration <= 30)
|
|
{
|
|
ii.UnitDescription = "GPos: 2001616";
|
|
}
|
|
else if (iServiceRecord.RoundedDuration > 30)
|
|
{
|
|
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 <= 10)
|
|
{
|
|
ii.UnitDescription = "GPos: 2001613";
|
|
}
|
|
else if (iServiceRecord.RoundedDuration <= 30)
|
|
{
|
|
ii.UnitDescription = "GPos: 2001612";
|
|
}
|
|
else if (iServiceRecord.RoundedDuration <= 45)
|
|
{
|
|
ii.UnitDescription = "GPos: 2001611";
|
|
}
|
|
else if (iServiceRecord.RoundedDuration > 45)
|
|
{
|
|
ii.UnitDescription = "GPos: 2001610";
|
|
}
|
|
}
|
|
}
|
|
|
|
return ii;
|
|
}
|
|
|
|
public virtual IList<InvoiceItem> CreateHausbesuchspauschale(List<ServiceRecordDC> serviceRecordsInPeriod, DateTimeSpan invoicePeriod, SupportConceptApprovalPeriod scap)
|
|
{
|
|
IList<InvoiceItem> items = new List<InvoiceItem>();
|
|
decimal hausbesuchspauschale = 8.53m;
|
|
hausbesuchspauschale = GetHausbesuchspauschale(scap.CostBearer2SupportConcept, invoicePeriod.StartDate);
|
|
int countHausbesuch = 0;
|
|
foreach (var sr in serviceRecordsInPeriod)
|
|
{
|
|
if (sr.ServiceDescription.Name.ToLower().Contains("hausbesuch") || 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;
|
|
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<InvoiceItem> CreateSummaryInvoiceItems(IList<InvoiceItem> 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;
|
|
}
|
|
}
|
|
}
|