Files
BeWoPlaner/ReportImp/AwoIntegrationsGGmbH/ServiceInvoiceReport.cs

96 lines
3.6 KiB
C#

using System;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using BS.Shared;
using BS.Shared.Extensions;
using DevExpress.XtraReports.UI;
namespace AwoIntegrationsGGmbH
{
public partial class ServiceInvoiceReport : XtraReport, IBeWoReport<ServiceInvoiceRO>
{
public ServiceInvoiceReport()
{
this.InitializeComponent();
}
public void SetReportDataSource(ServiceInvoiceRO pRO)
{
String start = String.Format("{0:M} / {0:yyyy}", pRO.AccountingPeriodStart);
if (pRO.ServiceInvoicePeriods != null && pRO.ServiceInvoicePeriods.Count > 0)
{
//Angaben zur Betreuungsart / Hilfeart
string angabe = "";
var customer = pRO.ServiceInvoicePeriods[0].CostBearer2SupportConcept.SupportConcept.Customer;
var betreuungsarten = customer.ValueList.Where(v2o => v2o.Entry.Type == ValueListEntryType.CustomerCareType).ToList();
if (betreuungsarten != null && betreuungsarten.Count > 0)
{
foreach (var art in betreuungsarten)
{
Match match = Regex.Match(art.Entry.Value, @"\(([^)]*)\)");
if (match.Success)
{
if (angabe != "")
{
angabe += ", ";
}
angabe += match.Groups[1].Value.Trim();
}
}
}
foreach (var sip in pRO.ServiceInvoicePeriods)
{
if (sip.ServiceInvoiceItems != null && sip.ServiceInvoiceItems.Count > 0)
{
foreach (var ii in sip.ServiceInvoiceItems)
{
ii.ServiceDescription = angabe + " " + start + " Familie " + pRO.CustomerLastName;
}
}
}
}
SetzeAdresse(pRO);
this.bindingSource1.DataSource = pRO;
}
private void SetzeAdresse(ServiceInvoiceRO pRO)
{
StringBuilder sb = new StringBuilder();
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation) && pRO.RecipientOrganisation.ToLower() != "selbstzahler")
{
sb.AppendLine(pRO.RecipientOrganisation);
}
//if (!String.IsNullOrEmpty(pRO.RecipientAddressLine1))
//{
// sb.AppendLine(pRO.RecipientAddressLine1);
//}
//if (!String.IsNullOrEmpty(pRO.RecipientContactPerson))
//{
// sb.AppendLine(pRO.RecipientContactPerson);
//}
if (!String.IsNullOrEmpty(pRO.RecipientDivision) && !String.IsNullOrEmpty(pRO.RecipientOrganisation) && pRO.RecipientOrganisation.ToLower() != "selbstzahler")
{
sb.AppendLine(pRO.RecipientDivision);
}
if (!String.IsNullOrEmpty(pRO.RecipientPoBox))
{
sb.AppendLine(pRO.RecipientPoBox);
}
else if (!String.IsNullOrEmpty(pRO.RecipientStreet))
{
sb.AppendLine(pRO.RecipientStreet);
}
if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown))
{
sb.AppendLine(pRO.RecipientPostCodeAndTown);
}
lblAdresse.Text = sb.ToString();
}
}
}