208 lines
6.6 KiB
C#
208 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;
|
|
using PraxisPusteblume.Invoicing;
|
|
|
|
namespace PraxisPusteblume
|
|
{
|
|
//[IDSpecificClass(Identifier = "RechnungReiten")]
|
|
public partial class RechnungReiten : XtraReport, IBeWoReport<InvoiceCustomerRO>
|
|
{
|
|
public RechnungReiten()
|
|
{
|
|
this.InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(InvoiceCustomerRO pRO)
|
|
{
|
|
|
|
//lblNotice.Text = "";
|
|
//if (String.IsNullOrEmpty(pRO.Notice))
|
|
//{
|
|
// lblAnlage.Visible = false;
|
|
// lblNotice.Visible = false;
|
|
//}
|
|
//else
|
|
//{
|
|
// lblNotice.Text = pRO.Notice;
|
|
//}
|
|
//lblMonat.Text = String.Format("{0:MMMM yyyy}", pRO.AccountingPeriodStart);
|
|
|
|
ErstelleAdressfeld(pRO);
|
|
|
|
var stats = GetStatistics(pRO);
|
|
if (stats != null)
|
|
{
|
|
lblReststunden.Text = String.Format("Reststunden der Bewilligung beim Bezirk: {0:0.##}",
|
|
(stats.MinutesApprovedTotal - stats.MinutesProvidedTotal) / 60);
|
|
}
|
|
|
|
//lblAdresse.Text = sb.ToString();
|
|
|
|
|
|
//lblNachweisFuer.Text = String.Format("Sehr geehrte Damen und Herren,\r\n\r\nfolgende Beiträge für Heilpädagogisches Reiten darf ich Ihnen in Rechnung stellen:");
|
|
|
|
|
|
|
|
decimal summe = 0;
|
|
|
|
if (pRO.InvoiceItems != null)
|
|
{
|
|
foreach (var i in pRO.InvoiceItems)
|
|
{
|
|
|
|
|
|
if (!String.IsNullOrEmpty(i.ItemDescription))
|
|
{
|
|
i.ItemDescription = i.ItemDescription.Replace("?", "€");
|
|
}
|
|
if (i.AmountTotal.HasValue)
|
|
{
|
|
summe += i.AmountTotal.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
//cellGesamtSumme.Text = String. pRO.GrossClaim;
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private void ErstelleAdressfeld(InvoiceCustomerRO pRo)
|
|
{
|
|
var cust = GetCustomer(pRo);
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
if (cust != null)
|
|
{
|
|
var adresse = cust.Person.InvoiceAddress;
|
|
if (adresse == null)
|
|
{
|
|
adresse = cust.Person.Address;
|
|
}
|
|
|
|
if (adresse != null)
|
|
{
|
|
if (String.IsNullOrEmpty(adresse.AddressLine1) && String.IsNullOrEmpty(adresse.AddressLine2))
|
|
{
|
|
sb.AppendLine(cust.Person.FirstNameLastName);
|
|
}
|
|
|
|
if (!String.IsNullOrEmpty(adresse.AddressLine1))
|
|
{
|
|
sb.AppendLine(adresse.AddressLine1);
|
|
}
|
|
|
|
if (!String.IsNullOrEmpty(adresse.AddressLine2))
|
|
{
|
|
sb.AppendLine(adresse.AddressLine2);
|
|
}
|
|
|
|
|
|
if (!String.IsNullOrEmpty(adresse.Street))
|
|
{
|
|
sb.AppendLine(adresse.Street);
|
|
}
|
|
|
|
sb.AppendLine("");
|
|
sb.AppendLine(String.Format("{0} {1}", adresse.PostalCode, adresse.Town));
|
|
}
|
|
}
|
|
|
|
lblAdresse.Text = sb.ToString();
|
|
}
|
|
|
|
private Customer GetCustomer(InvoiceCustomerRO pRo)
|
|
{
|
|
if (pRo.InvoiceBase.RecipientCustomerOid.HasValue)
|
|
{
|
|
return DAOFactory.GenericDAO.LoadByID<Customer>(pRo.InvoiceBase.RecipientCustomerOid.Value);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
private SupportConceptStatisticsDC GetStatistics(InvoiceCustomerRO ro)
|
|
{
|
|
if (ro.InvoiceBase.InvoiceItems != null && ro.InvoiceBase.InvoiceItems.Count > 0)
|
|
{
|
|
var sr = ro.InvoiceBase.InvoiceItems[0].ServiceRecord;
|
|
if (sr != null && sr.CostBearer2SupportConceptOid.HasValue)
|
|
{
|
|
var service = new OperationsServiceImp();
|
|
|
|
|
|
long cb2scOid = sr.CostBearer2SupportConceptOid.Value;
|
|
|
|
|
|
return service.CreateSupportConceptStatistics(cb2scOid, ro.AccountingPeriodEnd.Value);
|
|
}
|
|
//if (stats.PeriodStatistics != null && stats.PeriodStatistics.Count > 0)
|
|
//{
|
|
// foreach (var ps in stats.PeriodStatistics)
|
|
// {
|
|
// if (ps.SupportConceptApprovalPeriod != null &&
|
|
// ps.SupportConceptApprovalPeriod.ServiceCategory != null &&
|
|
// (ps.SupportConceptApprovalPeriod.ServiceCategory.Name.StartsWith("Verhinderung") ||
|
|
// ps.SupportConceptApprovalPeriod.ServiceCategory.Name.StartsWith("Betreuungsleistungen")))
|
|
// {
|
|
// return ps;
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
//return null;
|
|
}
|
|
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;
|
|
|
|
}
|
|
}
|
|
} |