179 lines
9.4 KiB
C#
179 lines
9.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using AwoDortmund.Invoicing;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Report.ReportObjects;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.DataContracts.Compact;
|
|
|
|
namespace BeWo.Report.DefaultReports
|
|
{
|
|
public partial class SonderFinanzauswertung : DevExpress.XtraReports.UI.XtraReport//, IBeWoReport<FinanceRO>
|
|
{
|
|
public SonderFinanzauswertung()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(FinanceRO pRO)
|
|
{
|
|
pRO.CalculateBillableAmountInReportTimeSpan();
|
|
|
|
if (pRO.ReportStartDate.HasValue && pRO.ReportEndDate.HasValue)
|
|
{
|
|
DateTime start = pRO.ReportStartDate.Value;
|
|
DateTime end = pRO.ReportEndDate.Value;
|
|
DateTimeSpan lastMonth = new DateTimeSpan();
|
|
lastMonth.StartDateTime = start;
|
|
lastMonth.EndDateTime = end.AddDays(1).AddTicks(-1);
|
|
|
|
if (start.Year == end.Year && start.Month == end.Month && start.Day == 1 &&
|
|
end.Day == DateTime.DaysInMonth(end.Year, end.Month))
|
|
{
|
|
lblTitel.Text = String.Format("Finanzauswertung {0:MMMM yyyy}", start);
|
|
cellBewilligtImZeitraumHeader.Text = String.Format("bewilligte FLS {0:MMMM}", start);
|
|
cellGeleistetImZeitraumHeader.Text = String.Format("geleistete Std. {0:MMMM}", start);
|
|
}
|
|
else
|
|
{
|
|
lblTitel.Text = String.Format("Finanzauswertung {0:dd.MM.yyyy}-{1:dd.MM.yyyy}", start, end);
|
|
cellBewilligtImZeitraumHeader.Text = String.Format("bewilligte FLS {0:dd.MM.yyyy}-{1:dd.MM.yyyy}", start, end);
|
|
cellGeleistetImZeitraumHeader.Text = String.Format("geleistete Std. {0:dd.MM.yyyy}-{1:dd.MM.yyyy}", start, end);
|
|
if (start.Year != end.Year || start.Month != end.Month)
|
|
lastMonth.StartDateTime = new DateTime(end.Year, end.Month, 1);
|
|
}
|
|
//if (pRO.RateFactor.HasValue)
|
|
//{
|
|
// cellRateFactorHeader.Text = String.Format("geleistete Std. x {0:0.##}", pRO.RateFactor);
|
|
//}
|
|
//else
|
|
//{
|
|
// cellRateFactorHeader.Visible = false;
|
|
// cellRateFactor.Visible = false;
|
|
//}
|
|
|
|
if (pRO.SupportConceptFinanceList != null)
|
|
{
|
|
var listLength = pRO.SupportConceptFinanceList.Count;
|
|
|
|
for (int i = listLength - 1; i >= 0; i--)
|
|
{
|
|
var scRo = pRO.SupportConceptFinanceList[i];
|
|
if (scRo.Costbearer2Supportconcept != null)
|
|
{
|
|
String kst = GetKostenstelle(scRo);
|
|
|
|
if (String.IsNullOrEmpty(kst) || kst.Contains("610900"))
|
|
{
|
|
scRo.Custom5 = "Kostenstelle 610900 - BEWO";
|
|
}
|
|
else if (kst.Contains("610910"))
|
|
{
|
|
scRo.Custom5 = "Kostenstelle 610910 - offener Treff";
|
|
}
|
|
else if (kst.Contains("610915"))
|
|
{
|
|
scRo.Custom5 = "Kostenstelle 610915 - Assistenzdienst";
|
|
}
|
|
else if (kst.Contains("610905"))
|
|
{
|
|
scRo.Custom5 = "Kostenstelle 610905 - Soziotherapie";
|
|
}
|
|
else
|
|
{
|
|
scRo.Custom5 = String.Format("Kostenstelle {0}", kst);
|
|
}
|
|
var invoices = DAOFactory.SearchDAO.GetServiceInvoices(scRo.Costbearer2Supportconcept.CostBearer2SupportConceptOid.Value, lastMonth);
|
|
// Splitten der Zeilen für die Krankenkassen
|
|
if (!String.IsNullOrEmpty(kst) && kst.Contains("610915"))
|
|
{
|
|
var count = 0;
|
|
var invCount = 0;
|
|
foreach (var ii in invoices)
|
|
{
|
|
if (ii.IsActive.Equals(ActivationTypeId.Active))
|
|
invCount += 1;
|
|
}
|
|
|
|
foreach (var ii in invoices)
|
|
{
|
|
if (ii.IsActive.Equals(ActivationTypeId.Active))
|
|
{
|
|
count += 1;
|
|
if (count == 1)
|
|
{
|
|
scRo.Custom1 = ii.InvoiceBase.InvoiceNumber.ToString();
|
|
if (invCount > 1)
|
|
{
|
|
scRo.ApprovedHoursInReportTimeSpan = 0;
|
|
scRo.BillableHoursInReportTimeSpanWithFactor = 0;
|
|
scRo.BillableAmountInReportTimeSpan = (decimal)ii.GetTotalClaim();
|
|
if (ii.ServiceInvoicePeriodList != null && ii.ServiceInvoicePeriodList.Count > 0 && ii.ServiceInvoicePeriodList[0].InvoiceItemList != null)
|
|
{
|
|
scRo.BillableHoursInReportTimeSpan = ii.ServiceInvoicePeriodList[0].InvoiceItemList[0].UnitCount ?? 0;
|
|
scRo.HourlyRate = ii.ServiceInvoicePeriodList[0].InvoiceItemList[0].AmountPerUnit ?? 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (count > 1)
|
|
{
|
|
var ro = new FinanceRO.SupportConceptFinanceRO();
|
|
ro.CustomerName = scRo.CustomerName;
|
|
ro.CostBearerName = scRo.CostBearerName;
|
|
ro.SupportConceptApprovalPeriod = scRo.SupportConceptApprovalPeriod;
|
|
ro.Custom5 = scRo.Custom5;
|
|
ro.Custom1 = ii.InvoiceBase.InvoiceNumber.ToString();
|
|
ro.BillableAmountInReportTimeSpan = (decimal)ii.GetTotalClaim();
|
|
if (ii.ServiceInvoicePeriodList != null && ii.ServiceInvoicePeriodList.Count > 0 && ii.ServiceInvoicePeriodList[0].InvoiceItemList != null)
|
|
{
|
|
ro.BillableHoursInReportTimeSpan = ii.ServiceInvoicePeriodList[0].InvoiceItemList[0].UnitCount ?? 0;
|
|
ro.HourlyRate = ii.ServiceInvoicePeriodList[0].InvoiceItemList[0].AmountPerUnit ?? 0;
|
|
}
|
|
pRO.SupportConceptFinanceList.Add(ro);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
foreach (var ii in invoices)
|
|
{
|
|
if (ii.IsActive.Equals(ActivationTypeId.Active))
|
|
{
|
|
scRo.Custom1 = ii.InvoiceBase.InvoiceNumber.ToString();
|
|
if (!String.IsNullOrEmpty(kst) && kst.Contains("610905"))
|
|
{
|
|
if (ii.ServiceInvoicePeriodList != null && ii.ServiceInvoicePeriodList.Count > 0 && ii.ServiceInvoicePeriodList[0].InvoiceItemList != null)
|
|
{
|
|
scRo.HourlyRate = ii.ServiceInvoicePeriodList[0].InvoiceItemList[0].AmountPerUnit ?? 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
cellBewilligtImZeitraumHeader.Visible = false;
|
|
cellBewilligteFLSImBereich.Visible = false;
|
|
cellGeleistetImBereich.Visible = false;
|
|
cellGeleistetImZeitraumHeader.Visible = false;
|
|
cellRateFactorHeader.Visible = false;
|
|
cellRateFactor.Visible = false;
|
|
}
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private string GetKostenstelle(FinanceRO.SupportConceptFinanceRO scRo)
|
|
{
|
|
return scRo.Costbearer2Supportconcept.SupportConcept.Customer.CostCenter;
|
|
}
|
|
}
|
|
}
|