Files
BeWoPlaner/ReportImp/SPZLeverkusen/ServicesOverviewReportJa.cs
2017-09-14 19:08:35 +02:00

82 lines
2.9 KiB
C#

using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.UI;
using BeWo.Report.ReportObjects;
using BeWo.Report;
using System.Collections.Generic;
using BeWo.Service.DCEntityMapper;
using BeWo.Service.Plugins;
using BS.Shared;
using BS.Shared.DataContracts;
using BS.Shared.Services;
namespace SPZLeverkusen
{
public partial class StundenzettelJugendamt : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
{
public StundenzettelJugendamt()
{
InitializeComponent();
}
public void SetReportDataSource(ServicesOverviewRO pRO)
{
if (pRO.Services != null)
{
List<ServicesOverviewRO.ServiceDetail> servicesBillable = new List<ServicesOverviewRO.ServiceDetail>();
foreach (ServicesOverviewRO.ServiceDetail s in pRO.Services)
{
if (s.IsBillable)
servicesBillable.Add(s);
}
pRO.Services = servicesBillable;
}
if (pRO.CostBearer2SupportConceptList != null && pRO.CostBearer2SupportConceptList.Count > 0)
{
var dc = MapperFactory.SupportConceptCostBearerRelDC_CostBearer2SupportConcept.MapToNewDC(pRO
.CostBearer2SupportConceptList[0]);
var calc = PluginLoader.FindClass<Calculations>();
pRO.ApprovedFLSPerMonth = GetApprovedHoursPerMonth(calc, dc);
}
this.bindingSource1.DataSource = pRO;
}
private decimal GetApprovedHoursPerMonth(Calculations calc, SupportConceptCostBearerRelDC c2s)
{
foreach (var scap in c2s.ApprovalPeriodList)
{
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;
}
}
}