diff --git a/ReportImp/LyvieKupfer/LyvieKupfer.csproj b/ReportImp/LyvieKupfer/LyvieKupfer.csproj
index 30b219163..5fa9b1a36 100644
--- a/ReportImp/LyvieKupfer/LyvieKupfer.csproj
+++ b/ReportImp/LyvieKupfer/LyvieKupfer.csproj
@@ -31,6 +31,7 @@
4
+
@@ -39,6 +40,7 @@
+
@@ -78,6 +80,7 @@
ServiceInvoiceReport.cs
+
diff --git a/ReportImp/LyvieKupfer/Service/CustomServiceRecordStatisticFactory.cs b/ReportImp/LyvieKupfer/Service/CustomServiceRecordStatisticFactory.cs
new file mode 100644
index 000000000..46926c4a1
--- /dev/null
+++ b/ReportImp/LyvieKupfer/Service/CustomServiceRecordStatisticFactory.cs
@@ -0,0 +1,120 @@
+using BeWo.Data.Entities;
+using BeWo.Service.Plugins;
+using BS.Shared.DataContracts;
+using BS.Shared.Extensions;
+using BS.Shared.Services;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace LyvieKupfer.Service
+{
+ public class CustomServiceRecordStatisticFactory : ServiceRecordStatisticFactory
+ {
+ protected override void ProcessServiceRecord(ServiceRecord sr, CostBearer2SupportConcept cb2sc, SupportConceptStatisticsDC stats, DateTime statisticsDate, Calculations calc)
+ {
+ decimal minutesProvided = 0;
+ decimal minutesProvidedRounded = 0;
+ decimal minutesProvidedThisWeek = 0;
+ decimal minutesProvidedThisMonth = 0;
+ decimal minutesProvidedUntilLastMonth = 0;
+
+ bool billable = false;
+ if (sr.ServiceDescription != null && sr.ServiceDescription.ServiceCategory != null)
+ {
+ billable = sr.ServiceDescription.ServiceCategory.IsBillable;
+ }
+
+ bool outOfPeriod = true;
+ if (cb2sc.StartDate.HasValue && cb2sc.EndDate.HasValue)
+ {
+ outOfPeriod = false;
+ DateTime end = cb2sc.EndDate.Value;
+ if (end < DateTime.MaxValue.Date)
+ end = end.AddDays(1);
+ if (sr.Start < cb2sc.StartDate || sr.Start >= end)
+ {
+ outOfPeriod = true;
+ }
+ }
+
+ SupportConceptPeriodStatisticsDC periodStats =
+ GetPeriodDCFromServiceRecord(stats.PeriodStatistics, sr);
+
+
+ if (billable || (periodStats != null && periodStats.SupportConceptApprovalPeriod.ServiceCategory != null))
+ {
+ minutesProvided = (decimal)sr.DurationMinutes;
+
+ if (!billable && periodStats.SupportConceptApprovalPeriod.ServiceCategory != null &&
+ !periodStats.SupportConceptApprovalPeriod.ServiceCategory.IsBillable)
+ {
+ minutesProvidedRounded = minutesProvided;
+ }
+ else
+ {
+ var srDc = MapToServiceRecordDCForStatistic(sr);
+ minutesProvidedRounded = calc.GetDocumentedDurationInMinutes(srDc, false);
+ if (periodStats != null)
+ {
+
+ if (periodStats.ServiceRecords == null)
+ {
+ periodStats.ServiceRecords = new List();
+ }
+ periodStats.ServiceRecords.Add(srDc);
+ }
+ }
+
+
+ var firstOfMonthDt = new DateTime(statisticsDate.Year, statisticsDate.Month, 1);
+ DateTime mondayDt = statisticsDate.GetLast(DayOfWeek.Monday).Date;
+ DateTime sundayDt = statisticsDate.GetNext(DayOfWeek.Sunday).Date;
+
+ if (sr.Start >= mondayDt && sr.Start < mondayDt.AddDays(7))
+ {
+ minutesProvidedThisWeek = minutesProvidedRounded;
+ }
+ if (sr.Start >= firstOfMonthDt && sr.Start < firstOfMonthDt.AddMonths(1))
+ {
+ minutesProvidedThisMonth = minutesProvidedRounded;
+ }
+ if (sr.Start >= stats.StatisticsStartDate && sr.Start < firstOfMonthDt)
+ {
+ minutesProvidedUntilLastMonth += minutesProvidedRounded;
+ }
+
+ CalculateFixedAmountBudget(sr, periodStats, statisticsDate);
+
+
+ }
+
+ if (outOfPeriod)
+ {
+ stats.MinutesOutOfApprovedPeriod += minutesProvidedRounded;
+ }
+ stats.MinutesProvidedTotal += minutesProvided;
+ stats.MinutesProvidedTotalRounded += minutesProvidedRounded;
+ stats.MinutesProvidedThisMonth += minutesProvidedThisMonth;
+ stats.IstTotalUntilThisMonth += minutesProvidedUntilLastMonth;
+ stats.MinutesProvidedThisWeek += minutesProvidedThisWeek;
+
+
+ if (periodStats != null)
+ {
+ if (outOfPeriod)
+ {
+ periodStats.MinutesOutOfApprovedPeriod += minutesProvidedRounded;
+ }
+
+ periodStats.MinutesProvidedTotal += minutesProvided;
+ periodStats.MinutesProvidedTotalRounded += minutesProvidedRounded;
+ periodStats.MinutesProvidedThisWeek += minutesProvidedThisWeek;
+ periodStats.MinutesProvidedThisMonth += minutesProvidedThisMonth;
+ periodStats.IstTotalUntilThisMonth += minutesProvidedUntilLastMonth;
+ }
+ }
+ }
+}