107 lines
3.7 KiB
C#
107 lines
3.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BeWo.Data;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BeWo.Service.Plugins;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.DataContracts.Compact;
|
|
using BS.Shared.Extensions;
|
|
using ChristopherusHausMID.Invoicing;
|
|
|
|
namespace ChristopherusHausMID.Service
|
|
{
|
|
public class CustomOperationService : OperationService
|
|
{
|
|
private ServiceDescription leistungSchulbegleitung;
|
|
private VacationService vacationService;
|
|
private Organisation schule;
|
|
|
|
protected override bool CreateServiceRecordsIfAnyExistInDateRange { get { return true; } }
|
|
|
|
//public override ServiceRecord CreateServiceRecord(ArbeitszeitEintrag ae, DateTime datum, CostBearer2SupportConcept c2s, ServiceDescription defaultSd)
|
|
//{
|
|
|
|
// var sr = base.CreateServiceRecord(ae, datum, c2s, defaultSd);
|
|
|
|
|
|
// return sr;
|
|
//}
|
|
|
|
//public override Employee GetHauptbetreuung(Customer customer, DateTime date)
|
|
//{
|
|
// return customer.Employee2CustomerList.FirstOrDefault(e2c => e2c.IsActive == ActivationTypeId.Active &&
|
|
// (!e2c.StartDate.HasValue || e2c.StartDate.Value.Date <= date) && (!e2c.EndDate.HasValue || e2c.EndDate.Value.Date >= date) &&
|
|
// e2c.ValueList.Any(b => b.Entry.Type.Equals(ValueListEntryType.StaffRoleType) &&
|
|
// b.Entry.Value.Contains("Hauptbetreuung")))?.Employee;
|
|
//}
|
|
|
|
private VacationService GetVacationService()
|
|
{
|
|
if (vacationService == null)
|
|
{
|
|
vacationService = PluginLoader.FindClass<VacationService>();
|
|
}
|
|
|
|
return vacationService;
|
|
}
|
|
|
|
private Organisation GetSchule(CostBearer2SupportConcept c2s)
|
|
{
|
|
if (schule == null)
|
|
{
|
|
schule = PoolHelper.GetSchule(c2s.SupportConcept.Customer);
|
|
}
|
|
|
|
return schule;
|
|
}
|
|
|
|
//public override bool HatAbwesenheit(DateTime start, Customer customer)
|
|
//{
|
|
// return base.HatAbwesenheit(start, customer);
|
|
//}
|
|
|
|
protected override IList<ServiceRecord> CreateServiceRecords(Arbeitszeit arbeitszeit, DateTime datum, CostBearer2SupportConcept c2s, ServiceDescription defaultSd, List<ServiceRecord> existingList)
|
|
{
|
|
var ferien = GetVacationService().GetFerien(datum, "nrw");
|
|
Feiertag schulFeiertag = null;
|
|
|
|
var schule = GetSchule(c2s);
|
|
if (schule != null)
|
|
{
|
|
schulFeiertag = PoolHelper.GetSchulfeiertag(schule, datum);
|
|
}
|
|
|
|
if (ferien == null && schulFeiertag == null)
|
|
{
|
|
return base.CreateServiceRecords(arbeitszeit, datum, c2s, defaultSd, existingList);
|
|
}
|
|
|
|
return new List<ServiceRecord>();
|
|
}
|
|
|
|
public override ServiceDescription GetDefaultServiceDescription(CostBearer2SupportConcept c2s)
|
|
{
|
|
if (leistungSchulbegleitung == null)
|
|
{
|
|
var sc = c2s.SupportConcept;
|
|
if (sc.ServiceAccountings.Count > 0)
|
|
{
|
|
leistungSchulbegleitung = sc.ServiceAccountings[0].ServiceDescription;
|
|
}
|
|
if (leistungSchulbegleitung == null)
|
|
{
|
|
leistungSchulbegleitung = base.GetDefaultServiceDescription(c2s);
|
|
}
|
|
}
|
|
|
|
return leistungSchulbegleitung;
|
|
}
|
|
|
|
|
|
}
|
|
} |