Files
BeWoPlaner/ReportImp/WegweiserBetreuungsdienstReports/CustomReportCreator.cs

161 lines
5.5 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.DefaultReports;
using BeWo.Report.ReportObjects;
using BeWo.Service.DCEntityMapper;
using BS.Shared.DataContracts;
using DevExpress.XtraReports.UI;
namespace BeWo.WegweiserBetreuungsdienstReports
{
public class CustomReportCreator : DefaultReportCreator
{
public override XtraReport CreateServiceInvoiceReport(string dcIds, long? invoiceBaseOid)
{
IBeWoReport<ServiceInvoiceRO> allReports = null;
var dcList = new List<ServiceInvoiceDC>();
if (!invoiceBaseOid.HasValue && !string.IsNullOrEmpty(dcIds))
{
var dcidStrs = dcIds.Split(';');
foreach (var oidStr in dcidStrs)
{
var oid = long.Parse(oidStr);
var invoice = DAOFactory.GenericDAO.LoadByID<ServiceInvoice>(oid);
var dc = MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewDC(invoice);
dcList.Add(dc);
}
}
if (invoiceBaseOid.HasValue && invoiceBaseOid.Value > 0)
{
var ib = DAOFactory.GenericDAO.LoadByID<InvoiceBase>(invoiceBaseOid.Value);
var si = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(invoiceBaseOid.Value);
var dc = MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewDC(si);
dcList.Add(dc);
}
foreach (var idc in dcList)
{
IBeWoReport<ServiceInvoiceRO> singleReport = null;
if (idc.InvoiceBase.RecipientOrganisation.Contains("LVR") || idc.InvoiceBase.RecipientOrganisation.Contains("Stadt Trier")
|| idc.InvoiceBase.RecipientOrganisation.Contains("Stadt Halle") || idc.InvoiceBase.RecipientOrganisation.Contains("Jugendhilfe")
|| (!String.IsNullOrEmpty(idc.InvoiceBase.RecipientDivision) && idc.InvoiceBase.RecipientDivision.Contains("Jugendhilfe")))
{
singleReport = new ServiceInvoiceReport();
}
else if (idc.InvoiceBase.RecipientOrganisation.Contains("Stadt Willich"))
singleReport = new RechnungSPFH();
else
{
singleReport = new RechnungKrankenkasse();
}
singleReport.SetReportDataSource(ServiceInvoiceRO.Create(idc));
((XtraReport)singleReport).CreateDocument();
if (allReports == null)
allReports = singleReport;
else
((XtraReport)allReports).Pages.AddRange(((XtraReport)singleReport).Pages);
}
if (allReports == null)
{
return new XtraReport();
}
return allReports as XtraReport;
}
public override XtraReport CreateServiceOverviewAllCustomersReport(int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay)
{
List<ServicesOverviewRO> lROs = ServicesOverviewRO.Create(month, year, orgaOid, empOid, startDay, endDay, serviceCategoryOid);
if (lROs.Count > 0)
{
var rootReport = CreateServicesOverviewReportForRo(lROs[0], serviceCategoryOid);
rootReport.CreateDocument();
for (int i = 1; i < lROs.Count; i++)
{
var lNext = CreateServicesOverviewReportForRo(lROs[i], serviceCategoryOid);
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.Create(customerOid, month, year, false, orgaOid, empOid, startDay, endDay, serviceCategoryOid);
return CreateServicesOverviewReportForRo(ro, serviceCategoryOid);
}
public override XtraReport CreateReportForServicesOverviewRo(ServicesOverviewRO ro, string reportId)
{
return CreateServicesOverviewReportForRo(ro, null);
}
private XtraReport CreateServicesOverviewReportForRo(ServicesOverviewRO ro, long? serviceCategoryOid)
{
XtraReport report = null;
ServicesOverviewRO bewoRo = ServicesOverviewRO.CopyFromRO(ro);
ServicesOverviewRO spfhRo = ServicesOverviewRO.CopyFromRO(ro);
ServicesOverviewRO sozioRo = ServicesOverviewRO.CopyFromRO(ro);
if (ro.Services != null)
{
foreach (ServicesOverviewRO.ServiceDetail s in ro.Services)
{
if (s.ServiceCategory.Contains("Sozialpädagogische") && s.ServiceCategory.Contains("Familien") && s.ServiceCategory.ToLower().Contains("hilfe"))
{
spfhRo.Services.Add(s);
}
else if (s.ServiceCategory.ToLower().Contains("soziotherapie") || s.ServiceCategory.ToLower().Contains("soziotherapeutisch"))
{
sozioRo.Services.Add(s);
}
else
{
bewoRo.Services.Add(s);
}
}
}
report = AddSubServicesOverviewReportToReport(report, new Leistungsnachweis(), spfhRo);
if (ro.Costbearer == "DDG GmbH")
{
report = AddSubServicesOverviewReportToReport(report, new StundenzettelDdg(), bewoRo);
}
else if (ro.Costbearer.Contains("LVR") || ro.Costbearer.Contains("LVR II"))
{
report = AddSubServicesOverviewReportToReport(report, new QuittierungsbelegLVR(), bewoRo);
}
else
{
report = AddSubServicesOverviewReportToReport(report, new Stundenzettel(), bewoRo);
}
report = AddSubServicesOverviewReportToReport(report, new LeistungsnachweisSoziotherapie(), sozioRo);
if (report == null)
report = new XtraReport();
return report;
}
}
}