MH: Lyvie Kupfer Ministatistik
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="DevExpress.DataAccess.v23.2, Version=23.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
||||
<Reference Include="DevExpress.Drawing.v23.2, Version=23.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
<Reference Include="DevExpress.Data.v23.2, Version=23.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
<Reference Include="DevExpress.Office.v23.2.Core, Version=23.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
@@ -39,6 +40,7 @@
|
||||
<Reference Include="DevExpress.Printing.v23.2.Core, Version=23.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
<Reference Include="DevExpress.Data.Desktop.v23.2, Version=23.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
<Reference Include="DevExpress.Utils.v23.2, Version=23.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
<Reference Include="DevExpress.Xpo.v23.2, Version=23.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
||||
<Reference Include="DevExpress.XtraPrinting.v23.2, Version=23.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
<Reference Include="DevExpress.Charts.v23.2.Core, Version=23.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
<Reference Include="DevExpress.XtraCharts.v23.2, Version=23.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
@@ -78,6 +80,7 @@
|
||||
<Compile Include="ServiceInvoiceReport.Designer.cs">
|
||||
<DependentUpon>ServiceInvoiceReport.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Service\CustomServiceRecordStatisticFactory.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Data\Data.csproj">
|
||||
|
||||
@@ -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<ServiceRecordDC>();
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user