MH: BAW Aachen HomeView

This commit is contained in:
2023-06-13 16:11:39 +02:00
parent fb6c9cdcd6
commit dc524a96d0

View File

@@ -1,8 +1,10 @@
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Service.Configuration;
using BeWo.Service.DCEntityMapper;
using BeWo.Service.Plugins;
using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts.Compact;
using System;
using System.Collections.Generic;
@@ -17,29 +19,62 @@ namespace BetreuungsserviceFuerAlltagUndWohnen.Service
public override List<CompactSupportConceptDC> GetExpiringSupportConcepts(long? employeeOid,
DateTime expiredUntil)
{
var list = new List<CompactSupportConceptDC>();
var emp = MapperFactory.EmployeeDC_Employee.MapToNewDC(DAOFactory.GenericDAO.GetByID<Employee>(employeeOid.Value));
var user = DAOFactory.GenericDAO.GetAllActive<ApplicationUser>().FirstOrDefault(au => au.Employee.Oid.Value == employeeOid.Value);
if (user != null)
{
// Wenn der angemeldete Nutzer alle Hilfepläne sehen darf, dann:
if (user.CheckForRight(UserRightType.SupportConcept_ViewAllSupportConcepts))
{
var list = MapperFactory.CompactSupportConceptDC_SupportConcept.MapToNewDCs(
// Alle auslaufenden Hilfepläne unabhängig vom betroffenen Mitarbeiter + Zeitraum zur Darstellung hinter den Vornamen
list = MapperFactory.CompactSupportConceptDC_SupportConcept.MapToNewDCs(
DAOFactory.SearchDAO.FindExpiringSupportConcepts(null, DateTime.Now.Date, expiredUntil));
return list.Where(s => s.StartDate.HasValue && s.EndDate.HasValue).ToList();
foreach (var item in list)
{
item.Customer.FirstName += " (Zeitraum)";
}
// Alle Hilfepläne mit Restbudget unter Verwaltungsschwellwert unabhängig vom betroffenen Mitarbeiter
//Schwellwert ziehen
string schwellwertAusVerwaltung = UserSettingsUtils.GetSettingValue(AppSettings.GetMandatorEntity().Settings, SettingsKeys.ZeiterfassungsSchwellwert);
//Alle aktiven Hilfepläne holen, die noch nicht in der oberen Liste sind und von denen die CostbearerOids sammeln + Budget zur Darstellung hinter den Vornamen
var allSCs = MapperFactory.CompactSupportConceptDC_SupportConcept.MapToNewDCs(
DAOFactory.GenericDAO.GetAllActive<SupportConcept>()).ToList().Where(sc => !list.Contains(sc));
var cb2scList = new List<long>();
foreach (var sc in allSCs)
{
cb2scList.AddRange(sc.CostBearerRelOids);
sc.Customer.FirstName += " (Budget)";
}
// Analysen der Hilfepläne holen und die Hilfepläne der Liste hinzufügen, bei denen die % des aufgebrauchten Budgets größer oder gleich dem Schwellwert sind
SupportConceptAnalysisCreator scac = new SupportConceptAnalysisCreator();
var analyse = scac.GetSupportConceptAnalysis(cb2scList, null, null, null, null, false);
foreach (var a in analyse)
{
if (a.BERecordedTillNowInPercent >= Convert.ToDecimal(schwellwertAusVerwaltung))
list.Add(allSCs.First(s => s.SupportConceptOid == a.SupportConceptOid));
}
}
// Wenn der angemeldete Nutzer nicht alle Hilfepläne sehen darf, dann Standard-Homeansicht
else
{
var list = MapperFactory.CompactSupportConceptDC_SupportConcept.MapToNewDCs(
list = MapperFactory.CompactSupportConceptDC_SupportConcept.MapToNewDCs(
DAOFactory.SearchDAO.FindExpiringSupportConcepts(employeeOid, DateTime.Now.Date, expiredUntil));
return list.Where(s => s.StartDate.HasValue && s.EndDate.HasValue).ToList();
}
}
else
{
var list = MapperFactory.CompactSupportConceptDC_SupportConcept.MapToNewDCs(
list = MapperFactory.CompactSupportConceptDC_SupportConcept.MapToNewDCs(
DAOFactory.SearchDAO.FindExpiringSupportConcepts(employeeOid, DateTime.Now.Date, expiredUntil));
return list.Where(s => s.StartDate.HasValue && s.EndDate.HasValue).ToList();
}
return list.Where(s => s.StartDate.HasValue && s.EndDate.HasValue).ToList();
}
}
}