186 lines
5.6 KiB
C#
186 lines
5.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using BeWo.BeWoAuxilio;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BS.Shared.Core;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace BeWoAuxilio
|
|
{
|
|
public class CustomReportCreator : DefaultReportCreator
|
|
{
|
|
public override XtraReport CreateQueryReport(long queryOid, string queryReportId)
|
|
{
|
|
if (queryOid == 100)
|
|
{
|
|
return CreateBonusbeleg(queryOid, queryReportId);
|
|
}
|
|
return base.CreateQueryReport(queryOid, queryReportId);
|
|
}
|
|
|
|
// Die Anzeige für Quartalsbonus funktioniert nur, wenn MA einzeln berechnet werden
|
|
// Daher Sammeldruck unter Berichte, sonst gleiche Ansicht wie Mitarbeiterstundenkonto
|
|
private XtraReport CreateBonusbeleg(long queryOid, string queryReportId)
|
|
{
|
|
var query = DAOFactory.GenericDAO.LoadByID<Query>(queryOid);
|
|
|
|
if (query == null)
|
|
return new XtraReport();
|
|
|
|
var path = Path.Combine(TempPath, queryReportId + ".xml");
|
|
var table = Utils.XMLDeserialize<DataTable>(path);
|
|
var qro = QueryRO.Create(query, table);
|
|
|
|
if (qro.Rows.Count > 0)
|
|
{
|
|
DateTime monat = DateTime.Parse(qro.Rows[0].Field1.ToString());
|
|
DateTimeSpan span = new DateTimeSpan();
|
|
span.StartDateTime = monat;
|
|
span.EndDateTime = monat.AddMonths(1).AddTicks(-1);
|
|
long? employeeOid = null;
|
|
if (qro.Rows[0].Field2 != null && qro.Rows[0].Field2.ToString() != "0")
|
|
{
|
|
employeeOid = Int64.Parse(qro.Rows[0].Field2.ToString());
|
|
MitarbeiterstundenkontoRO ro = MitarbeiterstundenkontoRO.Create(employeeOid, null, monat, monat.AddMonths(1), null);
|
|
XtraReport allReports = null;
|
|
|
|
foreach (var ed in ro.EmployeeDetailList)
|
|
{
|
|
Mitarbeiterstundenkonto beleg = new Mitarbeiterstundenkonto();
|
|
beleg.SetReportDataSource(ro);
|
|
beleg.CreateDocument();
|
|
if (allReports == null)
|
|
allReports = beleg;
|
|
else
|
|
allReports.Pages.AddRange(beleg.Pages);
|
|
}
|
|
if (allReports != null)
|
|
{
|
|
return allReports;
|
|
}
|
|
}
|
|
if (employeeOid == null)
|
|
{
|
|
XtraReport masterReport = new XtraReport();
|
|
masterReport.CreateDocument();
|
|
|
|
var employeeList = DAOFactory.GenericDAO.GetAllActive<Employee>();
|
|
employeeList = employeeList.OrderBy(e => e.Person.LastNameFirstName).ToList();
|
|
foreach (var e in employeeList)
|
|
{
|
|
employeeOid = e.Oid;
|
|
MitarbeiterstundenkontoRO ro = MitarbeiterstundenkontoRO.Create(employeeOid, null, monat, monat.AddMonths(1), null);
|
|
foreach (var ed in ro.EmployeeDetailList)
|
|
{
|
|
Mitarbeiterstundenkonto beleg = new Mitarbeiterstundenkonto();
|
|
beleg.SetReportDataSource(ro);
|
|
beleg.CreateDocument();
|
|
if (masterReport == null)
|
|
masterReport = beleg;
|
|
else
|
|
masterReport.Pages.AddRange(beleg.Pages);
|
|
}
|
|
}
|
|
return masterReport;
|
|
}
|
|
}
|
|
|
|
return new 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);
|
|
}
|
|
|
|
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, null, false);
|
|
|
|
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;
|
|
|
|
if (ro.StartDate < new DateTime(2018, 10, 1))
|
|
{
|
|
report = new Stundenzettel();
|
|
}
|
|
if (report == null)
|
|
report = new Quittierungsbeleg();
|
|
report.SetReportDataSource(ro);
|
|
|
|
return report as XtraReport;
|
|
}
|
|
}
|
|
}
|