2019-08-29 15:39:32 +02:00
using System ;
2022-08-17 10:05:28 +02:00
using System.Linq ;
2019-08-29 15:39:32 +02:00
using System.Text ;
using BeWo.Data.Access ;
using BeWo.Data.Entities ;
using BeWo.Report ;
using BeWo.Report.ReportObjects ;
using DevExpress.XtraReports.UI ;
namespace KetteReports
{
public partial class ServiceInvoiceReport : XtraReport , IBeWoReport < ServiceInvoiceRO >
{
public ServiceInvoiceReport ( )
{
this . InitializeComponent ( ) ;
}
public void SetReportDataSource ( ServiceInvoiceRO pRO )
{
if ( ! String . IsNullOrEmpty ( pRO . SenderContactPersonMail ) )
{
pRO . SenderContactPersonMail = pRO . SenderContactPersonMail . Replace ( "E-Mail:" , "" ) . Trim ( ) ;
}
if ( ! String . IsNullOrEmpty ( pRO . SenderContactPersonPhone ) )
{
pRO . SenderContactPersonPhone = pRO . SenderContactPersonPhone . Replace ( "Tel.:" , "" ) . Trim ( ) ;
}
if ( ! String . IsNullOrEmpty ( pRO . SenderContactPersonFax ) )
{
pRO . SenderContactPersonFax = pRO . SenderContactPersonFax . Replace ( "Fax:" , "" ) . Trim ( ) ;
}
2019-11-14 16:13:41 +01:00
//Rechnung an Sozialamt Bergisch Gladbach, Gybowitch und Herrn Schulze. Adresse Abrechnungsbetreuungsleistung f<> r steht kein Name
2019-08-29 15:39:32 +02:00
SetzeAdresse ( pRO ) ;
2022-07-20 14:07:41 +02:00
// Die haben verschiedene Bereiche, zwei Anpassungen sind nur f<> r Fachbereich Jugend - Erkennungsmerkmal ist "Jugendamt"
2022-07-04 16:05:46 +02:00
if ( pRO . RecipientOrganisation . ToLower ( ) . Contains ( "jugendamt" ) & & pRO . ServiceInvoicePeriods [ 0 ] . ServiceInvoiceItems [ 0 ] . UnitDescription ! = null )
2022-07-11 17:02:14 +02:00
pRO . CustomerReferenceNumber + = " " + pRO . ServiceInvoicePeriods [ 0 ] . ServiceInvoiceItems [ 0 ] . UnitDescription ;
2019-08-29 15:39:32 +02:00
DateTime start = pRO . AccountingPeriodStart ;
DateTime end = pRO . AccountingPeriodEnd ;
if ( start . Month = = end . Month & & start . Year = = end . Year )
{
lblAbrechnungszeitraum . Text = String . Format ( "hiermit berechnen wir f<> r den Monat {0:MMMM yyyy} folgende erbrachte T<> tigkeiten:" , start ) ;
}
else
{
lblAbrechnungszeitraum . Text = String . Format ( "hiermit berechnen wir f<> r den Zeitraum {0:MMMM yyyy} - {1:MMMM yyyy} folgende erbrachte T<> tigkeiten:" , start , end ) ;
}
String notice = String . Format ( "Bitte <20> berweisen Sie den geforderten Betrag bis zum {0:dd.MM.yyyy} auf die unten aufgef<65> hrte Bankverbindung." , pRO . InvoiceDateTime . Value . AddDays ( 21 ) ) ;
2022-07-20 14:07:41 +02:00
if ( pRO . RecipientOrganisation . ToLower ( ) . Contains ( "jugendamt" ) )
{
lblAbsender . Visible = false ;
lblKundennr . Visible = false ;
lblAbsenderJA . Visible = true ;
2022-11-10 10:30:28 +01:00
lblAdresszeile . Visible = false ;
lblAdresszeileJA . Visible = true ;
2022-07-20 14:07:41 +02:00
notice + =
2022-07-25 16:43:45 +02:00
"\nSollten Sie dem Lastschriftverfahren zugestimmt haben, wird der Rechnungsbetrag in den n<> chsten Tagen von ihrem Konto eingezogen.\nUm Ihre <20> berweisung besser zuordnen zu k<> nnen, bitten wir Sie um die Angabe der Rechnungsnummer." ;
2022-07-20 14:07:41 +02:00
}
else
2019-08-29 15:39:32 +02:00
notice + =
2022-07-25 16:43:45 +02:00
"\nSollten Sie dem Lastschriftverfahren zugestimmt haben, wird der Rechnungsbetrag in den n<> chsten Tagen von ihrem Konto eingezogen.\nUm Ihre <20> berweisung besser zuordnen zu k<> nnen, bitten wir Sie um die Angabe des Leistungsmonats, der Kundennummer und der Rechnungsnummer." ;
2019-08-29 15:39:32 +02:00
if ( String . IsNullOrEmpty ( pRO . Notice ) )
{
pRO . Notice = notice ;
}
else
{
pRO . Notice + = "\n\n" + notice ;
}
2022-08-17 10:05:28 +02:00
foreach ( var list in pRO . ServiceInvoicePeriods )
{
list . ServiceInvoiceItems = list . ServiceInvoiceItems . OrderBy ( i = > i . Duration ) . ThenBy ( i = > i . ServiceDescription ) . ToList ( ) ;
}
2019-08-29 15:39:32 +02:00
this . bindingSource1 . DataSource = pRO ;
}
private void SetzeAdresse ( ServiceInvoiceRO pRO )
{
if ( pRO . CustomerOid . HasValue )
{
Customer c = DAOFactory . GenericDAO . LoadByID < Customer > ( pRO . CustomerOid . Value ) ;
if ( c . Person . InvoiceAddress ! = null )
{
StringBuilder sb = new StringBuilder ( ) ;
if ( ! String . IsNullOrEmpty ( c . Person . InvoiceAddress . AddressLine1 ) )
{
sb . AppendLine ( c . Person . InvoiceAddress . AddressLine1 ) ;
}
if ( ! String . IsNullOrEmpty ( c . Person . InvoiceAddress . AddressLine2 ) )
{
sb . AppendLine ( c . Person . InvoiceAddress . AddressLine2 ) ;
}
if ( ! String . IsNullOrEmpty ( c . Person . InvoiceAddress . Street ) )
{
sb . AppendLine ( c . Person . InvoiceAddress . Street ) ;
}
if ( ! String . IsNullOrEmpty ( c . Person . InvoiceAddress . PostalCode ) | | ! String . IsNullOrEmpty ( c . Person . InvoiceAddress . Town ) )
{
sb . AppendLine ( String . Format ( "{0} {1}" , c . Person . InvoiceAddress . PostalCode , c . Person . InvoiceAddress . Town ) . Trim ( ) ) ;
}
lblAdresse . Text = sb . ToString ( ) ;
return ;
}
}
SetzeDefaultAdresse ( pRO ) ;
}
private void SetzeDefaultAdresse ( ServiceInvoiceRO pRO )
{
StringBuilder sb = new StringBuilder ( ) ;
2019-11-14 16:13:41 +01:00
if ( ! String . IsNullOrEmpty ( pRO . RecipientAddressLine1 ) )
{
if ( pRO . RecipientAddressLine1 . StartsWith ( "Herrn " ) )
{
pRO . RecipientAddressLine1 = pRO . RecipientAddressLine1 . Replace ( "Herrn" , "Herr" ) ;
}
pRO . RecipientOrganisation = pRO . RecipientAddressLine1 ;
}
2019-08-29 15:39:32 +02:00
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 ( ) ;
}
}
}