DiakoniewerkEssen/Validation/ServiceRecordValidator.cs Pflichfeld Doku nur für nicht Arbeitszeit, Zukunft schon bei 1 min nach jetzt starten

SupportOID=169166
This commit is contained in:
2026-07-28 16:24:20 +02:00
parent 91b248d676
commit 07b036f7d8
2 changed files with 62 additions and 0 deletions

View File

@@ -114,6 +114,7 @@
<Compile Include="Reporting\ServiceInvoiceReport67.Designer.cs">
<DependentUpon>ServiceInvoiceReport67.cs</DependentUpon>
</Compile>
<Compile Include="Validation\ServiceRecordValidator.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Data\Data.csproj">

View File

@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Service.DCEntityMapper;
using BeWo.Service.Plugins;
using BS.Shared;
using BS.Shared.DataContracts;
using BS.Shared.Extensions;
namespace DiakonieWerkEssen.Validation
{
public class BetreuwoServiceRecordValidator : ServiceRecordValidator
{
public override List<ServiceRecordValidationResultDC> ValidateServiceRecord(ServiceRecordDC newServiceRecord, SupportConceptStatisticsDC statistics,
int maxDaysEditServiceRecordsAllowed, IList<long> employeeOids, IList<long> cb2scOids)
{
var result = base.ValidateServiceRecord(newServiceRecord, statistics, maxDaysEditServiceRecordsAllowed, employeeOids, cb2scOids);
bool hasZukunftResult = false;
foreach (var r in result)
{
if (r.ResultType == ServiceRecordValidationResult.Custom && r.Message.Contains("Zukunft"))
{
hasZukunftResult = true;
}
}
if (!hasZukunftResult)
{
if (newServiceRecord.Start.Value > DateTime.Now)
{
result.Add(new ServiceRecordValidationResultDC
{
ResultType = ServiceRecordValidationResult.Custom,
Message = "Das gewählte Datum darf nicht in der Zukunft liegen."
});
}
}
// Dokumentationsfeld ist Pflicht - außer bei Arbeitszeiterfassung
if (!newServiceRecord.ServiceDescription.Category.Name.ToLower().Contains("arbeitszeiterfassung"))
{
if (newServiceRecord.Notice.IsNullOrEmpty())
{
result.Add(new ServiceRecordValidationResultDC
{
Allow = false,
EmployeeName = newServiceRecord.Employee.LastName + ", " + newServiceRecord.Employee.FirstName,
StartDate = newServiceRecord.Start.Value,
EndDate = newServiceRecord.End.Value,
ResultType = ServiceRecordValidationResult.Custom,
Message = "Das Dokumentationsfeld muss ausgefüllt werden."
});
}
}
return result;
}
}
}