200 lines
8.3 KiB
C#
200 lines
8.3 KiB
C#
using System;
|
|
using System.Text;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace DiakonischesWerkPassau
|
|
{
|
|
public partial class ServiceInvoiceReport : XtraReport, IBeWoReport<ServiceInvoiceRO>
|
|
{
|
|
public ServiceInvoiceReport()
|
|
{
|
|
this.InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServiceInvoiceRO pRO)
|
|
{
|
|
if (!String.IsNullOrEmpty(pRO.CustomerSalutation) && pRO.CustomerSalutation.ToLower() == "herr")
|
|
pRO.CustomerSalutation = "Herrn";
|
|
|
|
if (pRO.RecipientOrganisation.Contains("BWG"))
|
|
{
|
|
lblAbrechnungszeitraum.Text = String.Format("wir erlauben uns, die Fachleistungsstunden für {0} {1} für unsere Therapeutische Wohngemeinschaft in der Neuburger Straße im angeführten Abrechnungszeitraum " +
|
|
"gemäß beigefügtem Quittierungsbeleg in Rechnung zu stellen. Die anfallenden Kosten errechnen sich wie folgt:", pRO.CustomerSalutation, pRO.CustomerName);
|
|
if (pRO.CustomerReferenceNumber != null)
|
|
lblCustomer.Text += "; Therapeutische Wohngemeinschaft";
|
|
else lblCustomer.Text += " Therapeutische Wohngemeinschaft";
|
|
}
|
|
else if (pRO.RecipientOrganisation.Contains("TWG"))
|
|
{
|
|
lblAbrechnungszeitraum.Text = String.Format("wir erlauben uns, die Fachleistungsstunden für {0} {1} für unsere Therapeutische Wohngemeinschaft in der Minihofstraße " +
|
|
"im angeführten Abrechnungszeitraum gemäß beigefügtem Quittierungsbeleg in Rechnung zu stellen. " +
|
|
"Die anfallenden Kosten errechnen sich wie folgt:", pRO.CustomerSalutation, pRO.CustomerName);
|
|
if (pRO.CustomerReferenceNumber != null)
|
|
lblCustomer.Text += "; Therapeutische Wohngemeinschaft";
|
|
else lblCustomer.Text += " Therapeutische Wohngemeinschaft";
|
|
}
|
|
else if (pRO.RecipientOrganisation.Contains("Einzelwohnen"))
|
|
{
|
|
lblAbrechnungszeitraum.Text = String.Format("wir erlauben uns, die Fachleistungsstunden für das Betreute Einzelwohnen von {0} {1}" +
|
|
" gemäß beigefügtem Quittierungsbeleg in Rechnung zu stellen. Die anfallenden Kosten errechnen sich wie folgt:", pRO.CustomerSalutation, pRO.CustomerName);
|
|
if (pRO.CustomerReferenceNumber != null)
|
|
lblCustomer.Text += "; Betreutes Einzelwohnen";
|
|
else lblCustomer.Text += " Betreutes Einzelwohnen";
|
|
}
|
|
lblAbrechnungszeitraum.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopJustify;
|
|
|
|
if (!String.IsNullOrEmpty(pRO.CustomerSalutation) && pRO.CustomerSalutation.ToLower() == "herrn")
|
|
pRO.CustomerSalutation = "Herr";
|
|
|
|
if (pRO.RecipientOrganisation.Contains("Selbstzahler"))
|
|
{
|
|
SetzeCustomerZahlung(pRO);
|
|
lblCustomer.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
SetzeAnrede(pRO);
|
|
lblDebitor.Text = String.Format("Debitor: {0}", pRO.OrganisationDebitorNumber);
|
|
}
|
|
|
|
SetzeAdresse(pRO);
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
private void SetzeAdresse(ServiceInvoiceRO pRO)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation))
|
|
{
|
|
if (pRO.RecipientOrganisation.Contains("Selbstzahler"))
|
|
{
|
|
pRO.RecipientOrganisation = null;
|
|
pRO.RecipientDivision = null;
|
|
}
|
|
else
|
|
{
|
|
if (pRO.RecipientOrganisation.Contains("(BWG)"))
|
|
pRO.RecipientOrganisation = pRO.RecipientOrganisation.Replace("(BWG)", "");
|
|
else if (pRO.RecipientOrganisation.Contains("(TWG)"))
|
|
pRO.RecipientOrganisation = pRO.RecipientOrganisation.Replace("(TWG)", "");
|
|
else if (pRO.RecipientOrganisation.Contains("(Betreutes Einzelwohnen)"))
|
|
pRO.RecipientOrganisation = pRO.RecipientOrganisation.Replace("(Betreutes Einzelwohnen)", "");
|
|
sb.AppendLine(pRO.RecipientOrganisation);
|
|
}
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientDivision))
|
|
{
|
|
sb.AppendLine(pRO.RecipientDivision);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientContactPerson))
|
|
{
|
|
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();
|
|
}
|
|
private void SetzeAnrede(ServiceInvoiceRO pRO)
|
|
{
|
|
String anrede = "Sehr geehrte Damen und Herren,";
|
|
|
|
var p = GetKontaktPerson(pRO);
|
|
|
|
if (p != null)
|
|
{
|
|
if (p.Sex.HasValue && p.Sex.Value == Sex.Male)
|
|
{
|
|
anrede = "Sehr geehrter Herr " + p.LastName + ",";
|
|
}
|
|
else if (p.Sex.HasValue && p.Sex.Value == Sex.Female)
|
|
{
|
|
anrede = "Sehr geehrte Frau " + p.LastName + ",";
|
|
}
|
|
}
|
|
|
|
lblAnrede.Text = anrede;
|
|
}
|
|
|
|
private Person GetKontaktPerson(ServiceInvoiceRO pRO)
|
|
{
|
|
if (pRO.ServiceInvoicePeriods.Count > 0)
|
|
{
|
|
var c2s = pRO.ServiceInvoicePeriods[0].CostBearer2SupportConcept;
|
|
return c2s.CostBearerContactPerson;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
private void SetzeCustomerZahlung(ServiceInvoiceRO pRO)
|
|
{
|
|
bool sepa = false;
|
|
string mandat = null;
|
|
string idNr = null;
|
|
string iban = null;
|
|
string bank = null;
|
|
string bic = null;
|
|
|
|
Customer c = null;
|
|
if (pRO.CustomerOid.HasValue)
|
|
{
|
|
c = DAOFactory.GenericDAO.LoadByID<Customer>(pRO.CustomerOid.Value);
|
|
}
|
|
if (c == null)
|
|
{
|
|
if (pRO.ServiceInvoicePeriods.Count > 0)
|
|
{
|
|
var c2s = pRO.ServiceInvoicePeriods[0].CostBearer2SupportConcept;
|
|
c = c2s.SupportConcept.Customer;
|
|
}
|
|
}
|
|
|
|
if (c != null)
|
|
{
|
|
foreach (var vv in c.VarFieldValueList)
|
|
{
|
|
var varFieldValue = Utils.XMLDeserializeFromString(vv.SerializedValue, Type.GetType(vv.TypeName));
|
|
if (varFieldValue != null)
|
|
{
|
|
switch (vv.VarFieldDefOid)
|
|
{
|
|
case 1: // Lastschriftmandat
|
|
sepa = (bool)varFieldValue;
|
|
break;
|
|
case 2:
|
|
mandat = varFieldValue.ToString();
|
|
break;
|
|
case 3:
|
|
idNr = varFieldValue.ToString();
|
|
break;
|
|
case 4:
|
|
bank = varFieldValue.ToString();
|
|
break;
|
|
case 5:
|
|
iban = varFieldValue.ToString();
|
|
break;
|
|
case 6:
|
|
bic = varFieldValue.ToString();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (sepa)
|
|
xrZahlung.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);
|
|
}
|
|
}
|
|
}
|
|
} |