Files
BeWoPlaner/ReportImp/AsbRuhr/CustomReportCreator.cs

204 lines
6.9 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BeWo.Data;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using BS.Shared;
using BS.Shared.Core;
using DevExpress.XtraReports.UI;
namespace AsbRuhr
{
public class CustomReportCreator : DefaultReportCreator
{
public override XtraReport CreateQueryReport(long queryOid, string queryReportId)
{
if (queryOid == 400)
{
return base.CreateQueryReport(queryOid, queryReportId);
}
return base.CreateQueryReport(queryOid, queryReportId);
}
2022-11-17 08:46:57 +01:00
public override XtraReport CreateSettlementReport(string dcId, long? invoiceBaseOid)
{
long oid = 0;
long? ibOid = null;
2022-11-17 08:46:57 +01:00
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;
}
2021-02-02 23:23:05 +01:00
2022-11-17 08:46:57 +01:00
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);
}
2021-02-02 23:23:05 +01:00
2022-11-17 08:46:57 +01:00
//public override XtraReport CreateFinanceReport(DateTime? start, DateTime? end)
//{
// var report = FindReportImp<FinanceRO>();
// report.SetReportDataSource(FinanceRO.Create(start, end, true));
// return report as XtraReport;
// }
public override XtraReport CreateServiceOverviewAllCustomersReport(int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay)
{
2021-07-25 21:49:50 +02:00
List<ServicesOverviewRO> lROs = ServicesOverviewRO.Create(month, year, orgaOid, empOid, startDay, endDay, serviceCategoryOid);
if (lROs.Count > 0)
{
var rootReport = CreateServicesOverviewReportForRo(lROs[0], serviceCategoryOid);
if (rootReport.Pages.Count == 0)
{
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);
}
2021-02-02 23:23:05 +01:00
public override XtraReport CreateReportForServicesOverviewRo(ServicesOverviewRO ro, string reportId)
{
return CreateServicesOverviewReportForRo(ro, null);
}
private XtraReport CreateServicesOverviewReportForRo(ServicesOverviewRO ro, long? serviceCategoryOid)
{
XtraReport report = null;
ServicesOverviewRO flsRo = ServicesOverviewRO.CopyFromRO(ro);
ServicesOverviewRO assiRo = ServicesOverviewRO.CopyFromRO(ro);
if (ro.CustomerLastName.StartsWith("Blei"))
{
int test = 0;
}
if (ro.Services != null)
{
foreach (ServicesOverviewRO.ServiceDetail s in ro.Services)
{
ServicesOverviewRO.CreateSignatureString(s);
if (s.ServiceCategory.ToLower().Contains("assistenz"))
{
assiRo.Services.Add(s);
}
else
{
flsRo.Services.Add(s);
}
}
}
/*
* if (mandatorSettings != null && mandatorSettings.Contains("ShowEmployeeSignature=1"))
{
var serviceRecordOids = lResult.Services.Select(service => service.ServiceRecordOid).ToList();
var employeeSignature = DAOFactory.SearchDAO.GetConfirmationReceiptSignatureForServiceRecords(serviceRecordOids, SignatureType.Employee);
if(!(employeeSignature?.SignatureImage is null))
{
lResult.EmployeeSignature = ImageUtils.ConvertBase64StringToBitmap(employeeSignature?.SignatureImage);
lResult.EmployeeSignatureDate = employeeSignature?.InsTs;
}
var customerSignature = DAOFactory.SearchDAO.GetConfirmationReceiptSignatureForServiceRecords(serviceRecordOids, SignatureType.Customer);
lResult.CustomerSignature = customerSignature?.SignatureImage;
lResult.CustomerSignatureDate = customerSignature?.InsTs;
}
*/
if(assiRo?.Mandator?.Settings?.Contains("ShowEmployeeSignature=1") ?? false)
{
var serviceRecordOids = assiRo.Services.Select(service => service.ServiceRecordOid).ToList();
var employeeSignature = DAOFactory.SearchDAO.GetConfirmationReceiptSignatureForServiceRecords(serviceRecordOids, SignatureType.Employee);
if(!(employeeSignature?.SignatureImage is null))
{
assiRo.EmployeeSignature = ImageUtils.ConvertBase64StringToBitmap(employeeSignature?.SignatureImage);
assiRo.EmployeeSignatureDate = employeeSignature?.InsTs;
}
}
report = AddReportToReport<Quittierungsbeleg2>(report, flsRo);
report = AddReportToReport<QuittierungsbelegAssistenz>(report, assiRo);
//report = AddReportToReport(report, eingliederungshilfe);
if (report is null)
report = new XtraReport();
return report;
}
private XtraReport AddReportToReport<T>(XtraReport report, ServicesOverviewRO ro) where T : XtraReport, IBeWoReport<ServicesOverviewRO>, new()
{
if (ro.Services.Count > 0)
{
if (report == null)
{
report = new T();
((T)report).SetReportDataSource(ro);
}
else
{
if (report.Pages.Count == 0)
{
report.CreateDocument();
}
XtraReport newReport = new T();
((T)newReport).SetReportDataSource(ro);
newReport.CreateDocument();
report.Pages.AddRange(newReport.Pages);
}
}
return report;
}
}
}