Files
BeWoPlaner/ReportImp/GpzBiberachReports/ServiceInvoiceReportSoziotherapie.cs

160 lines
5.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using BS.Shared.Core;
using DevExpress.XtraReports.UI;
namespace BeWo.GpzBiberachReports
{
[IDSpecificClass(Identifier = "Soziotherapie")]
public partial class RechnungSoziotherapie : XtraReport, IBeWoReport<ServiceInvoiceRO>
{
public RechnungSoziotherapie()
{
this.InitializeComponent();
}
public void SetReportDataSource(ServiceInvoiceRO pRO)
{
//if (String.IsNullOrWhiteSpace(pRO.RecipientOrganisation) ||
// !pRO.RecipientOrganisation.ToLower().Contains("landratsamt biberach"))
//{
// this.Watermark.Image = null;
//}
StringBuilder sb = new StringBuilder();
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation) && !String.IsNullOrEmpty(pRO.RecipientOrganisation.Trim()))
{
sb.AppendLine(pRO.RecipientOrganisation);
}
if (!String.IsNullOrEmpty(pRO.RecipientContactPerson) && !String.IsNullOrEmpty(pRO.RecipientContactPerson.Trim()))
{
sb.AppendLine(pRO.RecipientContactPerson);
}
if (!String.IsNullOrEmpty(pRO.RecipientDivision) && !String.IsNullOrEmpty(pRO.RecipientDivision.Trim()))
{
sb.AppendLine(pRO.RecipientDivision);
}
if (!String.IsNullOrEmpty(pRO.RecipientStreet) && !String.IsNullOrEmpty(pRO.RecipientStreet.Trim()))
{
sb.AppendLine(pRO.RecipientStreet);
}
if (!String.IsNullOrEmpty(pRO.RecipientPoBox) && !String.IsNullOrEmpty(pRO.RecipientPoBox.Trim()))
{
sb.AppendLine(pRO.RecipientPoBox);
}
if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown) && !String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown.Trim()))
{
sb.AppendLine("");
sb.AppendLine(pRO.RecipientPostCodeAndTown);
}
lblAddress.Text = sb.ToString();
decimal minutesGespraeche = 0;
decimal minutesGruppe = 0;
decimal hausbesuchBetrag = 0;
decimal betragGespraeche = 0;
decimal betragGruppe = 0;
//pRO.InvoiceNumber = String.Format("8200-{0:yyyy}-{1}", pRO.InvoiceDateTime, pRO.InvoiceNumber);
pRO.InvoiceNumber = String.Format("8235-{0}", pRO.InvoiceNumber);
if (pRO.ServiceInvoicePeriods != null && pRO.ServiceInvoicePeriods.Count > 0)
{
foreach (var p in pRO.ServiceInvoicePeriods)
{
if (p.ServiceInvoiceItems != null && p.ServiceInvoiceItems.Count > 0)
{
List<ServiceInvoiceItemRO> hausbesuche = new List<ServiceInvoiceItemRO>();
ServiceInvoiceItemRO grundpauschale = null;
foreach (var i in p.ServiceInvoiceItems)
{
if (!String.IsNullOrEmpty(i.ServiceDescription))
{
//Nur bei ST Hausbesuch unten addieren
//Warum "Hausbesuchspauschale" bei Herrn Bösch
if (i.ServiceDescription.ToLower().IndexOf("hausbesuchspauschale") >= 0)
{
hausbesuche.Add(i);
}
else if (i.ServiceDescription.ToLower().IndexOf("grundpauschale") >= 0)
{
grundpauschale = i;
}
else if (i.ServiceDescription.ToLower().IndexOf("gruppe") >= 0)
{
i.Hours = i.Hours * 60;
//if (i.ServiceDescription.ToLower().IndexOf("ET") >= 0)
//{
minutesGruppe += i.Hours ?? 0;
betragGruppe += i.NetAmount ?? 0;
}
else
{
i.Hours = i.Hours * 60;
//if (i.ServiceDescription.ToLower().IndexOf("ET") >= 0)
//{
minutesGespraeche += i.Hours ?? 0;
betragGespraeche += i.NetAmount ?? 0;
//}
}
}
}
decimal hausbesuchTotal = 0;
foreach (var hausbesuchItem in hausbesuche)
{
p.ServiceInvoiceItems.Remove(hausbesuchItem);
if (!String.IsNullOrEmpty(cellHausbesuche.Text))
cellHausbesuche.Text += ", ";
cellHausbesuche.Text = String.Format("{0:0} á {1:0.00}", hausbesuchItem.UnitCount, hausbesuchItem.AmountPerUnit);
if (hausbesuchItem.NetAmount.HasValue)
hausbesuchTotal += hausbesuchItem.NetAmount.Value;
}
if (hausbesuchTotal > 0)
{
cellHausbesucheBetrag.Text = String.Format("{0:c}", hausbesuchTotal);
}
if (grundpauschale != null)
{
p.ServiceInvoiceItems.Remove(grundpauschale);
cellGrundpauschaleBetrag.Text = grundpauschale.GrossAmount;
}
cellGespraecheGesamt.Text = String.Format("{0:0} Minuten", minutesGespraeche);
cellGruppeGesamt.Text = String.Format("{0:0} Minuten", minutesGruppe);
cellGespraecheBetrag.Text = String.Format("{0:c}", betragGespraeche);
cellGruppeBetrag.Text = String.Format("{0:c}", betragGruppe);
}
}
}
cellBetrag.Text = pRO.GrossClaim;
this.bindingSource1.DataSource = pRO;
}
private void PageFooter_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = PrintingSystem.PageCount > 0;
}
}
}