39 lines
1.9 KiB
C#
39 lines
1.9 KiB
C#
using BeWo.Service.Plugins;
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace LebenshilfeWolfsburg.Validation
|
|
{
|
|
public class CustomServiceRecordValidator : ServiceRecordValidator
|
|
{
|
|
// Bei einer Gruppenbuchung ist ausschließlich die Leistung "Sonstiges" zulässig, um keine Wegepauschalen auszulösen
|
|
private const string ErlaubteLeistungBeiGruppenbuchung = "Sonstiges";
|
|
|
|
public override List<ServiceRecordValidationResultDC> ValidateServiceRecord(ServiceRecordDC newServiceRecord, SupportConceptStatisticsDC statistics, int maxDaysEditServiceRecordsAllowed, IList<long> employeeOids, IList<long> cb2scOids)
|
|
{
|
|
var validation = base.ValidateServiceRecord(newServiceRecord, statistics, maxDaysEditServiceRecordsAllowed, employeeOids, cb2scOids);
|
|
|
|
bool istGruppenbuchung = (cb2scOids != null && cb2scOids.Count > 1) || (employeeOids != null && employeeOids.Count > 1)
|
|
|| newServiceRecord.GroupOid.HasValue || (newServiceRecord.GroupPersonCount.HasValue && newServiceRecord.GroupPersonCount.Value > 1);
|
|
|
|
if (istGruppenbuchung && newServiceRecord.ServiceDescription.Category.ServiceCategoryOid == 8)
|
|
{
|
|
var leistung = newServiceRecord.ServiceDescription?.Name;
|
|
|
|
if (!string.Equals(leistung, ErlaubteLeistungBeiGruppenbuchung, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
validation.Add(new ServiceRecordValidationResultDC
|
|
{
|
|
ResultType = ServiceRecordValidationResult.Custom,
|
|
Allow = false,
|
|
Message = "Bei einer Gruppenbuchung ist ausschließlich die Leistung \"Sonstiges\" zulässig."
|
|
});
|
|
}
|
|
}
|
|
|
|
return validation;
|
|
}
|
|
}
|
|
} |