408 lines
15 KiB
C#
408 lines
15 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.Extensions;
|
|
using DevExpress.XtraReports.UI;
|
|
using HphBersenbrueckFreizeitUndReisen.Abrechnung;
|
|
|
|
namespace HphBersenbrueckFreizeitUndReisen
|
|
{
|
|
public partial class Abrechnungsbogen : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
|
|
{
|
|
|
|
// § 45b Entlastungsbetrag
|
|
|
|
//§39 Verhinderungspflege
|
|
|
|
//§ 43 Kurzzeitpflege
|
|
|
|
//Eingliederungshilfe
|
|
|
|
//Selbstzahler
|
|
|
|
private Dictionary<string, decimal> key2Value = new Dictionary<string, decimal>();
|
|
private decimal totalStundenEhrenamtlich1 = 0;
|
|
private decimal totalStundenEhrenamtlich2 = 0;
|
|
private decimal totalStundenEhrenamtlich3 = 0;
|
|
private decimal totalStundenHauptamtlich1 = 0;
|
|
private decimal totalStundenHauptamtlich2 = 0;
|
|
private decimal totalStundenHauptamtlich3 = 0;
|
|
private decimal totalPreisStunden1 = 0;
|
|
private decimal totalPreisStunden2 = 0;
|
|
private decimal totalPreisStunden3 = 0;
|
|
private decimal totalFreizeit1 = 0;
|
|
private decimal totalFreizeit2 = 0;
|
|
private decimal totalFreizeit3 = 0;
|
|
private decimal totalAusflug1 = 0;
|
|
private decimal totalAusflug2 = 0;
|
|
private decimal totalAusflug3 = 0;
|
|
|
|
private Pflegegrad? pflegegrad = null;
|
|
private IList<ServiceDescription> allServiceDesciptions = null;
|
|
public Abrechnungsbogen()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServicesOverviewRO ro)
|
|
{
|
|
ro.StartDate = ro.StartDate.AddDays(1);
|
|
var customer = GetCustomer(ro);
|
|
if (customer != null)
|
|
{
|
|
pflegegrad = customer.Pflegegrad;
|
|
|
|
lblPflegekasse.Text = VarFieldHelper.GetVarFieldForOid(1, customer);
|
|
if (pflegegrad.HasValue)
|
|
{
|
|
lblPflegestufe.Text = EnumTranslations.PflegegradTranslations[pflegegrad.Value];
|
|
}
|
|
lblGesetzVertreter.Text = CreateGesetzlVertreter(customer);
|
|
}
|
|
allServiceDesciptions = DAOFactory.GenericDAO.GetAllActive<ServiceDescription>();
|
|
|
|
lblMonat1.Text = String.Format("{0:MMM yy}", ro.StartDate);
|
|
lblMonat2.Text = String.Format("{0:MMM yy}", ro.StartDate.AddMonths(1));
|
|
lblMonat3.Text = String.Format("{0:MMM yy}", ro.StartDate.AddMonths(2));
|
|
|
|
if (ro.Services != null)
|
|
{
|
|
foreach (ServicesOverviewRO.ServiceDetail s in ro.Services)
|
|
{
|
|
AddDetailToTable(ro, s);
|
|
}
|
|
}
|
|
|
|
|
|
cellStunden1.Text = String.Format("{0:0.00}", (totalStundenEhrenamtlich1 + totalStundenHauptamtlich1) / 60);
|
|
cellStunden2.Text = String.Format("{0:0.00}", (totalStundenEhrenamtlich2 + totalStundenHauptamtlich2) / 60);
|
|
cellStunden3.Text = String.Format("{0:0.00}", (totalStundenEhrenamtlich3 + totalStundenHauptamtlich3) / 60);
|
|
|
|
//Umwandlung Pflege/Sachleistung alls neue Seite wie Verhinderungungspflege
|
|
|
|
//Fehler bei Frau Droste bei Verhinderungspflege und Selbstzahler
|
|
|
|
//Bei neuen Start bis Enddatum Kurzzurlaub neu berechnen
|
|
|
|
//Michael Rolfes Entlastungsbetrag taucht nicht auf
|
|
|
|
|
|
|
|
//var stundensatzEhren = GetStundensatz(descs, "Einzelbetreuung", ro.StartDate);
|
|
//var stundensatzHaupt = GetStundensatz(descs, "Einzelbetreuung Hauptamtl", ro.StartDate);
|
|
|
|
//var einzelstundenGesamt1 = (totalStundenEhrenamtlich1 / 60)* stundensatzEhren;
|
|
//einzelstundenGesamt1 += (totalStundenHauptamtlich1 / 60) * stundensatzHaupt;
|
|
|
|
cellEinzelSumme1.Text = String.Format("{0:c}", totalPreisStunden1);
|
|
|
|
//stundensatzEhren = GetStundensatz(descs, "Einzelbetreuung", ro.StartDate.AddMonths(1));
|
|
//stundensatzHaupt = GetStundensatz(descs, "Einzelbetreuung Hauptamtl", ro.StartDate);
|
|
|
|
//var einzelstundenGesamt2 = (totalStundenEhrenamtlich2 / 60) * stundensatzEhren;
|
|
//einzelstundenGesamt2 += (totalStundenHauptamtlich2 / 60) * stundensatzHaupt;
|
|
|
|
cellEinzelSumme2.Text = String.Format("{0:c}", totalPreisStunden2);
|
|
|
|
//stundensatzEhren = GetStundensatz(descs, "Einzelbetreuung", ro.StartDate.AddMonths(2));
|
|
//stundensatzHaupt = GetStundensatz(descs, "Einzelbetreuung Hauptamtl", ro.StartDate);
|
|
|
|
//var einzelstundenGesamt3 = (totalStundenEhrenamtlich3 / 60) * stundensatzEhren;
|
|
//einzelstundenGesamt3 += (totalStundenHauptamtlich3 / 60) * stundensatzHaupt;
|
|
|
|
cellEinzelSumme3.Text = String.Format("{0:c}", totalPreisStunden3);
|
|
|
|
cellFreizeitSumme1.Text = String.Format("{0:c}", totalFreizeit1);
|
|
cellFreizeitSumme2.Text = String.Format("{0:c}", totalFreizeit2);
|
|
cellFreizeitSumme3.Text = String.Format("{0:c}", totalFreizeit3);
|
|
|
|
cellAusflugSumme1.Text = String.Format("{0:c}", totalAusflug1);
|
|
cellAusflugSumme2.Text = String.Format("{0:c}", totalAusflug2);
|
|
cellAusflugSumme3.Text = String.Format("{0:c}", totalAusflug3);
|
|
|
|
cellPreis1.Text = String.Format("{0:c}", totalFreizeit1 + totalAusflug1 + totalPreisStunden1);
|
|
cellPreis2.Text = String.Format("{0:c}", totalFreizeit2 + totalAusflug2 + totalPreisStunden2);
|
|
cellPreis3.Text = String.Format("{0:c}", totalFreizeit3 + totalAusflug3 + totalPreisStunden3);
|
|
|
|
cellPreisGesamt.Text = String.Format("{0:c}", GetPreisGesamt());
|
|
|
|
lblAbrechnungsart.Text = GetAbrechnungsText(ro);
|
|
|
|
lblAbtretung.Visible = VarFieldHelper.HatAbtretungserklaerung(customer);
|
|
|
|
this.bindingSource1.DataSource = ro;
|
|
}
|
|
|
|
public decimal GetPreisGesamt()
|
|
{
|
|
return totalFreizeit1 + totalAusflug1 + totalFreizeit2 + totalAusflug2 + totalFreizeit3 + totalAusflug3 +
|
|
totalPreisStunden1 + totalPreisStunden2 + totalPreisStunden3;
|
|
}
|
|
|
|
private string CreateGesetzlVertreter(Customer c)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
sb.Append(VarFieldHelper.GetVarFieldForOid(2, c));
|
|
if (sb.Length > 0)
|
|
sb.Append(" ");
|
|
sb.Append(VarFieldHelper.GetVarFieldForOid(3, c));
|
|
if (sb.Length > 0)
|
|
sb.Append(" ");
|
|
sb.Append(VarFieldHelper.GetVarFieldForOid(4, c));
|
|
|
|
return sb.ToString();
|
|
}
|
|
|
|
private string GetAbrechnungsText(ServicesOverviewRO ro)
|
|
{
|
|
string text = "";
|
|
if (ro.Services.Count > 0)
|
|
{
|
|
var cat = ro.Services[0].ServiceCategory;
|
|
|
|
if (cat.ToLower().Contains("entlastung"))
|
|
{
|
|
text = "§ 45b SGBXI Entlastungsbetrag";
|
|
}
|
|
else if (cat.ToLower().Contains("verhinderung"))
|
|
{
|
|
text = "§39 SGBXI Verhinderungspflege";
|
|
}
|
|
else if (cat.ToLower().Contains("selbstzahler"))
|
|
{
|
|
text = "Selbstzahler";
|
|
}
|
|
else
|
|
{
|
|
text = cat;
|
|
}
|
|
}
|
|
return text;
|
|
}
|
|
|
|
private Customer GetCustomer(ServicesOverviewRO ro)
|
|
{
|
|
if (ro.CostBearer2SupportConceptList != null && ro.CostBearer2SupportConceptList.Count > 0)
|
|
{
|
|
return ro.CostBearer2SupportConceptList[0].SupportConcept.Customer;
|
|
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
private decimal GetStundensatz(IList<ServiceDescription> descs, string searchedName, string catName, DateTime startDate)
|
|
{
|
|
decimal stundensatz = 0;
|
|
|
|
foreach (var desc in descs)
|
|
{
|
|
var catName2 = desc.ServiceCategory.Name.ToLower().Trim();
|
|
if (!String.IsNullOrEmpty(desc.Name) && desc.CostRatePeriods != null && catName2 == catName)
|
|
{
|
|
if (desc.Name.ToLower().Trim() == searchedName.ToLower() || (desc.Name.ToLower().Contains("hauptamt") && searchedName.Contains("Haupt")))
|
|
{
|
|
//if (cat descName.Contains( && desc.ServiceCategory.Name == catName)))
|
|
var catDcs = MapperFactory.CostRatePeriodDC_CostRatePeriod.MapToNewDCs(desc.CostRatePeriods);
|
|
|
|
var cr = catDcs.GetCostRatePeriodForDate(CostRatePeriodType.AmountOfMoney, startDate);
|
|
|
|
if (cr != null && cr.CostRateValue.HasValue)
|
|
{
|
|
stundensatz = cr.CostRateValue.Value;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return stundensatz;
|
|
}
|
|
|
|
private void AddDetailToTable(ServicesOverviewRO ro, ServicesOverviewRO.ServiceDetail sd)
|
|
{
|
|
var table = xrTableMonat1;
|
|
|
|
if (sd.StartDate.Month == ro.StartDate.Month)
|
|
{
|
|
table = xrTableMonat1;
|
|
}
|
|
else if (sd.StartDate.Month == ro.StartDate.AddMonths(1).Month)
|
|
{
|
|
table = xrTableMonat2;
|
|
}
|
|
else if (sd.StartDate.Month == ro.StartDate.AddMonths(2).Month)
|
|
{
|
|
table = xrTableMonat3;
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
SetTableText(table, sd);
|
|
}
|
|
|
|
private void SetTableText(XRTable table, ServicesOverviewRO.ServiceDetail sd)
|
|
{
|
|
XRTableCell cell = null;
|
|
int row = sd.StartDate.Day;
|
|
int column = 1;
|
|
String text = "";
|
|
String descName = sd.ServiceDescription.ToLower().Trim();
|
|
String catName = sd.ServiceCategory.ToLower().Trim();
|
|
|
|
if (descName == "tagesfahrt")
|
|
{
|
|
decimal preis = AbrechnungsInfo.GetPreisForTagesfahrt(pflegegrad, sd.StartDate);
|
|
|
|
if (table.Name == "xrTableMonat1")
|
|
{
|
|
totalAusflug1 += preis;
|
|
}
|
|
else if (table.Name == "xrTableMonat2")
|
|
{
|
|
totalAusflug2 += preis;
|
|
}
|
|
else
|
|
{
|
|
totalAusflug3 += preis;
|
|
}
|
|
column = 3;
|
|
var zellenWert = GetZellenWert(table.Name, column, row);
|
|
zellenWert += preis;
|
|
SetzeZellenWert(zellenWert, table.Name, column, row);
|
|
text = String.Format("{0:c}", zellenWert);
|
|
}
|
|
else if(descName == "freizeitangebote")
|
|
{
|
|
decimal preis = AbrechnungsInfo.GetPreisForFreizeitangebot(pflegegrad, sd.StartDate);
|
|
|
|
if (table.Name == "xrTableMonat1")
|
|
{
|
|
totalFreizeit1 += preis;
|
|
}
|
|
else if (table.Name == "xrTableMonat2")
|
|
{
|
|
totalFreizeit2 += preis;
|
|
}
|
|
else
|
|
{
|
|
totalFreizeit3 += preis;
|
|
}
|
|
column = 2;
|
|
var zellenWert = GetZellenWert(table.Name, column, row);
|
|
zellenWert += preis;
|
|
SetzeZellenWert(zellenWert, table.Name, column, row);
|
|
text = String.Format("{0:c}", zellenWert);
|
|
}
|
|
else if (descName.Contains("ausflüge") || descName.Contains("ausflug"))
|
|
{
|
|
decimal preis = AbrechnungsInfo.GetPreisForAusflugFreizeittreff(pflegegrad, sd.StartDate);
|
|
|
|
if (table.Name == "xrTableMonat1")
|
|
{
|
|
totalAusflug1 += preis;
|
|
}
|
|
else if (table.Name == "xrTableMonat2")
|
|
{
|
|
totalAusflug2 += preis;
|
|
}
|
|
else
|
|
{
|
|
totalAusflug3 += preis;
|
|
}
|
|
column = 3;
|
|
var zellenWert = GetZellenWert(table.Name, column, row);
|
|
zellenWert += preis;
|
|
SetzeZellenWert(zellenWert, table.Name, column, row);
|
|
text = String.Format("{0:c}", zellenWert);
|
|
}
|
|
else if (descName.Contains("einzelbetreuung"))
|
|
{
|
|
decimal preis = 0;
|
|
|
|
if (descName.Contains("hauptamt"))
|
|
{
|
|
preis = GetStundensatz(allServiceDesciptions, "Einzelbetreuung Haupt", catName, sd.StartDate);
|
|
}
|
|
else
|
|
{
|
|
preis = GetStundensatz(allServiceDesciptions, "Einzelbetreuung", catName, sd.StartDate);
|
|
}
|
|
if (table.Name == "xrTableMonat1")
|
|
{
|
|
if (descName.Contains("hauptamt"))
|
|
{
|
|
totalStundenHauptamtlich1 += (decimal)sd.Minutes;
|
|
}
|
|
else
|
|
{
|
|
totalStundenEhrenamtlich1 += (decimal)sd.Minutes;
|
|
}
|
|
|
|
totalPreisStunden1 += ((decimal)sd.Minutes / 60) * preis;
|
|
}
|
|
else if (table.Name == "xrTableMonat2")
|
|
{
|
|
if (descName.Contains("hauptamt"))
|
|
{
|
|
totalStundenHauptamtlich2 += (decimal)sd.Minutes;
|
|
}
|
|
else
|
|
{
|
|
totalStundenEhrenamtlich2 += (decimal)sd.Minutes;
|
|
}
|
|
totalPreisStunden2 += ((decimal)sd.Minutes / 60) * preis;
|
|
}
|
|
else
|
|
{
|
|
if (descName.Contains("hauptamt"))
|
|
{
|
|
totalStundenHauptamtlich3 += (decimal)sd.Minutes;
|
|
}
|
|
else
|
|
{
|
|
totalStundenEhrenamtlich3 += (decimal)sd.Minutes;
|
|
}
|
|
totalPreisStunden3 += ((decimal)sd.Minutes / 60) * preis;
|
|
}
|
|
|
|
var zellenWert = GetZellenWert(table.Name, column, row);
|
|
zellenWert += (decimal)sd.Minutes;
|
|
|
|
SetzeZellenWert(zellenWert, table.Name, column, row);
|
|
text = String.Format("{0:0.00}", zellenWert / 60);
|
|
}
|
|
|
|
table.Rows[row].Cells[column].Text = text;
|
|
}
|
|
|
|
private void SetzeZellenWert(decimal neuerWert, string table, int column, int row)
|
|
{
|
|
String key = String.Format("{0}_{1}_{2}", table, column, row);
|
|
key2Value[key] = neuerWert;
|
|
}
|
|
|
|
private decimal GetZellenWert(String table, int column, int row)
|
|
{
|
|
String key = String.Format("{0}_{1}_{2}", table, column, row);
|
|
decimal decimalValue = 0;
|
|
|
|
if (key2Value.ContainsKey(key))
|
|
{
|
|
decimalValue = key2Value[key];
|
|
}
|
|
return decimalValue;
|
|
}
|
|
|
|
|
|
}
|
|
}
|