Files
BeWoPlaner/Service/Plugins/ServiceRecordDurationCalculator.cs
Lyndon 8ae75cfc77 Personenmodul hinzugefügt - schreibgeschützt
Mitarbeitermodul mit Abwesenheiten hinzugefügt
Einbau des Dokumententeils vereinfacht.
2026-02-04 18:03:01 +01:00

52 lines
2.1 KiB
C#

using BeWo.Data.Entities;
using BeWo.Service.DCEntityMapper;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using BS.Shared.Services;
namespace BeWo.Service.Plugins
{
public class ServiceRecordDurationCalculator : AbstractIDSpecificDefaultClass<ServiceRecordDurationCalculator>
{
public virtual void CalculateRoundedDuration(ServiceRecord sr)
{
//Wird vor dem eigentlichen Speichern aufgerufen
if (sr.CostBearer2SupportConcept != null && sr.ServiceDescription.ServiceCategory != null &&
sr.ServiceDescription.ServiceCategory.IsBillable)
{
var duration = (decimal)sr.End.Value.Subtract(sr.Start.Value).TotalMinutes;
Calculations calc = Calculations.GetInstance(sr.CostBearer2SupportConcept.CostBearer.ID);
var cc =
MapperFactory.CompactOrganisationDC_Organisation.MapToNewDC(
sr.CostBearer2SupportConcept.CostBearer.Organisation);
var roundedDuration = calc.GetRoundedDuration(cc, sr.Start.Value, duration);
sr.RoundedDuration = roundedDuration;
}
else
{
sr.RoundedDuration = (decimal)sr.End.Value.Subtract(sr.Start.Value).TotalMinutes;
}
}
public virtual void CalculateRoundedDuration(ServiceRecordDC newServiceRecord)
{
//Wird nur für die Validierung benötigt
if (newServiceRecord.ServiceDescription.Category != null &&
newServiceRecord.ServiceDescription.Category.IsBillable && newServiceRecord.CostBearer != null)
{
var duration = (decimal)newServiceRecord.End.Value.Subtract(newServiceRecord.Start.Value).TotalMinutes;
Calculations calc = Calculations.GetInstance(newServiceRecord.CostBearer.CostBearerID);
var roundedDuration = calc.GetRoundedDuration(newServiceRecord.CostBearer, newServiceRecord.Start.Value, duration);
newServiceRecord.RoundedDuration = roundedDuration;
}
}
}
}