HshCologne/Service/ServiceRecordValidator - Unterbinden für fast alle zum Overspending bei Betreuungsart UMA
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BeWo.Data;
|
||||
using BeWo.Data.Access;
|
||||
using BeWo.Data.Entities;
|
||||
using BeWo.Service.DCEntityMapper;
|
||||
using BeWo.Service.Plugins;
|
||||
@@ -65,5 +67,76 @@ namespace HshCologne
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
// Für die Betreuungsart soll kein wildes Überdokumentieren möglich sein bzw. nur durch Frau Ari
|
||||
if (list != null && list.Count > 0 && list.Any(m => m.ResultType == ServiceRecordValidationResult.ApprovedFLSOverspending)
|
||||
&& newServiceRecord.SupportConcept != null && newServiceRecord.SupportConcept.Customer != null && !Privilegiert())
|
||||
{
|
||||
var c = DAOFactory.GenericDAO.LoadByID<Customer>(newServiceRecord.Customer.Oid.Value);
|
||||
if (c != null)
|
||||
{
|
||||
if (CheckBetreuungsart(c)) // Prüfung nur für UMAs, sonst können die übererbringen
|
||||
{
|
||||
//String handlungsOption = "Möchten Sie trotzdem Speichern?";
|
||||
bool hatDasRechtTrotzdemZuSpeichern = false;
|
||||
|
||||
list.Add(new ServiceRecordValidationResultDC
|
||||
{
|
||||
ResultType = ServiceRecordValidationResult.Custom,
|
||||
Message = "Das Stundenkontingent wurde für diesen Fall erreicht, ein Speichern ist leider nicht möglich.\nBei Bedarf bitte an Frau Ari bzw. Ihre Teamleitung wenden.",
|
||||
Allow = hatDasRechtTrotzdemZuSpeichern
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private bool CheckBetreuungsart(Customer c)
|
||||
{
|
||||
bool uma = false;
|
||||
var betreuungsarten = c.ValueList.Where(v2o => v2o.Entry.Type == ValueListEntryType.CustomerCareType).ToList();
|
||||
if (betreuungsarten != null && betreuungsarten.Count > 0 && betreuungsarten.Any(b => b.Entry.Value.Contains("(UMA)")))
|
||||
{
|
||||
uma = true;
|
||||
}
|
||||
return uma;
|
||||
}
|
||||
|
||||
private bool Privilegiert()
|
||||
{
|
||||
ApplicationUser loggedInUser;
|
||||
|
||||
if (LoggedInUserOperationContextExt.Current != null &&
|
||||
LoggedInUserOperationContextExt.Current.User != null)
|
||||
{
|
||||
loggedInUser = LoggedInUserOperationContextExt.Current.User;
|
||||
}
|
||||
else
|
||||
{
|
||||
loggedInUser = SessionFacade.LoggedInUser;
|
||||
}
|
||||
|
||||
bool privilegiert = false;
|
||||
if (loggedInUser != null)
|
||||
{
|
||||
foreach (var group in loggedInUser.UserGroups)
|
||||
{
|
||||
var array = new string[] { "Administratoren", "Verwaltungsvertretung", "Teamleitung" };
|
||||
if (array.Contains(group.Name.Trim()))
|
||||
{
|
||||
privilegiert = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return privilegiert;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user