301 lines
14 KiB
C#
301 lines
14 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Service.Plugins;
|
|
using BS.Shared;
|
|
using BS.Shared.Services;
|
|
|
|
namespace AutismusKoelnBonn //BetreutesWohnen Stelzel
|
|
{
|
|
public partial class LeistungsnachweisJugendamt : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
|
|
{
|
|
public LeistungsnachweisJugendamt()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServicesOverviewRO pRO)
|
|
{
|
|
|
|
double summeFls = 0;
|
|
double summeAusfall = 0;
|
|
double summeWege = 0;
|
|
|
|
if (pRO.Services != null)
|
|
{
|
|
List<ServicesOverviewRO.ServiceDetail> servicesBillable = new List<ServicesOverviewRO.ServiceDetail>();
|
|
for (int i = 0; i < pRO.Services.Count; i++)
|
|
{
|
|
var s = pRO.Services[i];
|
|
|
|
if (s.IsBillable)
|
|
{
|
|
s.TimeRangeString = "";
|
|
if (s.ServiceDescription.Contains("Wege"))
|
|
{
|
|
if (i + 1 < pRO.Services.Count && s.StartDate.Date == pRO.Services[i + 1].StartDate.Date
|
|
&& !pRO.Services[i + 1].ServiceDescription.Contains("Wege") && pRO.Services[i + 1].IsBillable)
|
|
{
|
|
summeWege += s.Minutes;
|
|
pRO.Services[i + 1].Notice5 = String.Format("{0:0.00}", s.Minutes / 60);
|
|
}
|
|
else
|
|
{
|
|
summeWege += s.Minutes;
|
|
s.Notice5 = String.Format("{0:0.00}", s.Minutes / 60);
|
|
servicesBillable.Add(s);
|
|
}
|
|
}
|
|
else if (s.ServiceDescription.Contains("Ausfall"))
|
|
{
|
|
summeAusfall += s.Minutes;
|
|
s.Notice4 = String.Format("{0:0.00}", s.Minutes / 60);
|
|
servicesBillable.Add(s);
|
|
}
|
|
else
|
|
{
|
|
summeFls += s.Minutes;
|
|
s.TimeRangeString = String.Format("{0:0.00}", s.Minutes / 60);
|
|
servicesBillable.Add(s);
|
|
}
|
|
|
|
//wenn häufig mehrere Einträge pro Tag wird's schwierig... Dann zurück auf diese Version
|
|
//if (s.ServiceDescription.Contains("Ausfall"))
|
|
//{
|
|
// summeAusfall += s.Minutes;
|
|
// s.Notice4 = String.Format("{0:0.00}", s.Minutes / 60);
|
|
//}
|
|
//else if (s.ServiceDescription.Contains("Wege"))
|
|
//{
|
|
// summeWege += s.Minutes;
|
|
// s.Notice5 = String.Format("{0:0.00}", s.Minutes / 60);
|
|
//}
|
|
//else
|
|
//{
|
|
// summeFls += s.Minutes;
|
|
// s.TimeRangeString = String.Format("{0:0.00}", s.Minutes / 60);
|
|
//}
|
|
ServicesOverviewRO.CreateSignatureString(s);
|
|
}
|
|
}
|
|
|
|
|
|
pRO.Services = servicesBillable;
|
|
}
|
|
|
|
// Betreuuernamen setzen
|
|
foreach (var cb2sc in pRO.CostBearer2SupportConceptList)
|
|
{
|
|
if (cb2sc.CostBearer.Organisation.Name == pRO.Costbearer)
|
|
{
|
|
foreach (var scap in cb2sc.ApprovalPeriodList)
|
|
{
|
|
if (pRO.StartDate.Date >= scap.StartDate.Value.Date && pRO.EndDate.Date <= scap.EndDate.Value.Date)
|
|
{
|
|
if (scap.SupportConceptApprovalPeriod2Employee != null && scap.SupportConceptApprovalPeriod2Employee.Count > 0)
|
|
{
|
|
if (scap.SupportConceptApprovalPeriod2Employee.Count == 1)
|
|
cellBerater1.Text = scap.SupportConceptApprovalPeriod2Employee[0].Employee.Person.FirstNameLastName;
|
|
else
|
|
{
|
|
cellBerater1.Text = scap.SupportConceptApprovalPeriod2Employee[0].Employee.Person.FirstNameLastName;
|
|
cellBerater2.Text = scap.SupportConceptApprovalPeriod2Employee[1].Employee.Person.FirstNameLastName;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
cellSummeFls.Text = String.Format("{0:0.00}", summeFls / 60);
|
|
cellSummeAusfall.Text = String.Format("{0:0.00}", summeAusfall / 60);
|
|
cellSummeWegezeit.Text = String.Format("{0:0.00}", summeWege / 60);
|
|
cellSummeGesamt.Text = String.Format("Gesamt: {0:0.00}", (summeFls + summeAusfall + summeWege) / 60);
|
|
|
|
pRO.ApprovedFLSPerMonth = pRO.ApprovedFLSPerWeek * 4.33m;
|
|
|
|
//cellAsdBezirk.Text = pRO.o
|
|
cellAsdSachb.Text = "";
|
|
|
|
if (pRO.CostBearer2SupportConceptList != null && pRO.CostBearer2SupportConceptList.Count > 0)
|
|
{
|
|
if (pRO.CostBearer2SupportConceptList[0].CostBearerContactPerson != null)
|
|
{
|
|
String name = "";
|
|
if (pRO.CostBearer2SupportConceptList[0].CostBearerContactPerson.Sex.HasValue)
|
|
{
|
|
if (pRO.CostBearer2SupportConceptList[0].CostBearerContactPerson.Sex.Value == Sex.Male)
|
|
{
|
|
name = "Herr ";
|
|
}
|
|
else
|
|
{
|
|
name = "Frau ";
|
|
}
|
|
}
|
|
|
|
cellAsdSachb.Text = name + pRO.CostBearer2SupportConceptList[0].CostBearerContactPerson.LastName;
|
|
}
|
|
}
|
|
|
|
var adList = BerechneJugendamtSollIst(pRO);
|
|
|
|
var gesamt = (summeFls + summeAusfall + summeWege) / 60;
|
|
|
|
decimal approvedHoursTotal = 0;
|
|
decimal usedHoursPreviousMonthsTotal = 0;
|
|
decimal approvedHoursInTimeSpan = 0;
|
|
decimal remainingHoursTotal = 0;
|
|
if (adList.Count > 0)
|
|
{
|
|
var ad = adList[0];
|
|
|
|
cellStdBewZeitraum.Text = String.Format("{0:0.00}", ad.ApprovedHoursInTimeSpan);
|
|
cellBewilligungStart.Text = String.Format("{0:dd.MM.yyyy}", ad.TotalStartDate);
|
|
cellBewilligungEnd.Text = String.Format("{0:dd.MM.yyyy}", ad.TotalEndDate);
|
|
|
|
cellApprovedTotal.Text = String.Format("{0:0.00}", ad.ApprovedHoursTotal);
|
|
|
|
approvedHoursTotal += ad.ApprovedHoursTotal;
|
|
usedHoursPreviousMonthsTotal += ad.UsedHoursPreviousMonths;
|
|
approvedHoursInTimeSpan += ad.ApprovedHoursInTimeSpan;
|
|
remainingHoursTotal += ad.RemainingHoursTotal;
|
|
|
|
if (adList.Count > 1)
|
|
{
|
|
ad = adList[1];
|
|
cellBewilligtProWoche2.Text = String.Format("{0:0.00}", ad.ApprovedHoursPerWeek);
|
|
|
|
cellBewilligtVon2.Text = String.Format("{0:dd.MM.yyyy}", ad.TotalStartDate);
|
|
cellBewilligtBis2.Text = String.Format("{0:dd.MM.yyyy}", ad.TimeSpanEndDate);
|
|
pRO.EndDate = (DateTime)adList[0].TotalEndDate;
|
|
|
|
cellStdBewZeitraum2.Text = String.Format("{0:0.00}", ad.ApprovedHoursInTimeSpan);
|
|
cellBewilligtProWoche22.Text = String.Format("{0:0.00}", ad.ApprovedHoursPerWeek);
|
|
cellBewilligungStart2.Text = String.Format("{0:dd.MM.yyyy}", ad.TotalStartDate);
|
|
cellBewilligungEnd2.Text = String.Format("{0:dd.MM.yyyy}", ad.TotalEndDate);
|
|
|
|
cellApprovedTotal2.Text = String.Format("{0:0.00}", ad.ApprovedHoursTotal);
|
|
|
|
approvedHoursTotal += ad.ApprovedHoursTotal;
|
|
usedHoursPreviousMonthsTotal += ad.UsedHoursPreviousMonths;
|
|
approvedHoursInTimeSpan += ad.ApprovedHoursInTimeSpan;
|
|
remainingHoursTotal += ad.RemainingHoursTotal;
|
|
}
|
|
|
|
cellApprovedTotal3.Text = String.Format("{0:0.00}", approvedHoursTotal);
|
|
cellStundenVormonat3.Text = String.Format("{0:0.00}", usedHoursPreviousMonthsTotal);
|
|
cellStdBewZeitraum3.Text = String.Format("{0:0.00}", approvedHoursInTimeSpan);
|
|
cellRestStunden3.Text = String.Format("{0:0.00}", remainingHoursTotal);
|
|
|
|
cellSummeGesamt.Text = String.Format("Summe {0:0.00}", gesamt);
|
|
cellVerbleiben.Text = String.Format("{0:0.00}", remainingHoursTotal - (decimal)gesamt);
|
|
}
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private List<ServicesOverviewRO.ApprovalDetail> BerechneJugendamtSollIst(ServicesOverviewRO pRO)
|
|
{
|
|
var adList = new List<ServicesOverviewRO.ApprovalDetail>();
|
|
|
|
|
|
if (pRO.SupportConceptCostBearer != null && pRO.SupportConceptCostBearer.CostBearer2SupportConceptOid != null)
|
|
{
|
|
if (pRO.SupportConceptCostBearer.StartDate != null)
|
|
{
|
|
CostBearer2SupportConcept c2s = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(pRO.SupportConceptCostBearer.CostBearer2SupportConceptOid.Value);
|
|
var calc = PluginLoader.FindClass<Calculations>(c2s.CostBearer.ID) ?? Calculations.GetInstance(c2s.CostBearer.ID);
|
|
var endeVormonat = new DateTime(pRO.StartDate.Year, pRO.StartDate.Month, 1).AddDays(-1);
|
|
|
|
if (c2s.StartDate.HasValue && c2s.StartDate > pRO.StartDate)
|
|
{
|
|
pRO.StartDate = c2s.StartDate.Value;
|
|
}
|
|
|
|
if (c2s.EndDate.HasValue && c2s.EndDate < pRO.EndDate)
|
|
{
|
|
pRO.EndDate = c2s.EndDate.Value;
|
|
}
|
|
|
|
IList<ServiceRecord> allServiceRecords = c2s.ServiceRecords;
|
|
|
|
foreach (var scap in pRO.SupportConceptCostBearer.ApprovalPeriodList)
|
|
{
|
|
if (scap.StartDate <= pRO.EndDate && scap.EndDate >= pRO.StartDate)
|
|
{
|
|
var ad = new ServicesOverviewRO.ApprovalDetail();
|
|
adList.Add(ad);
|
|
if (scap.StartDate > pRO.StartDate)
|
|
ad.TimeSpanStartDate = (DateTime)scap.StartDate;
|
|
else
|
|
ad.TimeSpanStartDate = pRO.StartDate;
|
|
if (scap.EndDate < pRO.EndDate)
|
|
ad.TimeSpanEndDate = (DateTime)scap.EndDate;
|
|
else
|
|
ad.TimeSpanEndDate = pRO.EndDate;
|
|
|
|
ad.TotalStartDate = scap.StartDate.Value;
|
|
ad.TotalEndDate = scap.EndDate.Value;
|
|
|
|
TimeSpan ts = pRO.EndDate.Subtract(ad.TotalStartDate.Value);
|
|
|
|
ad.ApprovedHoursPerWeek = calc.GetApprovedHoursPerWeek(scap, pRO.SupportConceptCostBearer.CostBearer.CostRatePeriods) ?? 0;
|
|
ad.ApprovedHoursInTimeSpan = ad.DaysInTimeSpan * (ad.ApprovedHoursPerWeek / 7m);
|
|
ad.ApprovedHoursTotal = ad.DaysTotal * (ad.ApprovedHoursPerWeek / 7m);
|
|
|
|
decimal minutenIstBisEndeBeleg = 0;
|
|
decimal minutenIstVormonat = 0;
|
|
|
|
DateTime end = pRO.EndDate.Date.AddDays(1);
|
|
|
|
Dictionary<long, bool> groupBookingDict = new Dictionary<long, bool>();
|
|
foreach (var item in allServiceRecords)
|
|
{
|
|
if (!item.GroupOid.HasValue || !groupBookingDict.ContainsKey(item.GroupOid.Value))
|
|
{
|
|
if (item.GroupOid.HasValue)
|
|
groupBookingDict.Add(item.GroupOid.Value, true);
|
|
|
|
if (item.Start != null && item.Start >= ad.TotalStartDate)
|
|
{
|
|
if (item.ServiceDescription != null &&
|
|
item.ServiceDescription.ServiceCategory != null &&
|
|
item.ServiceDescription.ServiceCategory.IsBillable)
|
|
{
|
|
if (scap.ServiceCategory == null || scap.ServiceCategory.ServiceCategoryOid == item.ServiceDescription.ServiceCategory.Oid)
|
|
if (item.Start.Value < end)
|
|
{
|
|
var prozent = item.ServiceDescription.ServiceCategory.ProzentAbrechnung;
|
|
if (item.ServiceDescription.ProzentAbrechnung.HasValue)
|
|
{
|
|
prozent = item.ServiceDescription.ProzentAbrechnung.Value;
|
|
|
|
}
|
|
|
|
minutenIstBisEndeBeleg += (item.RoundedDuration * prozent) / 100;
|
|
|
|
if (item.Start.Value < endeVormonat.AddDays(1))
|
|
{
|
|
minutenIstVormonat += (item.RoundedDuration * prozent) / 100;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
ad.UsedHoursPreviousMonths = minutenIstVormonat / 60;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return adList;
|
|
}
|
|
}
|
|
}
|