Files
BeWoPlaner/ReportImp/PraxisPusteblume/BehandlungsnachweisHerrHerzog.cs

254 lines
8.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 = "Selbstzahler")]
public partial class BehandlungsnachweisHerrHerzog : XtraReport, IBeWoReport<ServiceInvoiceRO>
{
public BehandlungsnachweisHerrHerzog()
{
this.InitializeComponent();
}
public void SetReportDataSource(ServiceInvoiceRO pRO)
{
SetCustomerInfos(pRO);
lblZahlbar.Text = String.Format("Zahlbar jederzeit, spätestens bis {0:dd.MM.yyyy}",
pRO.InvoiceDateTime.Value.AddDays(8));
//lblNachweisFuer.Text = String.Format("Behandlungsnachweis für: {0}, geb. am {1:dd.MM.yyyy}",
// pRO.CustomerName, pRO.CustomerBirthdate);
//lblMonatJahr.Text = String.Format("Monat/Jahr: {0:MM}/{0:yyyy}", pRO.AccountingPeriodStart);
//var stats = GetStatistics(pRO);
//if (stats != null)
//{
// lblReststunden.Text = String.Format("Reststunden: {0:0.##}",
// (stats.MinutesApprovedTotal - stats.MinutesProvidedTotal) / 60);
//}
//lblAZ.Text = pRO.CustomerReferenceNumber;
//if (pRO.InvoiceDateTime.HasValue)
// pRO.Notice = String.Format("{0:dd.MM.yyyy}", pRO.InvoiceDateTime.Value.AddDays(30));
// if (pRO.ServiceInvoicePeriods != null)
// {
// foreach (var sip in pRO.ServiceInvoicePeriods)
// {
// if (sip.ServiceInvoiceItems != null)
// {
// foreach (var ii in sip.ServiceInvoiceItems)
// {
// ii.ServiceDescription = String.Format("{0}\n{1}", ii.ServiceDescription, ii.Notice);
// ii.CustomerFirstname = String.Format("{0:c}", ii.AmountPerUnit);
// if (!String.IsNullOrEmpty(ii.RateFactor))
// {
//var rfStr = ii.RateFactor.Replace("%", "").Replace(",00", "").Trim();
//int rfInt = 0;
//Int32.TryParse(rfStr, out rfInt);
//if (rateFactor > 1)
//{
// ii.CustomerFirstname = String.Format("{0} x {1:0.##}", ii.CustomerFirstname, rateFactor);
//}
//else
//{
// ii.CustomerFirstname = String.Format("{0}", ii.CustomerFirstname);
//}
// }
// }
// }
// }
// }
//SetCustomerInfos(pRO);
//cellDesription.Text = String.Format("Fachleistungsstunden {0:MM}/{0:yyyy}", pRO.AccountingPeriodStart);
decimal hourlyRate = 0;
decimal rateFactor = 1;
decimal hours = 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)
{
i.Notice = String.Format("{0:dd.MM.yyyy} / KW {1}", i.AccountingPeriodStart, InvoiceHelper.GetKW(i.AccountingPeriodStart.Value));
if (i.UnitCount != null && i.UnitCount.HasValue)
{
i.UnitCountString = String.Format("{0:0.##} Behandlungseinheit à {1:c}", i.UnitCount,
i.AmountPerUnit);
}
//i.ServiceDescription =
//if (i.HourlyRate.HasValue)
//{
// hourlyRate = i.HourlyRate.Value;
// if (!String.IsNullOrEmpty(i.RateFactor))
// {
// var rfStr = i.RateFactor.Replace("%", "").Replace(",00", "").Trim();
// int rfInt = 0;
// Int32.TryParse(rfStr, out rfInt);
// rateFactor = (100m + rfInt) / 100m;
// }
//}
if (i.Hours.HasValue)
hours += i.Hours.Value;
}
}
}
}
hours *= rateFactor;
//cellDesription.Text = "Behandlungseinheiten / Monat:";
//cellHours.Text = String.Format("{0:0.00} Stunden x", InvoiceHelper.GetUnitString(hours));
//cellHouryRate.Text = String.Format("{0:0.00} Euro", hourlyRate);
//cellClaim.Text = String.Format("{0} Euro", pRO.NetClaim.Replace("€", "").Trim());
this.bindingSource1.DataSource = pRO;
}
private SupportConceptStatisticsDC GetStatistics(ServiceInvoiceRO ro)
{
if (ro.InvoiceBase.SupportConceptCostBearerRelDc != null)
{
var service = new OperationsServiceImp();
long cb2scOid = ro.InvoiceBase.SupportConceptCostBearerRelDc.CostBearer2SupportConceptOid.Value;
return service.CreateSupportConceptStatistics(cb2scOid, ro.AccountingPeriodEnd);
//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)
{
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;
}
}
String name = String.Format("{0} {1}", pRO.CustomerSalutation, pRO.CustomerLastName);
if (c != null)
{
if (c.Person.InvoiceAddress != null)
{
if (!String.IsNullOrWhiteSpace(c.Person.InvoiceAddress.AddressLine1))
{
name = c.Person.InvoiceAddress.AddressLine1;
}
if (!String.IsNullOrWhiteSpace(c.Person.InvoiceAddress.Street))
{
pRO.CustomerStreet = c.Person.InvoiceAddress.Street;
}
if (!String.IsNullOrWhiteSpace(c.Person.InvoiceAddress.PostalCode))
{
pRO.CustomerPostalCode = c.Person.InvoiceAddress.PostalCode;
}
if (!String.IsNullOrWhiteSpace(c.Person.InvoiceAddress.Town))
{
pRO.CustomerTown = c.Person.InvoiceAddress.Town;
}
}
}
StringBuilder sb = new StringBuilder();
sb.AppendLine(name);
if (!String.IsNullOrEmpty(pRO.CustomerStreet))
{
sb.AppendLine(pRO.CustomerStreet);
}
sb.AppendLine(String.Format("{0} {1}", pRO.CustomerPostalCode, pRO.CustomerTown));
lblAdresse.Text = sb.ToString();
String nachname = "";
String anrede = "Sehr geehrte Familie";
if (pRO.InvoiceBase != null && !String.IsNullOrWhiteSpace(pRO.InvoiceBase.RecipientPersonLastName))
{
nachname = pRO.InvoiceBase.RecipientPersonLastName;
}
else
{
nachname = pRO.CustomerLastName;
}
lblAnrede.Text =
String.Format(
"{0} {1},\n\n\nfür die geleisteten Stunden im Bereich lerntherapeutische Intervention darf ich Ihnen in Rechnung stellen:",
anrede, nachname);
//txtMittelbindungsnr.Text = mnr;
}
}
}