115 lines
4.7 KiB
C#
115 lines
4.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
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 LebenshilfeKusel
|
|
{
|
|
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);
|
|
|
|
if (serviceInvoice.InvoiceBase != null && serviceInvoice.InvoiceBase.InvoiceId != null &&
|
|
(serviceInvoice.InvoiceBase.InvoiceId.Equals("RechnungNichtaerztlicheDialysesachleistung") || serviceInvoice.InvoiceBase.InvoiceId.Equals("RechnungHaeuslicheKrankenpflege")))
|
|
{
|
|
return base.CreateServiceInvoiceReport(dcIds, invoiceBaseOid);
|
|
}
|
|
|
|
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);
|
|
|
|
if (invoice.InvoiceBase != null && invoice.InvoiceBase.InvoiceId != null &&
|
|
(invoice.InvoiceBase.InvoiceId.Equals("RechnungNichtaerztlicheDialysesachleistung") || invoice.InvoiceBase.InvoiceId.Equals("RechnungHaeuslicheKrankenpflege")))
|
|
return base.CreateServiceInvoiceReport(dcIds, invoiceBaseOid);
|
|
|
|
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;
|
|
|
|
if (iDC.ServiceInvoicePeriods.Count > 0 && iDC.ServiceInvoicePeriods[0].SupportConceptApprovalPeriod.ServiceCategory != null)
|
|
{
|
|
XtraReport masterReport = new XtraReport();
|
|
masterReport.CreateDocument();
|
|
|
|
var serviceInvoiceReport = new ServiceInvoiceReport();
|
|
var ro = ServiceInvoiceRO.Create(iDC);
|
|
|
|
serviceInvoiceReport.SetReportDataSource(ro);
|
|
serviceInvoiceReport.CreateDocument();
|
|
|
|
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;
|
|
|
|
var qb = CreateServiceOverviewSingleCustomerReport(cOid, month, year, oOid, 0, null, 1, DateTime.DaysInMonth(year, month));
|
|
qb.CreateDocument();
|
|
|
|
masterReport.Pages.AddRange(serviceInvoiceReport.Pages);
|
|
foreach (DevExpress.XtraPrinting.Page item in masterReport.Pages)
|
|
{
|
|
item.AssignWatermark(serviceInvoiceReport.Watermark);
|
|
}
|
|
masterReport.Pages.AddRange(qb.Pages);
|
|
invoiceReport = masterReport;
|
|
|
|
}
|
|
else
|
|
{
|
|
IBeWoReport<ServiceInvoiceRO> singleReport = FindReportImp<ServiceInvoiceRO>(iDC.InvoiceBase.InvoiceId);
|
|
var ro = ServiceInvoiceRO.Create(iDC);
|
|
singleReport.SetReportDataSource(ro);
|
|
((XtraReport)singleReport).CreateDocument();
|
|
invoiceReport = singleReport as XtraReport;
|
|
}
|
|
|
|
if (allReports == null)
|
|
{
|
|
allReports = invoiceReport;
|
|
}
|
|
else
|
|
{
|
|
((XtraReport)allReports).Pages.AddRange(invoiceReport.Pages);
|
|
}
|
|
}
|
|
|
|
return allReports as XtraReport;
|
|
}
|
|
|
|
}
|
|
}
|
|
|