278 lines
12 KiB
C#
278 lines
12 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.Extensions;
|
|
|
|
namespace VSDHammReports.Alt
|
|
{
|
|
public partial class Spitzabrechnung : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<SettlementRO>
|
|
{
|
|
public Spitzabrechnung()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(SettlementRO pRO)
|
|
{
|
|
bool replaceFF = false;
|
|
bool hasFehlkontakte = false;
|
|
|
|
if (String.IsNullOrEmpty(pRO.RecipientOrganisation) || !pRO.RecipientOrganisation.ToLower().StartsWith("lwl"))
|
|
{
|
|
lblAZ.Text = "";
|
|
lblAZLabel.Text = "";
|
|
}
|
|
|
|
bool rateFactor = false;
|
|
rateFactor = pRO.InvoiceItems.Any(j => j.RateFactor > 0);
|
|
|
|
foreach (var ii in pRO.InvoiceItems)
|
|
{
|
|
|
|
if (!pRO.FehlkontakteString.IsNullOrEmpty() && ii.ItemDescription != null && ii.ItemDescription.Contains("Fehlkontakt")
|
|
|| (rateFactor && ii.RateFactor == 0))
|
|
{
|
|
Zwischensum.Visible = true;
|
|
hasFehlkontakte = true;
|
|
ii.ItemDescription = String.Format("{0:dd.MM.yyyy} bis {1:dd.MM.yyyy}", ii.ItemPeriodStart, ii.ItemPeriodEnd);
|
|
ii.ItemDescription += String.Format(": {0:0.##} Std. x {1:c}", ii.UnitCount, ii.AmountPerUnit);
|
|
ii.Notice = "Fehlkontakte";
|
|
if (String.IsNullOrEmpty(pRO.RecipientOrganisation) || pRO.RecipientOrganisation.ToLower().StartsWith("lwl"))
|
|
{
|
|
ii.Notice += " - 80 % abrechenbar";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ii.ItemDescription = String.Format("{0:dd.MM.yyyy} bis {1:dd.MM.yyyy}", ii.ItemPeriodStart, ii.ItemPeriodEnd);
|
|
ii.ItemDescription += String.Format(": {0:0.##} FLS x {1:c}", ii.UnitCount, ii.AmountPerUnit);
|
|
ii.Notice = "Fachleistungsstunden";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!pRO.HourlyRateNew.HasValue && pRO.DifferentHourlyRateCount > 0 && pRO.InvoiceItems != null && pRO.InvoiceItems.Count > 0)
|
|
{
|
|
pRO.RateFactor = 1;
|
|
replaceFF = true;
|
|
|
|
cellBewilligteFLSText.Text = "Bewilligte FLS";
|
|
cellRateFactorFLSText.Text = "";
|
|
cellApprovedFLSWithRF.Text = "";
|
|
|
|
if (pRO.InvoiceItems.Count == 3)
|
|
{
|
|
pRO.HourlyRate3EndDateString = String.Format("{0:dd.MM.yyyy}", pRO.InvoiceItems[0].ItemPeriodEnd);
|
|
pRO.GeleisteteFLSMitStundensatz3 = pRO.InvoiceItems[0].UnitCount;
|
|
pRO.Betrag1 = String.Format("{0:c}", pRO.InvoiceItems[0].AmountTotal);
|
|
pRO.HourlyRate3 = pRO.InvoiceItems[0].AmountPerUnit ?? 0;
|
|
|
|
pRO.HourlyRateOldStartDateString = String.Format("{0:dd.MM.yyyy}", pRO.InvoiceItems[1].ItemPeriodStart);
|
|
pRO.HourlyRateOldEndDateString = String.Format("{0:dd.MM.yyyy}", pRO.InvoiceItems[1].ItemPeriodEnd);
|
|
pRO.GeleisteteFLSMitStundensatzAlt = pRO.InvoiceItems[1].UnitCount;
|
|
pRO.Betrag2 = String.Format("{0:c}", pRO.InvoiceItems[1].AmountTotal);
|
|
pRO.HourlyRateOld = pRO.InvoiceItems[1].AmountPerUnit ?? 0;
|
|
|
|
pRO.HourlyRateNewStartDateString = String.Format("{0:dd.MM.yyyy}", pRO.InvoiceItems[2].ItemPeriodStart);
|
|
pRO.GeleisteteFLSMitStundensatzAktuell = pRO.InvoiceItems[2].UnitCount;
|
|
pRO.Betrag3 = String.Format("{0:c}", pRO.InvoiceItems[2].AmountTotal);
|
|
pRO.HourlyRateNew = pRO.InvoiceItems[2].AmountPerUnit ?? 0;
|
|
pRO.DifferentHourlyRateCount = 3;
|
|
}
|
|
else if (pRO.InvoiceItems.Count == 2)
|
|
{
|
|
|
|
pRO.HourlyRateOldEndDateString = String.Format("{0:dd.MM.yyyy}", pRO.InvoiceItems[0].ItemPeriodEnd);
|
|
pRO.GeleisteteFLSMitStundensatzAlt = pRO.InvoiceItems[0].UnitCount;
|
|
pRO.Betrag2 = String.Format("{0:c}", pRO.InvoiceItems[0].AmountTotal);
|
|
pRO.HourlyRateOld = pRO.InvoiceItems[0].AmountPerUnit ?? 0;
|
|
|
|
pRO.HourlyRateNewStartDateString = String.Format("{0:dd.MM.yyyy}", pRO.InvoiceItems[1].ItemPeriodStart);
|
|
pRO.GeleisteteFLSMitStundensatzAktuell = pRO.InvoiceItems[1].UnitCount;
|
|
pRO.Betrag3 = String.Format("{0:c}", pRO.InvoiceItems[1].AmountTotal);
|
|
pRO.HourlyRateNew = pRO.InvoiceItems[1].AmountPerUnit ?? 0;
|
|
pRO.DifferentHourlyRateCount = 2;
|
|
}
|
|
else
|
|
{
|
|
pRO.GeleisteteFLSMitStundensatzAktuell = pRO.InvoiceItems[0].UnitCount;
|
|
pRO.Betrag3 = String.Format("{0:c}", pRO.InvoiceItems[0].AmountTotal);
|
|
pRO.HourlyRateNew = pRO.InvoiceItems[0].AmountPerUnit ?? 0;
|
|
}
|
|
}
|
|
if (pRO.DifferentHourlyRateCount == 3)
|
|
{
|
|
|
|
pRO.Abrechnungstext1 = String.Format("{0} bis {1}",
|
|
pRO.AccountingStartDateString, pRO.HourlyRate3EndDateString);
|
|
|
|
pRO.Abrechnungstext1 += String.Format(": {0:0.##} FF {1}x {2:c}",
|
|
pRO.GeleisteteFLSMitStundensatz3, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRate3);
|
|
|
|
if (String.IsNullOrEmpty(pRO.Betrag1))
|
|
pRO.Betrag1 = String.Format("{0:c}", pRO.GeleisteteFLSMitStundensatz3 * (decimal)pRO.RateFactor * pRO.HourlyRate3);
|
|
|
|
|
|
pRO.Abrechnungstext2 = String.Format("{0} bis {1}",
|
|
pRO.HourlyRateOldStartDateString, pRO.HourlyRateOldEndDateString);
|
|
pRO.Abrechnungstext2 += String.Format(": {0:0.##} FF {1}x {2:c}",
|
|
pRO.GeleisteteFLSMitStundensatzAlt, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateOld);
|
|
if (String.IsNullOrEmpty(pRO.Betrag2))
|
|
pRO.Betrag2 = String.Format("{0:c}", pRO.GeleisteteFLSMitStundensatzAlt * (decimal)pRO.RateFactor * pRO.HourlyRateOld);
|
|
|
|
|
|
pRO.Abrechnungstext3 = String.Format("{0} bis {1}",
|
|
pRO.HourlyRateNewStartDateString, pRO.AccountingEndDateString);
|
|
pRO.Abrechnungstext3 += String.Format(": {0:0.##} FF {1}x {2:c}",
|
|
pRO.GeleisteteFLSMitStundensatzAktuell, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateNew);
|
|
if (String.IsNullOrEmpty(pRO.Betrag3))
|
|
pRO.Betrag3 = String.Format("{0:c}", pRO.GeleisteteFLSMitStundensatzAktuell * (decimal)pRO.RateFactor * pRO.HourlyRateNew);
|
|
}
|
|
else if (pRO.DifferentHourlyRateCount == 2)
|
|
{
|
|
|
|
pRO.Abrechnungstext2 = String.Format("{0} bis {1}",
|
|
pRO.AccountingStartDateString, pRO.HourlyRateOldEndDateString);
|
|
pRO.Abrechnungstext2 += String.Format(": {0:0.##} FF {1}x {2:c}",
|
|
pRO.GeleisteteFLSMitStundensatzAlt, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateOld);
|
|
if (String.IsNullOrEmpty(pRO.Betrag2))
|
|
pRO.Betrag2 = String.Format("{0:c}", pRO.GeleisteteFLSMitStundensatzAlt * (decimal)pRO.RateFactor * pRO.HourlyRateOld);
|
|
|
|
|
|
pRO.Abrechnungstext3 = String.Format("{0} bis {1}",
|
|
pRO.HourlyRateNewStartDateString, pRO.AccountingEndDateString);
|
|
pRO.Abrechnungstext3 += String.Format(": {0:0.##} FF {1}x {2:c}",
|
|
pRO.GeleisteteFLSMitStundensatzAktuell, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateNew);
|
|
if (String.IsNullOrEmpty(pRO.Betrag3))
|
|
pRO.Betrag3 = String.Format("{0:c}", pRO.GeleisteteFLSMitStundensatzAktuell * (decimal)pRO.RateFactor * pRO.HourlyRateNew);
|
|
}
|
|
else if (pRO.DifferentHourlyRateCount == 1)
|
|
{
|
|
pRO.Abrechnungstext3 = String.Format("{0} bis {1}",
|
|
pRO.AccountingStartDateString, pRO.AccountingEndDateString);
|
|
pRO.Abrechnungstext3 += String.Format(": {0:0.##} FF {1}x {2:c}",
|
|
pRO.GeleisteteFLSMitStundensatzAktuell, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateNew);
|
|
if (String.IsNullOrEmpty(pRO.Betrag3))
|
|
pRO.Betrag3 = String.Format("{0:c}", pRO.GeleisteteFLSMitStundensatzAktuell * (decimal)pRO.RateFactor * pRO.HourlyRateNew);
|
|
}
|
|
|
|
if (!String.IsNullOrEmpty(pRO.SenderContactPersonPhone))
|
|
{
|
|
pRO.SenderContactPersonPhone = pRO.SenderContactPersonPhone.Replace("Tel.: ", "");
|
|
pRO.SenderContactPersonMail = pRO.SenderContactPersonMail.Replace("E-Mail: ", "");
|
|
}
|
|
|
|
if (replaceFF)
|
|
{
|
|
if (!String.IsNullOrEmpty(pRO.Abrechnungstext1))
|
|
pRO.Abrechnungstext1 = pRO.Abrechnungstext1.Replace(" FF ", " FLS ");
|
|
if (!String.IsNullOrEmpty(pRO.Abrechnungstext2))
|
|
pRO.Abrechnungstext2 = pRO.Abrechnungstext2.Replace(" FF ", " FLS ");
|
|
if (!String.IsNullOrEmpty(pRO.Abrechnungstext3))
|
|
pRO.Abrechnungstext3 = pRO.Abrechnungstext3.Replace(" FF ", " FLS ");
|
|
}
|
|
|
|
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 && hasFehlkontakte == false)
|
|
{
|
|
//UpdateAbrechnungsFelder(pRO);
|
|
|
|
pRO.InvoiceItems = CreateDefaultSpitzabrechnungInvoiceItems(pRO);
|
|
}
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private IList<InvoiceItemDC> CreateDefaultSpitzabrechnungInvoiceItems(SettlementRO pRO)
|
|
{
|
|
IList<InvoiceItemDC> itemList = new List<InvoiceItemDC>();
|
|
if (pRO.DifferentHourlyRateCount == 3)
|
|
{
|
|
itemList.Add(new InvoiceItemDC
|
|
{
|
|
ItemDescription = String.Format("{0} bis {1}: {2:0.##} FLS {3}x {4:c}",
|
|
pRO.AccountingStartDateString, pRO.HourlyRate3EndDateString,
|
|
pRO.GeleisteteFLSMitStundensatz3, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRate3),
|
|
|
|
GrossAmountTotal = pRO.GeleisteteFLSMitStundensatz3 * pRO.RateFactor * pRO.HourlyRate3
|
|
});
|
|
|
|
itemList.Add(new InvoiceItemDC
|
|
{
|
|
ItemDescription = String.Format("{0} bis {1}: {2:0.##} FLS {3}x {4:c}",
|
|
pRO.HourlyRateOldStartDateString, pRO.HourlyRateOldEndDateString,
|
|
pRO.GeleisteteFLSMitStundensatzAlt, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateOld),
|
|
|
|
GrossAmountTotal = pRO.GeleisteteFLSMitStundensatzAlt * pRO.RateFactor * pRO.HourlyRateOld
|
|
});
|
|
|
|
itemList.Add(new InvoiceItemDC
|
|
{
|
|
ItemDescription = String.Format("{0} bis {1}: {2:0.##} FLS {3}x {4:c}",
|
|
pRO.HourlyRateNewStartDateString, pRO.AccountingEndDateString,
|
|
pRO.GeleisteteFLSMitStundensatzAktuell, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateNew),
|
|
|
|
GrossAmountTotal = pRO.GeleisteteFLSMitStundensatzAktuell * pRO.RateFactor * pRO.HourlyRateNew
|
|
});
|
|
|
|
}
|
|
else if (pRO.DifferentHourlyRateCount == 2)
|
|
{
|
|
itemList.Add(new InvoiceItemDC
|
|
{
|
|
ItemDescription = String.Format("{0} bis {1}: {2:0.##} FLS {3}x {4:c}",
|
|
pRO.AccountingStartDateString, pRO.HourlyRateOldEndDateString,
|
|
pRO.GeleisteteFLSMitStundensatzAlt, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateOld),
|
|
|
|
GrossAmountTotal = pRO.GeleisteteFLSMitStundensatzAlt * (decimal)pRO.RateFactor * pRO.HourlyRateOld
|
|
});
|
|
|
|
itemList.Add(new InvoiceItemDC
|
|
{
|
|
ItemDescription = String.Format("{0} bis {1}: {2:0.##} FLS {3}x {4:c}",
|
|
pRO.HourlyRateNewStartDateString, pRO.AccountingEndDateString,
|
|
pRO.GeleisteteFLSMitStundensatzAktuell, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateNew),
|
|
|
|
GrossAmountTotal = pRO.GeleisteteFLSMitStundensatzAktuell * pRO.RateFactor * pRO.HourlyRateNew
|
|
});
|
|
|
|
}
|
|
else
|
|
{
|
|
itemList.Add(new InvoiceItemDC
|
|
{
|
|
ItemDescription = String.Format("{0} bis {1}: {2:0.##} FLS {3}x {4:c}",
|
|
pRO.AccountingStartDateString, pRO.AccountingEndDateString,
|
|
pRO.GeleisteteFLSMitStundensatzAktuell, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateNew),
|
|
|
|
GrossAmountTotal = pRO.GeleisteteFLSMitStundensatzAktuell * pRO.RateFactor * pRO.HourlyRateNew
|
|
});
|
|
|
|
}
|
|
|
|
return itemList;
|
|
}
|
|
|
|
}
|
|
}
|