221 lines
6.0 KiB
C#
221 lines
6.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using BeWo.Data.Entities;
|
|
using BS.Shared;
|
|
|
|
|
|
namespace BeWo.Report.ReportObjects
|
|
{
|
|
public class UrlaubskontoBerechnung
|
|
{
|
|
|
|
|
|
public UrlaubskontoBerechnung()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
public virtual void CreateReport(UrlaubskontoRO ro)
|
|
{
|
|
CreateEmployeeDetails(ro);
|
|
|
|
CreateTeamDetails(ro);
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual void CreateTeamDetails(UrlaubskontoRO ro)
|
|
{
|
|
foreach (var teamDetail in ro.TeamDetailList)
|
|
{
|
|
teamDetail.EmployeeDetailList = FilterEmployeeList(teamDetail.EmployeeDetailList);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public virtual void CreateEmployeeDetails(UrlaubskontoRO ro)
|
|
{
|
|
foreach (var empDetail in ro.EmployeeDetailList)
|
|
{
|
|
empDetail.AllAbsenceTimes = empDetail.Employee.AbsenceTimes;
|
|
empDetail.TagZuUrlaub = new Dictionary<String, decimal>();
|
|
empDetail.TagZuKrankheit = new Dictionary<String, decimal>();
|
|
empDetail.AbsenceTimesInTimeSpan = new List<AbsenceTime>();
|
|
|
|
|
|
DateTime dt = ro.ReportStartDate;
|
|
|
|
while (dt <= ro.ReportEndDate)
|
|
{
|
|
String key = String.Format("{0:yyyyMMdd}", dt);
|
|
empDetail.TagZuUrlaub[key] = 0;
|
|
empDetail.TagZuKrankheit[key] = 0;
|
|
}
|
|
foreach (var at in empDetail.Employee.AbsenceTimes)
|
|
{
|
|
if ((!at.Start.HasValue || at.Start.Value <= ro.ReportEndDate) &&
|
|
(!at.End.HasValue || at.End.Value >= ro.ReportStartDate))
|
|
{
|
|
empDetail.AbsenceTimesInTimeSpan.Add(at);
|
|
dt = ro.ReportStartDate;
|
|
if (at.Start.HasValue && at.Start > dt)
|
|
{
|
|
dt = at.Start.Value;
|
|
}
|
|
|
|
DateTime end = ro.ReportEndDate;
|
|
if (at.End.HasValue && at.End < end)
|
|
{
|
|
end = at.End.Value;
|
|
}
|
|
while (dt <= end)
|
|
{
|
|
String key = String.Format("{0:yyyyMMdd}", dt);
|
|
empDetail.TagZuUrlaub[key] = 1;
|
|
empDetail.TagZuKrankheit[key] = 1;
|
|
|
|
dt = dt.AddDays(1);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
//DateTime monatsAnfang = ro.ReportStartDate;
|
|
//DateTime monatsEnde = monatsAnfang.AddMonths(1);
|
|
//DateTime berichtsAnfang = monatsAnfang;
|
|
//DateTime berichtsEnde = monatsEnde;
|
|
|
|
//Employee emp = empDetail.Employee;
|
|
|
|
// var c = GetContractForDate(emp, ro.ReportStartDate, ro.ReportEndDate);
|
|
|
|
//if (c != null)
|
|
//{
|
|
// if (c.EntryDate.HasValue && c.EntryDate > monatsAnfang)
|
|
// {
|
|
// berichtsAnfang = c.EntryDate.Value;
|
|
// }
|
|
// if (c.ContractEndDate.HasValue && c.ContractEndDate < monatsEnde)
|
|
// {
|
|
// berichtsEnde = c.ContractEndDate.Value.Date.AddDays(1);
|
|
// }
|
|
// empDetail.HasContract = true;
|
|
//}
|
|
|
|
//IList<ServiceRecord> recordsAll = DAOFactory.SearchDAO.FindServiceRecords(emp.Oid, null);
|
|
//recordsAll = AnalysisServiceImp.FilterActiveServiceRecords(recordsAll);
|
|
|
|
////
|
|
//IList<ServiceRecord> groupFilteredRecords = new List<ServiceRecord>();
|
|
//Dictionary<long, bool> groupBookingDict = new Dictionary<long, bool>();
|
|
//foreach (var item in recordsAll)
|
|
//{
|
|
|
|
// if (!item.GroupOid.HasValue || !groupBookingDict.ContainsKey(item.GroupOid.Value))
|
|
// {
|
|
// groupFilteredRecords.Add(item);
|
|
// if (item.GroupOid.HasValue)
|
|
// {
|
|
// groupBookingDict.Add(item.GroupOid.Value, true);
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
//while (berichtsAnfang < berichtsEnde)
|
|
//{
|
|
|
|
|
|
// berichtsAnfang = berichtsEnde;
|
|
// berichtsEnde = monatsEnde;
|
|
// c = GetNextValidContractForDate(berichtsAnfang, emp);
|
|
|
|
// if (c != null)
|
|
// {
|
|
// if (c.EntryDate.HasValue && c.EntryDate >= berichtsAnfang)
|
|
// berichtsAnfang = c.EntryDate.Value;
|
|
// if (c.ContractEndDate.HasValue && c.ContractEndDate < monatsEnde)
|
|
// {
|
|
// berichtsEnde = c.ContractEndDate.Value.Date.AddDays(1);
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
}
|
|
|
|
ro.EmployeeDetailList = FilterEmployeeList(ro.EmployeeDetailList);
|
|
}
|
|
|
|
|
|
public virtual List<UrlaubskontoRO.EmployeeDetail> FilterEmployeeList(List<UrlaubskontoRO.EmployeeDetail> employeeDetailList)
|
|
{
|
|
List<UrlaubskontoRO.EmployeeDetail> newEmpList = new List<UrlaubskontoRO.EmployeeDetail>();
|
|
|
|
foreach (var ed in employeeDetailList)
|
|
{
|
|
if (ed.Employee.IsActive == ActivationTypeId.Active)
|
|
{
|
|
newEmpList.Add(ed);
|
|
}
|
|
|
|
}
|
|
|
|
return newEmpList;
|
|
}
|
|
|
|
public virtual bool IsKrankheitAbsenceTime(AbsenceTime absenceTime)
|
|
{
|
|
return !String.IsNullOrEmpty(absenceTime.AbsenceReason.Description) &&
|
|
(absenceTime.AbsenceReason.Description.ToLower().IndexOf("arbeitsunfähig") >= 0
|
|
|| absenceTime.AbsenceReason.Description.ToLower().IndexOf("krank") >= 0);
|
|
}
|
|
|
|
public virtual bool IsUrlaubAbsenceTime(AbsenceTime absenceTime)
|
|
{
|
|
return !String.IsNullOrEmpty(absenceTime.AbsenceReason.Description) &&
|
|
absenceTime.AbsenceReason.Description.ToLower().IndexOf("urlaub") >= 0;
|
|
}
|
|
|
|
public virtual bool AddServiceRecordToDuration(ServiceRecord item)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public virtual decimal AddRateFactorToIst()
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
|
|
public Contract GetNextValidContractForDate(DateTime dt, Employee emp)
|
|
{
|
|
Contract contractNextToStartDate = emp.GetValidContractForDate(dt);
|
|
|
|
if (contractNextToStartDate == null)
|
|
{
|
|
|
|
foreach (var item in emp.Contracts)
|
|
{
|
|
if (item.EntryDate.HasValue && item.EntryDate.Value >= dt)
|
|
{
|
|
if (contractNextToStartDate == null || item.EntryDate.Value < contractNextToStartDate.EntryDate.Value)
|
|
{
|
|
contractNextToStartDate = item;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
return contractNextToStartDate;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|