210 lines
6.6 KiB
C#
210 lines
6.6 KiB
C#
using System;
|
|
using System.Text;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Service.ServiceImplementations;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace TwgJonathan
|
|
{
|
|
public partial class Rechnung : XtraReport, IBeWoReport<ServiceInvoiceRO>
|
|
{
|
|
public Rechnung()
|
|
{
|
|
this.InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServiceInvoiceRO pRO)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation))
|
|
{
|
|
sb.AppendLine(pRO.RecipientOrganisation);
|
|
sb.AppendLine("");
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientContactPerson))
|
|
{
|
|
sb.AppendLine(pRO.RecipientContactPerson);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientStreet))
|
|
{
|
|
sb.AppendLine(pRO.RecipientStreet);
|
|
sb.AppendLine("");
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown))
|
|
{
|
|
sb.AppendLine(pRO.RecipientPostCodeAndTown);
|
|
}
|
|
lblAdresse.Text = sb.ToString();
|
|
|
|
|
|
|
|
|
|
decimal tage = 0;
|
|
decimal pauschale = 0;
|
|
|
|
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.UnitCount.HasValue)
|
|
{
|
|
tage += i.UnitCount.Value;
|
|
}
|
|
if (i.AmountPerUnit.HasValue)
|
|
{
|
|
pauschale = i.AmountPerUnit.Value;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
cellHours.Text = String.Format("{0:0}", (int)tage);
|
|
cellTagessatz.Text = String.Format("{0:0.00} Euro", pauschale);
|
|
cellClaim.Text = String.Format("{0} Euro", pRO.NetClaim.Replace("€", "").Trim());
|
|
lblRechnungsbetrag.Text = cellClaim.Text;
|
|
|
|
lblAbsenceTimes.Text = GetAbsenceTimeString(pRO);
|
|
|
|
|
|
lblRechnungstext.Text = String.Format("Wir berechnen in oben genannten Zeitraum den genehmigten Betreuungssatz von {0:0.00} € pro Tag.", pauschale);
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
|
|
private String GetAbsenceTimeString(ServiceInvoiceRO pRO)
|
|
{
|
|
Customer c = null;
|
|
if (pRO.CustomerOid.HasValue)
|
|
{
|
|
c = DAOFactory.GenericDAO.LoadByID<Customer>(pRO.CustomerOid.Value);
|
|
}
|
|
else
|
|
{
|
|
if (pRO.InvoiceBase.SupportConceptOid.HasValue)
|
|
{
|
|
var sc = DAOFactory.GenericDAO.LoadByID<SupportConcept>(pRO.InvoiceBase.SupportConceptOid.Value);
|
|
c = sc.Customer;
|
|
}
|
|
}
|
|
if (c != null)
|
|
{
|
|
if (c.AbsenceTimes != null && c.AbsenceTimes.Count > 0)
|
|
{
|
|
DateTimeSpan span = new DateTimeSpan();
|
|
span.StartDate = pRO.AccountingPeriodStart;
|
|
span.EndDate = pRO.AccountingPeriodEnd;
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
foreach (var at in c.AbsenceTimes)
|
|
{
|
|
if (at.AbsenceSpan != null)
|
|
{
|
|
|
|
bool cont = !(at.Start != null && at.Start > span.EndDateTime);
|
|
|
|
if (cont && at.End != null && at.End < span.StartDateTime)
|
|
{
|
|
cont = false;
|
|
}
|
|
|
|
if (cont)
|
|
{
|
|
if (sb.Length > 0)
|
|
{
|
|
sb.Append("; ");
|
|
}
|
|
|
|
sb.Append(at.AbsenceReason.Description);
|
|
sb.Append(": ");
|
|
if (at.Start.HasValue)
|
|
{
|
|
sb.Append(string.Format("{0:00}", at.Start.Value.Day));
|
|
sb.Append(".");
|
|
sb.Append(string.Format("{0:00}", at.Start.Value.Month));
|
|
sb.Append(".");
|
|
sb.Append(at.Start.Value.Year.ToString().Substring(2));
|
|
|
|
sb.Append(" - ");
|
|
|
|
if (at.End.HasValue)
|
|
{
|
|
sb.Append(string.Format("{0:00}", at.End.Value.Day));
|
|
sb.Append(".");
|
|
sb.Append(string.Format("{0:00}", at.End.Value.Month));
|
|
sb.Append(".");
|
|
sb.Append(at.End.Value.Year.ToString().Substring(2));
|
|
}
|
|
else
|
|
{
|
|
sb.Append("...");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
private void SetCustomerInfos(ServiceInvoiceRO pRO)
|
|
{
|
|
String mnr = String.Empty;
|
|
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)
|
|
{
|
|
if (vv.VarFieldDefOid.Value == 2)
|
|
{
|
|
var varFieldValue = Utils.XMLDeserializeFromString(vv.SerializedValue, Type.GetType(vv.TypeName));
|
|
if (varFieldValue != null)
|
|
{
|
|
mnr = varFieldValue.ToString();
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//txtMittelbindungsnr.Text = mnr;
|
|
|
|
}
|
|
}
|
|
} |