112 lines
3.1 KiB
C#
112 lines
3.1 KiB
C#
using System;
|
|
using System.Linq;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BS.Shared;
|
|
using BS.Shared.Extensions;
|
|
|
|
namespace PerspektiveSL
|
|
{
|
|
public partial class Spitzabrechnung : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<Settlement2RO>
|
|
{
|
|
public Spitzabrechnung()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(Settlement2RO pRO)
|
|
{
|
|
decimal rateFactor = 1;
|
|
|
|
//foreach (var ii in pRO.InvoiceItems)
|
|
//{
|
|
|
|
// ii.DetailDescription = String.Format("{0:dd.MM.yyyy} bis {1:dd.MM.yyyy}: {2:0.##} FLS {4}x {3:c}",
|
|
// ii.PeriodStartDate,
|
|
// ii.PeriodEndDate,
|
|
// ii.UnitCount,
|
|
// ii.AmountPerUnit,
|
|
// ii.RateFactor.HasValue && ii.RateFactor.Value != 0 ? String.Format("x {0:0.##} ", (ii.RateFactor + 100) / 100) : "");
|
|
|
|
// if (ii.RateFactor.HasValue)
|
|
// {
|
|
// rateFactor = (100 + ii.RateFactor.Value) / 100;
|
|
// }
|
|
//}
|
|
//pRO.RateFactor = (double)rateFactor;
|
|
|
|
foreach (var ii in pRO.InvoiceItems)
|
|
{
|
|
if (ii.RateFactor.HasValue)
|
|
{
|
|
rateFactor = (100 + ii.RateFactor.Value) / 100;
|
|
}
|
|
|
|
if (!pRO.FehlkontakteString.IsNullOrEmpty() && ii.RateFactor == 0)
|
|
{
|
|
Zwischensumme.Visible = true;
|
|
//if (!ii.ItemDescription.IsNullOrEmpty())
|
|
//{
|
|
//ii.AbrechnungsText = Regex.Replace(ii.DetailDescription, ii.ItemDescription, "Fehlkontakte");
|
|
//}
|
|
ii.AbrechnungsText = ii.AbrechnungsText.Replace("FLS", "Std.");
|
|
ii.ItemDescription = "Fehlkontakte";
|
|
}
|
|
else if (ii.ItemDescription.IsNullOrEmpty())
|
|
{
|
|
ii.ItemDescription = "Fachleistungsstunden";
|
|
}
|
|
}
|
|
|
|
if (pRO.InvoiceBaseOid.HasValue)
|
|
{
|
|
var ib = DAOFactory.GenericDAO.LoadByID<InvoiceBase>(pRO.InvoiceBaseOid.Value);
|
|
if (ib.CostBearer2SupportConcept != null)
|
|
{
|
|
var cb2sc = ib.CostBearer2SupportConcept;
|
|
if (!String.IsNullOrEmpty(pRO.RecipientContactPerson))
|
|
{
|
|
if (cb2sc.CostBearerContactPerson != null && cb2sc.CostBearerContactPerson.Sex.HasValue)
|
|
{
|
|
string anrede = "Sehr geehrte Frau";
|
|
|
|
if (cb2sc.CostBearerContactPerson.Sex.Value == Sex.Male)
|
|
anrede = "Sehr geehrter Herr";
|
|
|
|
lblAnrede.Text = String.Format("{0} {1},", anrede, cb2sc.CostBearerContactPerson.LastName);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (pRO.Claim < 0)
|
|
{
|
|
pRO.FinalSentence = "";
|
|
}
|
|
|
|
if (!HatGruppen(pRO))
|
|
lblGruppe.Text = String.Format("{0} {1} hat nicht an Gruppenangeboten teilgenommen.", pRO.Salutation1, pRO.CustomerLastName);
|
|
|
|
if (pRO.FehlkontakteString != null && pRO.FehlkontakteString.Length > 0)
|
|
pRO.FehlkontakteString += " - Fehlkontakte werden von uns mit 80% des Stundensatzes abgerechnet.";
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private bool HatGruppen(Settlement2RO pRO)
|
|
{
|
|
if (pRO.InvoiceBaseOid.HasValue)
|
|
{
|
|
var ib = DAOFactory.GenericDAO.LoadByID<InvoiceBase>(pRO.InvoiceBaseOid.Value);
|
|
var cb2sc = ib.CostBearer2SupportConcept;
|
|
|
|
return cb2sc.ServiceRecords.Any(s => s.GroupOid.HasValue && s.GroupOid.Value > 0);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|