103 lines
4.1 KiB
C#
103 lines
4.1 KiB
C#
using System;
|
|
using System.Linq;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
|
|
namespace AWOMuensterlandRecklinghausen
|
|
{
|
|
public partial class Statuscheck : DevExpress.XtraReports.UI.XtraReport
|
|
{
|
|
public Statuscheck()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(FinanceRO pRO)
|
|
{
|
|
DateTime start = pRO.ReportStartDate.Value;
|
|
DateTime end = pRO.ReportEndDate.Value;
|
|
DateTimeSpan lastMonth = new DateTimeSpan();
|
|
lastMonth.StartDateTime = start;
|
|
lastMonth.EndDateTime = end.AddDays(1).AddTicks(-1);
|
|
|
|
if (pRO.SupportConceptFinanceList != null)
|
|
{
|
|
foreach (var scRo in pRO.SupportConceptFinanceList)
|
|
{
|
|
Customer c = DAOFactory.GenericDAO.LoadByID<Customer>(scRo.Costbearer2Supportconcept.SupportConcept.Customer.Oid ?? 0);
|
|
scRo.Custom1 = GetTeam(scRo, c);
|
|
scRo.SupportConceptTimeSpanString = GetHauptbetreuer(c);
|
|
var serviceRecordOids = scRo.ServiceRecords.Where(s => s.Start.Value.Date >= start.Date && s.Start.Value.Date <= end.Date).Select(s => (long)s.ServiceRecordOid).ToList();
|
|
var customerSignature = DAOFactory.SearchDAO.GetConfirmationReceiptSignatureForServiceRecords(serviceRecordOids, SignatureType.Customer);
|
|
|
|
if (!(customerSignature?.SignatureImage is null))
|
|
{
|
|
//var CustomerSignatureDate = customerSignature.InsTs;
|
|
scRo.Custom2 = "x";
|
|
}
|
|
var invoices = DAOFactory.SearchDAO.GetServiceInvoices(scRo.Costbearer2Supportconcept.CostBearer2SupportConceptOid.Value, lastMonth);
|
|
var count = 0;
|
|
scRo.Leistungskategorie = "";
|
|
foreach (var ii in invoices)
|
|
{
|
|
if (ii.IsActive.Equals(ActivationTypeId.Active))
|
|
{
|
|
if (ii.InvoiceBase.IsReviewed)
|
|
{
|
|
scRo.Custom3 = "x";
|
|
}
|
|
if (ii.InvoiceBase.IsSent)
|
|
{
|
|
scRo.Leistungskategorie = "x";
|
|
}
|
|
count += 1;
|
|
if (count == 1)
|
|
{
|
|
scRo.Custom4 = String.Format("{0:dd.MM.yyyy}", ii.InvoiceBase.InvoiceDate);
|
|
}
|
|
|
|
if (count > 1)
|
|
{
|
|
scRo.Custom4 += String.Format(", {0:dd.MM.yyyy}", ii.InvoiceBase.InvoiceDate);
|
|
}
|
|
scRo.Custom5 += String.Format("{0}", ii.InvoiceBase.Notice);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private string GetTeam(FinanceRO.SupportConceptFinanceRO scRo, Customer c)
|
|
{
|
|
string team = " ";
|
|
if (c.Team2CustomerList.Count > 0)
|
|
{
|
|
team = c.Team2CustomerList[0].Team.Name;
|
|
}
|
|
return team;
|
|
}
|
|
|
|
private string GetHauptbetreuer(Customer customer)
|
|
{
|
|
foreach (var e2c in customer.Employee2CustomerList)
|
|
{
|
|
foreach (var v2e in e2c.ValueList)
|
|
{
|
|
if (v2e.Entry.Type == ValueListEntryType.StaffRoleType && v2e.Entry.Value == "Hauptbetreuung")
|
|
{
|
|
return e2c.Employee.Person.FirstNameLastName;
|
|
}
|
|
}
|
|
}
|
|
//throw new FaultException<BeWoFault>(new BeWoFault(String.Format("Es wurde keine Hauptbetreuung für {0} gefunden.", customer.Person.FirstNameLastName), BeWoFaultType.CustomWithoutDetails));
|
|
return "";
|
|
}
|
|
}
|
|
}
|