Files
BeWoPlaner/ReportImp/AWOMuensterlandRecklinghausen/StatusCheckAbrechnung.cs

78 lines
2.9 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)
{
scRo.Custom1 = GetTeam(scRo);
// Customer c = DAOFactory.GenericDAO.LoadByID<Customer>(scro.Costbearer2Supportconcept.SupportConcept.Customer.CustomerOid);
var serviceRecordOids = scRo.ServiceRecords.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;
foreach (var ii in invoices)
{
if (ii.IsActive.Equals(ActivationTypeId.Active))
{
count += 1;
if (count == 1)
{
scRo.Custom3 = String.Format("{0:dd.MM.yyyy}", ii.InvoiceBase.InvoiceDate);
}
if (count > 1)
{
scRo.Custom3 += String.Format(", {0:dd.MM.yyyy}", ii.InvoiceBase.InvoiceDate);
}
}
}
}
}
this.bindingSource1.DataSource = pRO;
}
private string GetTeam(FinanceRO.SupportConceptFinanceRO scRo)
{
string team = " ";
Customer c = DAOFactory.GenericDAO.LoadByID<Customer>(scRo.Costbearer2Supportconcept.SupportConcept.Customer.Oid ?? 0);
if (c.Team2CustomerList.Count > 0)
{
team = c.Team2CustomerList[0].Team.Name;
}
return team;
}
}
}