2018-03-02 16:34:24 +01:00
using System ;
using System.Text ;
using BeWo.Data.Access ;
using BeWo.Data.Entities ;
using BeWo.Report ;
using BeWo.Report.ReportObjects ;
using BeWo.Service.Plugins ;
using BeWo.Service.ServiceImplementations ;
using BS.Shared ;
using BS.Shared.Core ;
using DevExpress.XtraReports.UI ;
namespace CaritasAhlen
{
public partial class ServiceInvoiceReport : XtraReport , IBeWoReport < ServiceInvoiceRO >
{
public ServiceInvoiceReport ( )
{
this . InitializeComponent ( ) ;
}
public void SetReportDataSource ( ServiceInvoiceRO pRO )
{
StringBuilder sb = new StringBuilder ( ) ;
if ( ! String . IsNullOrEmpty ( pRO . RecipientOrganisation ) )
{
sb . AppendLine ( pRO . RecipientOrganisation ) ;
}
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 ( ) ;
pRO . Notice = "" ;
ortDatum . Text = string . Format ( "Ahlen, den {0}" , pRO . InvoiceDate ) ;
//lblAZ.Text = pRO.CustomerReferenceNumber;
if ( pRO . InvoiceDateTime . HasValue )
pRO . Notice = String . Format ( "{0:dd.MM.yyyy}" , pRO . InvoiceDateTime . Value . AddDays ( 30 ) ) ;
decimal stunden = 0 ;
decimal stundenSatz = 0 ;
decimal rateFactor = 0 ;
if ( pRO . ServiceInvoicePeriods ! = null )
{
foreach ( var sip in pRO . ServiceInvoicePeriods )
{
if ( sip . ServiceInvoiceItems ! = null )
{
foreach ( var ii in sip . ServiceInvoiceItems )
{
//if (!String.IsNullOrEmpty(ii.RateFactor))
//{
//var rfStr = ii.RateFactor.Replace("%", "").Replace(",00", "").Trim();
//int rfInt = 0;
//Int32.TryParse(rfStr, out rfInt);
//rateFactor = (100m + rfInt) / 100m;
//}
if ( ii . HourlyRate . HasValue )
{
stundenSatz = ii . HourlyRate . Value ;
}
if ( ii . UnitCount . HasValue )
{
stunden = ii . UnitCount . Value ;
}
}
}
}
}
cellGeleisteteFls . Text = String . Format ( "{0:0.00}" , stunden ) ;
cellStundensatz . Text = String . Format ( "{0:c}" , stundenSatz ) ;
cellGesamt . Text = String . Format ( "{0}" , pRO . GrossClaim ) ;
SetCustomerInfos ( pRO ) ;
SetBewilligungInfos ( pRO ) ;
this . bindingSource1 . DataSource = pRO ;
}
private void SetCustomerInfos ( ServiceInvoiceRO pRO )
{
String mnr = String . Empty ;
Customer c = null ;
if ( pRO . CustomerOid . HasValue )
{
c = DAOFactory . GenericDAO . LoadByID < Customer > ( pRO . CustomerOid . Value ) ;
}
if ( c = = null )
{
if ( pRO . ServiceInvoicePeriods . Count > 0 )
{
var c2s = pRO . ServiceInvoicePeriods [ 0 ] . CostBearer2SupportConcept ;
c = c2s . SupportConcept . Customer ;
}
}
}
private void SetBewilligungInfos ( ServiceInvoiceRO pRO )
{
DateTime ? start = null ;
DateTime ? end = null ;
Customer c = null ;
long c2sOid = 0 ;
decimal gesamtbudget = 0 ;
decimal restBudget = 0 ;
if ( pRO . CustomerOid . HasValue )
{
c = DAOFactory . GenericDAO . LoadByID < Customer > ( pRO . CustomerOid . Value ) ;
}
if ( pRO . ServiceInvoicePeriods . Count > 0 )
{
var c2s = pRO . ServiceInvoicePeriods [ 0 ] . CostBearer2SupportConcept ;
c2sOid = c2s . Oid . Value ;
start = c2s . StartDate ;
end = c2s . EndDate ;
if ( c = = null )
{
c = c2s . SupportConcept . Customer ;
}
}
String customername = "" ;
String customername2 = "" ;
if ( c ! = null )
{
customername = c . Person . FirstNameLastName ;
customername2 = c . Person . FirstNameLastName ;
if ( c . Person . Sex . HasValue )
{
if ( c . Person . Sex . Value = = Sex . Female )
{
customername = "Frau " + customername ;
customername2 = "Frau " + customername2 ;
}
else
{
customername = "Herr " + customername ;
customername2 = "Herrn " + customername2 ;
}
}
}
if ( c2sOid > 0 )
{
ServiceRecordStatisticFactory factory = new ServiceRecordStatisticFactory ( ) ;
var stats = factory . CreateSupportConceptStatisticsImpl ( c2sOid , pRO . AccountingPeriodEnd ) ;
if ( stats ! = null )
{
gesamtbudget = stats . MinutesApprovedTotal / 60 ;
restBudget = ( stats . MinutesApprovedTotal - stats . MinutesProvidedTotal ) / 60 ;
}
}
lblBudget . Text = String . Format ( "{0} hat {1:0.00} Fachleistungsstunden f<> r den Bewilligungszeitraum {2:dd.MM.yyyy}-{3:dd.MM.yyyy} zur Verf<72> gung! {4:0.00} FLS bleiben noch zur Verf<72> gung." ,
customername ,
gesamtbudget ,
start ,
end ,
restBudget ) ;
2018-11-22 14:05:45 +01:00
2018-03-02 16:34:24 +01:00
lblAnrede . Text =
String . Format (
"Sehr geehrte Frau Althoff,\n\nhiermit stellen wir Ihnen die geleisteten Fachleistungsstunden f<> r {0} in Rechnung." ,
customername2 ) ;
}
}
}