140 lines
5.0 KiB
C#
140 lines
5.0 KiB
C#
using System;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using DevExpress.XtraReports.UI;
|
|
using BS.Shared.Core;
|
|
using FeidPartnerReports.Calculation;
|
|
|
|
namespace BeWo.FeidPartnerReports
|
|
{
|
|
[IDSpecificClass(Identifier = "Sammelrechnung")]
|
|
public partial class Sammelrechnung : XtraReport, IBeWoReport<ServiceInvoiceRO>
|
|
{
|
|
public Sammelrechnung()
|
|
{
|
|
this.InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServiceInvoiceRO pRO)
|
|
{
|
|
|
|
|
|
pRO.ServiceInvoicePeriods.Sort((a, b) => a.Customer.LastNameFirstName.CompareTo(b.Customer.LastNameFirstName));
|
|
|
|
BerechneKontingente(pRO);
|
|
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private void BerechneKontingente(ServiceInvoiceRO pRO)
|
|
{
|
|
var calc = new CustomCalculations();
|
|
|
|
decimal totalPerMonth = 0;
|
|
if (pRO.ServiceInvoicePeriods != null)
|
|
{
|
|
foreach (var sip in pRO.ServiceInvoicePeriods)
|
|
{
|
|
var c2s =
|
|
MapperFactory.SupportConceptCostBearerRelDC_CostBearer2SupportConcept.MapToNewDC(
|
|
sip.CostBearer2SupportConcept);
|
|
var scap =
|
|
MapperFactory.SupportConceptApprovalPeriodDC_SupportConceptApprovalPeriod.MapToNewDC(
|
|
sip.SupportConceptApprovalPeriod);
|
|
|
|
|
|
DateTime start = pRO.AccountingPeriodStart;
|
|
DateTime end = pRO.AccountingPeriodEnd;
|
|
|
|
if (scap.StartDate > start)
|
|
{
|
|
start = scap.StartDate.Value;
|
|
}
|
|
|
|
if (scap.EndDate < end)
|
|
{
|
|
end = scap.EndDate.Value;
|
|
}
|
|
|
|
|
|
var monate = DateTimeUtils.GetTotalMonths(start, end);
|
|
var stundenProMonat = calc.GetApprovedHoursForPeriod(c2s, scap, null, new DateTime(start.Year, start.Month, 1), new DateTime(start.Year, start.Month, 1).AddMonths(1).AddDays(-1), false) ?? 0;
|
|
|
|
var hours = monate.GanzeMonate * stundenProMonat;
|
|
if (monate.RestTageAnfang > 0)
|
|
{
|
|
if (start.Day > 15)
|
|
{
|
|
hours += stundenProMonat / 2;
|
|
}
|
|
else if (start.Day > 1)
|
|
{
|
|
hours += stundenProMonat;
|
|
}
|
|
}
|
|
if (monate.RestTageEnde > 0)
|
|
{
|
|
if (end.Day > 15)
|
|
{
|
|
hours += stundenProMonat;
|
|
}
|
|
else
|
|
{
|
|
hours += stundenProMonat / 2;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
totalPerMonth += hours;
|
|
|
|
//var total = calc.GetApprovedHoursForPeriod(c2s, scap, null, scap.StartDate, scap.EndDate, false);
|
|
sip.ApprovedHours = hours;
|
|
|
|
// Berechne gesamt Bewilligung
|
|
monate = DateTimeUtils.GetTotalMonths(scap.StartDate.Value, scap.EndDate.Value);
|
|
|
|
var gesamtStunden = monate.GanzeMonate * stundenProMonat;
|
|
if (monate.RestTageAnfang > 0)
|
|
{
|
|
if (scap.StartDate.Value.Day > 15)
|
|
{
|
|
gesamtStunden += stundenProMonat / 2;
|
|
}
|
|
else
|
|
{
|
|
gesamtStunden += stundenProMonat;
|
|
}
|
|
}
|
|
if (monate.RestTageEnde > 0)
|
|
{
|
|
if (scap.EndDate.Value.Day > 15)
|
|
{
|
|
gesamtStunden += stundenProMonat;
|
|
}
|
|
else
|
|
{
|
|
gesamtStunden += stundenProMonat / 2;
|
|
}
|
|
}
|
|
|
|
|
|
sip.ApprovedBE = String.Format("{0:0.00}", gesamtStunden);
|
|
//if (sip.SupportConceptApprovalPeriod.ApprovedBEPerInterval.HasValue)
|
|
//{
|
|
// var month = sip.SupportConceptApprovalPeriod.ApprovedBEPerInterval.Value / 12m;
|
|
// totalPerMonth += month;
|
|
//}
|
|
//if (sip.CostBearer2SupportConcept != null)
|
|
//{
|
|
// sip.SupportConceptApprovalPeriod.Notice = String.Format("{0:dd.MM.yyyy} - {1:dd.MM.yyyy}",
|
|
// sip.CostBearer2SupportConcept.StartDate, pRO.AccountingPeriodEnd);
|
|
//}
|
|
}
|
|
}
|
|
cellTotalPerMonth.Text = String.Format("{0:0.00}", totalPerMonth);
|
|
}
|
|
}
|
|
} |