113 lines
6.2 KiB
C#
113 lines
6.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report.ReportObjects;
|
|
using BS.Shared;
|
|
using BS.Shared.Extensions;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace HshCologne
|
|
{
|
|
public partial class ServiceInvoiceReportFLS : XtraReport
|
|
{
|
|
public List<ServiceInvoicePeriodRO> flsList { get; set; }
|
|
public List<ServiceInvoicePeriodRO> aggregiert { get; set; }
|
|
|
|
public ServiceInvoiceReportFLS()
|
|
{
|
|
this.InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServiceInvoiceRO pRO)
|
|
{
|
|
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation) && pRO.RecipientOrganisation.ToLower().Contains("erftstadt"))
|
|
{
|
|
Spalte4.Text = "Zeitraum";
|
|
xrTableCell1.Visible = true;
|
|
xrTableCell2.Visible = true;
|
|
xrTableCell3.Visible = true;
|
|
}
|
|
|
|
if (pRO.ServiceInvoicePeriods != null && pRO.ServiceInvoicePeriods.Count > 0)
|
|
{
|
|
decimal custKm = 0;
|
|
bool festeKm = false;
|
|
|
|
if (pRO.ServiceInvoicePeriods.All(sip => sip.ServiceInvoiceItems != null))
|
|
{
|
|
if (pRO.ServiceInvoicePeriods.Any(sip => sip.Notice == "Familienhilfe" || sip.Notice == "Schulbegleitung" || sip.Notice == "Fachleistungsstunden"))
|
|
{
|
|
// Erste Tabelle enthält alle Einzeleinträge aus der Zeiterfassung - quasi 2. QB
|
|
pRO.ServiceInvoicePeriods = pRO.ServiceInvoicePeriods.Where(sip => sip.Notice == "Familienhilfe" || sip.Notice == "Schulbegleitung" || sip.Notice == "Fachleistungsstunden").ToList();
|
|
foreach (var sip in pRO.ServiceInvoicePeriods)
|
|
{
|
|
if (sip.ServiceInvoiceItems != null && sip.ServiceInvoiceItems.Count > 0)
|
|
{
|
|
if (sip.ServiceInvoiceItems.Any(ii => ii.UnitDescription == "Fahrtkosten"))
|
|
{
|
|
sip.ServiceInvoiceItems = sip.ServiceInvoiceItems.Where(ii => ii.UnitDescription != "Fahrtkosten" && ii.UnitDescription != "Tagessatz").ToList();
|
|
// Check ob nachträgliche der Fahrtkilometer, wenn diese automatisch über InvoiceCreation vergeben werden
|
|
var c = DAOFactory.GenericDAO.LoadByID<Customer>(sip.Customer.CustomerOid);
|
|
if (c.HealthInsurance.IsNotNullOrEmpty() && decimal.TryParse(c.HealthInsurance, out custKm))
|
|
{
|
|
festeKm = true;
|
|
}
|
|
}
|
|
if (sip.ServiceInvoiceItems.Any(ii => ii.UnitDescription == "Tagessatz"))
|
|
{
|
|
sip.ServiceInvoiceItems = sip.ServiceInvoiceItems.Where(ii => ii.UnitDescription != "Tagessatz").ToList();
|
|
}
|
|
foreach (var ii in sip.ServiceInvoiceItems)
|
|
{
|
|
ii.UnitCountString = "";
|
|
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation) && pRO.RecipientOrganisation.ToLower().Contains("erftstadt"))
|
|
{
|
|
|
|
ii.UnitCountString = String.Format("{0:HH:mm}-{1:HH:mm}", ii.ServiceRecord.Start.Value, ii.ServiceRecord.End.Value);
|
|
if (ii.UnitCountString.StartsWith("00:00"))
|
|
{
|
|
ii.UnitCountString = "";
|
|
}
|
|
}
|
|
if (ii.ServiceRecord != null)
|
|
{
|
|
ii.Duration = String.Format("{0:ddd}./{0:dd.MM}", ii.ServiceRecord.Start.Value);
|
|
if (ii.Hours == 0 && ii.ServiceRecord.RoundedDuration != 0)
|
|
{
|
|
ii.Hours = Math.Round(ii.ServiceRecord.RoundedDuration / 60, 2, MidpointRounding.AwayFromZero);
|
|
}
|
|
// Angabe der Fahrtkilometer
|
|
if (ii.ServiceRecord.DistanceInMeter.HasValue)
|
|
{
|
|
ii.RateFactor = ii.ServiceRecord.DistanceInMeter.Value.ToString("n2");
|
|
}
|
|
// Angabe der Fahrtkilometer, wenn diese automatisch über InvoiceCreation vergeben werden
|
|
if (festeKm)
|
|
{
|
|
var leistungen = new List<string> { "HPG", "Hausbesuch", "Abholung und Begleitung", "Einsatz HPG", "Fachgespräch" };
|
|
if (leistungen.Contains(ii.ServiceRecord.ServiceDescription.Name))
|
|
{
|
|
ii.RateFactor = custKm.ToString("n2");
|
|
}
|
|
}
|
|
}
|
|
else // sehr uncool - ServiceRecord ist gelöscht
|
|
{
|
|
string old = ii.Duration.Substring(0, 8);
|
|
DateTime date = DateTime.ParseExact(old, "dd.MM.yy", CultureInfo.GetCultureInfo("de-DE"));
|
|
ii.Duration = string.Format(CultureInfo.GetCultureInfo("de-DE"), "{0:ddd}./{0:dd.MM}", date);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
}
|
|
} |