179 lines
6.3 KiB
C#
179 lines
6.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.Extensions;
|
|
using BeWo.Service.Dienstplanung;
|
|
|
|
|
|
namespace PraxisPusteblume
|
|
{
|
|
public class CustomMitarbeiterstundenkontoBerechnung : MitarbeiterstundenkontoBerechnung
|
|
{
|
|
public override MitarbeiterstundenkontoRO.DayDetail CreateDayDetail(DateTime date, MitarbeiterstundenkontoRO.EmployeeDetail ed)
|
|
{
|
|
var dd = base.CreateDayDetail(date, ed);
|
|
|
|
dd.MaxHoursUntilBreak = 6;
|
|
dd.MaxHoursUntilBreak2 = 9;
|
|
dd.BreakMinutes = 30;
|
|
dd.BreakMinutes2 = 15;
|
|
|
|
if (date < new DateTime(2019, 12, 1))
|
|
{
|
|
dd.MaxHoursUntilBreak = 0;
|
|
dd.BreakMinutes = 0;
|
|
dd.MaxHoursUntilBreak2 = 0;
|
|
dd.BreakMinutes2 = 0;
|
|
}
|
|
|
|
return dd;
|
|
}
|
|
|
|
public override bool ShouldCreateDayDetails()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public override decimal GetAdditionalHours(IList<MitarbeiterstundenkontoRO.DayDetail> days, DateTime berichtStart, DateTime berichtEnde, MitarbeiterstundenkontoRO.EmployeeDetail ed,
|
|
IList<StundenkontoServiceRecord> recordsAll)
|
|
{
|
|
var test = base.GetAdditionalHours(days, berichtStart, berichtEnde, ed, recordsAll);
|
|
|
|
if (ed.FlsIst + ed.MittelbarIst > 0)
|
|
{
|
|
ed.MittelbarIst += test;
|
|
|
|
ed.RelationFlsZuMittelbar = (ed.FlsIst / (ed.FlsIst + ed.MittelbarIst)) * 100;
|
|
}
|
|
|
|
return test;
|
|
}
|
|
|
|
protected override ServiceRecordSummary BerechneStunden(MitarbeiterstundenkontoRO.EmployeeDetail empDetail, IList<StundenkontoServiceRecord> groupFilteredRecords, DateTime berichtsAnfang,
|
|
DateTime berichtsEnde)
|
|
{
|
|
if (berichtsAnfang < new DateTime(2019, 12, 1))
|
|
{
|
|
return base.BerechneStunden(empDetail, groupFilteredRecords, berichtsAnfang, berichtsEnde);
|
|
}
|
|
|
|
decimal flsGesamt = 0;
|
|
decimal arbeitszeit = 0;
|
|
|
|
var sum = new ServiceRecordSummary();
|
|
sum.RecordsImBerichtszeitraum = new List<StundenkontoServiceRecord>();
|
|
//base.CorrectOverlappingTimes(groupFilteredRecords);
|
|
|
|
foreach (var item in groupFilteredRecords)
|
|
{
|
|
if (!IsServiceRecordFehlzeit(item))
|
|
{
|
|
if (item.Start >= berichtsAnfang && item.Start < berichtsEnde)
|
|
{
|
|
//if (AddServiceRecordToDuration(item))
|
|
//{
|
|
decimal duration = 0;
|
|
|
|
if (item.GroupRoundedDuration.HasValue)
|
|
{
|
|
duration = item.GroupRoundedDuration.Value;
|
|
}
|
|
else
|
|
{
|
|
duration = item.RoundedDuration;
|
|
}
|
|
|
|
if (item.ServiceDescription != null &&
|
|
item.ServiceDescription.Category != null)
|
|
{
|
|
if (item.ServiceDescription.Category.Name == "Arbeitszeit")
|
|
{
|
|
arbeitszeit += duration;
|
|
}
|
|
else if (item.ServiceDescription.Category.IsBillable)
|
|
{
|
|
flsGesamt += duration;
|
|
}
|
|
|
|
}
|
|
sum.RecordsImBerichtszeitraum.Add(item);
|
|
}
|
|
}
|
|
}
|
|
|
|
sum.IstAbrechenbar = flsGesamt;
|
|
sum.IstNichtAbrechenbar = arbeitszeit - flsGesamt;
|
|
|
|
return sum;
|
|
}
|
|
|
|
public override bool AddServiceRecordToDuration(StundenkontoServiceRecord item)
|
|
{
|
|
if (item.ServiceDescription != null && item.ServiceDescription.Category != null && item.ServiceDescription.Category.IsBillable && item.Start < new DateTime(2019, 10, 1))
|
|
{
|
|
if (item.CostBearer2SupportConcept != null)
|
|
{
|
|
var cb = item.CostBearer2SupportConcept.CostBearer;
|
|
|
|
var crlist = MapperFactory.CostRatePeriodDC_CostRatePeriod.MapToNewDCs(cb.CostRatePeriods);
|
|
|
|
var rateFactor = crlist.GetCostRatePeriodForDate(CostRatePeriodType.RateFactor, item.Start);
|
|
|
|
if (rateFactor != null && rateFactor.CostRateValue.HasValue)
|
|
{
|
|
decimal factor = rateFactor.CostRateValue.Value;
|
|
|
|
if (factor == 33.33m)
|
|
{
|
|
factor = 1 + (1m / 3m);
|
|
}
|
|
else
|
|
{
|
|
factor = (100 + factor) / 100;
|
|
}
|
|
|
|
item.RoundedDuration *= factor;
|
|
item.GroupRoundedDuration *= factor;
|
|
}
|
|
}
|
|
|
|
}
|
|
else if (item.Start >= new DateTime(2019, 12, 1))
|
|
{
|
|
if (item.ServiceDescription != null && item.ServiceDescription.Category != null && item.ServiceDescription.Category.Name == "Arbeitszeit")
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
//public override List<DateTime> GetFeiertage(int year)
|
|
//{
|
|
// var list = base.GetFeiertage(year);
|
|
|
|
// list.Add(new DateTime(year, 1, 6)); // , "Heilige Drei Könige"));
|
|
// list.Add(new DateTime(year, 8, 15)); // , "Mariä Himmelfahrt"));
|
|
// list.Add(new DateTime(year, 12, 31)); // , "Sylvester));
|
|
|
|
// return list;
|
|
//}
|
|
|
|
public override decimal GetFeiertagsFaktor(DateTime start)
|
|
{
|
|
if (start.Year >= 2020 && start.Month == 12 && (start.Day == 24 || start.Day == 31))
|
|
{
|
|
return 0.5m;
|
|
}
|
|
return base.GetFeiertagsFaktor(start);
|
|
}
|
|
}
|
|
}
|