Files
BeWoPlaner/ReportImp/HshCologne/CustomReportCreator.cs

282 lines
11 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 HshCologne
{
public class CustomReportCreator : DefaultReportCreator
{
public override XtraReport CreateServiceInvoiceReport(string dcIds, long? invoiceBaseOid)
{
if (String.IsNullOrEmpty(dcIds) && invoiceBaseOid.HasValue)
{
var serviceInvoice = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(invoiceBaseOid.Value);
dcIds = String.Format("{0}", serviceInvoice.Oid);
}
if (!string.IsNullOrEmpty(dcIds))
{
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);
}
return CreateInvoiceReport(dcList);
}
return new XtraReport();
}
private XtraReport CreateInvoiceReport(List<ServiceInvoiceDC> invoices)
{
XtraReport allReports = null;
foreach (var iDC in invoices)
{
XtraReport invoiceReport = null;
IBeWoReport<ServiceInvoiceRO> seite1 = FindReportImp<ServiceInvoiceRO>(iDC.InvoiceBase.InvoiceId);
if (iDC.ServiceInvoicePeriods.Count > 0)
{
var ro = ServiceInvoiceRO.Create(iDC);
seite1.SetReportDataSource(ro);
((XtraReport)seite1).CreateDocument();
invoiceReport = seite1 as XtraReport;
int month = iDC.InvoiceBase.AccountingPeriodStart.Value.Month;
int year = iDC.InvoiceBase.AccountingPeriodStart.Value.Year;
long cOid = iDC.InvoiceBase.SupportConceptCostBearerRelDc.SupportConcept.Customer.CustomerOid;
long oOid = iDC.InvoiceBase.RecipientOrganisationOid ?? 0;
// Bornheim möchte den Leistungsnachweis in zweifacher Ausfertigung
var costBearer = iDC.InvoiceBase.SupportConceptCostBearerRelDc.CostBearer;
int anzahlAusfertigungen = 1;
if (costBearer != null && costBearer.Name != null && costBearer.Name.Contains("Bornheim"))
{
anzahlAusfertigungen = 2;
}
while (month <= iDC.InvoiceBase.AccountingPeriodEnd.Value.Month)
{
for (int i = 0; i < anzahlAusfertigungen; i++)
{
var qb = CreateServiceOverviewSingleCustomerReport(cOid, month, year, oOid, 0, null, 1, DateTime.DaysInMonth(year, month));
qb.CreateDocument();
invoiceReport.Pages.AddRange(qb.Pages);
}
month++;
}
}
if (invoiceReport == null)
{
var ro = ServiceInvoiceRO.Create(iDC);
seite1.SetReportDataSource(ro);
((XtraReport)seite1).CreateDocument();
invoiceReport = seite1 as XtraReport;
}
if (allReports == null)
{
allReports = invoiceReport;
}
else
{
((XtraReport)allReports).Pages.AddRange(invoiceReport.Pages);
}
}
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);
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 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.Create(coid, month, year, true, orgaOid ?? 0, empOid ?? 0, startDay, endDay, serviceCategoryOid);
if (ro != null)
{
roList.Add(ro);
}
}
if (roList.Count > 0)
{
var rootReport = CreateServicesOverviewReportForRo(roList[0], serviceCategoryOid);
rootReport.CreateDocument();
for (int i = 1; i < roList.Count; i++)
{
var lNext = CreateServicesOverviewReportForRo(roList[i], serviceCategoryOid);
lNext.CreateDocument();
rootReport.Pages.AddRange(lNext.Pages);
}
return rootReport;
}
return new XtraReport();
}
private XtraReport CreateServicesOverviewReportForRo(ServicesOverviewRO ro, long? serviceCategoryOid)
{
XtraReport report = null;
ServicesOverviewRO bewoRo = CopyFromRO(ro);
ServicesOverviewRO spfhRo = CopyFromRO(ro);
ServicesOverviewRO sbdRo = CopyFromRO(ro);
if (ro.Services != null)
{
foreach (ServicesOverviewRO.ServiceDetail s in ro.Services)
{
if (s.ServiceCategory.ToLower().Contains("familien") || s.ServiceCategory.ToLower().Contains("außerschulische")
|| s.ServiceCategory.ToLower() == "fam" || s.ServiceCategory.ToLower().Contains("begleitet"))
{
spfhRo.Services.Add(s);
}
else if (s.ServiceCategory.ToLower().Contains("schulbegleitung"))
{
sbdRo.Services.Add(s);
}
else
{
spfhRo.Services.Add(s); // Auffangen von neuen Leistungskategorien
}
}
}
//report = AddReportToReport(report, new Quittierungsbeleg2(), bewoRo);
report = AddReportToReport(report, new LeistungsnachweisFamilienhilfe(), spfhRo);
if (ro.Costbearer != null && ro.Costbearer.Contains("Wesseling"))
{
report = AddReportToReport(report, new LeistungsnachweisSbWesseling(), sbdRo);
}
else
{
report = AddReportToReport(report, new LeistungsnachweisSchulbegleitung(), sbdRo);
}
//report = AddReportToReport(report, eingliederungshilfe);
if (report == null)
report = new XtraReport();
return report;
}
private XtraReport AddReportToReport(XtraReport masterReport, IBeWoReport<ServicesOverviewRO> newReport, ServicesOverviewRO ro)
{
if (ro.Services.Count > 0)
{
newReport.SetReportDataSource(ro);
((XtraReport)newReport).CreateDocument();
if (masterReport == null)
{
masterReport = newReport as XtraReport;
}
else
{
if (masterReport.Pages.Count == 0)
{
masterReport.CreateDocument();
}
masterReport.Pages.AddRange(((XtraReport)newReport).Pages);
}
}
return masterReport;
}
private ServicesOverviewRO CopyFromRO(ServicesOverviewRO ro)
{
ServicesOverviewRO newRo = new ServicesOverviewRO();
newRo.StartDate = ro.StartDate;
newRo.Abwesenheiten = ro.Abwesenheiten;
newRo.AbsenceTimes = ro.AbsenceTimes;
newRo.ApprovedEndDate = ro.ApprovedEndDate;
newRo.ApprovedFLSPerMonth = ro.ApprovedFLSPerMonth;
newRo.ApprovedFLSPerMonthTotal = ro.ApprovedFLSPerMonthTotal;
newRo.ApprovedFLSPerWeek = ro.ApprovedFLSPerWeek;
newRo.ApprovedFLSPerWeekTotal = ro.ApprovedFLSPerWeekTotal;
newRo.ApprovedFLSTotal = ro.ApprovedFLSTotal;
newRo.ApprovedStartDate = ro.ApprovedStartDate;
newRo.ContactEmployee = ro.ContactEmployee;
newRo.CostBearer2SupportConceptList = ro.CostBearer2SupportConceptList;
newRo.Costbearer = ro.Costbearer;
newRo.CustomerBirthday = ro.CustomerBirthday;
newRo.CustomerLastName = ro.CustomerLastName;
newRo.CustomerCity = ro.CustomerCity;
newRo.CustomerFirstName = ro.CustomerFirstName;
newRo.CustomerName = ro.CustomerName;
newRo.CustomerPostalCode = ro.CustomerPostalCode;
newRo.CustomerStreet = ro.CustomerStreet;
newRo.EndDate = ro.EndDate;
newRo.FreeMinutesThisMonth = ro.FreeMinutesThisMonth;
newRo.Month = ro.Month;
newRo.Year = ro.Year;
newRo.MainAttendant = ro.MainAttendant;
newRo.MainAttendantCommaSeperated = ro.MainAttendantCommaSeperated;
newRo.ReferenceNumber = ro.ReferenceNumber;
newRo.TotalFLMBillable = ro.TotalFLMBillable;
newRo.TotalFLM = ro.TotalFLM;
newRo.TotalFLMQualified = ro.TotalFLMQualified;
newRo.TotalFLMUnqualified = ro.TotalFLMUnqualified;
newRo.TotalFLS = ro.TotalFLS;
newRo.TotalFLSQualified = ro.TotalFLSQualified;
newRo.TotalFLSUnqualified = ro.TotalFLSUnqualified;
newRo.TotalFLSPerCostBearer = ro.TotalFLSPerCostBearer;
newRo.TotalGefahreneKilometer = ro.TotalGefahreneKilometer;
newRo.SupportConceptCostBearer = ro.SupportConceptCostBearer;
newRo.Mandator = ro.Mandator;
newRo.CustomerOid = ro.CustomerOid;
newRo.AllEmployees = ro.AllEmployees;
return newRo;
}
}
}