Files
BeWoPlaner/ReportImp/CaritasAhlen/SettlementReport.cs
2021-05-24 21:40:02 +02:00

249 lines
11 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.DataContracts;
using DevExpress.XtraReports.UI;
namespace CaritasAhlen
{
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();
}
SetzeAdresse(pRO);
ErstelleRechnungspositionen(pRO);
ortDatum.Text = string.Format("Ahlen, den {0}", pRO.InvoiceDate);
xrCheckBox2.Checked = true;
if (pRO.CostBearer2SupportConceptOid > 0)
{
var c2s = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(pRO.CostBearer2SupportConceptOid);
if (c2s.SupportConcept.Customer.TerminationDate.HasValue)
{
xrCheckBox1.Text = String.Format(" Die Betreuung wurde am {0:dd.MM.yyyy} beendet.",
c2s.SupportConcept.Customer.TerminationDate);
xrCheckBox2.Checked = false;
xrCheckBox1.Checked = true;
}
}
bindingSource1.DataSource = pRO;
}
private void SetzeAdresse(SettlementRO pRO)
{
StringBuilder sb = new StringBuilder();
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation) && !String.IsNullOrEmpty(pRO.RecipientOrganisation.Trim()))
{
sb.AppendLine(pRO.RecipientOrganisation);
}
if (!String.IsNullOrEmpty(pRO.RecipientContactPerson) && !String.IsNullOrEmpty(pRO.RecipientContactPerson.Trim()))
{
sb.AppendLine(pRO.RecipientContactPerson);
}
if (!String.IsNullOrEmpty(pRO.RecipientDivision) && !String.IsNullOrEmpty(pRO.RecipientDivision.Trim()))
{
sb.AppendLine(pRO.RecipientDivision);
}
if (!String.IsNullOrEmpty(pRO.RecipientStreet) && !String.IsNullOrEmpty(pRO.RecipientStreet.Trim()))
{
sb.AppendLine(pRO.RecipientStreet);
}
if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown) && !String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown.Trim()))
{
sb.AppendLine(pRO.RecipientPostCodeAndTown);
}
lblAddress.Text = sb.ToString();
}
private void ErstelleRechnungspositionen(SettlementRO pRO)
{
bool erstelleStandard = true;
if (pRO.InvoiceItems != null && pRO.InvoiceItems.Count > 0)
{
erstelleStandard = false;
if (pRO.InvoiceItems.Count == 1 && pRO.InvoiceItems[0].ItemDescription == "Spitzabrechnung")
{
erstelleStandard = true;
}
}
if (!erstelleStandard)
{
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);
}
}
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:0.00}", ii.AmountPerUnit);
cellFLS.Text = String.Format("{0:0.00}", ii.UnitCount);
}
private void ErstelleStandardRechnungspositionen(SettlementRO pRO)
{
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);
}
}
}
}