Files
BeWoPlaner/ReportImp/TeamPfeil/ServiceInvoiceReport.cs

112 lines
3.9 KiB
C#

using System;
using System.Text;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using DevExpress.XtraReports.UI;
namespace TeamPfeil
{
public partial class ServiceInvoiceReport : XtraReport, IBeWoReport<ServiceInvoiceRO>
{
public ServiceInvoiceReport()
{
this.InitializeComponent();
}
public void SetReportDataSource(ServiceInvoiceRO pRO)
{
StringBuilder sb = new StringBuilder();
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation))
{
sb.AppendLine(pRO.RecipientOrganisation);
}
if (!String.IsNullOrEmpty(pRO.RecipientContactPerson))
{
sb.AppendLine(pRO.RecipientContactPerson);
}
if (!String.IsNullOrEmpty(pRO.RecipientDivision))
{
sb.AppendLine(pRO.RecipientDivision);
}
if (!String.IsNullOrEmpty(pRO.RecipientStreet))
{
sb.AppendLine(pRO.RecipientStreet);
}
if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown))
{
sb.AppendLine(pRO.RecipientPostCodeAndTown);
}
lblAdresse.Text = sb.ToString();
DateTime start = pRO.AccountingPeriodStart;
DateTime end = pRO.AccountingPeriodEnd;
if (start.Month == end.Month && start.Year == end.Year)
{
Label_InvoiceMonth.Text = String.Format("{0:MMMM yyyy}", start);
}
else
{
Label_InvoiceMonth.Text = String.Format("{0:MMMM yyyy} - {1:MMMM yyyy}", start, end);
}
if (pRO.CustomerSalutation == "Herr")
{
pRO.CustomerSalutation = "Herrn";
}
if (pRO.OrganisationDebitorNumber != null && pRO.OrganisationDebitorNumber.StartsWith("ZE-Nummer"))
{
lblZeNummer.Text = pRO.OrganisationDebitorNumber;
}
pRO.NotBillableNote = "";
decimal hours = 0;
decimal rate = 0;
decimal amount = 0;
if (pRO.ServiceInvoicePeriods != null)
{
foreach (var sip in pRO.ServiceInvoicePeriods)
{
if (sip.ServiceInvoiceItems != null)
{
//pRO.NetClaim = string.Format("{0:0.00}", sip.ServiceInvoiceItems[0].HourlyRate);
foreach (var ii in sip.ServiceInvoiceItems)
{
hours += (decimal)ii.Hours;
if (pRO.NotBillableNote.Length > 0)
{
pRO.NotBillableNote += "\n \t \t \t ";
}
pRO.NotBillableNote += string.Format("{0:0.##} h x {1:0.00} € {2} = {3:c}", ii.Hours, ii.HourlyRate, ii.ServiceDescription, ii.NetAmount);
}
}
}
}
pRO.CreatorDivision = string.Format("{0:0.00}", hours);
//if (pRO.ServiceInvoicePeriods != null)
//{
// foreach (var sip in pRO.ServiceInvoicePeriods)
// {
// if (sip.ServiceInvoiceItems != null)
// {
// foreach (var ii in sip.ServiceInvoiceItems)
// {
// hours += (decimal)ii.Hours;
// rate = ii.HourlyRate.Value;
// amount += ii.NetAmount.Value;
// }
// }
// }
// pRO.CreatorDivision = String.Format("{0:0.##}", hours);
// pRO.NotBillableNote += String.Format("{0:n2}", amount);
//}
this.bindingSource1.DataSource = pRO;
}
}
}