diff --git a/ReportImp/HausDuelken/HausDuelken.csproj b/ReportImp/HausDuelken/HausDuelken.csproj
index 027bb3de0..08655dfb1 100644
--- a/ReportImp/HausDuelken/HausDuelken.csproj
+++ b/ReportImp/HausDuelken/HausDuelken.csproj
@@ -70,6 +70,7 @@
FLSListReport.cs
+
diff --git a/ReportImp/HausDuelken/Invoicing/AssistenzInvoiceCreation.cs b/ReportImp/HausDuelken/Invoicing/AssistenzInvoiceCreation.cs
new file mode 100644
index 000000000..28c3b716d
--- /dev/null
+++ b/ReportImp/HausDuelken/Invoicing/AssistenzInvoiceCreation.cs
@@ -0,0 +1,102 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BeWo.Data.Access;
+using BeWo.Data.Entities;
+using BeWo.Service.DCEntityMapper;
+using BeWo.Service.Invoicing;
+using BeWo.Service.Plugins;
+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 HausDuelken.Invoicing
+{
+
+ public class CustomAssistenzInvoiceCreation : InvoiceCreation
+ {
+ public override void SetInvoiceBaseData(int invoiceCounter, ServiceInvoice invoice, CostBearer costBearer, DateTimeSpan invoicePeriod, IList supportConceptList)
+ {
+ base.SetInvoiceBaseData(invoiceCounter, invoice, costBearer, invoicePeriod, supportConceptList);
+ invoice.InvoiceBase.InvoiceDate = invoice.InvoiceBase.AccountingPeriodEnd;
+ }
+
+
+ public override void SetAmountAdvancePayments(ServiceInvoice invoice)
+ {
+ //do nothing
+ }
+
+ public override void SetAmountEquityContribution(ServiceInvoice invoice)
+ {
+ //do nothing
+ }
+
+ public override InvoiceItem CreateInvoiceItem(ServiceRecordDC iServiceRecord, SupportConceptApprovalPeriod scap, BS.Shared.Services.Calculations calc)
+ {
+ if (!iServiceRecord.ServiceDescription.CategoryName.Contains("Assistenz"))
+ {
+ return null;
+ }
+
+ var ii = base.CreateInvoiceItem(iServiceRecord, scap, calc);
+ ii.ItemDescription = "Assistenzleistung";
+ return ii;
+ }
+
+ public override void SetInvoiceItems(ServiceInvoice invoice,
+ ServiceInvoicePeriod serviceInvoicePeriod,
+ SupportConceptApprovalPeriodDC supportConceptApprovalPeriod,
+ CostBearer2SupportConcept cb2sc,
+ DateTimeSpan invoicePeriod,
+ List serviceRecords)
+ {
+ BS.Shared.Services.Calculations calc = PluginLoader.FindClass(_SpecificID) ?? BS.Shared.Services.Calculations.GetInstance(_SpecificID);
+
+ if (ShouldCreateFixedAmounts(serviceInvoicePeriod, supportConceptApprovalPeriod, cb2sc))
+ {
+ CreateFixedAmounts(serviceInvoicePeriod, supportConceptApprovalPeriod, cb2sc);
+ }
+ else
+ {
+ 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 (serviceRecordsInPeriod.Count > 0)
+ {
+ var absenceTimes = MapperFactory.AbsenceTimeDC_AbsenceTime.MapToNewDCs(cb2sc.SupportConcept.Customer.AbsenceTimes);
+ Dictionary span2Hours = calc.GetAbsencesTimesNotBillable(absenceTimes);
+
+ // serviceInvoicePeriod.HoursNotBillableAbsence - eingeschränkte Anzahl bei Abwesenheit GILT laut LVR ausdrücklich nicht bei Assistenzleistungen
+ serviceInvoicePeriod.HoursNotBillableNotApproved +=
+ calc.GetHoursNotBillableDueToMoreThanApproved(supportConceptApprovalPeriod,
+ cb2sc.CostBearer.CostRatePeriods.MapToNewDCs(),
+ serviceRecordsInPeriod,
+ true, true);
+
+ var itemList = CreateInvoiceItems(serviceRecordsInPeriod, invoicePeriod, serviceInvoicePeriod.SupportConceptApprovalPeriod, calc);
+ serviceInvoicePeriod.InvoiceItemList.AddRange(itemList);
+ }
+ }
+ }
+
+ 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, false, true);
+ }
+ }
+}
diff --git a/ReportImp/HausDuelken/Invoicing/CustomInvoiceFactory.cs b/ReportImp/HausDuelken/Invoicing/CustomInvoiceFactory.cs
index a504c05e1..0eb6aaef3 100644
--- a/ReportImp/HausDuelken/Invoicing/CustomInvoiceFactory.cs
+++ b/ReportImp/HausDuelken/Invoicing/CustomInvoiceFactory.cs
@@ -18,7 +18,32 @@ namespace HausDuelken.Invoicing
return new CustomStationaerInvoiceCreation();
}
}
- return new InvoiceCreation();
+
+ foreach (var list in supportConcepts2ServiceRecords.Values)
+ {
+ foreach (var sr in list)
+ {
+ var sd = sr.ServiceDescription.Category;
+ var ic = GetInvoiceCreatorForCategory(sd);
+ if (ic != null)
+ return ic;
+ }
+ }
+ return new InvoiceCreation();
}
- }
+
+
+ private InvoiceCreation GetInvoiceCreatorForCategory(ServiceCategoryDC sd)
+ {
+ if (sd != null && !String.IsNullOrEmpty(sd.Name))
+ {
+ String cat = sd.Name.ToLower().Trim();
+ if (cat.IndexOf("assistenz") >= 0)
+ {
+ return new CustomAssistenzInvoiceCreation();
+ }
+ }
+ return null;
+ }
+ }
}
diff --git a/ReportImp/HausDuelken/Invoicing/CustomSettlementInvoiceCreation.cs b/ReportImp/HausDuelken/Invoicing/CustomSettlementInvoiceCreation.cs
index 6fc54d62e..54789f2f6 100644
--- a/ReportImp/HausDuelken/Invoicing/CustomSettlementInvoiceCreation.cs
+++ b/ReportImp/HausDuelken/Invoicing/CustomSettlementInvoiceCreation.cs
@@ -57,15 +57,15 @@ namespace HausDuelken
}
}
- public override InvoiceItemDC CreateInvoiceItemForAccountingPeriod(AccountingPeriod accountingPeriod)
- {
- var item = base.CreateInvoiceItemForAccountingPeriod(accountingPeriod);
- if (item.ItemDescription != null && item.ItemDescription.StartsWith("Assistenzleistung"))
- {
- item.RateFactor = null;
- }
- return item;
- }
+ //public override InvoiceItemDC CreateInvoiceItemForAccountingPeriod(AccountingPeriod accountingPeriod)
+ //{
+ // var item = base.CreateInvoiceItemForAccountingPeriod(accountingPeriod);
+ // if (item.ItemDescription != null && item.ItemDescription.StartsWith("Assistenzleistung"))
+ // {
+ // item.RateFactor = null;
+ // }
+ // return item;
+ //}
public override bool IsServiceRecordBillable(ServiceRecord iRecord)
{
@@ -73,7 +73,40 @@ namespace HausDuelken
{
return false;
}
+ if (iRecord.ServiceDescription.ServiceCategory.Name.Contains("Assistenz"))
+ {
+ return false;
+ }
return true;
}
+
+ public override bool CanCreateInvoiceTheOldWay(Settlement2DC si, CostBearer2SupportConcept c2s)
+ {
+ return false;
+ }
+
+ public override void CalculateSettlementInvoiceApprovedAmounts(Settlement2DC si, SupportConceptCostBearerRelDC relDC, BS.Shared.Services.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;
+ }
+ }
+ }
+
+
+ public override IList GetBillableServiceRecords(CostBearer2SupportConcept c2s)
+ {
+ return c2s.ServiceRecords.OrderBy(s => s.Start).Where(s => !s.ServiceDescription.ServiceCategory.Name.ToLower().Contains("assistenz")).ToList();
+ }
}
}
diff --git a/ReportImp/HausDuelken/SettlementReport2.cs b/ReportImp/HausDuelken/SettlementReport2.cs
index bbdd85cc1..a4938fd47 100644
--- a/ReportImp/HausDuelken/SettlementReport2.cs
+++ b/ReportImp/HausDuelken/SettlementReport2.cs
@@ -28,7 +28,7 @@ namespace HausDuelken.Alt
pRO.ApprovedFLS = null;
foreach (var ap in sc.ApprovalPeriodList)
{
- if (ap.ServiceCategory != null)
+ if (ap.ServiceCategory != null && !ap.ServiceCategory.Name.Contains("Assistenz"))
{
{
if (pRO.ApprovedFLS != null)