224 lines
8.2 KiB
C#
224 lines
8.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;
|
|
using FreundeskreisSuchthilfe.Service;
|
|
|
|
namespace FreundeskreisSuchthilfe.Reporting
|
|
{
|
|
public class FfReportCreator : 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, false, null, true, true);
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
private XtraReport CreateServicesOverviewReportForRo(ServicesOverviewRO ro, long? serviceCategoryOid)
|
|
{
|
|
IBeWoReport<ServicesOverviewRO> report = null;
|
|
|
|
|
|
if (!String.IsNullOrWhiteSpace(ro.Costbearer) && (ro.Costbearer.ToLower().Contains("§67")))
|
|
{
|
|
//report = new QuittierungsbelegDienstleistung();
|
|
}
|
|
|
|
if (!String.IsNullOrWhiteSpace(ro.Costbearer) && (ro.Costbearer.ToLower().Contains("Kreisverwaltung Kleve")))
|
|
{
|
|
//report = new QuittierungsbelegDienstleistung();
|
|
}
|
|
|
|
if (report == null)
|
|
{
|
|
if (ro.StartDate < new DateTime(2019, 1, 1))
|
|
{
|
|
report = new FreundeskreisSuchthilfe.Stundenzettel();
|
|
}
|
|
else
|
|
{
|
|
report = new FreundeskreisSuchthilfe.Quittierungsbeleg2();
|
|
}
|
|
}
|
|
|
|
report.SetReportDataSource(ro);
|
|
|
|
return report as XtraReport;
|
|
}
|
|
|
|
public override XtraReport CreateSettlementReport(string dcId, long? invoiceBaseOid)
|
|
{
|
|
var subreport = base.CreateSettlementReport(dcId, invoiceBaseOid);
|
|
|
|
var report = new Briefkopf();
|
|
report.SetSubReport(subreport);
|
|
report.DisplayName = "Spitzabrechnung";
|
|
|
|
return report;
|
|
}
|
|
|
|
public override XtraReport CreateCustomerInvoiceReport(long invoiceOid)
|
|
{
|
|
var subreport = base.CreateCustomerInvoiceReport(invoiceOid);
|
|
|
|
var report = new Briefkopf();
|
|
report.SetSubReport(subreport);
|
|
report.DisplayName = "Rechnung";
|
|
|
|
return report;
|
|
}
|
|
|
|
public override XtraReport CreateServiceInvoiceReport(string dcIds, long? invoiceBaseOid)
|
|
{
|
|
IBeWoReport<ServiceInvoiceRO> allReports = null;
|
|
|
|
if (String.IsNullOrEmpty(dcIds) && invoiceBaseOid.HasValue)
|
|
{
|
|
var serviceInvoice = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(invoiceBaseOid.Value);
|
|
dcIds = String.Format("{0}", serviceInvoice.Oid);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(dcIds))
|
|
{
|
|
var serviceInvoiceOid2CostbearerId = new Dictionary<long, string>();
|
|
var dcList = new List<ServiceInvoiceDC>();
|
|
|
|
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 (serviceInvoiceOid2CostbearerId.ContainsKey(oid))
|
|
continue;
|
|
|
|
if (!String.IsNullOrEmpty(invoice.InvoiceBase.InvoiceId))
|
|
serviceInvoiceOid2CostbearerId.Add(oid, invoice.InvoiceBase.InvoiceId);
|
|
else
|
|
{
|
|
foreach (var period in invoice.ServiceInvoicePeriodList)
|
|
{
|
|
try
|
|
{
|
|
if (period.SupportConceptApprovalPeriod != null)
|
|
{
|
|
AddCostBearerIdToDict(oid, serviceInvoiceOid2CostbearerId,
|
|
period.SupportConceptApprovalPeriod.CostBearer2SupportConcept);
|
|
|
|
}
|
|
foreach (var item in period.InvoiceItemList)
|
|
{
|
|
if (item.SupportConceptApprovalPeriodOid.HasValue)
|
|
{
|
|
var approvalPeriod =
|
|
DAOFactory.GenericDAO.LoadByID<SupportConceptApprovalPeriod>(item.SupportConceptApprovalPeriodOid.Value);
|
|
if (approvalPeriod.CostBearer2SupportConcept != null)
|
|
{
|
|
AddCostBearerIdToDict(oid, serviceInvoiceOid2CostbearerId, approvalPeriod.CostBearer2SupportConcept);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
//ignore
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
foreach (var iDC in dcList)
|
|
{
|
|
String reportId = null;
|
|
if (serviceInvoiceOid2CostbearerId.ContainsKey(iDC.ServiceInvoiceOid.Value))
|
|
reportId = serviceInvoiceOid2CostbearerId[iDC.ServiceInvoiceOid.Value];
|
|
|
|
IBeWoReport<ServiceInvoiceRO> singleReport = FindReportImp<ServiceInvoiceRO>(reportId);
|
|
|
|
singleReport.SetReportDataSource(ServiceInvoiceRO.Create(iDC));
|
|
|
|
if (allReports == null)
|
|
allReports = singleReport;
|
|
else
|
|
((XtraReport)allReports).Pages.AddRange(((XtraReport)singleReport).Pages);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var report = new Briefkopf();
|
|
report.SetSubReport(allReports as XtraReport);
|
|
report.DisplayName = "Rechnung";
|
|
report.CreateDocument();
|
|
return report;
|
|
|
|
}
|
|
|
|
public override XtraReport CreateAuslastungReport(long? employeeOid, IList<long> teamOids, DateTime startDate, DateTime endDate)
|
|
{
|
|
IBeWoReport<MitarbeiterauslastungRO> report;
|
|
if (teamOids != null && teamOids.Count > 0)
|
|
report = FindReportImp<MitarbeiterauslastungRO>("Teamauslastung");
|
|
else
|
|
report = FindReportImp<MitarbeiterauslastungRO>("Mitarbeiterauslastung");
|
|
|
|
if (employeeOid.HasValue || (teamOids != null && teamOids.Count > 0))
|
|
{
|
|
var x = MitarbeiterauslastungRO.Create(employeeOid, teamOids, startDate, endDate);
|
|
report.SetReportDataSource(x);
|
|
}
|
|
else
|
|
{
|
|
var employees = DAOFactory.GenericDAO.GetAllActiveAndArchived<Employee>();
|
|
var filteredEmps = FfEmployeeService.FilterList(employees);
|
|
var list = FfEmployeeService.FilterList(filteredEmps).Select(e => e.Oid.Value).ToList();
|
|
|
|
var x = MitarbeiterauslastungRO.Create(list, teamOids, startDate, endDate);
|
|
report.SetReportDataSource(x);
|
|
}
|
|
|
|
|
|
return report as XtraReport;
|
|
}
|
|
}
|
|
}
|