Files
BeWoPlaner/ReportImp/DiakonieMuelheim/SettlementReport2.cs

137 lines
4.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Report.ReportObjects;
using BS.Shared.DataContracts;
using BS.Shared.Extensions;
namespace BeWo.Report.DefaultReports
{
public partial class Spitzabrechnung : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<Settlement2RO>
{
public Spitzabrechnung()
{
InitializeComponent();
}
public void SetReportDataSource(Settlement2RO pRO)
{
if (pRO.InvoiceItems != null)
{
decimal rateFactor = 1;
foreach (var ii in pRO.InvoiceItems)
{
if (ii.RateFactor.HasValue)
{
rateFactor = (100 + ii.RateFactor.Value) / 100;
}
ii.ItemDescription = String.Format("{0:c}{1}", ii.AmountPerUnit, rateFactor.Equals(1) ? "" : " x " + rateFactor.ToString("F2"));
ii.DetailDescription = "geleistete Fachleistungsstunden";
if (!pRO.FehlkontakteString.IsNullOrEmpty() && ii.RateFactor == 0)
{
ii.DetailDescription = "Fehlkontakte";
}
}
}
SetzeWohnort(pRO);
this.bindingSource1.DataSource = pRO;
}
private void SetzeWohnort(Settlement2RO pRo)
{
if (pRo.InvoiceBaseOid.HasValue)
{
var ib = DAOFactory.GenericDAO.LoadByID<InvoiceBase>(pRo.InvoiceBaseOid.Value);
if (ib.CostBearer2SupportConcept != null)
{
var c = ib.CostBearer2SupportConcept.SupportConcept.Customer;
if (c != null && c.Person.Address != null)
{
lblWohnort.Text = String.Format("{0} in {1} {2}", c.Person.Address.Street, c.Person.Address.PostalCode, c.Person.Address.Town);
}
}
}
}
private String GetCustomerId(SettlementRO pRO)
{
var cb2sc = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(pRO.CostBearer2SupportConceptOid);
return cb2sc.CostBearer.ID;
}
private IList<InvoiceItemDC> CreateDefaultSpitzabrechnungInvoiceItems(SettlementRO pRO)
{
IList<InvoiceItemDC> itemList = new List<InvoiceItemDC>();
if (pRO.DifferentHourlyRateCount == 3)
{
itemList.Add(new InvoiceItemDC
{
ItemDescription = String.Format("{0:c}{1}", pRO.HourlyRate3, pRO.RateFactor == 1 ? "" : " x " + pRO.RateFactorText2),
GrossAmountTotal = pRO.GeleisteteFLSMitStundensatz3 * pRO.RateFactor * pRO.HourlyRate3,
UnitCount = pRO.GeleisteteFLSMitStundensatz3
});
itemList.Add(new InvoiceItemDC
{
ItemDescription = String.Format("{0:c}{1}", pRO.HourlyRateOld, pRO.RateFactor == 1 ? "" : " x " + pRO.RateFactorText2),
GrossAmountTotal = pRO.GeleisteteFLSMitStundensatzAlt * pRO.RateFactor * pRO.HourlyRateOld,
UnitCount = pRO.GeleisteteFLSMitStundensatzAlt
});
itemList.Add(new InvoiceItemDC
{
ItemDescription = String.Format("{0:c}{1}", pRO.HourlyRateNew, pRO.RateFactor == 1 ? "" : " x " + pRO.RateFactorText2),
GrossAmountTotal = pRO.GeleisteteFLSMitStundensatzAktuell * pRO.RateFactor * pRO.HourlyRateNew,
UnitCount = pRO.GeleisteteFLSMitStundensatzAktuell
});
}
else if (pRO.DifferentHourlyRateCount == 2)
{
itemList.Add(new InvoiceItemDC
{
ItemDescription = String.Format("{0:c}{1}", pRO.HourlyRateOld, pRO.RateFactor == 1 ? "" : " x " + pRO.RateFactorText2),
GrossAmountTotal = pRO.GeleisteteFLSMitStundensatzAlt * (decimal)pRO.RateFactor * pRO.HourlyRateOld,
UnitCount = pRO.GeleisteteFLSMitStundensatzAlt
});
itemList.Add(new InvoiceItemDC
{
ItemDescription = String.Format("{0:c}{1}", pRO.HourlyRateNew, pRO.RateFactor == 1 ? "" : " x " + pRO.RateFactorText2),
GrossAmountTotal = pRO.GeleisteteFLSMitStundensatzAktuell * pRO.RateFactor * pRO.HourlyRateNew,
UnitCount = pRO.GeleisteteFLSMitStundensatzAktuell
});
}
else
{
itemList.Add(new InvoiceItemDC
{
ItemDescription = String.Format("{0:c}{1}", pRO.HourlyRateNew, pRO.RateFactor == 1 ? "" : " x " + pRO.RateFactorText2),
GrossAmountTotal = pRO.GeleisteteFLSMitStundensatzAktuell * pRO.RateFactor * pRO.HourlyRateNew,
UnitCount = pRO.GeleisteteFLSMitStundensatzAktuell
});
}
return itemList;
}
}
}