138 lines
5.0 KiB
C#
138 lines
5.0 KiB
C#
using System;
|
|
using System.Text;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BeWo.Service.Plugins;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.Services;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace KollegiumEv
|
|
{
|
|
[IDSpecificClass(Identifier = "Fachleistung")]
|
|
public partial class RechnungFls : XtraReport, IBeWoReport<ServiceInvoiceRO>
|
|
{
|
|
public RechnungFls()
|
|
{
|
|
this.InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServiceInvoiceRO pRO)
|
|
{
|
|
foreach (var sip in pRO.ServiceInvoicePeriods)
|
|
{
|
|
foreach (var item in sip.ServiceInvoiceItems)
|
|
{
|
|
if (item.RateFactor != null && !item.RateFactor.Contains("%"))
|
|
item.ServiceDescription += " (Fehlkontakte)";
|
|
}
|
|
}
|
|
|
|
if (pRO.CustomerSalutation == "Herr")
|
|
{
|
|
pRO.CustomerSalutation = "Herrn";
|
|
}
|
|
|
|
if (pRO.AccountingPeriodStart.Month == pRO.AccountingPeriodEnd.Month && pRO.AccountingPeriodStart.Year == pRO.AccountingPeriodEnd.Year)
|
|
{
|
|
lblKostenzusage.Text = String.Format("Abrechnung {0:MMMM yyyy}", pRO.AccountingPeriodStart);
|
|
}
|
|
else
|
|
{
|
|
lblKostenzusage.Text = String.Format("Abrechnung {0:MMMM yyyy} bis {1:MMMM yyyy}", pRO.AccountingPeriodStart, pRO.AccountingPeriodEnd);
|
|
}
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation))
|
|
{
|
|
pRO.RecipientOrganisation = pRO.RecipientOrganisation.Replace("Assistenz", "").Trim();
|
|
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.RecipientPoBox))
|
|
{
|
|
sb.AppendLine(pRO.RecipientPoBox);
|
|
}
|
|
|
|
if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown))
|
|
{
|
|
sb.AppendLine(pRO.RecipientPostCodeAndTown);
|
|
}
|
|
lblAdresse.Text = sb.ToString();
|
|
|
|
SetBewilligung(pRO);
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private void SetBewilligung(ServiceInvoiceRO pRO)
|
|
{
|
|
DateTime? date = null;
|
|
|
|
decimal geleistetGesamt = 0;
|
|
decimal bewilligtWoche = 0;
|
|
decimal bewilligtGesamt = 0;
|
|
var calc = PluginLoader.FindClass<Calculations>();
|
|
|
|
DateTime start = pRO.AccountingPeriodStart;
|
|
DateTime end = pRO.AccountingPeriodEnd;
|
|
|
|
foreach (var sip in pRO.ServiceInvoicePeriods)
|
|
{
|
|
if (sip.SupportConceptApprovalPeriod != null && sip.CostBearer2SupportConcept != null)
|
|
{
|
|
if (sip.SupportConceptApprovalPeriod.StartDate.HasValue &&
|
|
sip.SupportConceptApprovalPeriod.StartDate < start)
|
|
{
|
|
start = sip.SupportConceptApprovalPeriod.StartDate.Value;
|
|
}
|
|
if (sip.SupportConceptApprovalPeriod.EndDate.HasValue &&
|
|
sip.SupportConceptApprovalPeriod.EndDate > end)
|
|
{
|
|
end = sip.SupportConceptApprovalPeriod.EndDate.Value;
|
|
}
|
|
|
|
var scapdc = MapperFactory.SupportConceptApprovalPeriodDC_SupportConceptApprovalPeriod.MapToNewDC(sip.SupportConceptApprovalPeriod);
|
|
var c2sdc =
|
|
MapperFactory.SupportConceptCostBearerRelDC_CostBearer2SupportConcept.MapToNewDC(
|
|
sip.CostBearer2SupportConcept);
|
|
|
|
bewilligtGesamt += calc.GetApprovedHoursTotal(scapdc, c2sdc.CostBearer.CostRatePeriods) ?? 0;
|
|
bewilligtWoche += calc.GetApprovedHoursPerWeek(scapdc, c2sdc.CostBearer.CostRatePeriods) ?? 0;
|
|
|
|
var sc = sip.SupportConceptApprovalPeriod.CostBearer2SupportConcept.SupportConcept;
|
|
|
|
date = sc.ApprovalDate;
|
|
}
|
|
|
|
foreach (var ii in sip.ServiceInvoiceItems)
|
|
{
|
|
geleistetGesamt += ii.Hours ?? 0;
|
|
}
|
|
}
|
|
|
|
pRO.AccountingPeriod = String.Format("{0:dd.MM.yyyy} bis {1:dd.MM.yyyy}", start, end);
|
|
|
|
lblBewilligungsZeitraum.Text = String.Format("Bewilligte Stunden vom {0}: {1:0.##} Stunden", pRO.AccountingPeriod, bewilligtGesamt);
|
|
|
|
|
|
pRO.ApprovedBESum = String.Format("{0:0.00}", bewilligtGesamt);
|
|
|
|
|
|
}
|
|
}
|
|
} |