201 lines
7.9 KiB
C#
201 lines
7.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace SPZLeverkusen
|
|
{
|
|
public class CustomReportCreator : DefaultReportCreator
|
|
{
|
|
public override XtraReport CreateServiceOverviewAllCustomersReport(int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay)
|
|
{
|
|
List<ServicesOverviewRO> lROs = ServicesOverviewRO.CreateAlt(month, year, orgaOid, empOid, startDay, endDay);
|
|
if (lROs != null && lROs.Count > 0)
|
|
lROs = lROs.OrderBy(ro => ro.CustomerLastName).ToList();
|
|
|
|
if (lROs.Count > 0)
|
|
{
|
|
var rootReport = CreateServicesOverviewReportForRo(lROs[0], serviceCategoryOid);
|
|
if (rootReport.Pages.Count == 0)
|
|
rootReport.CreateDocument();
|
|
|
|
for (int i = 1; i < lROs.Count; i++)
|
|
{
|
|
var lNext = CreateServicesOverviewReportForRo(lROs[i], serviceCategoryOid);
|
|
if (lNext.Pages.Count == 0)
|
|
lNext.CreateDocument();
|
|
rootReport.Pages.AddRange(lNext.Pages);
|
|
}
|
|
|
|
return rootReport;
|
|
}
|
|
return new XtraReport();
|
|
}
|
|
|
|
public override XtraReport CreateServiceOverviewSingleCustomerReport(long customerOid, int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay)
|
|
{
|
|
var ro = ServicesOverviewRO.CreateAlt(customerOid, month, year, false, orgaOid, empOid, startDay, endDay, serviceCategoryOid);
|
|
|
|
if (ro.Services != null && ro.Services.Count == 0)
|
|
ro = CreateLeerenEintragFuerRO(ro);
|
|
|
|
return CreateServicesOverviewReportForRo(ro, serviceCategoryOid);
|
|
|
|
}
|
|
|
|
public override XtraReport CreateServiceOverviewReportForCustomers(IList<long> customerOids, int month, int year, long? orgaOid, long? empOid, long? serviceCategoryOid, int startDay, int endDay, bool nurFehlende)
|
|
{
|
|
var roList = new List<ServicesOverviewRO>();
|
|
|
|
foreach (var coid in customerOids)
|
|
{
|
|
var ro = ServicesOverviewRO.CreateAlt(coid, month, year, false, orgaOid ?? 0, empOid ?? 0, startDay, endDay, serviceCategoryOid);
|
|
if (ro.Services != null && ro.Services.Count == 0)
|
|
ro = CreateLeerenEintragFuerRO(ro);
|
|
|
|
if (ro != null)
|
|
{
|
|
roList.Add(ro);
|
|
}
|
|
}
|
|
|
|
if (roList.Count > 0)
|
|
{
|
|
if (roList != null && roList.Count > 0)
|
|
roList = roList.OrderBy(ro => ro.CustomerLastName).ToList();
|
|
|
|
var rootReport = CreateServicesOverviewReportForRo(roList[0], serviceCategoryOid);
|
|
if (rootReport.Pages.Count == 0)
|
|
rootReport.CreateDocument();
|
|
|
|
for (int i = 1; i < roList.Count; i++)
|
|
{
|
|
var lNext = CreateServicesOverviewReportForRo(roList[i], serviceCategoryOid);
|
|
if (lNext.Pages.Count == 0)
|
|
lNext.CreateDocument();
|
|
rootReport.Pages.AddRange(lNext.Pages);
|
|
}
|
|
|
|
return rootReport;
|
|
}
|
|
return new XtraReport();
|
|
|
|
}
|
|
|
|
private ServicesOverviewRO CreateLeerenEintragFuerRO(ServicesOverviewRO ro)
|
|
{
|
|
var scs = DAOFactory.SearchDAO.GetAllActiveSupportConceptsByCustomers(new List<long>() { ro.CustomerOid }, false).ToList();
|
|
|
|
if (scs != null && scs.Count == 0)
|
|
return ro;
|
|
else if (scs != null && scs.Count >= 1)
|
|
{
|
|
ro.Costbearer = scs[0].CostBearer2SupportConceptList[0] != null ? scs[0].CostBearer2SupportConceptList[0].CostBearer.Organisation.Name : null;
|
|
ro.Services.Add(new ServicesOverviewRO.ServiceDetail() { Minutes = 0, ServiceDescription = "Keine Einträge in diesem Monat"});
|
|
}
|
|
|
|
return ro;
|
|
}
|
|
|
|
private XtraReport CreateServicesOverviewReportForRo(ServicesOverviewRO ro, long? serviceCategoryOid)
|
|
{
|
|
XtraReport report = null;
|
|
|
|
ServicesOverviewRO jugendamtRO = ServicesOverviewRO.CopyFromRO(ro);
|
|
ServicesOverviewRO ohneFehlkontaktenRO = ServicesOverviewRO.CopyFromRO(ro);
|
|
ServicesOverviewRO mitFehlkontaktenRO = ServicesOverviewRO.CopyFromRO(ro);
|
|
|
|
jugendamtRO.TotalFLMBillable = 0;
|
|
jugendamtRO.TotalFLS = 0;
|
|
ohneFehlkontaktenRO.TotalFLMBillable = 0;
|
|
ohneFehlkontaktenRO.TotalFLS = 0;
|
|
mitFehlkontaktenRO.TotalFLMBillable = 0;
|
|
mitFehlkontaktenRO.TotalFLS = 0;
|
|
|
|
if (ro.Services != null)
|
|
{
|
|
foreach (ServicesOverviewRO.ServiceDetail s in ro.Services)
|
|
{
|
|
if (!String.IsNullOrEmpty(ro.Costbearer) && ro.Costbearer.Contains("Jugendamt"))
|
|
{
|
|
jugendamtRO.Services.Add(s);
|
|
jugendamtRO.TotalFLMBillable += s.Minutes;
|
|
jugendamtRO.TotalFLS += s.Minutes / 60;
|
|
}
|
|
else if (!s.ServiceDescription.ToLower().Contains("fehlkontakt"))
|
|
{
|
|
ohneFehlkontaktenRO.Services.Add(s);
|
|
ohneFehlkontaktenRO.TotalFLMBillable += s.Minutes;
|
|
ohneFehlkontaktenRO.TotalFLS += s.Minutes / 60;
|
|
}
|
|
else if (s.ServiceDescription.ToLower().Contains("fehlkontakt"))
|
|
{
|
|
mitFehlkontaktenRO.Services.Add(s);
|
|
mitFehlkontaktenRO.TotalFLMBillable += s.Minutes;
|
|
mitFehlkontaktenRO.TotalFLS += s.Minutes / 60;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (report == null)
|
|
{
|
|
if (!String.IsNullOrEmpty(ro.Costbearer) && ro.Costbearer.Contains("Jugendamt"))
|
|
{
|
|
report = AddReportToReport<StundenzettelJugendamt>(report, jugendamtRO);
|
|
}
|
|
else
|
|
{
|
|
if (ro.StartDate < new DateTime(2019, 1, 1))
|
|
{
|
|
report = AddReportToReport<Stundenzettel>(report, ohneFehlkontaktenRO);
|
|
}
|
|
else
|
|
{
|
|
report = AddReportToReport<Quittierungsbeleg2>(report, ohneFehlkontaktenRO);
|
|
}
|
|
|
|
if (mitFehlkontaktenRO.TotalFLS > 0)
|
|
report = AddReportToReport<QuittierungsbelegMitFehlkontakten>(report, mitFehlkontaktenRO);
|
|
}
|
|
}
|
|
|
|
|
|
if (report == null)
|
|
report = new XtraReport();
|
|
return report;
|
|
}
|
|
|
|
private XtraReport AddReportToReport<T>(XtraReport report, ServicesOverviewRO ro) where T : XtraReport, IBeWoReport<ServicesOverviewRO>, new()
|
|
{
|
|
if (ro.Services.Count > 0)
|
|
{
|
|
if (report == null)
|
|
{
|
|
report = new T();
|
|
((T)report).SetReportDataSource(ro);
|
|
report.CreateDocument();
|
|
}
|
|
else
|
|
{
|
|
if (report.Pages.Count == 0)
|
|
{
|
|
report.CreateDocument();
|
|
}
|
|
|
|
XtraReport newReport = new T();
|
|
((T)newReport).SetReportDataSource(ro);
|
|
|
|
newReport.CreateDocument();
|
|
report.Pages.AddRange(newReport.Pages);
|
|
}
|
|
}
|
|
return report;
|
|
}
|
|
}
|
|
}
|