Files
BeWoPlaner/ReportImp/WhbRefrath/SettlementReport2.cs
2022-03-11 13:32:42 +01:00

114 lines
3.7 KiB
C#

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using BeWo.Report.ReportObjects;
using BeWo.Report;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BS.Shared;
using System.Text;
namespace WhbRefrath
{
public partial class Spitzabrechnung : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<Settlement2RO>
{
public Spitzabrechnung()
{
InitializeComponent();
}
public void SetReportDataSource(Settlement2RO pRO)
{
StringBuilder sb = new StringBuilder();
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation))
{
sb.AppendLine(pRO.RecipientOrganisation);
}
if (!String.IsNullOrEmpty(pRO.RecipientContactPerson))
{
sb.AppendLine(pRO.RecipientContactPerson);
}
if (!String.IsNullOrEmpty(pRO.RecipientDivision))
{
sb.AppendLine(pRO.RecipientDivision);
}
if (!String.IsNullOrEmpty(pRO.RecipientStreet))
{
sb.AppendLine(pRO.RecipientStreet);
}
if (!String.IsNullOrEmpty(pRO.RecipientPostBox))
{
sb.AppendLine(String.Format("Postfach {0}", pRO.RecipientPostBox));
}
if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown))
{
sb.AppendLine(pRO.RecipientPostCodeAndTown);
}
lblAdresse.Text = sb.ToString();
if (String.IsNullOrEmpty(pRO.Notice))
{
lblNotice.Visible = false;
}
decimal rateFactor = 1;
foreach (var ii in pRO.InvoiceItems)
{
if (ii.RateFactor.HasValue)
{
rateFactor = (100 + ii.RateFactor.Value) / 100;
}
}
pRO.RateFactor = (double)rateFactor;
SetzeErweiterungen(pRO);
if (pRO.Claim < 0)
{
pRO.Claim = -pRO.Claim;
pRO.FinalSentence = "Bitte verrechnen Sie die Überzahlung mit künftigen Abschlägen.";
lblForderung.Text = "Überzahlung:";
}
this.bindingSource1.DataSource = pRO;
}
private void SetzeErweiterungen(Settlement2RO pRo)
{
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);
}
}
foreach (var scap in cb2sc.ApprovalPeriodList)
{
if (scap != null && scap.ServiceCategory != null && scap.ServiceCategory.Name.Contains("Assistenz"))
{
lblAssistenzStd.Text = String.Format("{0:0.00} FLS", scap.ApprovedBETotal);
lblAssistenz.Text = "Bewilligte Assistenzstunden gesamt:";
}
}
if (lblAssistenz.Text == "")
xrTableRow1.Visible = false;
}
}
}
}
}