233 lines
10 KiB
C#
233 lines
10 KiB
C#
using System;
|
|
using System.Text;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Report;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace SehtMuenster
|
|
{
|
|
|
|
public partial class Budgetnachweis : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<SettlementRO>
|
|
{
|
|
public Budgetnachweis()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(SettlementRO pRO)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation))
|
|
{
|
|
sb.AppendLine(pRO.RecipientOrganisation);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientContactPerson))
|
|
{
|
|
sb.AppendLine(pRO.RecipientContactPerson);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientDivision))
|
|
{
|
|
sb.AppendLine(pRO.RecipientDivision);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientStreet))
|
|
{
|
|
sb.AppendLine(pRO.RecipientStreet);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown))
|
|
{
|
|
sb.AppendLine(pRO.RecipientPostCodeAndTown);
|
|
}
|
|
lblAdresse.Text = sb.ToString();
|
|
|
|
|
|
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("{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++);
|
|
//}
|
|
}
|
|
}
|
|
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 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;
|
|
}
|
|
}
|
|
}
|