diff --git a/ReportImp/AidsHilfeDuisburg/Invoicing/SettlementInvoiceCreation.cs b/ReportImp/AidsHilfeDuisburg/Invoicing/SettlementInvoiceCreation.cs index 7ef79d580..d3a126356 100644 --- a/ReportImp/AidsHilfeDuisburg/Invoicing/SettlementInvoiceCreation.cs +++ b/ReportImp/AidsHilfeDuisburg/Invoicing/SettlementInvoiceCreation.cs @@ -13,44 +13,62 @@ using BS.Shared.Services; namespace AidsHilfeDuisburg.Invoicing { - + public class CustomSettlementInvoiceCreation : SettlementInvoiceCreation { - public override bool CanCreateInvoiceTheOldWay(Settlement2DC si, CostBearer2SupportConcept c2s) - { - var relDC = c2s.MapToNewDC(); + public override bool CanCreateInvoiceTheOldWay(Settlement2DC si, CostBearer2SupportConcept c2s) + { + var relDC = c2s.MapToNewDC(); - DateTime start = si.AccountingPeriodStart.Value.Date; - DateTime end = si.AccountingPeriodEnd.Value.Date; - if (c2s.SupportConcept.Customer.TerminationDate.HasValue && - c2s.SupportConcept.Customer.TerminationDate.Value < end) - end = c2s.SupportConcept.Customer.TerminationDate.Value; - if (end > DateTime.Now) - { - var srList = c2s.ServiceRecords; - var max = srList.Max(s => s.End); + DateTime start = si.AccountingPeriodStart.Value.Date; + DateTime end = si.AccountingPeriodEnd.Value.Date; + if (c2s.SupportConcept.Customer.TerminationDate.HasValue && + c2s.SupportConcept.Customer.TerminationDate.Value < end) + end = c2s.SupportConcept.Customer.TerminationDate.Value; + if (end > DateTime.Now) + { + var srList = c2s.ServiceRecords; + var max = srList.Max(s => s.End); - if (max.HasValue && max < end) - end = max.Value; - } + if (max.HasValue && max < end) + end = max.Value; + } - var hourlyRatesInSpanList = relDC.CostBearer.CostRatePeriods.GetSpans(CostRatePeriodType.HourlyRate, start, end).ToList(); - if (hourlyRatesInSpanList.Count > 3) - return false; + var hourlyRatesInSpanList = relDC.CostBearer.CostRatePeriods.GetSpans(CostRatePeriodType.HourlyRate, start, end).ToList(); + if (hourlyRatesInSpanList.Count > 3) + return false; - var factorInSpanList = relDC.CostBearer.CostRatePeriods.GetSpans(CostRatePeriodType.RateFactor, start, end).ToList(); - if (factorInSpanList.Count > 1) - return false; + var factorInSpanList = relDC.CostBearer.CostRatePeriods.GetSpans(CostRatePeriodType.RateFactor, start, end).ToList(); + if (factorInSpanList.Count > 1) + return false; - return true; - } + return true; + } - public override bool IsServiceRecordBillable(ServiceRecord iRecord) - { - if (iRecord.ServiceDescription.ServiceCategory.Name.Contains("Assistenz")) - return false; + public override bool IsServiceRecordBillable(ServiceRecord iRecord) + { + if (iRecord.ServiceDescription.ServiceCategory.Name.Contains("Assistenz")) + return false; - return true; - } - } + return true; + } + + public override void CalculateSettlementInvoiceApprovedAmounts(Settlement2DC si, SupportConceptCostBearerRelDC relDC, Calculations calc) + { + si.ApprovedFLSWeekly = 0; + si.ApprovedFLS = 0; + foreach (var sp in relDC.ApprovalPeriodList) + { + if (sp.ServiceCategory == null || !sp.ServiceCategory.Name.Contains("Assistenz")) + { + si.ApprovedFLSWeekly += calc.GetApprovedHoursPerWeek(sp, relDC.CostBearer.CostRatePeriods) ?? 0m; + + decimal flsTotal = calc.GetApprovedHoursTotal(sp, relDC.CostBearer.CostRatePeriods) ?? 0m; + flsTotal = Math.Round(flsTotal, 2, MidpointRounding.AwayFromZero); + + si.ApprovedFLS += flsTotal; + } + } + } + } } diff --git a/ReportImp/BehindertNaUnd/Invoicing/SettlementInvoiceCreation.cs b/ReportImp/BehindertNaUnd/Invoicing/SettlementInvoiceCreation.cs index 6facc7242..8531b21aa 100644 --- a/ReportImp/BehindertNaUnd/Invoicing/SettlementInvoiceCreation.cs +++ b/ReportImp/BehindertNaUnd/Invoicing/SettlementInvoiceCreation.cs @@ -52,5 +52,23 @@ namespace BehindertNaUnd.Invoicing return true; } - } + + public override void CalculateSettlementInvoiceApprovedAmounts(Settlement2DC si, SupportConceptCostBearerRelDC relDC, Calculations calc) + { + si.ApprovedFLSWeekly = 0; + si.ApprovedFLS = 0; + foreach (var sp in relDC.ApprovalPeriodList) + { + if (sp.ServiceCategory == null || !sp.ServiceCategory.Name.Contains("Assistenz")) + { + si.ApprovedFLSWeekly += calc.GetApprovedHoursPerWeek(sp, relDC.CostBearer.CostRatePeriods) ?? 0m; + + decimal flsTotal = calc.GetApprovedHoursTotal(sp, relDC.CostBearer.CostRatePeriods) ?? 0m; + flsTotal = Math.Round(flsTotal, 2, MidpointRounding.AwayFromZero); + + si.ApprovedFLS += flsTotal; + } + } + } + } } diff --git a/ReportImp/PZDDuesseldorf/Invoicing/SettlementInvoiceCreation.cs b/ReportImp/PZDDuesseldorf/Invoicing/SettlementInvoiceCreation.cs index b335498f4..7a648f0e5 100644 --- a/ReportImp/PZDDuesseldorf/Invoicing/SettlementInvoiceCreation.cs +++ b/ReportImp/PZDDuesseldorf/Invoicing/SettlementInvoiceCreation.cs @@ -52,5 +52,23 @@ namespace PZDDuesseldorf.Invoicing return true; } - } + + public override void CalculateSettlementInvoiceApprovedAmounts(Settlement2DC si, SupportConceptCostBearerRelDC relDC, Calculations calc) + { + si.ApprovedFLSWeekly = 0; + si.ApprovedFLS = 0; + foreach (var sp in relDC.ApprovalPeriodList) + { + if (sp.ServiceCategory == null || !sp.ServiceCategory.Name.Contains("Assistenz")) + { + si.ApprovedFLSWeekly += calc.GetApprovedHoursPerWeek(sp, relDC.CostBearer.CostRatePeriods) ?? 0m; + + decimal flsTotal = calc.GetApprovedHoursTotal(sp, relDC.CostBearer.CostRatePeriods) ?? 0m; + flsTotal = Math.Round(flsTotal, 2, MidpointRounding.AwayFromZero); + + si.ApprovedFLS += flsTotal; + } + } + } + } } diff --git a/ReportImp/RatPlusTat/Invoicing/SettlementInvoiceCreation.cs b/ReportImp/RatPlusTat/Invoicing/SettlementInvoiceCreation.cs index 8b6d04b16..b5e34440f 100644 --- a/ReportImp/RatPlusTat/Invoicing/SettlementInvoiceCreation.cs +++ b/ReportImp/RatPlusTat/Invoicing/SettlementInvoiceCreation.cs @@ -52,5 +52,23 @@ namespace RatPlusTat.Invoicing return true; } - } + + public override void CalculateSettlementInvoiceApprovedAmounts(Settlement2DC si, SupportConceptCostBearerRelDC relDC, Calculations calc) + { + si.ApprovedFLSWeekly = 0; + si.ApprovedFLS = 0; + foreach (var sp in relDC.ApprovalPeriodList) + { + if (sp.ServiceCategory == null || !sp.ServiceCategory.Name.Contains("Assistenz")) + { + si.ApprovedFLSWeekly += calc.GetApprovedHoursPerWeek(sp, relDC.CostBearer.CostRatePeriods) ?? 0m; + + decimal flsTotal = calc.GetApprovedHoursTotal(sp, relDC.CostBearer.CostRatePeriods) ?? 0m; + flsTotal = Math.Round(flsTotal, 2, MidpointRounding.AwayFromZero); + + si.ApprovedFLS += flsTotal; + } + } + } + } }