AachenerLaienhelfer/Validator/ServiceRecordValidator.cs - Warnung auch bei FK Jugendamt nach 1 h

This commit is contained in:
2025-03-06 08:07:07 +01:00
parent 51dbf75aa2
commit f9d31341cd
2 changed files with 38 additions and 0 deletions

View File

@@ -101,6 +101,7 @@
<Compile Include="SettlementReport2.Designer.cs">
<DependentUpon>SettlementReport2.cs</DependentUpon>
</Compile>
<Compile Include="Validator\ServiceRecordValidator.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Data\Data.csproj">

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using BeWo.Data.Entities;
using BeWo.Service.DCEntityMapper;
using BeWo.Service.Plugins;
using BS.Shared;
using BS.Shared.DataContracts;
using BS.Shared.Extensions;
namespace AachenerLaienhelfer.Validator
{
public class CustomServiceRecordValidator : 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);
if (newServiceRecord.CostBearer != null && (newServiceRecord.CostBearer.Name.ToLower().Contains("jugendamt") || newServiceRecord.CostBearer.Name.ToLower().Contains("amt für")))
{
var duration = (decimal)newServiceRecord.End.Value.Subtract(newServiceRecord.Start.Value).TotalMinutes;
if (duration > 60 && (newServiceRecord.ServiceDescription.Name.ToLower().Contains("fehlkontakt") || newServiceRecord.ServiceDescription.Category.Name.ToLower().Contains("fehlkontakt")))
{
String message = String.Format("Die eingegebene Dauer des Fehlkontakts überschreitet die maximal abrechenbare Dauer von 1 Stunde.\nMöchten Sie trotzdem speichern?");
result.Add(new ServiceRecordValidationResultDC
{
ResultType = ServiceRecordValidationResult.Custom,
Message = message,
Allow = true
});
}
}
return result;
}
}
}