297 lines
13 KiB
C#
297 lines
13 KiB
C#
using System;
|
|
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 BS.Shared.Core;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace PerspektivenEV
|
|
{
|
|
public partial class ServiceInvoiceReport : XtraReport, IBeWoReport<ServiceInvoiceRO>
|
|
{
|
|
public ServiceInvoiceReport()
|
|
{
|
|
this.InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServiceInvoiceRO pRO)
|
|
{
|
|
DateTime start = pRO.AccountingPeriodStart;
|
|
DateTime end = pRO.AccountingPeriodEnd;
|
|
bool bthg = false;
|
|
String f = GetFunction(pRO);
|
|
if (f != null && f.ToLower().Contains("bthg"))
|
|
{
|
|
bthg = true;
|
|
}
|
|
|
|
string poBox = null;
|
|
if (pRO.InvoiceBase.RecipientContactInformations.Count > 0)
|
|
{
|
|
foreach (var i in pRO.InvoiceBase.RecipientContactInformations)
|
|
{
|
|
if (i.ContactType == BS.Shared.ContactType.private_POBox)
|
|
poBox = i.ContactValue;
|
|
}
|
|
}
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation) && !pRO.RecipientOrganisation.Contains("SELBSTZAHLER") && pRO.RecipientOrganisation != "EIGENANTEIL")
|
|
{
|
|
sb.AppendLine(pRO.RecipientOrganisation);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientAddressLine1))
|
|
{
|
|
sb.AppendLine(pRO.RecipientAddressLine1);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientContactPerson))
|
|
{
|
|
sb.AppendLine(pRO.RecipientContactPerson);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientDivision) && !String.IsNullOrEmpty(pRO.RecipientOrganisation) && !pRO.RecipientOrganisation.Contains("SELBSTZAHLER"))
|
|
{
|
|
sb.AppendLine(pRO.RecipientDivision);
|
|
}
|
|
if (!String.IsNullOrEmpty(poBox))
|
|
{
|
|
sb.AppendLine(poBox);
|
|
}
|
|
else if (!String.IsNullOrEmpty(pRO.RecipientPoBox))
|
|
{
|
|
sb.AppendLine(pRO.RecipientPoBox);
|
|
}
|
|
else if (!String.IsNullOrEmpty(pRO.RecipientStreet))
|
|
{
|
|
sb.AppendLine(pRO.RecipientStreet);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown))
|
|
{
|
|
sb.AppendLine("");
|
|
sb.AppendLine(pRO.RecipientPostCodeAndTown);
|
|
}
|
|
lblAdresse.Text = sb.ToString();
|
|
|
|
// Hier werden Infos für PFK gesetzt
|
|
long? customerOid = null;
|
|
foreach (var ip in pRO.ServiceInvoicePeriods)
|
|
{
|
|
if (ip.Customer != null)
|
|
{
|
|
customerOid = ip.Customer.CustomerOid;
|
|
break;
|
|
}
|
|
}
|
|
if (customerOid != null)
|
|
{
|
|
var custDC = MapperFactory.CustomerDC_Customer.MapToNewDC(DAOFactory.GenericDAO.GetByID<Customer>(customerOid.Value));
|
|
if (custDC.RelatedTeams.Any(t => t.Team.Name.ToLower() == "pfk"))
|
|
{
|
|
lblBetreffPfk1.Visible = true;
|
|
lblBetreffPfk2.Visible = true;
|
|
lblUeberweisungPfk.Visible = true;
|
|
lblZeitraumPfk1.Visible = true;
|
|
lblZeitraumPfk2.Visible = true;
|
|
|
|
lblBetreff.Visible = false;
|
|
lblUeberweisung.Visible = false;
|
|
}
|
|
if (custDC.RelatedTeams.Any(t => t.Team.Name.ToLower().Contains("tages") && pRO.RecipientOrganisation.Contains("SELBSTZAHLER")))
|
|
{
|
|
lblUeberschrift.Text = "Anzahl Tage";
|
|
}
|
|
}
|
|
|
|
if (pRO.RecipientOrganisation == "SELBSTZAHLER" || pRO.RecipientOrganisation == "EIGENANTEIL")
|
|
{
|
|
lblBetreff.Text += " durch Perspektiven e.V.";
|
|
lblUeberweisung.Text = "Bitte überweisen Sie den Betrag innerhalb von 14 Tagen auf unser Konto bei der Bank für Sozialwirtschaft DE92 3702 0500 0007 6025 00.";
|
|
SetzeCustomerZahlung(pRO, customerOid);
|
|
}
|
|
else
|
|
{
|
|
lblBetreff.Text += String.Format(" - Gz: {0}", pRO.CustomerReferenceNumber);
|
|
}
|
|
|
|
if (pRO.ServiceInvoicePeriods != null && pRO.ServiceInvoicePeriods.Count > 0)
|
|
{
|
|
foreach (var p in pRO.ServiceInvoicePeriods)
|
|
{
|
|
if (p.ServiceInvoiceItems != null && p.ServiceInvoiceItems.Count > 0)
|
|
{
|
|
foreach (var i in p.ServiceInvoiceItems)
|
|
{
|
|
if (i.ServiceDescription != null && !i.ServiceDescription.StartsWith("Rechnungsdifferenz"))
|
|
{
|
|
if (bthg) // Stand ab Juli 2023 ohne PFK
|
|
{
|
|
lblUeberschrift.Text = "Angef. Einheiten";
|
|
i.Duration = String.Format("{0:0.00}", i.Hours);
|
|
|
|
if (!i.ServiceDescription.Contains("Anfahrt") && !i.ServiceDescription.ToLower().Contains("pauschale")
|
|
&& !i.ServiceDescription.Contains("Terminabsage") && !i.ServiceDescription.Contains("Eigenanteil")
|
|
&& !i.ServiceDescription.Contains("Tagesstättentage") && !i.ServiceDescription.Contains("Flächen"))
|
|
{
|
|
if (start.Month == end.Month && start.Year == end.Year)
|
|
{
|
|
i.ServiceDescription = String.Format("{0:MMMM yyyy}", start);
|
|
}
|
|
else
|
|
{
|
|
i.ServiceDescription = String.Format("{0:MMMM yyyy} - {1:MMMM yyyy}", start, end);
|
|
}
|
|
}
|
|
else if (i.ServiceDescription.Contains("Anfahrt"))
|
|
{
|
|
if (start.Month == end.Month && start.Year == end.Year)
|
|
{
|
|
i.ServiceDescription = "Anfahrt(en)";
|
|
}
|
|
}
|
|
else if (i.ServiceDescription.Contains("Terminabsage"))
|
|
{
|
|
if (start.Month == end.Month && start.Year == end.Year)
|
|
i.ServiceDescription = "Terminabsage";
|
|
}
|
|
}
|
|
else //alte Bedingungen und PFK
|
|
{
|
|
if (!i.ServiceDescription.Contains("Pauschale"))
|
|
{
|
|
i.Duration = String.Format("{0:0.00}", i.Hours);
|
|
}
|
|
else
|
|
{
|
|
lblUeberschrift.Text = "Zeitraum";
|
|
lblAnlage.Text = "";
|
|
if (start.Month == end.Month && start.Year == end.Year)
|
|
i.Duration = String.Format("{0:MMMM yyyy}", start);
|
|
}
|
|
if (!i.ServiceDescription.Contains("Anfahrt") && !i.ServiceDescription.Contains("Handgeld") && !i.ServiceDescription.ToLower().Contains("pauschale")
|
|
&& !i.ServiceDescription.Contains("gefahren") && !i.ServiceDescription.Contains("Terminabsage") && !i.ServiceDescription.Contains("Eigenanteil"))
|
|
{
|
|
if (start.Month == end.Month && start.Year == end.Year)
|
|
i.ServiceDescription = String.Format("{0:MMMM yyyy}", start);
|
|
else
|
|
i.ServiceDescription = String.Format("{0:MMMM yyyy} - {1:MMMM yyyy}", start, end);
|
|
}
|
|
else if (i.ServiceDescription.Contains("Anfahrt"))
|
|
{
|
|
if (start.Month == end.Month && start.Year == end.Year)
|
|
i.ServiceDescription = "Anfahrt(en)";
|
|
}
|
|
else if (i.ServiceDescription.Contains("Terminabsage"))
|
|
{
|
|
if (start.Month == end.Month && start.Year == end.Year)
|
|
i.ServiceDescription = "Terminabsage";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//Sonderlösung um im Notice-Feld bei Bedarf Teilzahlungen anzeigen zu können
|
|
int index = 0;
|
|
if (!String.IsNullOrEmpty(pRO.Notice))
|
|
{
|
|
index = pRO.Notice.IndexOf("\r\n");
|
|
if (index == 0)
|
|
index = pRO.Notice.IndexOf("BEZAHLT");
|
|
if (index > 0)
|
|
pRO.Notice = pRO.Notice.Remove(index);
|
|
}
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private void SetzeCustomerZahlung(ServiceInvoiceRO pRO, long? customerOid)
|
|
{
|
|
bool sepa = false;
|
|
string mandat = null;
|
|
string idNr = null;
|
|
string iban = null;
|
|
string bank = null;
|
|
string bic = null;
|
|
|
|
Customer c = null;
|
|
if (pRO.ServiceInvoicePeriods.Count > 0 && pRO.ServiceInvoicePeriods[0].CostBearer2SupportConcept != null)
|
|
{
|
|
var c2s = pRO.ServiceInvoicePeriods[0].CostBearer2SupportConcept;
|
|
if (c2s.SupportConcept.Customer != null)
|
|
{
|
|
c = c2s.SupportConcept.Customer;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (pRO.InvoiceBase.SupportConceptOid != null)
|
|
{
|
|
var sc = DAOFactory.GenericDAO.LoadByID<SupportConcept>(pRO.InvoiceBase.SupportConceptOid.Value);
|
|
c = DAOFactory.GenericDAO.LoadByID<Customer>(sc.Customer.Oid.Value);
|
|
}
|
|
}
|
|
if (c == null && customerOid != null)
|
|
{
|
|
c = DAOFactory.GenericDAO.LoadByID<Customer>(customerOid.Value);
|
|
}
|
|
if (c != null && c.VarFieldValueList.Count != 0)
|
|
{
|
|
foreach (var vv in c.VarFieldValueList)
|
|
{
|
|
var varFieldValue = Utils.XMLDeserializeFromString(vv.SerializedValue, Type.GetType(vv.TypeName));
|
|
if (varFieldValue != null)
|
|
{
|
|
switch (vv.VarFieldDefOid)
|
|
{
|
|
case 31: // Lastschriftmandat
|
|
sepa = (bool)varFieldValue;
|
|
break;
|
|
case 32:
|
|
mandat = varFieldValue.ToString();
|
|
break;
|
|
case 33:
|
|
idNr = varFieldValue.ToString();
|
|
break;
|
|
case 34:
|
|
bank = varFieldValue.ToString();
|
|
break;
|
|
case 35:
|
|
iban = varFieldValue.ToString();
|
|
break;
|
|
case 36:
|
|
bic = varFieldValue.ToString();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (sepa)
|
|
{
|
|
lblUeberweisung.Text = String.Format("Unsere Forderung ziehen wir in den nächsten Tagen mit der SEPA-Lastschrift zum Mandat {0} zu der Gläubiger - Identifikationsnummer " +
|
|
"{1} von Ihrem Konto IBAN {2} bei der {3}, BIC {4} ein.", mandat, idNr, iban, bank, bic);
|
|
}
|
|
}
|
|
}
|
|
|
|
private String GetFunction(ServiceInvoiceRO pRO)
|
|
{
|
|
if (pRO.InvoiceBase != null && pRO.InvoiceBase.SupportConceptCostBearerRelDc != null)
|
|
{
|
|
var c2s = pRO.InvoiceBase.SupportConceptCostBearerRelDc;
|
|
return c2s.CostBearer.Function;
|
|
}
|
|
else if (pRO.InvoiceBase.RecipientCostBearerOid != null)
|
|
{
|
|
var cbOid = pRO.InvoiceBase.RecipientCostBearerOid ?? 0;
|
|
var cb = DAOFactory.GenericDAO.GetByID<CostBearer>(cbOid);
|
|
return cb.Organisation.Function.Value;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
} |