184 lines
5.8 KiB
C#
184 lines
5.8 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 = "Sammelrechnung")]
|
|
public partial class Sammelrechnung : XtraReport, IBeWoReport<ServiceInvoiceRO>
|
|
{
|
|
public Sammelrechnung()
|
|
{
|
|
this.InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServiceInvoiceRO pRO)
|
|
{
|
|
if (pRO.InvoiceBase != null && pRO.InvoiceBase.RecipientOrganisationOid.HasValue)
|
|
{
|
|
var org = DAOFactory.GenericDAO.LoadByID<Organisation>(pRO.InvoiceBase.RecipientOrganisationOid.Value);
|
|
pRO.OrganisationDebitorNumber = org.DebitorNumber;
|
|
|
|
}
|
|
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);
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation))
|
|
{
|
|
sb.AppendLine(pRO.RecipientOrganisation);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientDivision))
|
|
{
|
|
sb.AppendLine(pRO.RecipientDivision);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientStreet))
|
|
{
|
|
sb.AppendLine(pRO.RecipientStreet);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown))
|
|
{
|
|
sb.AppendLine(pRO.RecipientPostCodeAndTown);
|
|
}
|
|
lblAdresse.Text = sb.ToString();
|
|
|
|
|
|
lblNachweisFuer.Text = String.Format("Sehr geehrte Damen und Herren,\r\n\r\nfür geleistete heilpädagogische Behandlung im Rahmen der Fachdienststunden für den {0} darf ich Ihnen in Rechnung stellen:",
|
|
pRO.RecipientOrganisation);
|
|
|
|
|
|
|
|
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)
|
|
{
|
|
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;
|
|
|
|
cellGesamtText.Text = String.Format("{0} Betreuungseinheiten á {1:c}", InvoiceHelper.GetUnitString(hours), hourlyRate);
|
|
cellGesamtSumme.Text = pRO.GrossClaim;
|
|
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)
|
|
{
|
|
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;
|
|
|
|
}
|
|
}
|
|
} |