109 lines
3.2 KiB
C#
109 lines
3.2 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 BeWo.Service.DCEntityMapper;
|
|
using BS.Shared.DataContracts;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace BeWo.IBPReports
|
|
{
|
|
public class IBPReportCreator : DefaultReportCreator
|
|
{
|
|
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);
|
|
|
|
if (lROs.Count > 0)
|
|
{
|
|
String reportId = null;
|
|
if (orgaOid > 0)
|
|
{
|
|
var organisation = DAOFactory.GenericDAO.LoadByID<Organisation>(orgaOid);
|
|
if (organisation != null)
|
|
reportId = organisation.Name;
|
|
}
|
|
|
|
|
|
var rootReport = CreateServicesOverviewReportForRo(lROs[0], reportId);
|
|
rootReport.CreateDocument();
|
|
|
|
for (int i = 1; i < lROs.Count; i++)
|
|
{
|
|
var lNext = CreateServicesOverviewReportForRo(lROs[i], reportId);
|
|
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)
|
|
{
|
|
String reportId = null;
|
|
if (orgaOid > 0)
|
|
{
|
|
var organisation = DAOFactory.GenericDAO.LoadByID<Organisation>(orgaOid);
|
|
if (organisation != null)
|
|
reportId = organisation.Name;
|
|
}
|
|
|
|
var ro = ServicesOverviewRO.Create(customerOid, month, year, false, orgaOid, empOid, startDay, endDay, serviceCategoryOid);
|
|
|
|
return CreateServicesOverviewReportForRo(ro, reportId);
|
|
|
|
}
|
|
|
|
private XtraReport CreateServicesOverviewReportForRo(ServicesOverviewRO ro, String reportId)
|
|
{
|
|
IBeWoReport<ServicesOverviewRO> report = null;
|
|
|
|
foreach (var s in ro.Services)
|
|
{
|
|
if (report == null && s.ServiceCategory.Contains("BeWo 67"))
|
|
report = new BeWo.IBPReports.StundenzettelBeWo67();
|
|
}
|
|
if (report == null)
|
|
report = new BeWo.IBPReports.Stundenzettel();
|
|
report.SetReportDataSource(ro);
|
|
|
|
return report as XtraReport;
|
|
}
|
|
|
|
public override XtraReport CreateSettlementReport(string dcId, long? invoiceBaseOid)
|
|
{
|
|
long oid = 0;
|
|
long? ibOid = null;
|
|
|
|
if (string.IsNullOrEmpty(dcId) && invoiceBaseOid.HasValue)
|
|
{
|
|
ibOid = invoiceBaseOid.Value;
|
|
}
|
|
else
|
|
{
|
|
Int64.TryParse(dcId, out oid);
|
|
var si = DAOFactory.GenericDAO.LoadByID<SettlementInvoice>(oid);
|
|
ibOid = si.InvoiceBase.Oid;
|
|
}
|
|
|
|
if (ibOid.HasValue && ibOid.Value > 0)
|
|
{
|
|
var ib = DAOFactory.GenericDAO.LoadByID<InvoiceBase>(ibOid.Value);
|
|
string cbName = ib.CostBearer2SupportConcept.CostBearer.Organisation.Name;
|
|
if (cbName.Contains("Landschaftsverband Westfalen-Lippe") || cbName.StartsWith("LWL "))
|
|
return base.CreateSettlementReport(null, ibOid, true);
|
|
}
|
|
|
|
|
|
return base.CreateSettlementReport(dcId, invoiceBaseOid, false);
|
|
|
|
}
|
|
}
|
|
}
|