Files

124 lines
4.9 KiB
C#

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Text;
using DevExpress.XtraReports.UI;
using BeWo.Report.ReportObjects;
using BeWo.Report;
namespace InputFamilienhilfe.Neu
{
public partial class Rechnung : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServiceInvoiceRO>
{
public string invoiceName;
public Rechnung()
{
InitializeComponent();
}
public void SetReportDataSource(ServiceInvoiceRO 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();
DateTime end = pRO.AccountingPeriodEnd;
string alias = "";
if (pRO.ServiceInvoicePeriods != null && pRO.ServiceInvoicePeriods.Count > 0 && pRO.ServiceInvoicePeriods[0].Customer != null)
{
alias = pRO.ServiceInvoicePeriods[0].Customer.CustomerAlias;
}
invoiceName = String.Format("-{0:MM} {1} {2} {3}", end, pRO.CustomerLastName, alias, pRO.InvoiceBase.RecipientPersonLastName);
lblRechnungsnummer.Text = pRO.InvoiceNumber;
bool isVerfahrensbeistandschaft = false;
decimal amount = 0;
if (pRO.ServiceInvoicePeriods.Count == 1 && pRO.ServiceInvoicePeriods[0].ServiceInvoiceItems.Count == 1)
{
var ii = pRO.ServiceInvoicePeriods[0].ServiceInvoiceItems[0];
if (!String.IsNullOrEmpty(ii.ServiceDescription) && ii.ServiceDescription.ToLower().Contains("verfahrensbeistand"))
{
isVerfahrensbeistandschaft = true;
amount = ii.NetAmount ?? 0;
}
if (!String.IsNullOrEmpty(ii.ServiceDescription) && ii.ServiceDescription.ToLower().Contains("rechnungsdifferenz") && ii.ServiceDescription.EndsWith("?")) // CB HACK: Ich habe gesehen, dass bei denen in der DB das Euro Zeichen in ein Fragezeichen umgewandelt wurde
{
ii.ServiceDescription = ii.ServiceDescription.Replace("?", "€");
}
//if (pRO.ServiceInvoicePeriods[0].SupportConceptApprovalPeriod != null && pRO.ServiceInvoicePeriods[0].SupportConceptApprovalPeriod.ApprovedFixedAmount.HasValue)
//{
// lblRechnungstext.Text = String.Format("für die Soziale Gruppenarbeit im Leistungszeitraum {0:dd.MM.yyyy} - {0:dd.MM.yyyy} erlaube ich mir Ihnen folgende Pauschale zu berechnen:", pRO.AccountingPeriodStart, pRO.AccountingPeriodEnd);
//}
}
if (isVerfahrensbeistandschaft)
{
//xrSubreport1.Visible = false;
if (amount > 500)
{
lblRechnungstext.Text = "gemäß § 158 Abs. 4 FamFG in Verbindung mit § 158 Abs. 4 S. 3 FamFG erlaube ich mir für die o.g. Verfahrensbeistandschaft folgende Rechnung zu stellen";
}
else
{
lblRechnungstext.Text = "gemäß § 158 Abs. 4 FamFG erlaube ich mir für die o.g. Verfahrensbeistandschaft folgende Rechnung zu stellen";
}
}
DateTime frist = pRO.InvoiceDateTime.Value.AddDays(14);
lblFrist.Text = String.Format("Ich bitte Sie, den Rechnungsbetrag in Höhe von {0:c} bis zum {1:dd.MM.yyyy} unter Angabe der Rechnungsnummer auf das unten angegebene Konto zu überweisen.", pRO.GrossClaim, frist);
//else
//{
var subReport = xrSubreport1.ReportSource as RechnungspositionenSubReport;
if (subReport != null)
subReport.SetReportDataSource(pRO);
//}
int posCount = 0;
foreach (var sip in pRO.ServiceInvoicePeriods)
{
posCount += sip.ServiceInvoiceItems.Count;
}
if (posCount > 6)
{
bottomMarginBand1.HeightF = 30;
GroupFooter1.PrintAtBottom = false;
}
this.bindingSource1.DataSource = pRO;
}
private void ChangeName(object sender, EventArgs e)
{
PrintingSystem.Document.Name = lblRechnungsnummer.Text + invoiceName;
}
}
}