323 lines
11 KiB
C#
323 lines
11 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
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 = "IFS")]
|
|
public partial class IfsRechnung : XtraReport, IBeWoReport<ServiceInvoiceRO>
|
|
{
|
|
public IfsRechnung()
|
|
{
|
|
this.InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServiceInvoiceRO pRO)
|
|
{
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation))
|
|
{
|
|
if (pRO.RecipientOrganisation.EndsWith(" - IFS"))
|
|
{
|
|
pRO.RecipientOrganisation = pRO.RecipientOrganisation.Replace(" - IFS", "").Trim();
|
|
}
|
|
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("Klient/in: {0}, geb. am {1:dd.MM.yyyy}",
|
|
pRO.CustomerName, pRO.CustomerBirthdate);
|
|
|
|
lblMonatJahr.Text = String.Format("Abrechnungsmonat:: {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 rateFactor = 1;
|
|
ServiceInvoiceItemRO pauschaleItem = null;
|
|
|
|
Dictionary<String, LeistungsBetrag> summen = new Dictionary<string, LeistungsBetrag>();
|
|
|
|
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.ServiceDescription == "Pauschale für Teamsitzung")
|
|
{
|
|
pauschaleItem = i;
|
|
}
|
|
else
|
|
{
|
|
|
|
|
|
i.CustomerFirstname = "";
|
|
i.CustomerLastname = "";
|
|
i.ServiceDescription = "";
|
|
|
|
String key = "";
|
|
String summenName = "";
|
|
|
|
if (i.ServiceRecord != null)
|
|
{
|
|
key = String.Format("{0}_{1:c}", i.ServiceRecord.ServiceDescription.Name,
|
|
i.HourlyRate);
|
|
summenName = i.ServiceRecord.ServiceDescription.Name;
|
|
|
|
i.ServiceDescription = i.ServiceRecord.ServiceDescription.CategoryName
|
|
.Replace("IFS -", "").Trim();
|
|
|
|
if (i.ServiceRecord.ServiceDescription.Name.ToLower().Contains("mobil"))
|
|
{
|
|
i.CustomerFirstname = "x";
|
|
}
|
|
else if (i.ServiceRecord.ServiceDescription.Name.ToLower().Contains("ambulant"))
|
|
{
|
|
i.CustomerLastname = "x";
|
|
}
|
|
}
|
|
|
|
if (i.UnitCount.HasValue)
|
|
{
|
|
i.UnitCountString = InvoiceHelper.GetUnitString(i.UnitCount);
|
|
}
|
|
|
|
LeistungsBetrag betrag = null;
|
|
|
|
if (!summen.ContainsKey(key))
|
|
{
|
|
betrag = new LeistungsBetrag();
|
|
betrag.Leistung = summenName;
|
|
betrag.Stundensatz = i.HourlyRate ?? 0;
|
|
summen.Add(key, betrag);
|
|
}
|
|
else
|
|
{
|
|
betrag = summen[key];
|
|
}
|
|
|
|
|
|
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;
|
|
}
|
|
|
|
betrag.Stunden += i.Hours ?? 0;
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if (pauschaleItem == null)
|
|
{
|
|
lblBezeichnungTeam.Visible = false;
|
|
lblGleichTeam.Visible = false;
|
|
lblBetragTeamsitzung.Visible = false;
|
|
tableSummen.Top -= 30;
|
|
}
|
|
else
|
|
{
|
|
lblBetragTeamsitzung.Text = String.Format("{0:0.00} Euro", pauschaleItem.NetAmount);
|
|
}
|
|
|
|
ErstelleSummenTabelle(summen.Values.OrderBy(s => s.Leistung).ToList());
|
|
|
|
cellClaimGesamt.Text = String.Format("{0} Euro", pRO.NetClaim.Replace("€", "").Trim());
|
|
|
|
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private void ErstelleSummenTabelle(IList<LeistungsBetrag> summen)
|
|
{
|
|
int index = 0;
|
|
foreach (var summe in summen)
|
|
{
|
|
DevExpress.XtraReports.UI.XRTableRow row = null;
|
|
if (index < tableSummen.Rows.Count - 1)
|
|
{
|
|
row = tableSummen.Rows[index];
|
|
}
|
|
else
|
|
{
|
|
row = tableSummen.InsertRowBelow(tableSummen.Rows[tableSummen.Rows.Count - 2]);
|
|
}
|
|
|
|
row.Cells[0].Text = summe.Leistung;
|
|
|
|
row.Cells[1].Text = String.Format("{0:0.00} Stunden x", InvoiceHelper.GetUnitString(summe.Stunden));
|
|
row.Cells[2].Text = String.Format("{0:0.00} Euro", summe.Stundensatz);
|
|
row.Cells[3].Text = "=";
|
|
row.Cells[4].Text = String.Format("{0:0.00} Euro", summe.Stunden * summe.Stundensatz);
|
|
|
|
index++;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
}
|
|
|
|
internal class LeistungsBetrag
|
|
{
|
|
public String Leistung { get; set; }
|
|
public decimal Stunden { get; set; }
|
|
public decimal Stundensatz { get; set; }
|
|
}
|
|
} |