181 lines
7.1 KiB
C#
181 lines
7.1 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 DomizielAnsbach
|
|
{
|
|
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 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
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
IBeWoReport<ServiceInvoiceRO> allReports = null;
|
|
|
|
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));
|
|
((XtraReport)singleReport).CreateDocument();
|
|
if (allReports == null)
|
|
allReports = singleReport;
|
|
else
|
|
((XtraReport)allReports).Pages.AddRange(((XtraReport)singleReport).Pages);
|
|
|
|
if (reportId == "RgBezirkDetail")
|
|
{
|
|
singleReport = FindReportImp<ServiceInvoiceRO>("RgBezirk");
|
|
singleReport.SetReportDataSource(ServiceInvoiceRO.Create(iDC));
|
|
((XtraReport)singleReport).CreateDocument();
|
|
if (allReports == null)
|
|
allReports = singleReport;
|
|
else
|
|
((XtraReport)allReports).Pages.AddRange(((XtraReport)singleReport).Pages);
|
|
}
|
|
}
|
|
|
|
return allReports as XtraReport;
|
|
}
|
|
return new 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, serviceCategoryOid);
|
|
|
|
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);
|
|
|
|
if (lNext.Pages.Count == 0)
|
|
{
|
|
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)
|
|
{
|
|
XtraReport report = null;
|
|
|
|
|
|
ServicesOverviewRO bewoRo = ServicesOverviewRO.CopyFromRO(ro);
|
|
ServicesOverviewRO pbRo = ServicesOverviewRO.CopyFromRO(ro);
|
|
|
|
|
|
|
|
if (ro.Services != null)
|
|
{
|
|
foreach (ServicesOverviewRO.ServiceDetail s in ro.Services)
|
|
{
|
|
//if (!s.ServiceCategory.StartsWith("Dienstleistung"))
|
|
//{
|
|
if (s.ServiceCategory.Contains("Ambulant Betreutes "))
|
|
{
|
|
bewoRo.Services.Add(s);
|
|
}
|
|
else
|
|
{
|
|
pbRo.Services.Add(s);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
report = AddSubServicesOverviewReportToReport(report, new QuittierungsbelegAbw(), bewoRo);
|
|
report = AddSubServicesOverviewReportToReport(report, new QuittierungsbelegPB(), pbRo);
|
|
|
|
|
|
if (report == null)
|
|
report = new XtraReport();
|
|
|
|
return report as XtraReport;
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|