149 lines
4.4 KiB
C#
149 lines
4.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report.ReportObjects;
|
|
using BS.Shared.DataContracts;
|
|
|
|
namespace BeWo.Report.DefaultReports.Alt
|
|
{
|
|
public partial class Spitzabrechnung : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<SettlementRO>
|
|
{
|
|
public Spitzabrechnung()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(SettlementRO pRO)
|
|
{
|
|
bool isDefaultSpitzabrechnung = false;
|
|
|
|
|
|
if (pRO.InvoiceItems != null && pRO.InvoiceItems.Count == 1)
|
|
{
|
|
var ii = pRO.InvoiceItems[0];
|
|
if ((ii.ItemDescription == "Spitzabrechung" || ii.ItemDescription == "Spitzabrechnung") && ii.GrossAmountTotal == null && ii.RateFactor == null)
|
|
{
|
|
isDefaultSpitzabrechnung = true;
|
|
}
|
|
}
|
|
if (!isDefaultSpitzabrechnung)
|
|
{
|
|
if (pRO.DifferentHourlyRateCount > 0 && pRO.HourlyRateNew.HasValue)
|
|
{
|
|
isDefaultSpitzabrechnung = true;
|
|
}
|
|
}
|
|
|
|
if (isDefaultSpitzabrechnung)
|
|
{
|
|
//UpdateAbrechnungsFelder(pRO);
|
|
|
|
pRO.InvoiceItems = CreateDefaultSpitzabrechnungInvoiceItems(pRO);
|
|
}
|
|
else
|
|
{
|
|
var id = GetCustomerId(pRO);
|
|
if (id == "LWLNEU")
|
|
{
|
|
pRO.RateFactorText = null;
|
|
pRO.RateFactorText2 = null;
|
|
|
|
if (pRO.InvoiceItems != null)
|
|
{
|
|
foreach (var ii in pRO.InvoiceItems)
|
|
{
|
|
ii.ItemDescription = String.Format("{0:c}", ii.AmountPerUnit);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (pRO.InvoiceItems != null)
|
|
{
|
|
foreach (var ii in pRO.InvoiceItems)
|
|
{
|
|
ii.ItemDescription = String.Format("{0:c}{1}", ii.AmountPerUnit, ii.RateFactor == 0 ? "" : " x " + pRO.RateFactorText2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
}
|
|
}
|