306 lines
10 KiB
C#
306 lines
10 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.Remoting.Messaging;
|
|
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 AbrechnungsbogenReisen : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
|
|
{
|
|
private Dictionary<string, decimal> key2Value = new Dictionary<string, decimal>();
|
|
private Dictionary<string, Dictionary<String, bool>> key2TagesDict = new Dictionary<string, Dictionary<String, bool>>();
|
|
private decimal totalVerhinderungspflege1 = 0;
|
|
private decimal totalVerhinderungspflege2 = 0;
|
|
private decimal totalZusatz1 = 0;
|
|
private decimal totalZusatz2 = 0;
|
|
private decimal totalKurzzeit1 = 0;
|
|
private decimal totalKurzzeit2 = 0;
|
|
private decimal totalSelbstzahler1 = 0;
|
|
private decimal totalSelbstzahler2 = 0;
|
|
|
|
private Pflegegrad? pflegegrad = null;
|
|
public AbrechnungsbogenReisen()
|
|
{
|
|
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);
|
|
}
|
|
lblMonat1.Text = String.Format("{0:MMM yy}", ro.StartDate);
|
|
lblMonat2.Text = String.Format("{0:MMM yy}", ro.StartDate.AddMonths(1));
|
|
|
|
|
|
if (ro.Services != null)
|
|
{
|
|
ErstelleTagesDict(ro.Services);
|
|
foreach (ServicesOverviewRO.ServiceDetail s in ro.Services)
|
|
{
|
|
AddDetailToTable(ro, s);
|
|
}
|
|
}
|
|
|
|
cellSumme11.Text = String.Format("{0:c}", totalVerhinderungspflege1);
|
|
cellSumme21.Text = String.Format("{0:c}", totalVerhinderungspflege2);
|
|
|
|
cellSumme12.Text = String.Format("{0:c}", totalZusatz1);
|
|
cellSumme22.Text = String.Format("{0:c}", totalZusatz2);
|
|
|
|
cellSumme13.Text = String.Format("{0:c}", totalKurzzeit1);
|
|
cellSumme23.Text = String.Format("{0:c}", totalKurzzeit2);
|
|
|
|
cellSumme14.Text = String.Format("{0:c}", totalSelbstzahler1);
|
|
cellSumme24.Text = String.Format("{0:c}", totalSelbstzahler2);
|
|
|
|
|
|
cellPreis1.Text = String.Format("{0:c}", totalVerhinderungspflege1 + totalZusatz1 + totalKurzzeit1 + totalSelbstzahler1);
|
|
cellPreis2.Text = String.Format("{0:c}", totalVerhinderungspflege2 + totalZusatz2 + totalKurzzeit2 + totalSelbstzahler2);
|
|
|
|
cellPreisGesamt.Text = String.Format("{0:c}", totalVerhinderungspflege1 + totalZusatz1 + totalKurzzeit1 + totalSelbstzahler1 +
|
|
totalVerhinderungspflege2 + totalZusatz2 + totalKurzzeit2 + totalSelbstzahler2);
|
|
|
|
this.bindingSource1.DataSource = ro;
|
|
}
|
|
|
|
|
|
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 Customer GetCustomer(ServicesOverviewRO ro)
|
|
{
|
|
if (ro.CostBearer2SupportConceptList != null && ro.CostBearer2SupportConceptList.Count > 0)
|
|
{
|
|
return ro.CostBearer2SupportConceptList[0].SupportConcept.Customer;
|
|
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
private decimal GetStundensatz(IList<ServiceCategory> cats, string categoryName, DateTime startDate)
|
|
{
|
|
decimal stundensatz = 0;
|
|
|
|
foreach (var cat in cats)
|
|
{
|
|
if (!String.IsNullOrEmpty(cat.Name))
|
|
{
|
|
if (cat.Name.ToLower().Trim() == categoryName.ToLower() && cat.CostRatePeriods != null)
|
|
{
|
|
var catDcs = MapperFactory.CostRatePeriodDC_CostRatePeriod.MapToNewDCs(cat.CostRatePeriods);
|
|
|
|
var cr = catDcs.GetCostRatePeriodForDate(CostRatePeriodType.AmountOfMoney, startDate);
|
|
|
|
if (cr != null && cr.CostRateValue.HasValue)
|
|
{
|
|
stundensatz = cr.CostRateValue.Value;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return stundensatz;
|
|
}
|
|
|
|
private void ErstelleTagesDict(List<ServicesOverviewRO.ServiceDetail> services)
|
|
{
|
|
foreach (var sd in services)
|
|
{
|
|
String leistung = sd.ServiceCategory.ToLower().Trim();
|
|
|
|
|
|
if (!key2TagesDict.ContainsKey(leistung))
|
|
{
|
|
key2TagesDict[leistung] = new Dictionary<String, bool>();
|
|
}
|
|
|
|
DateTime start = sd.StartDate;
|
|
DateTime end = sd.EndDate;
|
|
|
|
if (sd.ServiceDescription == "Kurzurlaub")
|
|
{
|
|
while (start <= end)
|
|
{
|
|
String key = String.Format("{0:dd.MM.yyyy}", start);
|
|
|
|
if (!key2TagesDict[leistung].ContainsKey(key))
|
|
{
|
|
key2TagesDict[leistung].Add(key, true);
|
|
}
|
|
start = start.AddDays(1);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
private void AddDetailToTable(ServicesOverviewRO ro, ServicesOverviewRO.ServiceDetail sd)
|
|
{
|
|
|
|
var table = xrTableMonat1;
|
|
|
|
DateTime start = sd.StartDate;
|
|
DateTime end = sd.EndDate;
|
|
|
|
|
|
while (start <= end)
|
|
{
|
|
bool cont = true;
|
|
if (start.Month == ro.StartDate.Month)
|
|
{
|
|
table = xrTableMonat1;
|
|
}
|
|
else if (start.Month == ro.StartDate.AddMonths(1).Month)
|
|
{
|
|
table = xrTableMonat2;
|
|
}
|
|
else
|
|
{
|
|
cont = false;
|
|
}
|
|
|
|
if (cont)
|
|
{
|
|
SetTableText(table, start, sd.ServiceCategory, sd.ServiceDescription);
|
|
}
|
|
start = start.AddDays(1);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
private void SetTableText(XRTable table, DateTime dt, String categorie, String serviceDescription)
|
|
{
|
|
XRTableCell cell = null;
|
|
|
|
int column = 1;
|
|
String text = "";
|
|
|
|
|
|
int row = dt.Day;
|
|
|
|
String leistung = categorie.ToLower().Trim();
|
|
var key2Date = key2TagesDict[leistung];
|
|
|
|
decimal preis = 0;
|
|
|
|
if (serviceDescription.Contains("Kurzurlaub"))
|
|
{
|
|
preis = AbrechnungsInfo.GetPreisForKurzurlaub(pflegegrad, key2Date, dt);
|
|
}
|
|
else
|
|
{
|
|
preis = AbrechnungsInfo.GetPreisForReisen(pflegegrad, dt);
|
|
}
|
|
|
|
|
|
if (leistung.Contains("verhinderungspflege"))
|
|
{
|
|
if (table.Name == "xrTableMonat1")
|
|
{
|
|
totalVerhinderungspflege1 += preis;
|
|
}
|
|
else
|
|
{
|
|
totalVerhinderungspflege2 += preis;
|
|
}
|
|
|
|
text = String.Format("{0:c}", AddToGesamtSumme(preis, table.Name, column, row));
|
|
}
|
|
else if (leistung.Contains("entlastung"))
|
|
{
|
|
if (table.Name == "xrTableMonat1")
|
|
{
|
|
totalZusatz1 += preis;
|
|
}
|
|
else
|
|
{
|
|
totalZusatz2 += preis;
|
|
}
|
|
column = 2;
|
|
text = String.Format("{0:c}", AddToGesamtSumme(preis, table.Name, column, row));
|
|
}
|
|
else if (leistung.Contains("kurzzeit"))
|
|
{
|
|
if (table.Name == "xrTableMonat1")
|
|
{
|
|
totalKurzzeit1 += preis;
|
|
}
|
|
else
|
|
{
|
|
totalKurzzeit2 += preis;
|
|
}
|
|
column = 3;
|
|
text = String.Format("{0:c}", AddToGesamtSumme(preis, table.Name, column, row));
|
|
}
|
|
else if (leistung.Contains("selbstzahler"))
|
|
{
|
|
if (table.Name == "xrTableMonat1")
|
|
{
|
|
totalSelbstzahler1 += preis;
|
|
}
|
|
else
|
|
{
|
|
totalSelbstzahler2 += preis;
|
|
}
|
|
column = 4;
|
|
text = String.Format("{0:c}", AddToGesamtSumme(preis, table.Name, column, row));
|
|
}
|
|
|
|
table.Rows[row].Cells[column].Text = text;
|
|
|
|
|
|
}
|
|
|
|
private decimal AddToGesamtSumme(decimal preis, string name, int column, int row)
|
|
{
|
|
String key = String.Format("{0}_{1}_{2}", name, column, row);
|
|
decimal decimalValue = 0;
|
|
|
|
if (key2Value.ContainsKey(key))
|
|
{
|
|
decimalValue = key2Value[key];
|
|
}
|
|
decimalValue += preis;
|
|
key2Value[key] = decimalValue;
|
|
|
|
return decimalValue;
|
|
|
|
}
|
|
}
|
|
}
|