176 lines
6.0 KiB
C#
176 lines
6.0 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.Collections;
|
|
using System.ComponentModel;
|
|
using System.Text;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using DevExpress.XtraReports.UI;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BS.Shared;
|
|
using System.Collections.Generic;
|
|
using BS.Shared.Core;
|
|
|
|
namespace BeWo.TRIASAmbulanteSozialarbeit
|
|
{
|
|
[IDSpecificClass(Identifier = "HHND")]
|
|
public partial class RechnungHaushaltsnaheDienstleistung : XtraReport, IBeWoReport<ServiceInvoiceRO>
|
|
{
|
|
public RechnungHaushaltsnaheDienstleistung()
|
|
{
|
|
this.InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServiceInvoiceRO pRO)
|
|
{
|
|
bool selbstzahler = pRO.RecipientOrganisation != null && pRO.RecipientOrganisation.StartsWith("Selbstzahler");
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
if ("Haushaltshilfe".Equals(pRO.RecipientOrganisation))
|
|
{
|
|
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);
|
|
}
|
|
SetzePrivatAnrede(pRO);
|
|
}
|
|
else
|
|
{
|
|
String anrede = "Frau ";
|
|
var p = GetAnsprechpartner(pRO);
|
|
|
|
if (p != null)
|
|
{
|
|
lblAnrede.Text = String.Format("Sehr geehrte Frau {0},", p.LastName);
|
|
|
|
if (p != null && p.Sex.HasValue && p.Sex.Value == Sex.Male)
|
|
{
|
|
lblAnrede.Text = String.Format("Sehr geehrter Herr {0},", p.LastName);
|
|
|
|
anrede = "Herr ";
|
|
}
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation) && !selbstzahler)
|
|
{
|
|
sb.AppendLine(pRO.RecipientOrganisation);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientContactPerson))
|
|
{
|
|
sb.AppendLine(String.Format("{0}{1}", anrede, pRO.RecipientContactPerson));
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientStreet))
|
|
{
|
|
sb.AppendLine(pRO.RecipientStreet);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown))
|
|
{
|
|
sb.AppendLine(pRO.RecipientPostCodeAndTown);
|
|
}
|
|
}
|
|
lblAdresse.Text = sb.ToString();
|
|
lblIK.Text = "Institutskennzeichen: 460948378";
|
|
|
|
|
|
decimal stundensatz = 0;
|
|
decimal pauschale = 0;
|
|
|
|
foreach (var sip in pRO.ServiceInvoicePeriods)
|
|
{
|
|
var listOhnePauschale = new List<ServiceInvoiceItemRO>();
|
|
|
|
foreach (var ii in sip.ServiceInvoiceItems)
|
|
{
|
|
if (ii.ServiceDescription == "Anfahrtspauschale")
|
|
{
|
|
pauschale = ii.AmountPerUnit ?? 0;
|
|
}
|
|
else
|
|
{
|
|
listOhnePauschale.Add(ii);
|
|
stundensatz = ii.AmountPerUnit ?? 0;
|
|
}
|
|
|
|
}
|
|
|
|
foreach (var ii in listOhnePauschale)
|
|
{
|
|
ii.GrossAmount = String.Format("{0:c}", pauschale);
|
|
}
|
|
|
|
sip.ServiceInvoiceItems = listOhnePauschale;
|
|
}
|
|
|
|
|
|
|
|
lblAbrechnungszeitraum.Text = lblAbrechnungszeitraum.Text.Replace("[STUNDENSATZ]", String.Format("{0:c}", stundensatz)).Replace("[ANFAHRTPAUSCHALE]", String.Format("{0:c}", pauschale));
|
|
|
|
String customername = pRO.CustomerName;
|
|
|
|
if (pRO.InvoiceBase.CustomerOid > 0)
|
|
{
|
|
var c = DAOFactory.GenericDAO.LoadByID<Customer>(pRO.InvoiceBase.CustomerOid);
|
|
if (c.Person.Sex.HasValue && c.Person.Sex.Value == Sex.Male)
|
|
{
|
|
customername = String.Format("Herr {0}", customername);
|
|
}
|
|
else
|
|
{
|
|
customername = String.Format("Frau {0}", customername);
|
|
}
|
|
}
|
|
|
|
if (selbstzahler)
|
|
lblAbrechnungszeitraum.Text = lblAbrechnungszeitraum.Text.Replace(" für [CUSTOMER]", "");
|
|
else
|
|
lblAbrechnungszeitraum.Text = lblAbrechnungszeitraum.Text.Replace("[CUSTOMER]", customername);
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
|
|
|
|
private void SetzePrivatAnrede(ServiceInvoiceRO pRo)
|
|
{
|
|
|
|
if (pRo.InvoiceBase.SupportConceptCostBearerRelDc != null)
|
|
{
|
|
var c = pRo.InvoiceBase.SupportConceptCostBearerRelDc.SupportConcept.Customer;
|
|
if (c != null)
|
|
{
|
|
//var p = DAOFactory.GenericDAO.LoadByID<Person>(pdc.PersonOid);
|
|
|
|
if (c.Sex.HasValue)
|
|
{
|
|
if (c.Sex.Value == Sex.Male)
|
|
{
|
|
lblAnrede.Text = String.Format("Sehr geehrter Herr {0},", c.LastName);
|
|
}
|
|
else
|
|
{
|
|
lblAnrede.Text = String.Format("Sehr geehrte Frau {0},", c.LastName);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
private Person GetAnsprechpartner(ServiceInvoiceRO pRo)
|
|
{
|
|
if (pRo.InvoiceBase.RecipientPersonOid.HasValue)
|
|
{
|
|
return DAOFactory.GenericDAO.LoadByID<Person>(pRo.InvoiceBase.RecipientPersonOid.Value);
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
} |