Files
BeWoPlaner/ReportImp/SKFMMonheim/RechnungBeWo67.cs

97 lines
4.0 KiB
C#

using System;
using System.Linq;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using BS.Shared.Core;
using DevExpress.XtraReports.UI;
namespace SKFMMonheim
{
[IDSpecificClass(Identifier = "BeWo67")]
public partial class RechnungBeWo67 : XtraReport, IBeWoReport<ServiceInvoiceRO>
{
public RechnungBeWo67()
{
this.InitializeComponent();
}
public void SetReportDataSource(ServiceInvoiceRO pRO)
{
DateTime start = pRO.AccountingPeriodStart;
DateTime end = pRO.AccountingPeriodEnd;
decimal hourlyRate = 0;
decimal rateFactor = 1;
decimal hours = 0;
bool differenz = false;
decimal hourlyRateOld = 0;
decimal hoursOld = 0;
if (pRO.ServiceInvoicePeriods != null && pRO.ServiceInvoicePeriods.Count > 0)
{
foreach (var p in pRO.ServiceInvoicePeriods)
{
if (p.ServiceInvoiceItems != null && p.ServiceInvoiceItems.Count > 0)
{
if (p.ServiceInvoiceItems.Any(i => i.NetAmount < 0))
{
differenz = true;
}
foreach (var i in p.ServiceInvoiceItems)
{
if (differenz && i.NetAmount < 0)
{
if (i.HourlyRate.HasValue)
{
hourlyRateOld = i.HourlyRate.Value;
}
if (i.Hours.HasValue)
{
hoursOld += i.Hours.Value;
}
}
else
{
if (i.HourlyRate.HasValue)
{
hourlyRate = i.HourlyRate.Value;
if (!String.IsNullOrEmpty(i.RateFactor))
{
var rfStr = i.RateFactor.Replace("%", "").Replace(",00", "").Trim();
int rfInt = 0;
Int32.TryParse(rfStr, out rfInt);
rateFactor = (100m + rfInt) / 100m;
}
}
if (i.Hours.HasValue)
{
hours += i.Hours.Value;
}
}
}
}
}
}
if (differenz)
{
lblForderung.Text =
String.Format("Aktuell ergibt sich eine Forderung von {0:0.00} Std. x {1:0.00} EUR = {2:0.00} EUR.", hours, hourlyRate, hours * hourlyRate);
lblForderung.Text += String.Format("\nAbzüglich der bereits abgerechneten {0:0.00} Std. x {1:0.00} EUR = {2:0.00} EUR.", hoursOld, hourlyRateOld, hoursOld * hourlyRateOld);
lblForderung.Text += String.Format("\nHieraus ergibt sich eine Forderung von {0:0.00} EUR.", pRO.NetClaim);
}
else
{
lblForderung.Text =
String.Format("Hieraus ergibt sich eine Forderung von {0:0.00} Std. x {1:0.00} EUR = {2:0.00} EUR.", hours, hourlyRate, pRO.NetClaim);
}
lblAbrechnungszeitraum.Text =
String.Format(
"Im Zeitraum vom {0:dd.MM.yyyy} bis {1:dd.MM.yyyy} wurden {2:0.00} Dienstleistungsstunden unmittelbare Betreuungsleistungen des Betreuten Wohnens erbracht.",
pRO.AccountingPeriodStart, pRO.AccountingPeriodEnd, hours);
this.bindingSource1.DataSource = pRO;
}
}
}