185 lines
7.6 KiB
C#
185 lines
7.6 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using DevExpress.XtraReports.UI;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Report;
|
|
using BeWo.Service.Plugins;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.Services;
|
|
using BS.Shared.DataContracts;
|
|
|
|
namespace PraunheimerWerkstaetten3
|
|
{
|
|
public partial class Stundenzettel : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
|
|
{
|
|
public Stundenzettel()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServicesOverviewRO pRO)
|
|
{
|
|
lblDatum.Text = String.Format("{0:dd.MM.yyyy}", DateTime.Now);
|
|
|
|
BerechneSollIst(pRO);
|
|
;
|
|
|
|
decimal plusMinusVormonat = ((pRO.MinutenGeleistetGesamt - (decimal) pRO.TotalFLMBillable)/60) - ((pRO.MinutenSollGesamt / 60) - pRO.ApprovedFLSPerMonth);
|
|
//cellPlusMinusVormonat.Text = String.Format("{0:0.00}", plusMinusVormonat);
|
|
|
|
var zuLeisten = pRO.ApprovedFLSPerMonth - plusMinusVormonat;
|
|
|
|
//cellSollPlusVormonat.Text = String.Format("{0:0.00}", zuLeisten);
|
|
|
|
var fls = ((decimal)pRO.TotalFLMBillable) / 60;
|
|
//lblUbertragung.Text = String.Format("{0:0.00}", fls - zuLeisten);
|
|
|
|
|
|
|
|
DateTime dt = DateTime.Now.Date.AddHours(pRO.TotalFLS);
|
|
lblGeleisteteStunden.Text = String.Format("(geleistete Std.: {0} Std. {1:00} Min.)", dt.TimeOfDay.Hours,dt.TimeOfDay.Minutes);
|
|
|
|
|
|
if (pRO.Services != null)
|
|
{
|
|
List<ServicesOverviewRO.ServiceDetail> servicesBillable = new List<ServicesOverviewRO.ServiceDetail>();
|
|
|
|
foreach (var sr in pRO.Services)
|
|
{
|
|
if (sr.IsBillable)
|
|
{
|
|
DateTime dt2 = DateTime.Now.Date.AddMinutes(sr.Minutes);
|
|
|
|
sr.Notice2 = String.Format("{0}:{1:00}", dt2.TimeOfDay.Hours, dt2.TimeOfDay.Minutes);
|
|
|
|
servicesBillable.Add(sr);
|
|
}
|
|
}
|
|
|
|
pRO.Services = servicesBillable;
|
|
}
|
|
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
|
|
|
|
private void BerechneSollIst(ServicesOverviewRO ro)
|
|
{
|
|
if (ro.SupportConceptCostBearer != null && ro.SupportConceptCostBearer.CostBearer2SupportConceptOid != null)
|
|
{
|
|
if (ro.SupportConceptCostBearer.StartDate != null)
|
|
{
|
|
var c2s = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(ro.SupportConceptCostBearer.CostBearer2SupportConceptOid.Value);
|
|
|
|
IList<ServiceRecord> allServiceRecords = c2s.ServiceRecords;
|
|
|
|
decimal flmSoll = 0;
|
|
int daysPassed = 0;
|
|
|
|
var monate = DateTimeUtils.GetTotalMonths(ro.SupportConceptCostBearer.StartDate.Value, ro.EndDate);
|
|
|
|
var calc = PluginLoader.FindClass<Calculations>(c2s.CostBearer.ID) ?? Calculations.GetInstance(c2s.CostBearer.ID);
|
|
|
|
ro.ApprovedFLSPerMonth = GetApprovedHoursPerMonth(calc, ro.SupportConceptCostBearer);
|
|
//cellFLSproJahr.Text = String.Format("{0:0.00}", ro.ApprovedFLSPerMonth * 12);
|
|
|
|
flmSoll = monate.AnzahlMonateGesamt * ro.ApprovedFLSPerMonth;
|
|
|
|
decimal minutenIst = 0;
|
|
|
|
DateTime end = ro.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.Start != null)
|
|
{
|
|
if (item.Start >= ro.SupportConceptCostBearer.StartDate.Value && item.Start.Value < end)
|
|
{
|
|
if (item.ServiceDescription != null && item.ServiceDescription.ServiceCategory != null && item.ServiceDescription.ServiceCategory.IsBillable)
|
|
{
|
|
var prozent = item.ServiceDescription.ServiceCategory.ProzentAbrechnung;
|
|
if (item.ServiceDescription.ProzentAbrechnung.HasValue)
|
|
{
|
|
prozent = item.ServiceDescription.ProzentAbrechnung.Value;
|
|
|
|
}
|
|
|
|
minutenIst += (item.RoundedDuration * prozent) / 100;
|
|
|
|
if (item.GroupOid.HasValue)
|
|
groupBookingDict.Add(item.GroupOid.Value, true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
ro.MinutenGeleistetGesamt = minutenIst;
|
|
ro.MinutenSollGesamt = flmSoll * 60;
|
|
ro.FreeMinutesThisMonth = ro.MinutenSollGesamt - minutenIst;
|
|
|
|
var customer = c2s.SupportConcept.Customer;
|
|
|
|
foreach (var e2c in customer.Employee2CustomerList)
|
|
{
|
|
foreach (var v2o in e2c.ValueList)
|
|
{
|
|
if (v2o.Entry.SystemEntryID.HasValue && v2o.Entry.SystemEntryID.Value == SystemEntryID.EmployeeRoleMainAttendant)
|
|
{
|
|
cellFallFachkraft.Text = e2c.Employee.Person.FirstNameLastName;
|
|
}
|
|
else if (v2o.Entry.Value == "Fachkraft")
|
|
{
|
|
cellFachkraft.Text = e2c.Employee.Person.FirstNameLastName;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private decimal GetApprovedHoursPerMonth(Calculations calc, SupportConceptCostBearerRelDC c2s)
|
|
{
|
|
foreach (var scap in c2s.ApprovalPeriodList)
|
|
{
|
|
if (scap.ServiceCategory != null && (scap.ServiceCategory.Name == "Teilhabeassistenz" || scap.ServiceCategory.Name == "Hauswirtschaft"))
|
|
{
|
|
if (scap.ApprovedBEInterval.HasValue && scap.ApprovedBEPerInterval.HasValue)
|
|
{
|
|
if (scap.ApprovedBEInterval.Value == SupportConceptApprovalInterval.Monthly)
|
|
{
|
|
return scap.ApprovedBEPerInterval.Value;
|
|
}
|
|
else if (scap.ApprovedBEInterval.Value == SupportConceptApprovalInterval.Quarterly)
|
|
{
|
|
return scap.ApprovedBEPerInterval.Value / 3;
|
|
}
|
|
else if (scap.ApprovedBEInterval.Value == SupportConceptApprovalInterval.HalfYearly)
|
|
{
|
|
return scap.ApprovedBEPerInterval.Value / 6;
|
|
}
|
|
else if (scap.ApprovedBEInterval.Value == SupportConceptApprovalInterval.Yearly)
|
|
{
|
|
return scap.ApprovedBEPerInterval.Value / 12;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
var flsProWoche = calc.GetApprovedHoursPerWeek(c2s, c2s.StartDate.Value) ?? 0;
|
|
|
|
return flsProWoche*4.34m;
|
|
}
|
|
}
|
|
}
|