Files
BeWoPlaner/ReportImp/FreundeskreisSuchthilfe/ServiceInvoiceReport.cs
Christian dbe7021361 CB
2019-08-19 11:59:38 +02:00

124 lines
4.6 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 FreundeskreisSuchthilfe
{
public partial class ServiceInvoiceReport : XtraReport, IBeWoReport<ServiceInvoiceRO>
{
public ServiceInvoiceReport()
{
this.InitializeComponent();
}
public void SetReportDataSource(ServiceInvoiceRO pRO)
{
DateTime start = pRO.AccountingPeriodStart;
DateTime end = pRO.AccountingPeriodEnd;
if (start.Month == end.Month && start.Year == end.Year)
{
lblMonat.Text = String.Format("für den Monat {0:MMMM yyyy} berechnen wir Ihnen wie folgt:", start);
}
else
{
lblMonat.Text = String.Format("für den Zeitraum {0:MMMM yyyy} - {1:MMMM yyyy} berechnen wir Ihnen wie folgt:", start, end);
}
StringBuilder sb = new StringBuilder();
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.RecipientContactPerson) && !String.IsNullOrEmpty(pRO.RecipientContactPerson.Trim()))
{
sb.AppendLine(pRO.RecipientContactPerson);
}
if (!String.IsNullOrEmpty(pRO.RecipientStreet) && !String.IsNullOrEmpty(pRO.RecipientStreet.Trim()))
{
sb.AppendLine(pRO.RecipientStreet);
}
if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown) && !String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown.Trim()))
{
sb.AppendLine("");
sb.Append(pRO.RecipientPostCodeAndTown);
}
lblAddress.Text = sb.ToString();
if (pRO.ServiceInvoicePeriods != null)
{
foreach (var sip in pRO.ServiceInvoicePeriods)
{
if (sip.ServiceInvoiceItems != null)
{
foreach (var ii in sip.ServiceInvoiceItems)
{
if (ii.AccountingPeriodStart.Value.Month == ii.AccountingPeriodEnd.Value.Month && ii.AccountingPeriodStart.Value.Year == ii.AccountingPeriodEnd.Value.Year)
{
ii.Duration = String.Format("{0:MM}/{0:yyyy}", start);
}
ii.HourlyRateString = "";
if (ii.Hours.HasValue)
{
ii.HourlyRateString = String.Format("{0:0.##}", ii.Hours);
if (!String.IsNullOrEmpty(ii.RateFactor))
{
var rfStr = ii.RateFactor.Replace("%", "").Replace(",00", "").Trim();
int rfInt = 0;
Int32.TryParse(rfStr, out rfInt);
decimal rateFactor = (100m + rfInt) / 100m;
if (rateFactor > 1)
{
ii.HourlyRateString += String.Format(" x {0:0.##}", rateFactor);
}
}
}
}
}
}
}
String datum = "";
if (pRO.InvoiceDateTime.HasValue)
{
datum = String.Format("{0:dd.MM.yyyy}", pRO.InvoiceDateTime.Value.AddDays(14));
}
lblZahlungsziel.Text = lblZahlungsziel.Text.Replace("{Datum}", datum);
//lblBewilligungVom.Text = String.Format("Bewilligung vom: {0:dd.MM.yyyy}", GetBewilligungsDatum(pRO));
this.bindingSource1.DataSource = pRO;
}
private DateTime? GetBewilligungsDatum(ServiceInvoiceRO pRo)
{
if (pRo.InvoiceBase != null && pRo.InvoiceBase.SupportConceptCostBearerRelDc != null)
{
var sc = DAOFactory.GenericDAO.LoadByID<SupportConcept>(pRo.InvoiceBase.SupportConceptCostBearerRelDc
.SupportConcept.SupportConceptOid);
return sc.ApprovalDate;
}
return null;
}
}
}