KcmGmbH/Service/ServiceRecordValidator.cs - Startzeit bei IsBilling verpflichtend

This commit is contained in:
2025-06-16 12:16:00 +02:00
parent b365986db1
commit e20e03d163
2 changed files with 30 additions and 0 deletions

View File

@@ -85,6 +85,7 @@
<Compile Include="ServiceInvoiceReport.Designer.cs">
<DependentUpon>ServiceInvoiceReport.cs</DependentUpon>
</Compile>
<Compile Include="Service\ServiceRecordValidator.cs" />
<Compile Include="SettlementReport.cs">
<SubType>Component</SubType>
</Compile>

View File

@@ -0,0 +1,29 @@
using BeWo.Service.Plugins;
using BS.Shared;
using BS.Shared.DataContracts;
using System;
using System.Collections.Generic;
using System.Linq;
namespace KcmGmbH.Service
{
public class CustomServiceRecordValidator : ServiceRecordValidator
{
public override List<ServiceRecordValidationResultDC> ValidateServiceRecord(ServiceRecordDC newServiceRecord, SupportConceptStatisticsDC statistics, int maxDaysEditServiceRecordsAllowed, IList<long> employeeOids, IList<long> cb2scOids)
{
var list = base.ValidateServiceRecord(newServiceRecord, statistics, maxDaysEditServiceRecordsAllowed, employeeOids, cb2scOids);
DateTime start = newServiceRecord.Start.Value;
bool noTime = (start.Hour == 0 && start.Minute == 0 && start.Second == 1); //Keine Zeit angegeben
var duration = (decimal)newServiceRecord.End.Value.Subtract(newServiceRecord.Start.Value).TotalMinutes;
if (noTime && duration != 0 && newServiceRecord.ServiceDescription.Category.IsBillable)
{
list.Add(new ServiceRecordValidationResultDC
{
ResultType = ServiceRecordValidationResult.Custom,
Message = "Der Zeiterfassungseintrag muss eine Startzeit haben."
});
}
return list;
}
}
}