Files
BeWoPlaner/ReportImp/DomizielAnsbach/RechnungZV.cs

135 lines
5.4 KiB
C#

using BeWo.Report.ReportObjects;
using DevExpress.XtraReports.UI;
using BS.Shared.Core;
using BeWo.Report;
using System;
using System.Text;
using DomizielAnsbach.Service;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BS.Shared;
namespace DomizielAnsbach
{
[IDSpecificClass(Identifier = "RgZV")]
public partial class RechnungZV : XtraReport, IBeWoReport<ServiceInvoiceRO>
{
public RechnungZV()
{
this.InitializeComponent();
}
public void SetReportDataSource(ServiceInvoiceRO pRO)
{
var sb = new StringBuilder();
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation))
{
sb.AppendLine(pRO.RecipientOrganisation);
}
if (!String.IsNullOrEmpty(pRO.RecipientAddressLine1))
{
sb.AppendLine(pRO.RecipientAddressLine1);
}
if (!String.IsNullOrEmpty(pRO.RecipientDivision))
{
sb.AppendLine(pRO.RecipientDivision);
}
if (!String.IsNullOrEmpty(pRO.RecipientContactPerson) && pRO.RecipientContactPerson != pRO.RecipientOrganisation)
{
SetzeAnrede(pRO);
sb.AppendLine(pRO.RecipientContactPerson);
}
if (!String.IsNullOrEmpty(pRO.RecipientStreet))
{
sb.AppendLine(pRO.RecipientStreet);
}
if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown))
{
sb.AppendLine(pRO.RecipientPostCodeAndTown);
}
lblAdresse.Text = sb.ToString();
if (pRO.RecipientOrganisation.ToLower().Contains("rda ggmbh"))
{
pRO.Notice += " Rechnung umsatzsteuerfrei gemäß Freistellungsbescheid vom Finanzamt vom 17.10.2023 \n St.- Nr. 203 / 107 / 10734";
}
DateTime start = pRO.AccountingPeriodStart;
DateTime end = pRO.AccountingPeriodEnd;
if (start.Month == end.Month && start.Year == end.Year)
{
lblAbrechnungsinterval.Text = "Monat";
lblAbrechnungszeitraum.Text = String.Format("{0:MMMM yyyy}", start);
}
else
{
lblAbrechnungszeitraum.Text = String.Format("{0:MMMM yyyy} - {1:MMMM yyyy}", start, end);
}
long? customerOid = pRO.ServiceInvoicePeriods[0].Customer.CustomerOid;
if (customerOid.HasValue && pRO.InvoiceBase.RecipientCostBearerOid.HasValue)
{
var c = DAOFactory.GenericDAO.LoadByID<Customer>(customerOid.Value);
var pausch = ZuverdienstHelper.GetPauschalen(pRO.InvoiceBase.RecipientCostBearerOid.Value, c, end);
if (pausch.motZuwend4 != 0 && pausch.dateMotZuwend4 != DateTime.MinValue && pausch.dateMotZuwend4 <= pRO.AccountingPeriodEnd)
{
lblMot2.Text += String.Format("{0:dd.MM.yyyy} {1:c2}", pausch.dateMotZuwend4, pausch.motZuwend4);
lblMot1.Text += String.Format("{0:dd.MM.yyyy} {1:c2}", pausch.dateMotZuwend3, pausch.motZuwend3);
}
else if (pausch.motZuwend3 != 0 && pausch.dateMotZuwend3 != DateTime.MinValue && pausch.dateMotZuwend3 <= pRO.AccountingPeriodEnd)
{
lblMot2.Text += String.Format("{0:dd.MM.yyyy} {1:c2}", pausch.dateMotZuwend3, pausch.motZuwend3);
lblMot1.Text += String.Format("{0:dd.MM.yyyy} {1:c2}", pausch.dateMotZuwend2, pausch.motZuwend2);
}
else if (pausch.motZuwend2 != 0 && pausch.dateMotZuwend2 != DateTime.MinValue && pausch.dateMotZuwend2 <= pRO.AccountingPeriodEnd)
{
lblMot2.Text += String.Format("{0:dd.MM.yyyy} {1:c2}", pausch.dateMotZuwend2, pausch.motZuwend2);
lblMot1.Text += String.Format("{0:dd.MM.yyyy} {1:c2}", pausch.dateMotZuwend1, pausch.motZuwend1);
}
else if (pausch.motZuwend1 != 0 && pausch.dateMotZuwend1 != DateTime.MinValue && pausch.dateMotZuwend1 <= pRO.AccountingPeriodEnd)
{
lblMot2.Text += String.Format("{0:dd.MM.yyyy} {1:c2}", pausch.dateMotZuwend1, pausch.motZuwend1);
lblMot1.Text = "";
}
}
var anhang = new DomizielAnsbach.RechnungZVTN();
xrSubreport1.ReportSource = anhang;
anhang.SetReportDataSource(pRO);
this.bindingSource1.DataSource = pRO;
}
private void SetzeAnrede(ServiceInvoiceRO pRO)
{
var p = GetKontaktPerson(pRO);
if (p != null)
{
if (p.Sex.HasValue && p.Sex.Value == Sex.Male)
{
pRO.RecipientContactPerson = "Herr " + pRO.RecipientContactPerson;
}
else if (p.Sex.HasValue && p.Sex.Value == Sex.Female)
{
pRO.RecipientContactPerson = "Frau " + pRO.RecipientContactPerson;
}
}
}
private Person GetKontaktPerson(ServiceInvoiceRO pRO)
{
if (pRO.ServiceInvoicePeriods.Count > 0)
{
var c2s = pRO.ServiceInvoicePeriods[0].CostBearer2SupportConcept;
return c2s.CostBearerContactPerson;
}
return null;
}
}
}