135 lines
4.0 KiB
C#
135 lines
4.0 KiB
C#
using System;
|
|
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 BetreuWoWesel
|
|
{
|
|
[IDSpecificClass(Identifiers = new string[] { "AbrechnungHD" })]
|
|
public partial class ServiceInvoiceReport : XtraReport, IBeWoReport<ServiceInvoiceRO>
|
|
{
|
|
public ServiceInvoiceReport()
|
|
{
|
|
this.InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServiceInvoiceRO pRO)
|
|
{
|
|
//DateTime start = pRO.AccountingPeriodStart;
|
|
//DateTime end = pRO.AccountingPeriodEnd;
|
|
//if (start.Month == end.Month && start.Year == end.Year)
|
|
//{
|
|
// lblMonat.Text = String.Format("Für den Monat {0:MMMM yyyy}", start);
|
|
//}
|
|
//else
|
|
//{
|
|
// lblMonat.Text = String.Format("Für den Monat {0:MMMM yyyy} - {1:MMMM yyyy}", start, end);
|
|
//}
|
|
if (!String.IsNullOrWhiteSpace(pRO.RecipientOrganisation))
|
|
{
|
|
pRO.RecipientOrganisation = pRO.RecipientOrganisation.Replace(" HD", "").Trim();
|
|
}
|
|
|
|
decimal hourlyRate = 0;
|
|
decimal rateFactor = 1;
|
|
decimal hours = 0;
|
|
if (pRO.ServiceInvoicePeriods != null && pRO.ServiceInvoicePeriods.Count > 0)
|
|
{
|
|
foreach (var p in pRO.ServiceInvoicePeriods)
|
|
{
|
|
|
|
if (p.ServiceInvoiceItems != null && p.ServiceInvoiceItems.Count > 0)
|
|
{
|
|
|
|
foreach (var i in p.ServiceInvoiceItems)
|
|
{
|
|
if (i.HourlyRate.HasValue)
|
|
{
|
|
hourlyRate = i.HourlyRate.Value;
|
|
|
|
if (!String.IsNullOrEmpty(i.RateFactor))
|
|
{
|
|
var rfStr = i.RateFactor.Replace("%", "").Replace(",00", "").Trim();
|
|
int rfInt = 0;
|
|
Int32.TryParse(rfStr, out rfInt);
|
|
|
|
rateFactor = (100m + rfInt) / 100m;
|
|
}
|
|
}
|
|
|
|
if (i.Hours.HasValue)
|
|
hours += i.Hours.Value;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (!String.IsNullOrEmpty(pRO.CustomerSalutation) && pRO.CustomerSalutation.ToLower() == "herr")
|
|
pRO.CustomerSalutation = "Herrn";
|
|
|
|
//lblNettoStunden.Text = String.Format("{0:0.00}", hours);
|
|
hours *= rateFactor;
|
|
lblAbrechnungstext.Text = String.Format("{0:0.##} Tage x {1:c}", hours, hourlyRate);
|
|
|
|
//pRO.NetClaim = pRO.NetClaim.Replace("€", "EUR");
|
|
|
|
var betreuungsart = GetBetreuungsart(pRO);
|
|
if (!String.IsNullOrWhiteSpace(betreuungsart))
|
|
{
|
|
betreuungsart = betreuungsart.Replace("WES HG ", "").Trim();
|
|
}
|
|
pRO.Notice = betreuungsart;
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
public String GetBetreuungsart(ServiceInvoiceRO pRO)
|
|
{
|
|
if (pRO.ServiceInvoicePeriods != null && pRO.ServiceInvoicePeriods.Count > 0)
|
|
{
|
|
if (pRO.ServiceInvoicePeriods[0].SupportConceptApprovalPeriod != null &&
|
|
pRO.ServiceInvoicePeriods[0].SupportConceptApprovalPeriod.ServiceCategory != null)
|
|
{
|
|
var name = pRO.ServiceInvoicePeriods[0].SupportConceptApprovalPeriod.ServiceCategory.Name;
|
|
|
|
name = name.Replace("HD ", "").Trim();
|
|
|
|
return name;
|
|
}
|
|
|
|
var c = DAOFactory.GenericDAO.LoadByID<Customer>(pRO.CustomerOid.Value);
|
|
|
|
foreach (var v2o in c.ValueList)
|
|
{
|
|
if (v2o.Entry.Type == ValueListEntryType.CustomerCareType)
|
|
{
|
|
return v2o.Entry.Value;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if (pRO.CustomerOid.HasValue)
|
|
{
|
|
var c = DAOFactory.GenericDAO.LoadByID<Customer>(pRO.CustomerOid.Value);
|
|
|
|
foreach (var v2o in c.ValueList)
|
|
{
|
|
if (v2o.Entry.Type == ValueListEntryType.CustomerCareType)
|
|
{
|
|
return v2o.Entry.Value;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return "";
|
|
}
|
|
}
|
|
} |