271 lines
9.5 KiB
C#
271 lines
9.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report.ReportObjects;
|
|
using BS.Shared.Core;
|
|
using BeWo.Service.Dienstplanung;
|
|
|
|
|
|
namespace BeWo.SeWo
|
|
{
|
|
public class SeWoMitarbeiterstundenkontoBerechnung : MitarbeiterstundenkontoBerechnung
|
|
{
|
|
private bool ignoreSeWoRufUndNotdienst = true;
|
|
public bool IgnoreSeWoRufUndNotdienst {
|
|
get { return ignoreSeWoRufUndNotdienst; }
|
|
set { ignoreSeWoRufUndNotdienst = value; }
|
|
}
|
|
|
|
//private MitarbeiterstundenkontoRO.EmployeeDetail currentEmployee = null;
|
|
|
|
public override void HandleServiceRecords(MitarbeiterstundenkontoRO.EmployeeDetail empDetail, IList<StundenkontoServiceRecord> groupFilteredRecords, Contract contract)
|
|
{
|
|
StundenBerechnungHelper.CorrectOverlappingTimes(groupFilteredRecords.Where(s => s.ServiceDescription.Category.Name != "SeWo Ruf" && s.ServiceDescription.Category.Name != "SeWo Notdienst").OrderBy(s => s.Start).ToList());
|
|
}
|
|
|
|
public override void CreateEmployeeDetails(MitarbeiterstundenkontoRO ro)
|
|
{
|
|
base.CreateEmployeeDetails(ro);
|
|
|
|
foreach (var empDetail in ro.EmployeeDetailList)
|
|
{
|
|
var c = GetContractForDate(empDetail.Employee, ro.ReportStartDate, ro.ReportEndDate);
|
|
|
|
if (c != null)
|
|
{
|
|
if (c.EmploymentType != null && !String.IsNullOrWhiteSpace(c.EmploymentType.Name))
|
|
{
|
|
if (c.EmploymentType.Name.Contains("Minijob") || c.EmploymentType.Name.Contains("Werkstudent"))
|
|
{
|
|
if (empDetail.UeberstundenGesamt.HasValue)
|
|
{
|
|
empDetail.UeberstundenGesamt = 0;
|
|
}
|
|
if (empDetail.UeberstundenVormonat.HasValue)
|
|
{
|
|
empDetail.UeberstundenVormonat = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override decimal? BerechneUeberstunden(MitarbeiterstundenkontoRO.EmployeeDetail ed, decimal? ueberstundenStd, Contract c, DateTime start,
|
|
DateTime ende)
|
|
{
|
|
if (c != null)
|
|
{
|
|
if (c.EmploymentType != null && !String.IsNullOrWhiteSpace(c.EmploymentType.Name))
|
|
{
|
|
if (c.EmploymentType.Name.Contains("Minijob") || c.EmploymentType.Name.Contains("Werkstudent"))
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
return base.BerechneUeberstunden(ed, ueberstundenStd, c, start, ende);
|
|
}
|
|
//public override void HandleServiceRecord(MitarbeiterstundenkontoRO.EmployeeDetail emp, StundenkontoServiceRecord item)
|
|
// {
|
|
// if (currentEmployee == null || emp.Employee.Oid != currentEmployee.Employee.Oid)
|
|
// {
|
|
// allSpans.Clear();
|
|
// currentEmployee = emp;
|
|
// }
|
|
// }
|
|
|
|
public override bool AddServiceRecordToDuration(StundenkontoServiceRecord item)
|
|
{
|
|
if (IsKrankheitAbsenceServiceRecord(item) || IsUrlaubAbsenceServiceRecord(item))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (item.ServiceDescription != null && !String.IsNullOrEmpty(item.ServiceDescription.Name) &&
|
|
item.ServiceDescription.Name == "Pause" && item.ServiceDescription.Category.Name != "Schlafbereitschaft")
|
|
{
|
|
return false;
|
|
}
|
|
if (IgnoreSeWoRufUndNotdienst)
|
|
{
|
|
|
|
if (item.ServiceDescription.Category.Name == "SeWo Ruf")
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (item.ServiceDescription.Category.Name == "SeWo Notdienst")
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
//if (item.ServiceDescription != null && item.ServiceDescription.Category != null)
|
|
//{
|
|
// var p = item.ServiceDescription.Category.ProzentAbrechnung;
|
|
|
|
// if (p != 100 && p > 0)
|
|
// {
|
|
// item.RoundedDuration *= (p / 100);
|
|
// item.GroupRoundedDuration *= (p / 100);
|
|
// }
|
|
//}
|
|
|
|
return true;
|
|
}
|
|
|
|
private bool IsKrankheitAbsenceServiceRecord(StundenkontoServiceRecord item)
|
|
{
|
|
if (item.ServiceDescription.Name.ToLower().Contains("krankheit"))
|
|
{
|
|
return true;
|
|
}
|
|
if (item.ServiceDescription.Name.ToLower().Contains("corona"))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsUrlaubAbsenceServiceRecord(StundenkontoServiceRecord item)
|
|
{
|
|
if (item.ServiceDescription.Name.ToLower().Contains("urlaub"))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
protected override AbsenceTimeHours GetAbwesenheitenDurchServiceRecords(MitarbeiterstundenkontoRO.EmployeeDetail empDetail, Contract c, IList<StundenkontoServiceRecord> groupFilteredRecords,
|
|
DateTime berichtsAnfang, DateTime berichtsEnde)
|
|
{
|
|
AbsenceTimeHours ath = new AbsenceTimeHours();
|
|
|
|
foreach (var item in groupFilteredRecords)
|
|
{
|
|
if (item.Start >= berichtsAnfang && item.Start < berichtsEnde)
|
|
{
|
|
if (IsKrankheitAbsenceServiceRecord(item))
|
|
{
|
|
ath.StundenKrankheit += item.RoundedDuration / 60;
|
|
empDetail.Custom8 += 1;
|
|
empDetail.Custom10 += item.RoundedDuration / 60;
|
|
}
|
|
else if (IsUrlaubAbsenceServiceRecord(item))
|
|
{
|
|
ath.StundenUrlaub += item.RoundedDuration / 60;
|
|
empDetail.Custom9 += 1;
|
|
empDetail.Custom10 += item.RoundedDuration / 60;
|
|
}
|
|
}
|
|
}
|
|
|
|
return ath;
|
|
}
|
|
|
|
public override bool SollPauseBerechnen()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public override decimal BerechneAutoPausen(IList<StundenkontoServiceRecord> recordsThisMonth)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
public override bool IsServiceRecordFehlzeit(StundenkontoServiceRecord sr)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public override void HandleServiceRecord(MitarbeiterstundenkontoRO.EmployeeDetail emp, StundenkontoServiceRecord item)
|
|
{
|
|
if (item.ServiceDescription != null)
|
|
{
|
|
if (!String.IsNullOrEmpty(item.ServiceDescription.Name) && item.ServiceDescription.Name.Contains("Pause") && item.ServiceDescription.Category.Name != "Schlafbereitschaft")
|
|
{
|
|
return;
|
|
}
|
|
if (item.ServiceDescription.Category.Name == "SeWo Ruf")
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (item.ServiceDescription.Category.Name == "SeWo Notdienst")
|
|
{
|
|
return;
|
|
}
|
|
decimal duration = 0;
|
|
|
|
if (item.GroupRoundedDuration.HasValue)
|
|
{
|
|
duration = item.GroupRoundedDuration.Value;
|
|
}
|
|
else
|
|
{
|
|
duration = item.RoundedDuration;
|
|
}
|
|
|
|
if (item.ServiceDescription.Category != null)
|
|
{
|
|
var p = item.ServiceDescription.Category.ProzentStundenkonto ?? item.ServiceDescription.Category.Percentage;
|
|
|
|
if (item.ServiceDescription.ProzentStundenkonto.HasValue)
|
|
{
|
|
p = item.ServiceDescription.ProzentStundenkonto.Value;
|
|
}
|
|
if (p != 100 && p > 0)
|
|
{
|
|
duration *= (p / 100);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (item.ServiceDescription.Category.Name.Contains("Fachleistung"))
|
|
{
|
|
emp.Custom1 += duration / 60;
|
|
}
|
|
else if (item.ServiceDescription.Category.Name == "Assistenzleistung")
|
|
{
|
|
emp.Custom2 += duration / 60;
|
|
}
|
|
else if (item.ServiceDescription.Category.Name.Contains("Overhead"))
|
|
{
|
|
emp.Custom3 += duration / 60;
|
|
}
|
|
else
|
|
{
|
|
emp.Custom4 += duration / 60;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override bool UseServiceDescriptionPercentage()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public override List<DateTime> GetFeiertage(int year)
|
|
{
|
|
var list = base.GetFeiertage(year);
|
|
|
|
if (year >= 2025)
|
|
list.Add(new DateTime(year, 12, 31));
|
|
|
|
return list;
|
|
}
|
|
|
|
public override decimal GetFeiertagsFaktor(DateTime start)
|
|
{
|
|
if (start.Month == 12 && (start.Day == 24 || start.Day == 31))
|
|
return 0.5m;
|
|
|
|
return base.GetFeiertagsFaktor(start);
|
|
}
|
|
}
|
|
}
|