127 lines
5.0 KiB
C#
127 lines
5.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BeWo.Service.Plugins;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.Extensions;
|
|
using BS.Shared.Services;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace AWOMuensterlandRecklinghausen
|
|
{
|
|
[IDSpecificClass(Identifier = "SBD2024")]
|
|
public partial class ServiceInvoiceReport : XtraReport, IBeWoReport<ServiceInvoiceRO>
|
|
{
|
|
public ServiceInvoiceReport()
|
|
{
|
|
this.InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServiceInvoiceRO pRO)
|
|
{
|
|
//CreateAbrechnungsItems(pRO);
|
|
SetzeEmpfaengerAdresse(pRO);
|
|
SetzeBetraege(pRO);
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private void SetzeBetraege(ServiceInvoiceRO pRO)
|
|
{
|
|
if (pRO.ServiceInvoicePeriods != null)
|
|
{
|
|
foreach (var sip in pRO.ServiceInvoicePeriods)
|
|
{
|
|
if (sip.SupportConceptApprovalPeriod != null)
|
|
{
|
|
if (sip.SupportConceptApprovalPeriod.ServiceCategory != null)
|
|
{
|
|
if (sip.SupportConceptApprovalPeriod.ServiceCategory.Name.Contains("Interne"))
|
|
{
|
|
if (!sip.SupportConceptApprovalPeriod.Notice.IsNullOrEmpty())
|
|
{
|
|
lblEndtext.Text = sip.SupportConceptApprovalPeriod.Notice + "\n \n" + lblEndtext.Text;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lblserCat.Text = sip.SupportConceptApprovalPeriod.ServiceCategory.Name;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach (var sip in pRO.ServiceInvoicePeriods)
|
|
{
|
|
if (sip.ServiceInvoiceItems.Count > 1)
|
|
{
|
|
sip.ServiceInvoiceItems = sip.ServiceInvoiceItems.OrderBy(b => b.AmountPerUnit).ToList();
|
|
var listLength = sip.ServiceInvoiceItems.Count;
|
|
for (int i = listLength - 1; i >= 1; i--)
|
|
{
|
|
var ii = sip.ServiceInvoiceItems[i];
|
|
var iiNew = sip.ServiceInvoiceItems[i - 1];
|
|
if (ii.AmountPerUnit == iiNew.AmountPerUnit && ii.ServiceDescription == iiNew.ServiceDescription)
|
|
{
|
|
iiNew.UnitCount = ii.UnitCount + iiNew.UnitCount;
|
|
iiNew.Hours = ii.Hours + iiNew.Hours;
|
|
iiNew.NetAmount = ii.NetAmount + iiNew.NetAmount;
|
|
iiNew.GrossAmount = String.Format("{0:c2}", iiNew.NetAmount);
|
|
sip.ServiceInvoiceItems.Remove(ii);
|
|
}
|
|
}
|
|
}
|
|
|
|
else if (sip.ServiceInvoiceItems != null) // Spezialtext im Fall von Sonderbuchung für Rechnungsdifferenz
|
|
{
|
|
foreach (var ii in sip.ServiceInvoiceItems)
|
|
{
|
|
if (!String.IsNullOrEmpty(ii.ServiceDescription) && ii.ServiceDescription.StartsWith("Rechnungsdifferenz")
|
|
&& pRO.InvoiceBase.SupportConceptOid.HasValue)
|
|
{
|
|
if (!pRO.Notice.IsNullOrEmpty())
|
|
{
|
|
lblEndtext.Text = pRO.Notice + "\n \n" + lblEndtext.Text;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void SetzeEmpfaengerAdresse(ServiceInvoiceRO pRO)
|
|
{
|
|
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.RecipientAddressLine1))
|
|
{
|
|
sb.AppendLine(pRO.RecipientAddressLine1);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientStreet))
|
|
{
|
|
sb.AppendLine(pRO.RecipientStreet);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown))
|
|
{
|
|
sb.AppendLine(pRO.RecipientPostCodeAndTown);
|
|
}
|
|
lblAdresse.Text = sb.ToString();
|
|
}
|
|
}
|
|
} |