Files
BeWoPlaner/ReportImp/FeidPartnerReports/CollectiveBillingReportTab.cs

70 lines
2.9 KiB
C#

using BeWo.Report;
using BeWo.Report.ReportObjects;
using DevExpress.XtraReports.UI;
using BS.Shared.Core;
using System;
namespace FeidPartnerReports
{
[IDSpecificClass(Identifier = "Sammelrechnung")]
public partial class SammelrechnungTab : XtraReport, IBeWoReport<ServiceInvoiceRO>
{
public SammelrechnungTab()
{
this.InitializeComponent();
}
public void SetReportDataSource(ServiceInvoiceRO pRO)
{
if (pRO.RecipientOrganisation.Contains("67"))
{
lblAnzahl.Text = "Monat";
lblEPreis.Text = "Monat";
}
pRO.ServiceInvoicePeriods.Sort((a, b) => a.Customer.LastNameFirstName.CompareTo(b.Customer.LastNameFirstName));
foreach (var sip in pRO.ServiceInvoicePeriods)
{
sip.Customer.LastName = sip.Customer.LastName + ", " + sip.Customer.FirstName;
if (sip.Notice != null)
{
if (sip.ServiceInvoiceItems.Count > 0)
sip.NotBillableString = sip.ServiceInvoiceItems[0].UnitDescription;
}
if (sip.SupportConceptApprovalPeriod.ServiceCategory == null || sip.SupportConceptApprovalPeriod.ServiceCategory != null && sip.SupportConceptApprovalPeriod.ServiceCategory.Name.Contains("Monat"))
sip.ApprovedHours = 1;
else
{
DateTime end = sip.SupportConceptApprovalPeriod.EndDate ?? pRO.AccountingPeriodEnd;
DateTime start = sip.SupportConceptApprovalPeriod.StartDate ?? pRO.AccountingPeriodStart;
sip.ApprovedHours = (decimal)(end - start).TotalDays;
}
if (sip.CostBearer2SupportConcept.CustomerReferenceNumber == null)
sip.CostBearer2SupportConcept.CustomerReferenceNumber = "LVG";
}
pRO.ServiceInvoicePeriods.Sort((a, b) => a.Customer.LastNameFirstName.CompareTo(b.Customer.LastNameFirstName));
var count = pRO.ServiceInvoicePeriods.Count;
var pos = 1;
for (int i = 0; i < count; i++)
{
var sip = pRO.ServiceInvoicePeriods[i];
if (sip.ServiceInvoiceItems.Count > 0)
{
foreach (var ii in sip.ServiceInvoiceItems)
{
ii.CustomerFirstname = pos++.ToString();
if(ii.Notice == null && sip.SupportConceptApprovalPeriod != null && sip.SupportConceptApprovalPeriod.ApprovedBEPerInterval.HasValue)
{
ii.Notice = String.Format("{0:n0}", sip.SupportConceptApprovalPeriod.ApprovedBEPerInterval.Value);
}
}
}
}
this.bindingSource1.DataSource = pRO;
}
}
}