145 lines
6.3 KiB
C#
145 lines
6.3 KiB
C#
using BeWo.Report.ReportObjects;
|
|
using DevExpress.XtraReports.UI;
|
|
using BS.Shared.Core;
|
|
using BeWo.Report;
|
|
using System;
|
|
using System.Text;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Data.Access;
|
|
|
|
namespace Wabe
|
|
{
|
|
[IDSpecificClass(Identifier = "RgBezirk")]
|
|
public partial class SammelrechnungBezirkDetail : XtraReport, IBeWoReport<ServiceInvoiceRO>
|
|
{
|
|
public SammelrechnungBezirkDetail()
|
|
{
|
|
this.InitializeComponent();
|
|
}
|
|
|
|
private static int GetQuarter(DateTime actualDate)
|
|
{
|
|
int quarter = (int)Math.Ceiling(actualDate.Month / (double)3);
|
|
return quarter;
|
|
}
|
|
|
|
public void SetReportDataSource(ServiceInvoiceRO pRO)
|
|
{
|
|
var newSip = new ServiceInvoicePeriodRO();
|
|
decimal? sumCustomerMonth = 0;
|
|
string prevMonth = null;
|
|
var counter = 0;
|
|
string grund = null;
|
|
string gz = "ZE Nr. 70033 ";
|
|
bool Mittelfranken2026 = false;
|
|
if (pRO.RecipientOrganisation != null && pRO.RecipientOrganisation.Contains("Bezirk Mittelfranken")
|
|
&& pRO.AccountingPeriodStart > new DateTime(2025,12,31))
|
|
{
|
|
Mittelfranken2026 = true;
|
|
gz = "Rang.Nr. 40447 ";
|
|
cellHeader.Text += "\nAbwesenheiten";
|
|
}
|
|
|
|
if (pRO.ServiceInvoicePeriods != null)
|
|
{
|
|
foreach (var sip in pRO.ServiceInvoicePeriods)
|
|
{
|
|
prevMonth = null;
|
|
if (sip.CostBearer2SupportConcept.SupportConcept.Customer.TerminationDate.HasValue
|
|
&& sip.CostBearer2SupportConcept.SupportConcept.Customer.TerminationDate > pRO.AccountingPeriodStart
|
|
&& sip.CostBearer2SupportConcept.SupportConcept.Customer.TerminationDate < pRO.AccountingPeriodEnd)
|
|
{
|
|
if (sip.CostBearer2SupportConcept.SupportConcept.Customer.TerminationReason != null)
|
|
{
|
|
grund = sip.CostBearer2SupportConcept.SupportConcept.Customer.TerminationReason.Value;
|
|
}
|
|
}
|
|
counter += 1;
|
|
if (sip.ServiceInvoiceItems != null)
|
|
{
|
|
foreach (var sii in sip.ServiceInvoiceItems)
|
|
{
|
|
sii.CustomerLastname = "";
|
|
if (prevMonth == null)
|
|
{
|
|
sumCustomerMonth = sii.NetAmount;
|
|
sii.NetAmount = null;
|
|
sii.CustomerLastname = String.Format("geb. {0:dd.MM.yyyy} \nAktenzeichen {1} \n {2}\nAufnahmedatum: {3:dd.MM.yyyy}",
|
|
sii.CustomerBirthdate, sip.CostBearer2SupportConcept.CustomerReferenceNumber, gz, sip.Customer.AssistanceBegin);
|
|
|
|
if (sip.Customer.TerminationDate.HasValue)
|
|
{
|
|
sii.CustomerLastname += String.Format("\nEntlassungsdatum: {0:dd.MM.yyyy}", sip.Customer.TerminationDate);
|
|
}
|
|
if (Mittelfranken2026)
|
|
{
|
|
var abwesend = GetAbwesenheiten(sip, pRO.AccountingPeriodStart, pRO.AccountingPeriodEnd);
|
|
if (abwesend != null && abwesend.Length > 0)
|
|
{
|
|
sii.CustomerLastname += "\n" + abwesend;
|
|
}
|
|
}
|
|
}
|
|
else if (sii.Notice == prevMonth)
|
|
{
|
|
sumCustomerMonth += sii.NetAmount;
|
|
sii.NetAmount = sumCustomerMonth;
|
|
}
|
|
else if (sii.Notice != prevMonth)
|
|
{
|
|
sumCustomerMonth = sii.NetAmount;
|
|
sii.NetAmount = null;
|
|
}
|
|
prevMonth = sii.Notice;
|
|
sii.RateFactor = counter.ToString();
|
|
if (grund != null)
|
|
{
|
|
sii.ServiceDescription += grund;
|
|
grund = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
lblQuartal.Text = GetQuarter(pRO.AccountingPeriodEnd).ToString() + ". Quartal " + pRO.AccountingPeriodEnd.Year.ToString();
|
|
lblMonate.Text = pRO.AccountingPeriodStart.ToString("MMMM") + " - " + pRO.AccountingPeriodEnd.ToString("MMMM");
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
private string GetAbwesenheiten(ServiceInvoicePeriodRO sip, DateTime start, DateTime end)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
var c = DAOFactory.GenericDAO.LoadByID<Customer>(sip.Customer.Oid.Value);
|
|
|
|
if (c.AbsenceTimes != null)
|
|
{
|
|
foreach (var at in c.AbsenceTimes)
|
|
{
|
|
if ((!at.Start.HasValue || at.Start.Value <= end) && (!at.End.HasValue || at.End.Value >= start))
|
|
{
|
|
if (sb.Length > 0)
|
|
{
|
|
sb.Append(", ");
|
|
}
|
|
|
|
sb.Append(String.Format("{0:dd.MM.}", at.Start));
|
|
if (!at.End.HasValue || at.End.Value > at.Start)
|
|
{
|
|
sb.Append(" bis ");
|
|
if (at.End.HasValue)
|
|
{
|
|
sb.Append(String.Format("{0:dd.MM.}", at.End));
|
|
}
|
|
else
|
|
{
|
|
sb.Append("unbekannt");
|
|
}
|
|
}
|
|
sb.Append(": " + at.AbsenceReason.Description);
|
|
}
|
|
}
|
|
}
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
} |