Files
BeWoPlaner/ReportImp/ProBalance/Sammelrechnung.cs
2020-02-06 18:43:11 +01:00

87 lines
3.1 KiB
C#

using System;
using System.Collections.Generic;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using BS.Shared.DataContracts;
namespace ProBalance
{
public partial class Sammelrechnung : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServiceInvoiceRO>
{
public Sammelrechnung()
{
InitializeComponent();
}
public void SetReportDataSource(ServiceInvoiceRO pRO)
{
decimal geleistetGesamt = 0;
if (pRO.ServiceInvoicePeriods != null)
{
foreach (var sip in pRO.ServiceInvoicePeriods)
{
if (sip.ServiceInvoiceItems != null)
{
foreach (var ii in sip.ServiceInvoiceItems)
{
ii.UnitDescription = String.Format("{0:dd.MM.yyyy} - {1:dd.MM.yyyy}", ii.AccountingPeriodStart, ii.AccountingPeriodEnd);
ii.ServiceDescription = String.Format("{0:0.##} FLS {1}x {2:c}",
ii.UnitCount, String.IsNullOrEmpty(ii.RateFactor) ? "" : "x " + ii.RateFactor + " ",
ii.AmountPerUnit);
geleistetGesamt += ii.UnitCount ?? 0;
}
}
}
}
SetzeGesamtBewilligung(pRO);
cellGeleistetGesamt.Text = String.Format("{0:0.00}", geleistetGesamt);
this.bindingSource1.DataSource = pRO;
}
private void SetzeGesamtBewilligung(ServiceInvoiceRO pRo)
{
decimal bewilligtGesamt = 0;
if (pRo.InvoiceBase != null && pRo.InvoiceBase.SupportConceptCostBearerRelDc != null)
{
var start = pRo.InvoiceBase.SupportConceptCostBearerRelDc.StartDate;
var end = pRo.InvoiceBase.SupportConceptCostBearerRelDc.EndDate;
cellGesamtBewilligungszeitraum.Text =
String.Format("Bewilligte Fachleistungsstunden vom {0:dd.MM.yyyy} bis {1:dd.MM.yyyy}:", start, end);
foreach (var scap in pRo.InvoiceBase.SupportConceptCostBearerRelDc.ApprovalPeriodList)
{
if (scap.StartDate <= pRo.AccountingPeriodEnd && scap.EndDate >= pRo.AccountingPeriodStart)
{
if (scap.ApprovedFixedAmount.HasValue)
{
bewilligtGesamt = scap.ApprovedFixedAmount.Value;
}
else
{
var calc = BS.Shared.Services.Calculations.GetInstance("");
bewilligtGesamt = calc.GetApprovedHoursTotal(scap,
pRo.InvoiceBase.SupportConceptCostBearerRelDc.CostBearer
.CostRatePeriods) ?? 0;
}
}
}
}
cellGesamtFLSBewilligt.Text = String.Format("{0:0.00}", bewilligtGesamt);
}
}
}