Files
BeWoPlaner/ReportImp/AutismusKoelnBonn/RechnungFaktor.cs

139 lines
5.4 KiB
C#

using System;
using System.Text;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using BS.Shared.Core;
using DevExpress.XtraReports.UI;
namespace AutismusKoelnBonn
{
[IDSpecificClass(Identifier = "Faktor")]
public partial class ServiceInvoiceReportFactor : XtraReport, IBeWoReport<ServiceInvoiceRO>
{
public ServiceInvoiceReportFactor()
{
this.InitializeComponent();
}
public void SetReportDataSource(ServiceInvoiceRO pRO)
{
// Die haben verschiedene Standorte/Schwerpunkte und das über Teams abgebildet -> eine Vorlage verschiedene "Absender" je nach Team
// jeder Klient ist derzeit wirklich nur in einem Team
DateTime start = pRO.AccountingPeriodStart;
DateTime end = pRO.AccountingPeriodEnd;
string poBox = null;
if (pRO.InvoiceBase.RecipientContactInformations.Count > 0)
{
foreach (var i in pRO.InvoiceBase.RecipientContactInformations)
{
if (i.ContactType == BS.Shared.ContactType.private_POBox)
poBox = i.ContactValue;
}
}
StringBuilder sb = new StringBuilder();
//if (!String.IsNullOrEmpty(pRO.RecipientAddressLine1) && !String.IsNullOrEmpty(pRO.RecipientAddressLine1.Trim())))
//{
// sb.AppendLine(pRO.RecipientAddressLine1);
//}
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation) && !String.IsNullOrEmpty(pRO.RecipientOrganisation.Trim()))
{
sb.AppendLine(pRO.RecipientOrganisation);
}
if (!String.IsNullOrEmpty(pRO.RecipientDivision) && !String.IsNullOrEmpty(pRO.RecipientDivision.Trim()))
{
sb.AppendLine(pRO.RecipientDivision);
}
if (!String.IsNullOrEmpty(pRO.RecipientAddressLine1) && !String.IsNullOrEmpty(pRO.RecipientAddressLine1.Trim()))
{
sb.AppendLine(pRO.RecipientAddressLine1);
}
if (!String.IsNullOrEmpty(pRO.RecipientContactPerson) && !String.IsNullOrEmpty(pRO.RecipientContactPerson.Trim()))
{
sb.AppendLine(pRO.RecipientContactPerson);
}
if (!String.IsNullOrEmpty(poBox))
{
sb.AppendLine(poBox);
}
//else 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();
string team = "MoveAut Team Köln";
Customer c;
if (pRO.ServiceInvoicePeriods.Count > 0 && pRO.ServiceInvoicePeriods[0].Customer.Oid.HasValue)
{
c = DAOFactory.GenericDAO.LoadByID<Customer>(pRO.ServiceInvoicePeriods[0].Customer.Oid ?? 0);
if (c.Team2CustomerList.Count > 0)
team = c.Team2CustomerList[0].Team.Name;
}
if (team.Contains("BeWo Bonn"))
{
lblAbsenderBonn.Visible = true;
lblTeamBonn.Visible = true;
lblAbsenderKoeln.Visible = false;
lblHeaderKoeln.Visible = false;
lblTeamKoeln.Visible = false;
}
else if (team.Contains("HZE Bonn"))
{
lblAbsenderBonn.Visible = true;
lblTeamBonn.Visible = false;
lblBonnHZE.Visible = true;
lblAbsenderKoeln.Visible = false;
lblHeaderKoeln.Visible = false;
lblTeamKoeln.Visible = false;
}
else if (team.Contains("HZE Köln"))
{
lblTeamKoelnHZE.Visible = true;
lblHeaderKoelnHZE.Visible = true;
lblHeaderKoeln.Visible = false;
lblTeamKoeln.Visible = false;
}
foreach (var sip in pRO.ServiceInvoicePeriods)
{
foreach (var ii in sip.ServiceInvoiceItems)
{
ii.Notice = "";
ii.UnitCountString = "";
double hours = (double)Convert.ToDecimal(ii.Hours ?? 1);
if (ii.ServiceDescription != "Fallpauschale" && ii.ServiceDescription != "Fehlkontakt")
{
ii.ServiceDescription = "Fachleistungsstunden";
if (ii.Hours != null && ii.Hours != 0)
{
var hoursMitFaktor = ii.Hours.Value;
ii.Hours = ii.Hours / 1.2m;
ii.Notice = String.Format("{0:0.00}", hoursMitFaktor - ii.Hours);
ii.UnitCountString = String.Format("{0:0.00}", hoursMitFaktor);
}
}
else
{
ii.UnitCountString = String.Format("{0:0.00}", hours);
}
}
}
this.bindingSource1.DataSource = pRO;
}
}
}