266 lines
11 KiB
C#
266 lines
11 KiB
C#
using BeWo.Data;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts;
|
|
using DevExpress.XtraReports.UI;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace InputFamilienhilfe
|
|
{
|
|
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;
|
|
|
|
if (iDC.ServiceInvoicePeriods.Count > 0 && iDC.ServiceInvoicePeriods[0].Customer != null
|
|
&& iDC.ServiceInvoicePeriods[0].Customer.CustomerAlias != null &&
|
|
iDC.ServiceInvoicePeriods[0].Customer.CustomerAlias.ToLower() != "aws" &&
|
|
iDC.ServiceInvoicePeriods[0].Customer.CustomerAlias.ToLower() != "bjw" &&
|
|
iDC.ServiceInvoicePeriods[0].Customer.CustomerAlias.ToLower() != "bjw egh" &&
|
|
iDC.ServiceInvoicePeriods[0].Customer.CustomerAlias.ToLower() != "tagesbetreuung" &&
|
|
iDC.ServiceInvoicePeriods[0].Customer.CustomerAlias.ToLower() != "ion")
|
|
{
|
|
var seite1 = new InputFamilienhilfe.Neu.Rechnung();
|
|
var ro = ServiceInvoiceRO.Create(iDC);
|
|
seite1.SetReportDataSource(ro);
|
|
seite1.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();
|
|
|
|
seite1.Pages.AddRange(qb.Pages);
|
|
invoiceReport = seite1;
|
|
|
|
}
|
|
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;
|
|
}
|
|
|
|
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);
|
|
List<ServicesOverviewRO> lROs = 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);
|
|
lNext.CreateDocument();
|
|
rootReport.Pages.AddRange(lNext.Pages);
|
|
}
|
|
|
|
return rootReport;
|
|
}
|
|
return new XtraReport();
|
|
}
|
|
|
|
private List<ServicesOverviewRO> Create(int pMonth, int pYear, long orgaOid, long empOid, int startDay, int endDay, long? serviceCategoryOid = null)
|
|
{
|
|
var roList = new List<ServicesOverviewRO>();
|
|
List<long> customerOids = new List<long>();
|
|
ApplicationUser loggedInUser = null;
|
|
|
|
if (LoggedInUserOperationContextExt.Current != null && LoggedInUserOperationContextExt.Current.User != null)
|
|
{
|
|
loggedInUser = LoggedInUserOperationContextExt.Current.User;
|
|
}
|
|
else
|
|
{
|
|
loggedInUser = SessionFacade.LoggedInUser;
|
|
}
|
|
|
|
if (loggedInUser != null && loggedInUser.Employee != null)
|
|
{
|
|
bool all = false;
|
|
foreach (var group in loggedInUser.UserGroups)
|
|
{
|
|
if (group.Name.ToLower().Contains("admin") || group.Name.ToLower().Contains("verwaltung"))
|
|
{
|
|
all = true;
|
|
}
|
|
}
|
|
|
|
if (all)
|
|
{
|
|
customerOids.AddRange(DAOFactory.GenericDAO.GetAllActive<Customer>()
|
|
.OrderBy(ob => ob.Person.LastName + ", " + ob.Person.FirstName).Select(c => c.Oid.Value));
|
|
}
|
|
else
|
|
{
|
|
var teams = DAOFactory.SearchDAO.FindLeadingTeams(loggedInUser.Employee.Oid.Value);
|
|
|
|
foreach (var team in teams)
|
|
{
|
|
foreach (var employee in team.MemberList)
|
|
{
|
|
foreach (var e2c in employee.Employee2CustomerList)
|
|
{
|
|
if (e2c.Customer.IsActive == ActivationTypeId.Active)
|
|
{
|
|
foreach (var v2o in e2c.ValueList)
|
|
{
|
|
if (v2o.Entry.Type == ValueListEntryType.StaffRoleType &&
|
|
v2o.Entry.Value.Contains("Hauptbetreuung"))
|
|
{
|
|
if (!customerOids.Contains(e2c.Customer.Oid.Value))
|
|
{
|
|
customerOids.Add(e2c.Customer.Oid.Value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
foreach (var coid in customerOids)
|
|
{
|
|
var ro = ServicesOverviewRO.Create(coid, pMonth, pYear, true, orgaOid, empOid, startDay, endDay, serviceCategoryOid);
|
|
|
|
//ServicesOverviewRO ro = ServicesOverviewRO.Create(customer, pSpan, disableEmptySupportConcepts, orgaOid, empOid, searchServiceRecordsByEndDate, serviceCategoryOid);
|
|
if (ro != null)
|
|
{
|
|
roList.Add(ro);
|
|
}
|
|
}
|
|
|
|
return roList.OrderBy(r => r.CustomerLastName + ", " + r.CustomerFirstName).ToList();
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
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)
|
|
{
|
|
IBeWoReport<ServicesOverviewRO> report = null;
|
|
//if (serviceCategoryOid != null && serviceCategoryOid == 11)
|
|
//{
|
|
report = new InputFamilienhilfe.StundennachweisBetrUmgang();
|
|
//}
|
|
//else if (serviceCategoryOid != null && serviceCategoryOid != 11)
|
|
//{
|
|
// report = new InputFamilienhilfe.Stundennachweis();
|
|
//}
|
|
//else
|
|
//{
|
|
// if (ro.Services != null)
|
|
// {
|
|
// foreach (ServicesOverviewRO.ServiceDetail s in ro.Services)
|
|
// {
|
|
// //if (s.ServiceCategory.ToLower().Contains("betreuter umgang")) // alter Beleg kann wohl weg
|
|
// //{
|
|
// report = new InputFamilienhilfe.StundennachweisBetrUmgang();
|
|
// break;
|
|
// //}
|
|
// //else
|
|
// //{
|
|
// // report = new InputFamilienhilfe.Stundennachweis();
|
|
// // break;
|
|
// //}
|
|
// }
|
|
// }
|
|
//}
|
|
report.SetReportDataSource(ro);
|
|
return report as XtraReport;
|
|
}
|
|
}
|
|
}
|