From 07b036f7d87b1f5bf676f31c032d2ee4e76e3f48 Mon Sep 17 00:00:00 2001 From: Alexandra Date: Tue, 28 Jul 2026 16:24:20 +0200 Subject: [PATCH] =?UTF-8?q?DiakoniewerkEssen/Validation/ServiceRecordValid?= =?UTF-8?q?ator.cs=20=20Pflichfeld=20Doku=20nur=20f=C3=BCr=20nicht=20Arbei?= =?UTF-8?q?tszeit,=20Zukunft=20schon=20bei=201=20min=20nach=20jetzt=20star?= =?UTF-8?q?ten=20SupportOID=3D169166?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DiakonieWerkEssen.csproj | 1 + .../Validation/ServiceRecordValidator.cs | 61 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 ReportImp/DiakoniewerkEssen/Validation/ServiceRecordValidator.cs diff --git a/ReportImp/DiakoniewerkEssen/DiakonieWerkEssen.csproj b/ReportImp/DiakoniewerkEssen/DiakonieWerkEssen.csproj index 56a76a12c..170c11731 100644 --- a/ReportImp/DiakoniewerkEssen/DiakonieWerkEssen.csproj +++ b/ReportImp/DiakoniewerkEssen/DiakonieWerkEssen.csproj @@ -114,6 +114,7 @@ ServiceInvoiceReport67.cs + diff --git a/ReportImp/DiakoniewerkEssen/Validation/ServiceRecordValidator.cs b/ReportImp/DiakoniewerkEssen/Validation/ServiceRecordValidator.cs new file mode 100644 index 000000000..5f01cab2f --- /dev/null +++ b/ReportImp/DiakoniewerkEssen/Validation/ServiceRecordValidator.cs @@ -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 ValidateServiceRecord(ServiceRecordDC newServiceRecord, SupportConceptStatisticsDC statistics, + int maxDaysEditServiceRecordsAllowed, IList employeeOids, IList 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; + } + } +} \ No newline at end of file