285 lines
13 KiB
C#
285 lines
13 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using BeWo.Data.Access;
|
||
using BeWo.Data.Entities;
|
||
using BeWo.Report;
|
||
using BeWo.Report.ReportObjects;
|
||
using BeWo.Service.DCEntityMapper;
|
||
using BeWo.Service.Plugins;
|
||
using BS.Shared;
|
||
using BS.Shared.DataContracts;
|
||
using BS.Shared.Services;
|
||
|
||
namespace Nous
|
||
{
|
||
public partial class Rechnung : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServiceInvoiceRO>
|
||
{
|
||
public Rechnung()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
|
||
public void SetReportDataSource(ServiceInvoiceRO pRO)
|
||
{
|
||
if (pRO.CustomerBirthdate.HasValue)
|
||
{
|
||
var custDC = DAOFactory.SearchDAO.FindCustomer(pRO.CustomerFirstName, pRO.CustomerLastName, pRO.CustomerBirthdate.Value).ToList();
|
||
|
||
if (custDC.Count > 0)
|
||
{
|
||
if (custDC.Count == 1)
|
||
{
|
||
var dc = MapperFactory.CustomerDC_Customer.MapToNewDC(custDC[0]);
|
||
// Wenn InvoiceAddressTown Leverkusen, dann Leverkusener-Standort mit Logo und Adresse
|
||
if (dc.InvoiceAddressTown != null && dc.InvoiceAddressTown.ToLower().Contains("leverkusen"))
|
||
{
|
||
pbLeverkusen.Visible = true;
|
||
lblAdresseLeverkusen.Visible = true;
|
||
lblNOUS.Text = lblNOUS.Text.Replace("IBAN DE95 3755 1440 0100 1439 57", "DE91 3755 1440 0100 1775 91");
|
||
lblNOUS.Text = lblNOUS.Text.Replace("Wallstr. 81", "Friedrich-Ebert-Str. 120");
|
||
lblNOUS.Text = lblNOUS.Text.Replace("51063 Köln", "51373 Leverkusen");
|
||
lblNOUS.Text = lblNOUS.Text.Replace("Geschäftsführer", "Geschäftsleitung");
|
||
lblNOUS.Text = lblNOUS.Text.Replace("S. Schwope", "Deniz Erden");
|
||
lblNOUS.Text = lblNOUS.Text.Replace("0151 . 24 01 19 84", "0176 47 18 36 56");
|
||
lblNOUS.Text = lblNOUS.Text.Replace("G. Gurgsdies", "");
|
||
lblNOUS.Text = lblNOUS.Text.Replace("0176 . 51 00 40 98", "");
|
||
|
||
}
|
||
else
|
||
{
|
||
pbStandard.Visible = true;
|
||
lblStandard.Visible = true;
|
||
lblAdresseStandard.Visible = true;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
pbStandard.Visible = true;
|
||
lblStandard.Visible = true;
|
||
lblAdresseStandard.Visible = true;
|
||
}
|
||
|
||
|
||
SetBewilligung(pRO);
|
||
SetzeEmpfaengerAdresse(pRO);
|
||
|
||
foreach (var sip in pRO.ServiceInvoicePeriods)
|
||
{
|
||
foreach (var ii in sip.ServiceInvoiceItems)
|
||
{
|
||
ii.UnitDescription = String.Format("{0:0.00} FLS x {1:c}", ii.UnitCount, ii.AmountPerUnit);
|
||
|
||
if (ii.ServiceDescription == null)
|
||
{
|
||
ii.ServiceDescription = "Fallpauschale";
|
||
ii.UnitDescription = string.Format("{0:c}", ii.AmountPerUnit);
|
||
}
|
||
else
|
||
{
|
||
// Familienhilfe Fachkraft
|
||
if (ii.ServiceDescription == "Sozialpädagogische Familienhilfe nach §31 SGB VIII")
|
||
{
|
||
this.lblTitel.Text = "Rechnung \r\nMonat [AccountingPeriodStart!MMMM yyyy] Sozialpädagogische Familienhilfe nach §31 SGB VIII für\r\n[CustomerLastName], [CustomerFirstName] geb.: [CustomerBirthdate!dd.MM.yyyy]";
|
||
ii.ServiceDescription = "Fachkraft";
|
||
}
|
||
// Flexhilfe Fachkraft
|
||
else if (ii.ServiceDescription == "Flexible Erziehungshilfe nach §27 Abs. 2 SGB VIII")
|
||
{
|
||
this.lblTitel.Text = "Rechnung \r\nMonat [AccountingPeriodStart!MMMM yyyy] Flexible Erziehungshilfe nach §27 Abs. 2 SGB VIII für\r\n[CustomerLastName], [CustomerFirstName] geb.: [CustomerBirthdate!dd.MM.yyyy]";
|
||
ii.ServiceDescription = "Fachkraft";
|
||
}
|
||
// INSPE Fachkraft
|
||
else if (ii.ServiceDescription == "Intensive sozialpädagogische Betreuung nach §35 SGB VIII")
|
||
{
|
||
this.lblTitel.Text = "Rechnung \r\nMonat [AccountingPeriodStart!MMMM yyyy] Intensive sozialpädagogische Betreuung nach §35 SGB VIII für\r\n[CustomerLastName], [CustomerFirstName] geb.: [CustomerBirthdate!dd.MM.yyyy]";
|
||
ii.ServiceDescription = "Fachkraft";
|
||
}
|
||
// EGH KJ
|
||
else if (ii.ServiceDescription == "Eingliederungshilfe für Kinder und Jugendliche mit seelischer Behinderung nach §35a SGB VIII")
|
||
{
|
||
this.lblTitel.Text = "Rechnung \r\nMonat [AccountingPeriodStart!MMMM yyyy] Eingliederungshilfe für Kinder und Jugendliche mit seelischer Behinderung nach §35a SGB VIII für\r\n[CustomerLastName], [CustomerFirstName] geb.: [CustomerBirthdate!dd.MM.yyyy]";
|
||
ii.ServiceDescription = "Fachkraft";
|
||
}
|
||
// Familienhilfe Ergänzungskraft
|
||
else if (ii.ServiceDescription.Contains("Ergänzungskraft nach §27 SGB VIII"))
|
||
{
|
||
if (!this.lblTitel.Text.Contains("§")) // Wenn noch eine andere Hilfe geleistet wurde soll Ergänzungshilfe nicht im Titel stehen
|
||
this.lblTitel.Text = "Rechnung \r\nMonat [AccountingPeriodStart!MMMM yyyy] Ergänzungskraft nach §27 SGB VIII für\r\n[CustomerLastName], [CustomerFirstName] geb.: [CustomerBirthdate!dd.MM.yyyy]";
|
||
|
||
if (ii.ServiceDescription == "1 Ergänzungskraft nach §27 SGB VIII")
|
||
{
|
||
ii.ServiceDescription = "Ergänzungskraft";
|
||
}
|
||
else if (ii.ServiceDescription == "2 Ergänzungskraft nach §27 SGB VIII")
|
||
{
|
||
ii.ServiceDescription = "Fachkraft";
|
||
}
|
||
}
|
||
// Schulbegleitung Fachkraft (Jetzt Inklusionsbegleitung)
|
||
else if (ii.ServiceDescription.Contains("Schulbegleitung nach §35a SGB VIII"))
|
||
{
|
||
this.lblTitel.Text = "Rechnung \r\nMonat [AccountingPeriodStart!MMMM yyyy] Inklusionsbegleitung nach §35a SGB VIII für\r\n[CustomerLastName], [CustomerFirstName] geb.: [CustomerBirthdate!dd.MM.yyyy]";
|
||
|
||
if (ii.ServiceDescription == "1 Schulbegleitung nach §35a SGB VIII")
|
||
{
|
||
ii.ServiceDescription = "Fachkraft";
|
||
}
|
||
else if (ii.ServiceDescription == "2 Schulbegleitung nach §35a SGB VIII")
|
||
{
|
||
ii.ServiceDescription = "Assistenzkr. m. 2-jähr. Ausb.";
|
||
}
|
||
else if (ii.ServiceDescription == "3 Schulbegleitung nach §35a SGB VIII")
|
||
{
|
||
ii.ServiceDescription = "Assistenzkraft";
|
||
}
|
||
}
|
||
// AFT
|
||
else if (ii.ServiceDescription.Contains("Aufsuchende Familientherapie nach §27 Abs. 3 SGB VIII"))
|
||
{
|
||
this.lblTitel.Text = "Rechnung \r\nMonat [AccountingPeriodStart!MMMM yyyy] Aufsuchende Familientherapie nach §27 Abs. 3 SGB VIII für\r\n[CustomerLastName], [CustomerFirstName] geb.: [CustomerBirthdate!dd.MM.yyyy]";
|
||
ii.ServiceDescription = "Fachkraft";
|
||
}
|
||
else if (ii.ServiceDescription.Contains("Schul"))
|
||
{
|
||
this.lblTitel.Text = "Rechnung \r\nMonat [AccountingPeriodStart!MMMM yyyy] Inklusionsbegleitung nach §35a SGB VIII für\r\n[CustomerLastName], [CustomerFirstName] geb.: [CustomerBirthdate!dd.MM.yyyy]";
|
||
ii.ServiceDescription = "Fachkraft";
|
||
}
|
||
else
|
||
{
|
||
ii.ServiceDescription = "Fachkraft";
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
this.bindingSource1.DataSource = pRO;
|
||
}
|
||
|
||
private void SetBewilligung(ServiceInvoiceRO pRo)
|
||
{
|
||
if (pRo.InvoiceBase != null && pRo.InvoiceBase.SupportConceptCostBearerRelDc != null)
|
||
{
|
||
var c2s = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(pRo.InvoiceBase.SupportConceptCostBearerRelDc.CostBearer2SupportConceptOid.Value);
|
||
var c2sDc = MapperFactory.SupportConceptCostBearerRelDC_CostBearer2SupportConcept.MapToNewDC(c2s);
|
||
|
||
var calc = PluginLoader.FindClass<Calculations>(c2s.CostBearer.ID) ?? Calculations.GetInstance(c2s.CostBearer.ID);
|
||
|
||
var approvedTotal = calc.GetApprovedHoursPerWeekAverage(c2sDc, false) ?? 0;
|
||
|
||
decimal? approvedFls = null;
|
||
decimal? approvedErg = null;
|
||
|
||
String flsText = "";
|
||
foreach (var scap in c2sDc.ApprovalPeriodList)
|
||
{
|
||
|
||
if (scap.ServiceCategory != null && scap.ServiceCategory.Name.Contains("Fachkraft"))
|
||
{
|
||
approvedFls = calc.GetApprovedHoursPerWeek(scap, c2sDc.CostBearer.CostRatePeriods);
|
||
}
|
||
else if (scap.ServiceCategory != null && scap.ServiceCategory.Name.Contains("Ergänzung"))
|
||
{
|
||
approvedErg = calc.GetApprovedHoursPerWeek(scap, c2sDc.CostBearer.CostRatePeriods);
|
||
}
|
||
}
|
||
|
||
if (!approvedFls.HasValue && !approvedErg.HasValue)
|
||
{
|
||
flsText = String.Format("{0:0.##} FLS/Woche", approvedTotal);
|
||
}
|
||
else
|
||
{
|
||
if (approvedFls.HasValue)
|
||
{
|
||
flsText = String.Format("{0:0.##} FLS/Woche", approvedFls);
|
||
}
|
||
|
||
if (approvedErg.HasValue)
|
||
{
|
||
if (flsText.Length > 0)
|
||
{
|
||
|
||
flsText += "\n";
|
||
}
|
||
flsText += String.Format("{0:0.##} Std./Woche", approvedErg);
|
||
}
|
||
}
|
||
|
||
cellFls.Text = flsText;
|
||
}
|
||
|
||
String hauptbetreuer = "";
|
||
List<String> alleBetreuer = new List<string>();
|
||
foreach (var sip in pRo.ServiceInvoicePeriods)
|
||
{
|
||
|
||
foreach (var ii in sip.ServiceInvoiceItems)
|
||
{
|
||
if (!String.IsNullOrEmpty(ii.Notice))
|
||
{
|
||
var names = ii.Notice.Split(',');
|
||
|
||
foreach (var name in names)
|
||
{
|
||
alleBetreuer.Add(name);
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
foreach (var name in alleBetreuer)
|
||
{
|
||
if (!hauptbetreuer.Contains(name))
|
||
{
|
||
if (hauptbetreuer.Length > 0)
|
||
{
|
||
hauptbetreuer += "\n";
|
||
}
|
||
|
||
hauptbetreuer += name;
|
||
}
|
||
}
|
||
cellBerater.Text = hauptbetreuer;
|
||
}
|
||
|
||
private void SetzeEmpfaengerAdresse(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.RecipientContactPerson))
|
||
{
|
||
sb.Append("z.Hd. ");
|
||
|
||
sb.AppendLine(pRO.RecipientContactPerson);
|
||
}
|
||
if (!String.IsNullOrEmpty(pRO.RecipientAddressLine1))
|
||
{
|
||
sb.AppendLine(pRO.RecipientAddressLine1);
|
||
}
|
||
if (!String.IsNullOrEmpty(pRO.RecipientStreet))
|
||
{
|
||
sb.AppendLine(pRO.RecipientStreet);
|
||
}
|
||
if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown))
|
||
{
|
||
sb.AppendLine(pRO.RecipientPostCodeAndTown);
|
||
}
|
||
lblAdresse.Text = sb.ToString();
|
||
}
|
||
}
|
||
}
|