Die ServiceRecord-Validierung geschieht jetzt ausschließlich auf dem Server. Der Benutzer wird lediglich gefragt, ob trotz vorhandener Überschneidungen etc. gespeichert werden soll, sofern er die Rechte dazu hat.

This commit is contained in:
Lyndon
2018-12-10 23:40:38 -04:00
parent 199f114d29
commit f4e7d42d44
16 changed files with 795 additions and 554 deletions

View File

@@ -4,7 +4,7 @@ using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using BeWo.Service.DCEntityMapper;
using BeWo.Service.ServiceImplementations;
using BeWoPlanerMobil.Models;
@@ -23,6 +23,7 @@ using BS.Shared.Services;
using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.Compatibility;
using static BS.Shared.ServiceRecordValidationResult;
using ServiceRecordDC = BS.Shared.DataContracts.ServiceRecordDC;
namespace BeWoPlanerMobil.Controllers
@@ -158,6 +159,11 @@ namespace BeWoPlanerMobil.Controllers
{
LoadRecordsToModel();
}
if (Model.SelectedEmployee == null)
{
Model.SelectedEmployee = MobileSessionFacade.LoggedInCompactEmployee;
}
}
catch (Exception e)
{
@@ -171,6 +177,11 @@ namespace BeWoPlanerMobil.Controllers
[Authorize]
public ActionResult SetShowOnlyOwnSupportConcepts(FormCollection collection)
{
if (Model == null)
{
return RedirectToActionPermanent("Index", "Login");
}
var newValue = "true,false" == collection["ShowOnlyOwnSupportConcepts"];
Model.ShowOnlyOwnSupportConcepts = newValue;
@@ -182,6 +193,11 @@ namespace BeWoPlanerMobil.Controllers
[Authorize]
public ActionResult SetShowExpiredSupportConcepts(FormCollection pCollection)
{
if (Model == null)
{
return RedirectToActionPermanent("Index", "Login");
}
var newValue = "true,false" == pCollection["ShowExpiredSupportConcepts"];
Model.ShowExpiredSupportConcepts = newValue;
@@ -191,6 +207,12 @@ namespace BeWoPlanerMobil.Controllers
public ActionResult UpdateSettings(string pKey, string pValue)
{
if (Model == null)
{
RedirectToActionPermanent("Index", "Login");
return null;
}
var userSettings = GetUser().Settings;
UserSettingsUtils.SetSettingValue(SettingsType.ApplicationSettings, pKey, pValue, userSettings);
@@ -211,7 +233,8 @@ namespace BeWoPlanerMobil.Controllers
{
if (Model == null)
{
return "SessionTimeout";
RedirectToActionPermanent("Index", "Login");
return null;
}
var sc = Model.SupportConcepts.FirstOrDefault(f => f.CostBearerRelations.Any(cbr => cbr.CostBearer2SupportConceptOid.HasValue && cbr.CostBearer2SupportConceptOid.Value.Equals(pCostbearer2SupportConceptOid)));
@@ -305,8 +328,15 @@ namespace BeWoPlanerMobil.Controllers
}
}
[Authorize]
public string LoadBWPSettings()
{
if (Model == null)
{
RedirectToActionPermanent("Index", "Login");
return null;
}
var m = OperationsService.GetMandator();
var time = MobileUtils.GetSettingValue(m.Settings, "TimeUntilUILock");
@@ -315,6 +345,12 @@ namespace BeWoPlanerMobil.Controllers
public string CheckEndDate()
{
if (Model == null)
{
RedirectToActionPermanent("Index", "Login");
return null;
}
var m = OperationsService.GetMandator();
var endtime = MobileUtils.GetSettingValue(m.Settings, "IsEndDateVisible");
@@ -323,6 +359,12 @@ namespace BeWoPlanerMobil.Controllers
public string CheckOnlyYearMonth()
{
if (Model == null)
{
RedirectToActionPermanent("Index", "Login");
return null;
}
var m = OperationsService.GetMandator();
var yearMonth = MobileUtils.GetSettingValue(m.Settings, "IsOnlyYearMonthVisible");
@@ -331,6 +373,12 @@ namespace BeWoPlanerMobil.Controllers
public string CheckIsZeiterfassDateNormal()
{
if (Model == null)
{
RedirectToActionPermanent("Index", "Login");
return null;
}
var m = OperationsService.GetMandator();
var normal = MobileUtils.GetSettingValue(m.Settings, "IsZeiterfassDateNormal");
@@ -339,6 +387,12 @@ namespace BeWoPlanerMobil.Controllers
public string CheckIsZeiterfassungInStdMin()
{
if (Model == null)
{
RedirectToActionPermanent("Index", "Login");
return null;
}
var m = OperationsService.GetMandator();
var zeiterInStdMin = MobileUtils.GetSettingValue(m.Settings, "IsZeiterfassungInStdMin");
@@ -347,6 +401,12 @@ namespace BeWoPlanerMobil.Controllers
public string CheckDokuReiter()
{
if (Model == null)
{
RedirectToActionPermanent("Index", "Login");
return null;
}
return SerializeObject(Model.Dokutypes);
}
@@ -370,10 +430,11 @@ namespace BeWoPlanerMobil.Controllers
{
try
{
if (Model == null)
{
return "SessionTimeout";
RedirectToActionPermanent("Index", "Login");
return null;
}
var date = DateTime.ParseExact(newtoday, "dd.MM.yyyy", null);
@@ -470,9 +531,10 @@ namespace BeWoPlanerMobil.Controllers
{
try
{
if(Model == null)
if (Model == null)
{
return "SessionTimeout";
RedirectToActionPermanent("Index", "Login");
return null;
}
var supportConceptStatistics = OperationsService.CreateSupportConceptStatistics(oid, DateTime.Now);
@@ -493,7 +555,8 @@ namespace BeWoPlanerMobil.Controllers
{
if (Model == null)
{
SerializeObject("SessionTimeout");
RedirectToActionPermanent("Index", "Login");
return;
}
var date = DateTime.Parse(day);
@@ -523,7 +586,8 @@ namespace BeWoPlanerMobil.Controllers
{
if (Model == null)
{
SerializeObject("SessionTimeout");
RedirectToActionPermanent("Index", "Login");
return;
}
var date = DateTime.Parse(pStartDate);
@@ -542,13 +606,14 @@ namespace BeWoPlanerMobil.Controllers
Originator = MobileSessionFacade.LoggedInCompactEmployee
};
var newE2S = new Employee2SchedulerAppointmentDC();
newE2S.Employee = MobileSessionFacade.LoggedInCompactEmployee;
var newE2S = new Employee2SchedulerAppointmentDC
{
Employee = MobileSessionFacade.LoggedInCompactEmployee
};
newApp.EmployeeList.Add(newE2S);
var list = new List<SchedulerAppointmentDC>();
list.Add(newApp);
var list = new List<SchedulerAppointmentDC> {newApp};
//var a1 = new List<SchedulerAppointmentDC> {
// new SchedulerAppointmentDC
// {
@@ -579,7 +644,8 @@ namespace BeWoPlanerMobil.Controllers
{
if (Model == null)
{
return "SessionTimeout";
RedirectToActionPermanent("Index", "Login");
return null;
}
var date = DateTime.ParseExact(newtoday, "dd.MM.yyyy", null);
@@ -603,7 +669,8 @@ namespace BeWoPlanerMobil.Controllers
{
if (Model == null)
{
SerializeObject("SessionTimeout");
RedirectToActionPermanent("Index", "Login");
return;
}
var date = DateTime.Parse(zeitstempel);
@@ -630,7 +697,8 @@ namespace BeWoPlanerMobil.Controllers
{
if (Model == null)
{
return SerializeObject("SessionTimeout");
RedirectToActionPermanent("Index", "Login");
return null;
}
Model.SaveSignature = save;
@@ -645,7 +713,13 @@ namespace BeWoPlanerMobil.Controllers
public string LoadServiceCategories(long pServiceCategoryOid)
{
try
if (Model == null)
{
RedirectToActionPermanent("Index", "Login");
return null;
}
try
{
var scm = Model?.ServiceCategories.FirstOrDefault(s => s.ServiceCategoryOid.Value == pServiceCategoryOid);
@@ -661,6 +735,12 @@ namespace BeWoPlanerMobil.Controllers
[Authorize]
public string LoadTextbausteineForServiceCategory(long pServiceCategoryOid)
{
if (Model == null)
{
RedirectToActionPermanent("Index", "Login");
return null;
}
try
{
if (!MobileSessionFacade.CheckForUserRight(UserRightType.TextbausteineNurEigeneAnsehen) && !MobileSessionFacade.CheckForUserRight(UserRightType.TextbausteineAlleAnsehen))
@@ -709,6 +789,12 @@ namespace BeWoPlanerMobil.Controllers
public string LoadCompleteTextbausteinByOid(long pTextbausteinOid)
{
if (Model == null)
{
RedirectToActionPermanent("Index", "Login");
return null;
}
var abc = Model.Textbausteine.FirstOrDefault(f => f.TextModuleOid.HasValue && f.TextModuleOid.Value == pTextbausteinOid);
return abc?.Text;
@@ -718,14 +804,13 @@ namespace BeWoPlanerMobil.Controllers
{
try
{
if (Model == null)
if (Model == null)
{
SerializeObject("SessionTimeout");
}
else
{
Model.ErrorWert = errorwert;
RedirectToActionPermanent("Index", "Login");
return;
}
Model.ErrorWert = errorwert;
}
catch (Exception e)
{
@@ -891,12 +976,12 @@ namespace BeWoPlanerMobil.Controllers
Model.NewServiceRecord.ServiceRecordFormat = ServiceRecordFormate.OriginaleZeiterfassung;
Model.NewServiceRecord.Notice = doku1 == string.Empty ? null : doku1;
Model.NewServiceRecord.Notice = string.IsNullOrEmpty(doku1) ? null : doku1;
Model.NewServiceRecord.Notice2 = doku2 == string.Empty ? null : doku2;
Model.NewServiceRecord.Notice3 = doku3 == string.Empty ? null : doku3;
Model.NewServiceRecord.Notice4 = doku4 == string.Empty ? null : doku4;
Model.NewServiceRecord.Notice5 = doku5 == string.Empty ? null : doku5;
Model.NewServiceRecord.Notice2 = string.IsNullOrEmpty(doku2) ? null : doku2;
Model.NewServiceRecord.Notice3 = string.IsNullOrEmpty(doku3) ? null : doku3;
Model.NewServiceRecord.Notice4 = string.IsNullOrEmpty(doku4) ? null : doku4;
Model.NewServiceRecord.Notice5 = string.IsNullOrEmpty(doku5) ? null : doku5;
var serviceDescOid = 0L;
@@ -1357,52 +1442,6 @@ namespace BeWoPlanerMobil.Controllers
}
}
}
private static ServiceRecordDC CloneServiceRecordForGroupBooking(ServiceRecordDC pOriginal)
{
var m = pOriginal;
var clone = new ServiceRecordDC
{
CostBearer = m.CostBearer,
CostBearer2SupportConceptOid = m.CostBearer2SupportConceptOid,
Customer = m.Customer,
Employee = m.Employee,
End = m.End,
Goals = m.Goals,
GroupEmployeeCount = m.GroupEmployeeCount,
GroupOid = m.GroupOid,
SignatureOid = m.SignatureOid,
GroupPersonCount = m.GroupPersonCount,
GroupRoundedDuration = m.GroupRoundedDuration,
InsUser = m.InsUser,
InsertedOn = m.InsertedOn,
Notice = m.Notice,
Notice2 = m.Notice2,
Notice3 = m.Notice3,
Notice4 = m.Notice4,
Notice5 = m.Notice5,
RTFNotice1 = m.RTFNotice1,
RTFNotice2 = m.RTFNotice2,
RTFNotice3 = m.RTFNotice3,
RTFNotice4 = m.RTFNotice4,
RTFNotice5 = m.RTFNotice5,
RoundedDuration = m.RoundedDuration,
ServiceDescription = m.ServiceDescription,
Start = m.Start,
SupportConcept = m.SupportConcept,
ServiceRecordType = m.ServiceRecordType,
DistanceInMeter = m.DistanceInMeter,
IP = m.IP,
Relevance = m.Relevance,
IsCreatedInMobileClient = true,
WohnheimbuchungsOid = m.WohnheimbuchungsOid,
DurationInStunden = m.DurationInStunden,
ServiceRecordFormat = m.ServiceRecordFormat
};
return clone;
}
[Authorize]
public ActionResult SaveZeiterfassungAfterCrash(string pDatum, string pStartDate, string pEndDate, string pDuration, string pNotice, string pServiceDescription, string pNotice2, string pNotice3, string pNotice4, string pNotice5, string pEndDate2)
@@ -1699,7 +1738,7 @@ namespace BeWoPlanerMobil.Controllers
if (Model == null)
{
RedirectToActionPermanent("Index", "Login");
return " ";
return null;
}
Model.SelectedServiceDescriptionOid = pServiceDescriptionOid;
@@ -1730,7 +1769,13 @@ namespace BeWoPlanerMobil.Controllers
private void LoadRecordsToModel()
{
if(Model.Zeitraum < 0 || Model.CostBearer2SupportConceptOid.HasValue && Model.CostBearer2SupportConceptOid.Value == -1)
if (Model == null)
{
RedirectToActionPermanent("Index", "Login");
return;
}
if (Model.Zeitraum < 0 || Model.CostBearer2SupportConceptOid.HasValue && Model.CostBearer2SupportConceptOid.Value == -1)
{
Model.ServiceRecords = new List<ServiceRecordDC>();
return;
@@ -1833,6 +1878,12 @@ namespace BeWoPlanerMobil.Controllers
public string GetSelectedRecordInformation()
{
if (Model == null)
{
RedirectToActionPermanent("Index", "Login");
return null;
}
var result = string.Empty;
if (Model.SelectedServiceRecordOid.HasValue)
@@ -1845,16 +1896,24 @@ namespace BeWoPlanerMobil.Controllers
public string GetSelectedRecordInformationWithOid(long oid)
{
if (Model == null)
{
RedirectToActionPermanent("Index", "Login");
return null;
}
LoadRecordsToModel();
return SerializeObject(Model.ServiceRecords.First(f => f.ServiceRecordOid == oid));
}
[Authorize]
public string CheckRights(string von, string bis, bool inEditMode, string dateString, string startString, string endString)
{
{
if (Model == null)
{
return "SessionTimeout";
RedirectToActionPermanent("Index", "Login");
return null;
}
log.Info($"CheckRights: von:{von};bis:{bis};inEditMode:{inEditMode};dateString:{dateString};startString:{startString};endString:{endString}");
@@ -1898,10 +1957,14 @@ namespace BeWoPlanerMobil.Controllers
checkSR.Start = startDt;
checkSR.End = endDt;
if (Model.Employee.EmployeeOid != null)
checkSR.IP = Request.UserHostAddress;
checkSR.ServiceDescription = OperationsService.GetServiceDescription(Model.SelectedServiceDescriptionOid.Value);
checkSR.Employee = Model.SelectedEmployee ?? MobileSessionFacade.LoggedInCompactEmployee;
if (Model.SelectedEmployee != null && !Model.IsInGroupBookingMode)
{
checkSR.Employee = MobileSessionFacade.LoggedInCompactEmployee;
var sc = Model.SupportConcepts.FirstOrDefault(fod => fod.CostBearerRelations.Any(a => a.CostBearer2SupportConceptOid.HasValue && a.CostBearer2SupportConceptOid.Value.Equals(Model.CostBearer2SupportConceptOid)));
if (sc != null)
@@ -1918,26 +1981,25 @@ namespace BeWoPlanerMobil.Controllers
if (intervall > 0)
{
checkSR.RoundedDuration = dauer % intervall != 0 ? dauer + (intervall - (dauer % intervall)) : dauer;
checkSR.RoundedDuration = dauer % intervall != 0 ? dauer + (intervall - dauer % intervall) : dauer;
}
checkSR.CostBearer2SupportConceptOid = Model.CostBearer2SupportConceptOid;
}
}
checkSR.IP = Request.UserHostAddress;
checkSR.InsertedOn = DateTime.Now;
checkSR.InsUser = $"{MobileSessionFacade.LoggedInEmployee.FirstName} {MobileSessionFacade.LoggedInEmployee.LastName}";
checkSR.ServiceDescription = OperationsService.GetServiceDescription(Model.SelectedServiceDescriptionOid.Value);
var mandator = OperationsService.GetMandator();
var settings = mandator.Settings ?? string.Empty;
var splitSettings = settings.Split(';');
var maxDaysEditSRsAllowedSetting = splitSettings.ToList().FirstOrDefault(f => f.Contains("MaxDaysEditServiceRecordsAllowed"));
var maxDaysEditSRsAllowed = maxDaysEditSRsAllowedSetting != null ? int.Parse(maxDaysEditSRsAllowedSetting.Split('=')[1]) : 0;
var limitFuerZeiterfassungSetting = splitSettings.ToList().FirstOrDefault(f => f.Contains("AnzTageZeiterfassErfolgt"));
var limitFuerZeiterfassung = limitFuerZeiterfassungSetting != null ? limitFuerZeiterfassungSetting.Split('=')[1] : "0";
var limitFuerZeiterfassung = limitFuerZeiterfassungSetting != null ? int.Parse(limitFuerZeiterfassungSetting.Split('=')[1]) : 0;
if (MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowEditAfterMaxDaysInNextMonth))
{
maxDaysEditSRsAllowed = -1;
}
SupportConceptStatisticsDC stats = null;
@@ -1948,7 +2010,10 @@ namespace BeWoPlanerMobil.Controllers
var employees = new List<long> {checkSR.Employee.EmployeeOid};
var newResult = new ValidationResult();
var validationResults = new List<ServiceRecord2Validation>();
checkSR.ServiceRecordFormat = ServiceRecordFormate.OriginaleZeiterfassung;
checkSR.DurationInStunden = ZeiterfassungsDauer.Minuten;
string dateRangeString;
@@ -1967,33 +2032,21 @@ namespace BeWoPlanerMobil.Controllers
var cb2scOids = (from scDc in Model.SelectedSupportConcepts where scDc.CostBearerRelations != null && scDc.CostBearerRelations.Count > 0 select scDc.CostBearerRelations[0].CostBearer2SupportConceptOid.Value).ToList();
var nodes = new List<FlatSupportConceptTreeNodeDC>();
foreach (var sc in CustomerService.LoadCompactSupportConceptsById(Model.SelectedSupportConcepts.Select(s => s.SupportConceptOid.Value)))
var relations = CustomerService.GetSupportConceptCostBearerRelationsById(cb2scOids);
foreach (var rel in relations)
{
nodes.Add(CreateFlatSupportConceptItem(sc, null));
}
var sr = CloneServiceRecordForGroupBooking(checkSR);
foreach (var node in nodes)
{
if (node?.SupportConceptTreeNodeDC != null)
{
var scDc = node.SupportConceptTreeNodeDC.SupportConcept;
var cbDc = node.SupportConceptTreeNodeDC.CostBearer;
var relDc = node.SupportConceptTreeNodeDC.SupportConceptCostBearerRelDC;
sr.SupportConcept = rel.SupportConcept;
sr.CostBearer = rel.CostBearer;
sr.CostBearer2SupportConceptOid = rel.CostBearer2SupportConceptOid;
checkSR.SupportConcept = scDc;
checkSR.CostBearer = cbDc;
var result = OperationsService.ValidateServiceRecord(sr, null, maxDaysEditSRsAllowed, employees, cb2scOids);
dateRangeString = rel.DateRangeString;
if (relDc != null)
{
checkSR.CostBearer2SupportConceptOid = relDc.CostBearer2SupportConceptOid;
}
}
var result = OperationsService.ValidateServiceRecord(checkSR, stats, maxDaysEditSRsAllowed, employees, cb2scOids);
dateRangeString = node?.SupportConceptTreeNodeDC != null ? node.SupportConceptTreeNodeDC.SupportConceptCostBearerRelDC.DateRangeString : "";
newResult.ServiceRecord2Validations.Add(new ServiceRecord2Validation(checkSR, result, dateRangeString));
validationResults.Add(new ServiceRecord2Validation(sr, result, dateRangeString));
}
}
else
@@ -2002,15 +2055,142 @@ namespace BeWoPlanerMobil.Controllers
dateRangeString = node?.SupportConceptTreeNodeDC != null ? node.SupportConceptTreeNodeDC.SupportConceptCostBearerRelDC.DateRangeString : "";
var result = OperationsService.ValidateServiceRecordEntry(checkSR, stats, maxDaysEditSRsAllowed, checkSR.GroupOid.HasValue, employees);
newResult.ServiceRecord2Validations.Add(new ServiceRecord2Validation(checkSR, result, dateRangeString));
validationResults.Add(new ServiceRecord2Validation(checkSR, result, dateRangeString));
}
newResult.MaxDaysEditServiceRecordsAllowed = maxDaysEditSRsAllowed.ToString();
newResult.LimitFuerZeiterfassung = limitFuerZeiterfassung;
newResult.Rights.Add(0, MobileSessionFacade.LoggedInUser.UserGroups.Any(a => a.Rights.Any(f => f.RightType.Equals(UserRightType.ServiceRecord_AllowCreateOverlappingFLS))));
newResult.Rights.Add(1, MobileSessionFacade.LoggedInUser.UserGroups.Any(a => a.Rights.Any(f => f.RightType.Equals(UserRightType.ServiceRecord_AllowCreateMoreFLSThanApproved))));
newResult.Rights.Add(2, MobileSessionFacade.LoggedInUser.UserGroups.Any(a => a.Rights.Any(f => f.RightType.Equals(UserRightType.BookServiceRecordAfterSettlementInvoice))));
var allowOverlappingFLS = MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowCreateOverlappingFLS);
var allowMoreFLSThanApproved = MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowCreateMoreFLSThanApproved);
var bookAfterSettlementInvoice = MobileSessionFacade.CheckForUserRight(UserRightType.BookServiceRecordAfterSettlementInvoice);
var newResult = new ValidationResult();
var exitLoop = false;
foreach (var sr2v in validationResults)
{
if(exitLoop)
{
break;
}
foreach (var vr in sr2v.ValidationResults)
{
if (exitLoop)
{
break;
}
switch(vr.ResultType)
{
case ServiceRecordOverlapping:
if (allowOverlappingFLS)
{
newResult.KannTrotzdemGespeichertWerden = true;
newResult.Message += "An dem gewählten Datum '" + von + "' existiert bereits ein Eintrag (" + vr.Message + " bei Klient/in " + vr.CustomerName + "). Möchten Sie trotzdem speichern?<br />";
exitLoop = false;
}
else
{
newResult.Message += "An dem gewählten Datum '" + von + "' existiert bereits ein Eintrag (" + vr.Message + " bei Klient/in " + vr.CustomerName + "). Speichern nicht möglich.<br />";
exitLoop = true;
newResult.KannTrotzdemGespeichertWerden = false;
}
break;
case EmployeeOverlapping:
if (allowOverlappingFLS)
{
newResult.Message += "An dem gewählten Datum " + von + " existiert bereits ein Eintrag von " + vr.EmployeeName + " (" + vr.Message + "). Möchten Sie trotzdem speichern?<br />";
exitLoop = false;
newResult.KannTrotzdemGespeichertWerden = true;
}
else
{
newResult.Message += "An dem gewählten Datum " + von + " existiert bereits ein Eintrag von " + vr.EmployeeName + " (" + vr.Message + "). Speichern nicht möglich.<br />";
exitLoop = true;
newResult.KannTrotzdemGespeichertWerden = false;
}
break;
case OutsideOfSupportConcept:
newResult.Message += "Das gewählte Datum " + von.Substring(0, 10) + " liegt außerhalb des Zeitraumes des gewählten Hilfeplans (" + sr2v.HilfePlanZeitraum + "). Speichern nicht möglich.<br />";
newResult.KannTrotzdemGespeichertWerden = false;
exitLoop = true;
break;
case ApprovedFLSOverspending:
var klient = "diesen Hilfeplan";
if (!string.IsNullOrEmpty(vr.CustomerName))
{
klient = "Klient/in " + vr.CustomerName;
}
var msg = "Die für " + klient + " genehmigten FLS (" + vr.ApprovedHours + ") werden mit diesem Eintrag überschritten. (" + vr.HoursNew + ").";
if (allowMoreFLSThanApproved)
{
newResult.Message += msg + " Möchten Sie trotzdem speichern?<br />";
exitLoop = false;
newResult.KannTrotzdemGespeichertWerden = true;
}
else
{
newResult.Message += msg + " Speichern nicht möglich.<br />";
exitLoop = true;
newResult.KannTrotzdemGespeichertWerden = false;
}
break;
case OutOfEditLimit:
newResult.Message += "Sie können keine neuen Leistungen für den " + von + " dokumentieren, da bereits der " + maxDaysEditSRsAllowed + ". des nachfolgenden Monats überschritten ist. Speichern nicht möglich.<br />";
exitLoop = true;
newResult.KannTrotzdemGespeichertWerden = false;
break;
case Error:
newResult.Message += "Beim Speichern ist ein Fehler aufgetreten. Speichern nicht möglich.<br />";
exitLoop = true;
newResult.KannTrotzdemGespeichertWerden = false;
break;
case SettlementInvoiceAlreadyExisting:
var klient2 = "diesen Hilfeplan";
if(!string.IsNullOrEmpty(vr.CustomerName))
{
klient2 = "Klient/in " + vr.CustomerName;
}
if (bookAfterSettlementInvoice)
{
newResult.Message += "Es existiert bereits eine Spitzabrechnung für " + klient2 + ". Um diesen Eintrag zu berücksichtigen, muss eventuell eine neue Spitzabrechnung erstellt werden. Möchten Sie trotzdem speichern?<br />";
exitLoop = false;
newResult.KannTrotzdemGespeichertWerden = true;
}
else
{
newResult.Message += "Sie können den Eintrag nicht bearbeiten, da bereits eine Spitzabrechnung für " + klient2 + " erstellt wurde. Speichern nicht möglich.<br />";
exitLoop = true;
newResult.KannTrotzdemGespeichertWerden = false;
}
break;
case FristAbgelaufen:
var intervall = "einem Tag";
if (limitFuerZeiterfassung != 1)
{
intervall = "" + limitFuerZeiterfassung + " Tagen";
}
newResult.Message += "Sie können keine neuen Leistungen für den " + von + " dokumentieren, da die Zeiterfassung innerhalb von " + intervall + " erfolgen muss. Das Speichern ist nicht möglich.<br />";
exitLoop = true;
newResult.KannTrotzdemGespeichertWerden = false;
break;
case Custom:
newResult.Message += vr.Message + "<br />";
exitLoop = true;
newResult.KannTrotzdemGespeichertWerden = false;
break;
}
}
}
Model.NewServiceRecord = new ServiceRecordDC();
@@ -2264,6 +2444,8 @@ namespace BeWoPlanerMobil.Controllers
Model.SelectedEmployees.Clear();
Model.SelectedSupportConcepts.Clear();
Model.SelectedEmployee = MobileSessionFacade.LoggedInCompactEmployee;
if (Model.SelectedSupportConcept != null)
{
var details = OperationsService.GetSupportConceptTreeNodeDetailInfo(Model.SelectedSupportConcept.Customer.CustomerOid, Model.SelectedSupportConcept.SupportConceptOid, Model.CostBearer2SupportConceptOid);
@@ -2429,5 +2611,104 @@ namespace BeWoPlanerMobil.Controllers
return MainModel.IsEmployeeSelectionVisible.ToString();
}
private IEnumerable<ServiceRecordDC> CalculateGroupBookingDuration(int pEmployeeCount, int pCustomerCount, ICollection<long> cb2ScOids, ServiceRecordDC pBaseRecord)
{
var compactSupportConcepts = CustomerServiceImp.GetCompactSupportConcepts((from sc in Model.SelectedSupportConcepts where sc.SupportConceptOid != null select sc.SupportConceptOid.Value).ToList(), GetUser().Employee.EmployeeOid);
var nodes = (from supportConcept in Model.SelectedSupportConcepts let cb = supportConcept.CostBearerRelations.FirstOrDefault(f => cb2ScOids.Contains(f.CostBearer2SupportConceptOid.Value)) let sc = compactSupportConcepts.FirstOrDefault(f => f.SupportConceptOid == supportConcept.SupportConceptOid) where cb != null && sc != null select SupportConceptService.CreateFlatSupportConceptItem(sc, CustomerService.LoadOrganisationCompact(cb.CostBearer.OrganisationOid))).ToList();
var list = new List<ServiceRecordDC>();
foreach(var node in nodes)
{
var sc = CloneServiceRecordForGroupBooking(pBaseRecord);
if(pBaseRecord.RoundedDuration == 0)
{
if(pBaseRecord.Start.HasValue && pBaseRecord.End.HasValue)
{
var minutes = pBaseRecord.End.Value.Subtract(pBaseRecord.Start.Value).TotalMinutes;
pBaseRecord.RoundedDuration = (decimal)minutes;
}
}
sc.GroupRoundedDuration = pBaseRecord.RoundedDuration;
sc.CostBearer2SupportConceptOid = node.SupportConceptTreeNodeDC.SupportConceptCostBearerRelDC.CostBearer2SupportConceptOid;
sc.SupportConcept = node.SupportConceptTreeNodeDC.SupportConcept;
sc.CostBearer = node.SupportConceptTreeNodeDC.CostBearer;
sc.Customer = node.SupportConceptTreeNodeDC.Customer;
sc.GroupEmployeeCount = pEmployeeCount;
sc.GroupPersonCount = pCustomerCount;
list.Add(sc);
}
var roundDuration = false;
var minuteInterval = 0;
string calcdId = null;
var lastMinuteInterval = -1;
if(Model.SelectedServiceDescriptionOid.HasValue && IsBillable(Model.SelectedServiceDescriptionOid.Value, Model.GetServiceDesctiptions()))
{
roundDuration = true;
foreach(var org in from dc in Model.SelectedSupportConcepts where dc.CostBearerRelations.Count > 0 select dc.CostBearerRelations.First().CostBearer)
{
if(org != null)
{
minuteInterval = org.ActualMinuteIntervall;
if(lastMinuteInterval == -1)
{
lastMinuteInterval = minuteInterval;
calcdId = org.CostBearerID;
}
else if(lastMinuteInterval != minuteInterval)
{
roundDuration = false;
}
}
else if(minuteInterval >= 0)
{
roundDuration = false;
}
else
{
minuteInterval = 0;
}
}
}
var duration = Model.NewServiceRecord.RoundedDuration;
var totalDuration = duration;
var groupDuration = OperationsService.CalculateGroupDuration2(pCustomerCount, pEmployeeCount, Model.NewServiceRecord.RoundedDuration, nodes.Select(s => s.SupportConceptTreeNodeDC.SupportConceptCostBearerRelDC.CostBearer2SupportConceptOid.Value).ToArray());
if(groupDuration != null)
{
pBaseRecord.GroupRoundedDuration = groupDuration.TotalDuration;
pBaseRecord.RoundedDuration = groupDuration.SingleDuration;
}
else
{
if(minuteInterval > 0 && roundDuration)
{
var calc = Calculations.GetInstance(calcdId);
totalDuration = calc.GetRoundedDuration(minuteInterval, duration);
}
pBaseRecord.RoundedDuration = Math.Round(totalDuration / pCustomerCount, 0, MidpointRounding.AwayFromZero);
pBaseRecord.GroupRoundedDuration = totalDuration;
}
return list;
}
}
}