263 lines
9.4 KiB
C#
263 lines
9.4 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.ServiceImplementations;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.Extensions;
|
|
using DevExpress.XtraReports.UI;
|
|
using PraxisPusteblume.Invoicing;
|
|
|
|
namespace PraxisPusteblume
|
|
{
|
|
[IDSpecificClass(Identifier = "IfsRechnungBezirk")]
|
|
public partial class IfsRechnungBezirk : XtraReport, IBeWoReport<ServiceInvoiceRO>
|
|
{
|
|
public IfsRechnungBezirk()
|
|
{
|
|
this.InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServiceInvoiceRO pRO)
|
|
{
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation))
|
|
{
|
|
if (pRO.RecipientOrganisation.EndsWith(" - IFS"))
|
|
{
|
|
pRO.RecipientOrganisation = pRO.RecipientOrganisation.Replace(" - IFS", "").Trim();
|
|
}
|
|
|
|
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();
|
|
|
|
|
|
|
|
decimal? ambulantBe = null;
|
|
decimal? ambulantPreis = null;
|
|
decimal? mobilBe = null;
|
|
decimal? mobilPreis = null;
|
|
decimal? teamBe = null;
|
|
decimal? teamPreis = null;
|
|
decimal? investBe = null;
|
|
decimal? investPreis = null;
|
|
|
|
|
|
if (pRO.ServiceInvoicePeriods != null && pRO.ServiceInvoicePeriods.Count > 0)
|
|
{
|
|
foreach (var p in pRO.ServiceInvoicePeriods)
|
|
{
|
|
|
|
if (p.ServiceInvoiceItems != null && p.ServiceInvoiceItems.Count > 0)
|
|
{
|
|
|
|
foreach (var i in p.ServiceInvoiceItems)
|
|
{
|
|
decimal count = i.UnitCount ?? 0;
|
|
decimal amount = 0;
|
|
|
|
Decimal.TryParse(i.GrossAmount.Replace("€", "").Trim(), out amount);
|
|
|
|
|
|
if (i.ServiceDescription.Contains("Team"))
|
|
{
|
|
if (!teamBe.HasValue)
|
|
{
|
|
teamBe = 0;
|
|
}
|
|
|
|
teamBe += count;
|
|
|
|
if (!teamPreis.HasValue)
|
|
{
|
|
teamPreis = 0;
|
|
}
|
|
|
|
teamPreis += amount;
|
|
|
|
}
|
|
else if (i.ServiceDescription.Contains("Invest"))
|
|
{
|
|
if (!investBe.HasValue)
|
|
{
|
|
investBe = 0;
|
|
}
|
|
|
|
investBe += count;
|
|
|
|
if (!investPreis.HasValue)
|
|
{
|
|
investPreis = 0;
|
|
}
|
|
|
|
investPreis += amount;
|
|
|
|
}
|
|
else if (i.ServiceDescription.Contains("mobil"))
|
|
{
|
|
if (!mobilBe.HasValue)
|
|
{
|
|
mobilBe = 0;
|
|
}
|
|
|
|
mobilBe += count;
|
|
|
|
if (!mobilPreis.HasValue)
|
|
{
|
|
mobilPreis = 0;
|
|
}
|
|
|
|
mobilPreis += amount;
|
|
|
|
|
|
}
|
|
else if (i.ServiceDescription.Contains("ambulant"))
|
|
{
|
|
if (!ambulantBe.HasValue)
|
|
{
|
|
ambulantBe = 0;
|
|
}
|
|
|
|
ambulantBe += count;
|
|
|
|
if (!ambulantPreis.HasValue)
|
|
{
|
|
ambulantPreis = 0;
|
|
}
|
|
|
|
ambulantPreis += amount;
|
|
}
|
|
|
|
if (i.ServiceRecord != null)
|
|
{
|
|
pRO.CreatorName = i.ServiceRecord.InsUser;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
cellAmbulantBe.Text = String.Format("{0:0.##}", ambulantBe);
|
|
cellAmbulantBetrag.Text = String.Format("{0:c}", ambulantPreis);
|
|
cellMobilBe.Text = String.Format("{0:0.##}", mobilBe);
|
|
cellMobilBetrag.Text = String.Format("{0:c}", mobilPreis);
|
|
cellTeamBe.Text = String.Format("{0:0.##}", teamBe);
|
|
cellTeamBetrag.Text = String.Format("{0:c}", teamPreis);
|
|
cellInvestBe.Text = String.Format("{0:0.##}", investBe);
|
|
cellInvestBetrag.Text = String.Format("{0:c}", investPreis);
|
|
|
|
//cellPreisg.Text = String.Format("{0:c}", investPreis);
|
|
|
|
cellGesamtSumme.Text = pRO.GrossClaim;
|
|
|
|
SetzePreise(pRO);
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private void SetzePreise(ServiceInvoiceRO pRO)
|
|
{
|
|
decimal preisAmbulant = 60.29m;
|
|
decimal preisMobil = 80.83m;
|
|
decimal preisGruppe = 33.68m;
|
|
decimal preisTeam = 11.26m;
|
|
decimal preisInvest = 4.84m;
|
|
|
|
|
|
if (pRO.AccountingPeriodStart >= new DateTime(2020, 3, 1))
|
|
{
|
|
preisTeam = 11.38m;
|
|
preisGruppe = 34.05m;
|
|
}
|
|
if (pRO.AccountingPeriodStart >= new DateTime(2021, 6, 1))
|
|
{
|
|
preisTeam = 11.63m;
|
|
}
|
|
|
|
if (DateTime.Now >= new DateTime(2021, 8, 17))
|
|
{
|
|
preisInvest = 6.86m;
|
|
}
|
|
if (pRO.AccountingPeriodStart >= new DateTime(2025, 04, 01))
|
|
{
|
|
var preise = DAOFactory.GenericDAO.GetAllActive<Preis>();
|
|
preisInvest = GetPreis(preise, "Invest (TS)", pRO.AccountingPeriodStart);
|
|
preisTeam = GetPreis(preise, "Team", pRO.AccountingPeriodStart);
|
|
}
|
|
|
|
var cat = DAOFactory.SearchDAO.FindServiceCategoryByName("IFS - Psychologie / Heilpädagogik");
|
|
if (cat != null)
|
|
{
|
|
var sdList = DAOFactory.SearchDAO.FindServiceDescriptionForCategory(cat.Oid.Value);
|
|
|
|
var mobil = sdList.FirstOrDefault(s => s.Name.Contains("mobil"));
|
|
if (mobil != null && mobil.CostRatePeriods != null)
|
|
{
|
|
var crpList = MapperFactory.CostRatePeriodDC_CostRatePeriod.MapToNewDCs(mobil.CostRatePeriods);
|
|
CostRatePeriodDC crp = crpList.GetCostRatePeriodForDate(CostRatePeriodType.AmountOfMoney, pRO.AccountingPeriodStart);
|
|
|
|
if (crp != null && crp.CostRateValue.HasValue)
|
|
{
|
|
preisMobil = crp.CostRateValue.Value;
|
|
}
|
|
}
|
|
var ambulant = sdList.FirstOrDefault(s => s.Name.Contains("ambulant"));
|
|
if (ambulant != null && ambulant.CostRatePeriods != null)
|
|
{
|
|
var crpList = MapperFactory.CostRatePeriodDC_CostRatePeriod.MapToNewDCs(ambulant.CostRatePeriods);
|
|
CostRatePeriodDC crp = crpList.GetCostRatePeriodForDate(CostRatePeriodType.AmountOfMoney, pRO.AccountingPeriodStart);
|
|
|
|
if (crp != null && crp.CostRateValue.HasValue)
|
|
{
|
|
preisAmbulant = crp.CostRateValue.Value;
|
|
}
|
|
}
|
|
}
|
|
|
|
cellPreisAmbulant.Text = String.Format("{0:c}", preisAmbulant);
|
|
cellPreisMobil.Text = String.Format("{0:c}", preisMobil);
|
|
cellPreisTeam.Text = String.Format("{0:c}", preisTeam);
|
|
cellPreisInvest.Text = String.Format("{0:c}", preisInvest);
|
|
}
|
|
|
|
private static decimal GetPreis(IList<Preis> allePreise, String name, DateTime datum)
|
|
{
|
|
var tagessatz = allePreise.Where(p => p.Name.Contains(name)).FirstOrDefault();
|
|
if (tagessatz != null)
|
|
{
|
|
var crlist = MapperFactory.CostRatePeriodDC_CostRatePeriod.MapToNewDCs(tagessatz.CostRatePeriods);
|
|
var cr = crlist.GetCostRatePeriodForDate(CostRatePeriodType.AmountOfMoney, datum);
|
|
if (cr != null && cr.CostRateValue.HasValue)
|
|
{
|
|
return cr.CostRateValue.Value;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
}
|
|
} |