238 lines
11 KiB
C#
238 lines
11 KiB
C#
using System;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Report;
|
|
using BS.Shared.DataContracts;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace BeWo.SHGSchwerte
|
|
{
|
|
public partial class Spitzabrechnung : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<SettlementRO>
|
|
{
|
|
public Spitzabrechnung()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(SettlementRO pRO)
|
|
{
|
|
if (!String.IsNullOrEmpty(pRO.SenderContactPersonPhone))
|
|
{
|
|
pRO.SenderContactPersonPhone = pRO.SenderContactPersonPhone.Replace("Tel.:", "").Trim();
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.SenderContactPersonFax))
|
|
{
|
|
pRO.SenderContactPersonFax = pRO.SenderContactPersonFax.Replace("Fax:", "").Trim();
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.SenderContactPersonMail))
|
|
{
|
|
pRO.SenderContactPersonMail = pRO.SenderContactPersonMail.Replace("E-Mail:", "").Trim();
|
|
}
|
|
|
|
ortDatum.Text = string.Format("Schwerte, {0}", DateTime.Now.ToShortDateString());
|
|
|
|
xrCheckBox2.Checked = true;
|
|
DateTime? terminationDate = null;
|
|
|
|
if (pRO.CostBearer2SupportConceptOid > 0)
|
|
{
|
|
var c2s = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(pRO.CostBearer2SupportConceptOid);
|
|
|
|
if (c2s.SupportConcept.Customer.TerminationDate.HasValue)
|
|
{
|
|
terminationDate = c2s.SupportConcept.Customer.TerminationDate;
|
|
xrCheckBox1.Text = String.Format(" Die Betreuung wurde am {0:dd.MM.yyyy} beendet.",
|
|
c2s.SupportConcept.Customer.TerminationDate);
|
|
xrCheckBox2.Checked = false;
|
|
xrCheckBox1.Checked = true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ErstelleRechnungspositionen(pRO, terminationDate);
|
|
|
|
|
|
|
|
|
|
|
|
bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private void ErstelleRechnungspositionen(SettlementRO pRO, DateTime? terminationDate)
|
|
{
|
|
if (pRO.InvoiceItems != null && pRO.InvoiceItems.Count > 0)
|
|
{
|
|
int rowIndex = 0;
|
|
foreach (var ii in pRO.InvoiceItems)
|
|
{
|
|
if (ii.UnitCount.HasValue && ii.UnitCount.Value > 0)
|
|
{
|
|
AddRechnungsposition(ii, rowIndex++);
|
|
}
|
|
}
|
|
//if (pRO.InvoiceItems.Count == 3)
|
|
//{
|
|
// SetzeRechnungsTexte(pRO.InvoiceItems[0], cellStart1, cellEnd1, cellHourlyRate1, cellFLS1);
|
|
// SetzeRechnungsTexte(pRO.InvoiceItems[1], cellStart2, cellEnd2, cellHourlyRate2, cellFLS2);
|
|
// SetzeRechnungsTexte(pRO.InvoiceItems[2], cellStart3, cellEnd3, cellHourlyRate3, cellFLS3);
|
|
//}
|
|
//else if (pRO.InvoiceItems.Count == 2)
|
|
//{
|
|
// SetzeRechnungsTexte(pRO.InvoiceItems[0], cellStart1, cellEnd1, cellHourlyRate1, cellFLS1);
|
|
// SetzeRechnungsTexte(pRO.InvoiceItems[1], cellStart2, cellEnd2, cellHourlyRate2, cellFLS2);
|
|
//}
|
|
//else
|
|
//{
|
|
// SetzeRechnungsTexte(pRO.InvoiceItems[0], cellStart1, cellEnd1, cellHourlyRate1, cellFLS1);
|
|
//}
|
|
}
|
|
else
|
|
{
|
|
ErstelleStandardRechnungspositionen(pRO, terminationDate);
|
|
}
|
|
}
|
|
|
|
private void AddRechnungsposition(InvoiceItemDC ii, int rowIndex)
|
|
{
|
|
XRTableRow newRow = null;
|
|
if (rowIndex > 2)
|
|
{
|
|
newRow = tableRechnungspositionen.InsertRowBelow(tableRechnungspositionen.Rows[tableRechnungspositionen.Rows.Count - 1]);
|
|
}
|
|
else
|
|
{
|
|
newRow = tableRechnungspositionen.Rows[rowIndex + 1];
|
|
}
|
|
newRow.Cells[0].Text = String.Format("{0:dd.MM.yyyy}", ii.ItemPeriodStart);
|
|
newRow.Cells[1].Text = String.Format("{0:dd.MM.yyyy}", ii.ItemPeriodEnd);
|
|
newRow.Cells[2].Text = String.Format("{0:0.00}", ii.AmountPerUnit);
|
|
newRow.Cells[3].Text = String.Format("{0:0.00}", ii.UnitCount);
|
|
}
|
|
|
|
private void SetzeRechnungsTexte(InvoiceItemDC ii, XRTableCell cellStart, XRTableCell cellEnd, XRTableCell cellHourlyRate, XRTableCell cellFLS)
|
|
{
|
|
cellStart.Text = String.Format("{0:dd.MM.yyyy}", ii.ItemPeriodStart);
|
|
cellEnd.Text = String.Format("{0:dd.MM.yyyy}", ii.ItemPeriodEnd);
|
|
cellHourlyRate.Text = String.Format("{0:c}", ii.AmountPerUnit);
|
|
cellFLS.Text = String.Format("{0:0.00}", ii.UnitCount);
|
|
}
|
|
|
|
private void ErstelleStandardRechnungspositionen(SettlementRO pRO, DateTime? terminationDate)
|
|
{
|
|
|
|
pRO.AccountingEndDateString = CorrectPossibleTerminationEndDate(pRO.AccountingEndDateString, terminationDate);
|
|
|
|
if (pRO.DifferentHourlyRateCount == 3)
|
|
{
|
|
//Erbrachte Leistungen (FLS) - bis [HourlyRateOldEndDateString] à [HourlyRateOldString] €
|
|
|
|
pRO.Abrechnungstext1 = String.Format("{0} bis {1}",
|
|
pRO.AccountingStartDateString, pRO.HourlyRate3EndDateString);
|
|
|
|
pRO.Abrechnungstext1 += String.Format(": {0:0.##} FLS {1}x {2:c}",
|
|
pRO.GeleisteteFLSMitStundensatz3, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRate3);
|
|
|
|
//[AccountingStartDateString] - [HourlyRate3EndDateString] sind [RecordedFLSWithHourlyRate3String] Std. x [HourlyRate3String] € =";
|
|
|
|
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.##} FLS {1}x {2:c}",
|
|
pRO.GeleisteteFLSMitStundensatzAlt, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateOld);
|
|
|
|
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.##} FLS {1}x {2:c}",
|
|
pRO.GeleisteteFLSMitStundensatzAktuell, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateNew);
|
|
|
|
pRO.Betrag3 = String.Format("{0:c}", pRO.GeleisteteFLSMitStundensatzAktuell * (decimal)pRO.RateFactor * pRO.HourlyRateNew);
|
|
|
|
|
|
|
|
cellStart1.Text = pRO.AccountingStartDateString;
|
|
cellEnd1.Text = pRO.HourlyRate3EndDateString;
|
|
cellHourlyRate1.Text = pRO.HourlyRate3String;
|
|
cellFLS1.Text = pRO.RecordedFLSWithHourlyRate3String;
|
|
|
|
cellStart2.Text = pRO.HourlyRateOldStartDateString;
|
|
cellEnd2.Text = pRO.HourlyRateOldEndDateString;
|
|
cellHourlyRate2.Text = pRO.HourlyRateOldString;
|
|
cellFLS2.Text = pRO.RecordedFLSWithOldHourlyRateString;
|
|
|
|
cellStart3.Text = pRO.HourlyRateNewStartDateString;
|
|
cellEnd3.Text = pRO.AccountingEndDateString;
|
|
cellHourlyRate3.Text = pRO.HourlyRateNewString;
|
|
cellFLS3.Text = pRO.RecordedFLSWithNewHourlyRateString;
|
|
}
|
|
else if (pRO.DifferentHourlyRateCount == 2)
|
|
{
|
|
|
|
pRO.Abrechnungstext2 = String.Format("{0} bis {1}",
|
|
pRO.AccountingStartDateString, pRO.HourlyRateOldEndDateString);
|
|
pRO.Abrechnungstext2 += String.Format(": {0:0.##} FLS {1}x {2:c}",
|
|
pRO.GeleisteteFLSMitStundensatzAlt, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateOld);
|
|
|
|
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.##} FLS {1}x {2:c}",
|
|
pRO.GeleisteteFLSMitStundensatzAktuell, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateNew);
|
|
|
|
pRO.Betrag3 = String.Format("{0:c}", pRO.GeleisteteFLSMitStundensatzAktuell * (decimal)pRO.RateFactor * pRO.HourlyRateNew);
|
|
|
|
|
|
cellStart1.Text = pRO.AccountingStartDateString;
|
|
cellEnd1.Text = pRO.HourlyRateOldEndDateString;
|
|
cellHourlyRate1.Text = pRO.HourlyRateOldString;
|
|
cellFLS1.Text = pRO.RecordedFLSWithOldHourlyRateString;
|
|
|
|
cellStart2.Text = pRO.HourlyRateNewStartDateString;
|
|
cellEnd2.Text = pRO.AccountingEndDateString;
|
|
cellHourlyRate2.Text = pRO.HourlyRateNewString;
|
|
cellFLS2.Text = pRO.RecordedFLSWithNewHourlyRateString;
|
|
}
|
|
else
|
|
{
|
|
cellStart1.Text = pRO.AccountingStartDateString;
|
|
cellEnd1.Text = pRO.AccountingEndDateString;
|
|
cellHourlyRate1.Text = pRO.HourlyRateNewString;
|
|
cellFLS1.Text = pRO.RecordedFLSWithNewHourlyRateString;
|
|
|
|
pRO.Abrechnungstext3 = String.Format("{0} bis {1}",
|
|
pRO.AccountingStartDateString, pRO.AccountingEndDateString);
|
|
pRO.Abrechnungstext3 += String.Format(": {0:0.##} FLS {1}x {2:c}",
|
|
pRO.GeleisteteFLSMitStundensatzAktuell, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateNew);
|
|
|
|
pRO.Betrag3 = String.Format("{0:c}", pRO.GeleisteteFLSMitStundensatzAktuell * (decimal)pRO.RateFactor * pRO.HourlyRateNew);
|
|
}
|
|
}
|
|
|
|
private string CorrectPossibleTerminationEndDate(string dateString, DateTime? terminationDate)
|
|
{
|
|
if (terminationDate.HasValue)
|
|
{
|
|
DateTime dt = DateTime.MinValue;
|
|
if (DateTime.TryParse(dateString, out dt))
|
|
{
|
|
if (terminationDate < dt)
|
|
{
|
|
return String.Format("{0:dd.MM.yyyy}", terminationDate);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return dateString;
|
|
}
|
|
}
|
|
}
|