VereinBeratungTherapie/Invoicing/CollectiveInvoiceCreation - Umrechnung in LG - Nullpointer in Rg gefixt

This commit is contained in:
2025-06-10 16:29:46 +02:00
parent 7b9609571c
commit 9c2d064587
2 changed files with 100 additions and 24 deletions

View File

@@ -49,8 +49,16 @@ namespace VereinBeratungTherapie
for (int i = listLength - 1; i >= 0; i--)
{
var sip = pRO.ServiceInvoicePeriods[i];
if (sip.Customer.Name.Contains("Baba"))
{
int test = 1;
}
if (sip.ServiceInvoiceItems[0].ServiceDescription != null && sip.ServiceInvoiceItems[0].ServiceDescription.StartsWith("Qualifizierte Assistenz TS"))
{
if (sip.Customer.Name.Contains("Baba"))
{
int test = 1;
}
if (i + 1 != listLength && pRO.ServiceInvoicePeriods[i + 1].ServiceInvoiceItems[0].ServiceDescription.StartsWith("Qualifizierte Assistenz"))
{
var ii = sip.ServiceInvoiceItems[0];
@@ -177,6 +185,10 @@ namespace VereinBeratungTherapie
for (int i = 0; i < count; i++)
{
var sip = pRO.ServiceInvoicePeriods[i];
if (sip.Customer.Name.Contains("Baba"))
{
int test = 1;
}
sip.NotBillableString = i.ToString();
if (sip.ServiceInvoiceItems.Count > 0)
{
@@ -188,16 +200,19 @@ namespace VereinBeratungTherapie
// if (sip.ServiceInvoiceItems.Count > 0)
// //sip.NotBillableString = sip.ServiceInvoiceItems[0].UnitDescription;
//}
if (sip.SupportConceptApprovalPeriod.ServiceCategory == null || sip.SupportConceptApprovalPeriod.ServiceCategory != null && sip.SupportConceptApprovalPeriod.ServiceCategory.Name.Contains("Monat"))
sip.ApprovedHours = 1;
else
if (sip.SupportConceptApprovalPeriod != null)
{
DateTime end = sip.SupportConceptApprovalPeriod.EndDate ?? pRO.AccountingPeriodEnd;
DateTime start = sip.SupportConceptApprovalPeriod.StartDate ?? pRO.AccountingPeriodStart;
if (sip.SupportConceptApprovalPeriod.ServiceCategory == null || sip.SupportConceptApprovalPeriod.ServiceCategory != null && sip.SupportConceptApprovalPeriod.ServiceCategory.Name.Contains("Monat"))
sip.ApprovedHours = 1;
else
{
DateTime end = sip.SupportConceptApprovalPeriod.EndDate ?? pRO.AccountingPeriodEnd;
DateTime start = sip.SupportConceptApprovalPeriod.StartDate ?? pRO.AccountingPeriodStart;
sip.ApprovedHours = (decimal)(end - start).TotalDays;
sip.ApprovedHours = (decimal)(end - start).TotalDays;
}
}
if (sip.CostBearer2SupportConcept.CustomerReferenceNumber == null)
if (sip.CostBearer2SupportConcept != null && sip.CostBearer2SupportConcept.CustomerReferenceNumber == null)
{
sip.CostBearer2SupportConcept.CustomerReferenceNumber = "";
}

View File

@@ -146,6 +146,7 @@ namespace VereinBeratungTherapie.Invoicing
end = supportConceptApprovalPeriod.EndDate.Value;
}
decimal lgMin = 1;
decimal LG = 1;
var cat = supportConceptApprovalPeriod.ServiceCategory;
if (cat != null)
@@ -199,15 +200,24 @@ namespace VereinBeratungTherapie.Invoicing
decimal preisLG = 0;
if (supportConceptApprovalPeriod.ApprovedBEPerInterval.HasValue)
{
LG = supportConceptApprovalPeriod.ApprovedBEPerInterval.Value;
lgMin = supportConceptApprovalPeriod.ApprovedBEPerInterval.Value;
}
if (data != null && data.Count > 0)
{
// LWV rundet den Prei bei KA und alten Bewilligungen QA auf Minutenwert und bei neuer QA auf Stunden :-P
if ((cat.Abbreviation.Contains("QA") || cat.Name.Contains("Qualifizierte"))
&& new List<decimal> { 60, 120, 180, 240, 330, 450, 630, 900 }.Contains(LG))
// LWV rundet den Preis bei KA und alten Bewilligungen QA auf Minutenwert und bei neuer QA auf Stunden :-P
if (cat.Abbreviation.Contains("QA") || cat.Name.Contains("Qualifizierte"))
//&& new List<decimal> { 60, 120, 180, 240, 330, 450, 630, 900 }.Contains(LG))
{
if (supportConceptApprovalPeriod.Notice != null && supportConceptApprovalPeriod.Notice.ToLower().Contains("alt"))
{
LG = lgMin;
}
else
{
LG = GetLeistungsgruppe(lgMin, cat);
}
ii.Notice = String.Format("{0:n0}", LG);
LG = Math.Round(LG / 60, 2, MidpointRounding.AwayFromZero);
if (data != null && data.Count > 0 && supportConceptApprovalPeriod.ApprovedBEPerInterval != null)
{
@@ -221,7 +231,7 @@ namespace VereinBeratungTherapie.Invoicing
{
preisLG = data[0].AmountTotal.Value;
preis = Math.Round(preisLG / 60, 4, MidpointRounding.AwayFromZero);
ii.AmountPerUnit = Math.Round(preis * LG, 2, MidpointRounding.AwayFromZero);
ii.AmountPerUnit = Math.Round(preis * lgMin, 2, MidpointRounding.AwayFromZero);
ii.AmountTotal = ii.UnitCount * ii.AmountPerUnit;
}
}
@@ -230,24 +240,24 @@ namespace VereinBeratungTherapie.Invoicing
if (cat.Abbreviation.Contains("TS")
&& cb2sc.ApprovalPeriodList.Any(a => a.ServiceCategory.Abbreviation.Contains(cat.Abbreviation.Substring(0, 2)) && !a.ServiceCategory.Abbreviation.Contains("TS")))
{
GetKombiniertenPreisQA(serviceInvoicePeriod, supportConceptApprovalPeriod, cat, cb2sc, LG, preisLG, ii);
GetKombiniertenPreisQA(serviceInvoicePeriod, supportConceptApprovalPeriod, cat, cb2sc, lgMin, LG, preisLG, ii);
}
}
}
}
ii.GrossAmountTotal = ii.AmountTotal;
serviceInvoicePeriod.InvoiceItemList.Add(ii);
// ToDo!!! letzter Monat wird bei Kompensatorischer Assistenz spitzabgerechnet!!!
// siehe Übersicht Umstellung Vergütung...xlsx -> hier kommt die normale Monatszeile plus je eine Zeile pro Jahr mit zu wenig erbrachten Stunden!
}
}
private void GetKombiniertenPreisQA(ServiceInvoicePeriod period, SupportConceptApprovalPeriodDC scapTS, ServiceCategoryDC cat, CostBearer2SupportConcept cb2sc, decimal LG, decimal? preis, InvoiceItem ii)
private void GetKombiniertenPreisQA(ServiceInvoicePeriod period, SupportConceptApprovalPeriodDC scapTS, ServiceCategoryDC cat, CostBearer2SupportConcept cb2sc, decimal lgMin, decimal LG, decimal? preis, InvoiceItem ii)
{
// BeckerA, 26.05.2025: Anpassung in Umrechnung der LG, ABER das war nur für QA nötig, allerdings scheint es noch Altfälle zu gebenm die ohnehin Minutenweise umgerechnet wurden
// z.B. Babadagi
// BeckerA, 26.05.2025: Programmierung soweit angepasst, GetKombiniertenPreis fehlt noch, warte da auf ihre Rückmeldung
// Errechnung des summierten Preises und dann Korrektur für TS
var scapBws = cb2sc.ApprovalPeriodList.Where(a => a.ServiceCategory != null && a.ServiceCategory.Abbreviation.Contains(cat.Abbreviation.Substring(0, 2)) && a.ServiceCategory.Abbreviation.Substring(2, 2) == "BW").ToList();
var scapBws = cb2sc.ApprovalPeriodList.Where(a => a.ServiceCategory != null && a.ServiceCategory.Abbreviation.Contains(cat.Abbreviation.Substring(0, 2))
&& a.ServiceCategory.Abbreviation.Substring(2, 2) == "BW").ToList();
if (scapBws != null)
{
foreach (var ap in scapBws)
@@ -265,17 +275,27 @@ namespace VereinBeratungTherapie.Invoicing
lgBw = ap.ApprovedBEPerInterval.Value;
}
// LWV rundet den Prei bei KA und alten Bewilligungen QA auf Minutenwert und bei neuer QA auf Stunden :-P
if ((cat.Abbreviation.Contains("QA") || cat.Name.Contains("Qualifizierte")))
if (cat.Abbreviation.Contains("QA") || cat.Name.Contains("Qualifizierte"))
{
if (new List<decimal> { 60, 120, 180, 240, 330, 450, 630, 900 }.Contains(lgBw))
if (ap.Notice == null || !ap.Notice.ToLower().Contains("alt"))
{
preisBw = Math.Round(preis.Value * lgBw / 60, 2, MidpointRounding.AwayFromZero);
lgGes = Math.Round((LG + lgBw) / 60, 2, MidpointRounding.AwayFromZero);
lgGes = GetLeistungsgruppe(lgMin + lgBw, cat);
lgBw = GetLeistungsgruppe(lgBw, cat);
}
else
{
lgGes = lgMin + lgBw;
preisGes = Math.Round(minPreis * lgGes, 2, MidpointRounding.AwayFromZero);
}
if (new List<decimal> { 60, 120, 180, 240, 330, 450, 630, 900 }.Contains(lgBw))
{
preisBw = Math.Round(preis.Value * lgBw / 60, 2, MidpointRounding.AwayFromZero);
}
else // Altfälle
{
preisBw = Math.Round(minPreis * lgBw, 2, MidpointRounding.AwayFromZero);
lgGes = LG + lgBw;
}
if (new List<decimal> { 60, 120, 180, 240, 330, 450, 630, 900 }.Contains(lgGes))
{
@@ -302,6 +322,47 @@ namespace VereinBeratungTherapie.Invoicing
}
}
private decimal GetLeistungsgruppe(decimal? approvedBEPerInterval, ServiceCategoryDC cat)
{
// Qualifizierte Assistenz wird in Stufen - sogenannten Leistungsgruppen abgerechnet -
decimal lg = 60;
if (approvedBEPerInterval == null || approvedBEPerInterval.Value < 91)
{
lg = 60;
}
else if (approvedBEPerInterval.Value < 151)
{
lg = 120;
}
else if (approvedBEPerInterval.Value < 211)
{
lg = 180;
}
else if (approvedBEPerInterval.Value < 271)
{
lg = 240;
}
else if (approvedBEPerInterval.Value < 391)
{
lg = 330;
}
else if (approvedBEPerInterval.Value < 511)
{
lg = 450;
}
else if (approvedBEPerInterval.Value < 751)
{
lg = 630;
}
else if (approvedBEPerInterval.Value < 1051)
{
lg = 900;
}
return lg;
}
private static decimal GetPreis(IList<Preis> allePreise, String name, DateTime datum)
{
var pausch = allePreise.Where(p => p.Name.Contains(name)).FirstOrDefault();