2023-09-08 15:52:55 +02:00
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 ;
namespace DomizielAnsbach.Service
{
public class CustomOperationService : OperationService
{
private ServiceDescription leistungSchulbegleitung ;
private ServiceDescription leistungWegezeit ;
private ServiceDescription leistungSonderzeit ;
private ServiceDescription leistungBusbegleitung ;
2024-09-17 21:10:47 +02:00
protected override bool CreateServiceRecordsIfAnyExistInDateRange { get { return true ; } }
2023-09-08 15:52:55 +02:00
public override ServiceRecord CreateServiceRecord ( ArbeitszeitEintrag ae , DateTime datum , CostBearer2SupportConcept c2s , ServiceDescription defaultSd )
{
var leistung = GetLeistungSonderzeit ( ) ;
if ( ! String . IsNullOrEmpty ( ae . Notice ) )
{
//if (ae.Notice.ToLower().Contains("bus"))
//{
// leistung = GetLeistungBusbegleitung();
//}
//else
if ( ae . Notice . StartsWith ( "Un" ) ) // Unterricht, es gibt leider so viele Tippfehler in der Notice z.B. Unerricht, Unttericht etc. dass ich denke ein Prüfen auf "Un" genügt
{
leistung = GetDefaultServiceDescription ( ) ;
}
//else if (ae.Notice.Contains("Befö"))
//{
// leistung = GetLeistungWegezeit(); // Beförderung mit allen fantasievollen Schreibweisen.
//}
}
var sr = base . CreateServiceRecord ( ae , datum , c2s , leistung ) ;
return sr ;
}
2024-09-17 21:10:47 +02:00
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 ;
}
2023-09-08 15:52:55 +02:00
public override ServiceDescription GetDefaultServiceDescription ( CostBearer2SupportConcept c2s )
{
return GetDefaultServiceDescription ( ) ;
}
public override ServiceDescription GetDefaultServiceDescription ( )
{
if ( leistungSchulbegleitung = = null )
{
leistungSchulbegleitung = DAOFactory . GenericDAO . LoadByID < ServiceDescription > ( 13 ) ;
}
return leistungSchulbegleitung ;
}
private ServiceDescription GetLeistungWegezeit ( )
{
if ( leistungWegezeit = = null )
{
leistungWegezeit = DAOFactory . GenericDAO . LoadByID < ServiceDescription > ( 14 ) ;
}
return leistungWegezeit ;
}
private ServiceDescription GetLeistungSonderzeit ( )
{
if ( leistungSonderzeit = = null )
{
leistungSonderzeit = DAOFactory . GenericDAO . LoadByID < ServiceDescription > ( 15 ) ;
}
return leistungSonderzeit ;
}
private ServiceDescription GetLeistungBusbegleitung ( )
{
if ( leistungBusbegleitung = = null )
{
leistungBusbegleitung = DAOFactory . GenericDAO . LoadByID < ServiceDescription > ( 17 ) ;
}
return leistungBusbegleitung ;
}
}
}