80 lines
2.9 KiB
C#
80 lines
2.9 KiB
C#
using System;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BeWo.Service.Plugins;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.Services;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace PsychosozialeProjekteSaarpfalz
|
|
{
|
|
[IDSpecificClass(Identifier = "Sozio")]
|
|
|
|
public partial class ServiceInvoiceReport : XtraReport, IBeWoReport<ServiceInvoiceRO>
|
|
{
|
|
public ServiceInvoiceReport()
|
|
{
|
|
this.InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServiceInvoiceRO pRO)
|
|
{
|
|
DateTime start = pRO.AccountingPeriodStart;
|
|
DateTime end = pRO.AccountingPeriodEnd;
|
|
|
|
SetBewilligung(pRO);
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private void SetBewilligung(ServiceInvoiceRO pRO)
|
|
{
|
|
DateTime? date = null;
|
|
|
|
decimal geleistetGesamt = 0;
|
|
decimal bewilligtWoche = 0;
|
|
decimal bewilligtGesamt = 0;
|
|
var calc = PluginLoader.FindClass<Calculations>();
|
|
|
|
DateTime start = pRO.AccountingPeriodStart;
|
|
DateTime end = pRO.AccountingPeriodEnd;
|
|
|
|
foreach (var sip in pRO.ServiceInvoicePeriods)
|
|
{
|
|
if (sip.SupportConceptApprovalPeriod != null && sip.CostBearer2SupportConcept != null)
|
|
{
|
|
if (sip.SupportConceptApprovalPeriod.StartDate.HasValue &&
|
|
sip.SupportConceptApprovalPeriod.StartDate < start)
|
|
{
|
|
start = sip.SupportConceptApprovalPeriod.StartDate.Value;
|
|
}
|
|
if (sip.SupportConceptApprovalPeriod.EndDate.HasValue &&
|
|
sip.SupportConceptApprovalPeriod.EndDate > end)
|
|
{
|
|
end = sip.SupportConceptApprovalPeriod.EndDate.Value;
|
|
}
|
|
|
|
var scapdc = MapperFactory.SupportConceptApprovalPeriodDC_SupportConceptApprovalPeriod.MapToNewDC(sip.SupportConceptApprovalPeriod);
|
|
var c2sdc =
|
|
MapperFactory.SupportConceptCostBearerRelDC_CostBearer2SupportConcept.MapToNewDC(
|
|
sip.CostBearer2SupportConcept);
|
|
|
|
bewilligtGesamt += calc.GetApprovedHoursTotal(scapdc, c2sdc.CostBearer.CostRatePeriods) ?? 0;
|
|
bewilligtWoche += calc.GetApprovedHoursPerWeek(scapdc, c2sdc.CostBearer.CostRatePeriods) ?? 0;
|
|
|
|
var sc = sip.SupportConceptApprovalPeriod.CostBearer2SupportConcept.SupportConcept;
|
|
|
|
date = sc.ApprovalDate;
|
|
}
|
|
|
|
foreach (var ii in sip.ServiceInvoiceItems)
|
|
{
|
|
geleistetGesamt += ii.Hours ?? 0;
|
|
}
|
|
}
|
|
|
|
pRO.ApprovedBESum = String.Format("{0:0.##}", bewilligtGesamt-geleistetGesamt);
|
|
}
|
|
}
|
|
} |