Files
BeWoPlaner/ReportImp/BfpDus/ServiceInvoiceReport.cs

141 lines
4.9 KiB
C#

using System;
using System.Text;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using DevExpress.XtraReports.UI;
namespace BfpDus
{
public partial class ServiceInvoiceReport : XtraReport, IBeWoReport<ServiceInvoiceRO>
{
private ServiceInvoiceRO ro;
public ServiceInvoiceReport()
{
this.InitializeComponent();
}
public ServiceInvoiceRO ServiceInvoiceRo
{
get { return ro; }
}
public void SetReportDataSource(ServiceInvoiceRO pRO)
{
ro = pRO;
DateTime start = pRO.AccountingPeriodStart;
DateTime end = pRO.AccountingPeriodEnd;
if (pRO.InvoiceBase != null && pRO.InvoiceBase.SupportConceptCostBearerRelDc != null)
{
if (pRO.InvoiceBase.SupportConceptCostBearerRelDc.StartDate.HasValue)
{
start = pRO.InvoiceBase.SupportConceptCostBearerRelDc.StartDate.Value;
}
if (pRO.InvoiceBase.SupportConceptCostBearerRelDc.EndDate.HasValue)
{
end = pRO.InvoiceBase.SupportConceptCostBearerRelDc.EndDate.Value;
}
}
if (pRO.RecipientOrganisation == "Privat")
{
pRO.RecipientOrganisation = "";
if (pRO.InvoiceBase != null)
{
var cOid = pRO.InvoiceBase?.RecipientCustomerOid;
if (cOid.HasValue)
{
var c = DAOFactory.GenericDAO.LoadByID<Customer>(cOid.Value);
if (c.Person.Sex.HasValue)
{
if (c.Person.Sex.Value == BS.Shared.Sex.Male)
{
pRO.RecipientOrganisation = "Herr";
}
else if (c.Person.Sex.Value == BS.Shared.Sex.Female)
{
pRO.RecipientOrganisation = "Frau";
}
}
}
}
}
StringBuilder sb = new StringBuilder();
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation))
{
sb.AppendLine(pRO.RecipientOrganisation);
}
if (!String.IsNullOrEmpty(pRO.RecipientDivision))
{
sb.AppendLine(pRO.RecipientDivision);
}
if (!String.IsNullOrEmpty(pRO.RecipientContactPerson))
{
sb.AppendLine(pRO.RecipientContactPerson);
}
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("");
sb.AppendLine(pRO.RecipientPostCodeAndTown);
}
lblAnschrift.Text = sb.ToString();
foreach (var sip in pRO.ServiceInvoicePeriods)
{
int index = 1;
foreach (var item in sip.ServiceInvoiceItems)
{
if (item.ServiceDescription.Contains("Fehl"))
{
item.UnitDescription = item.ServiceDescription;
}
else
{
item.UnitDescription = "Stunden";
}
if (index++ == 1)
{
item.ServiceDescription = String.Format("Monat {0:yyyy.MM}", pRO.AccountingPeriodStart);
}
else
{
item.ServiceDescription = "";
}
item.Notice = "";
if (!String.IsNullOrEmpty(item.RateFactor))
{
if (Decimal.TryParse(item.RateFactor.Replace("%", ""), out var d))
{
item.Notice = String.Format("x Faktor {0:0.0#}", (100 + d) / 100);
}
}
}
}
//if (start.Month == end.Month && start.Year == end.Year)
//{
// lblAbrechnungszeitraum.Text = String.Format("hiermit berechnen wir für den Monat {0:MMMM yyyy} folgende erbrachte Tätigkeiten:", start);
//}
//else
//{
lblAbrechnungszeitraum.Text = String.Format("Zeitraum von {0:MMMM yyyy} bis {1:MMMM yyyy} folgende erbrachte Tätigkeiten:", start, end);
//}
this.bindingSource1.DataSource = pRO;
}
}
}