MalteserJohanniterJohanneshaus/Invoicing/CollectiveInvoiceTSHCreation - Abrechnung TSH

This commit is contained in:
2026-03-10 17:47:44 +01:00
parent 933561242c
commit 5ec7e6e4db
7 changed files with 324 additions and 49 deletions

View File

@@ -72,7 +72,7 @@ namespace MalteserJohanniterJohanneshaus
IBeWoReport<AdditionalServiceBookingRO> report = null;
var region = DAOFactory.GenericDAO.LoadByID<AdditionalServiceRegion>(addServiceRegionOid);
//var service = region.Name;
var service = region.Name;
var ro = AdditionalServiceBookingRO.Create(region, month, year);
report.SetReportDataSource(ro);
@@ -105,9 +105,7 @@ namespace MalteserJohanniterJohanneshaus
private List<ServicesOverviewRO> Create(int pMonth, int pYear, long orgaOid, long empOid, int startDay, int endDay, long? serviceCategoryOid = null)
{
var roList = new List<ServicesOverviewRO>();
List<long> customerOids = new List<long>();
ApplicationUser loggedInUser = null;
if (LoggedInUserOperationContextExt.Current != null && LoggedInUserOperationContextExt.Current.User != null)
@@ -132,13 +130,11 @@ namespace MalteserJohanniterJohanneshaus
if (all)
{
customerOids.AddRange(DAOFactory.GenericDAO.GetAllActive<Customer>()
.OrderBy(ob => ob.Person.LastName + ", " + ob.Person.FirstName).Select(c => c.Oid.Value));
customerOids.AddRange(DAOFactory.GenericDAO.GetAllActive<Customer>().OrderBy(ob => ob.Person.LastName + ", " + ob.Person.FirstName).Select(c => c.Oid.Value));
}
else
{
var teams = DAOFactory.SearchDAO.FindLeadingTeams(loggedInUser.Employee.Oid.Value);
foreach (var team in teams)
{
foreach (var employee in team.MemberList)
@@ -163,16 +159,11 @@ namespace MalteserJohanniterJohanneshaus
}
}
}
}
foreach (var coid in customerOids)
{
var ro = ServicesOverviewRO.Create(coid, pMonth, pYear, true, orgaOid, empOid, startDay, endDay, serviceCategoryOid);
//ServicesOverviewRO ro = ServicesOverviewRO.Create(customer, pSpan, disableEmptySupportConcepts, orgaOid, empOid, searchServiceRecordsByEndDate, serviceCategoryOid);
if (ro != null)
{
roList.Add(ro);
@@ -185,7 +176,6 @@ namespace MalteserJohanniterJohanneshaus
public override XtraReport CreateServiceOverviewReportForCustomers(IList<long> customerOids, int month, int year, long? orgaOid, long? empOid, long? serviceCategoryOid, int startDay, int endDay, bool nurFehlende)
{
var roList = new List<ServicesOverviewRO>();
foreach (var coid in customerOids)
{
var ro = ServicesOverviewRO.Create(coid, month, year, true, orgaOid ?? 0, empOid ?? 0, startDay, endDay, serviceCategoryOid);
@@ -197,7 +187,6 @@ namespace MalteserJohanniterJohanneshaus
if (roList.Count > 0)
{
var rootReport = CreateServicesOverviewReportForRo(roList[0], serviceCategoryOid);
rootReport.CreateDocument();
@@ -210,16 +199,14 @@ namespace MalteserJohanniterJohanneshaus
return rootReport;
}
return new XtraReport();
return new XtraReport();
}
public override XtraReport CreateServiceOverviewSingleCustomerReport(long customerOid, int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay)
{
var ro = ServicesOverviewRO.Create(customerOid, month, year, false, orgaOid, empOid, startDay, endDay, serviceCategoryOid);
return CreateServicesOverviewReportForRo(ro, serviceCategoryOid);
}
private XtraReport CreateServicesOverviewReportForRo(ServicesOverviewRO ro, long? serviceCategoryOid)
@@ -248,33 +235,5 @@ namespace MalteserJohanniterJohanneshaus
return report as XtraReport;
}
//public override XtraReport CreateQueryReport(long queryOid, String queryReportId)
//{
// var query = DAOFactory.GenericDAO.LoadByID<Query>(queryOid);
// if (query is null)
// {
// return new XtraReport();
// }
// var path = Utils.CreateSavePath(TempPath, queryReportId + ".xml");
// var table = Utils.XMLDeserialize<DataTable>(path);
// var qro = QueryRO.Create(query, table);
// if (qro.Rows.Count > 0)
// {
// Belegungsquoten report = new Belegungsquoten();
// report.SetReportDataSource(qro);
// if (report != null)
// {
// return report;
// }
// }
// return FindReportImp<QueryRO>(null, query.ReportTypeName) as XtraReport;
//}
}
}

View File

@@ -231,7 +231,7 @@ namespace MalteserJohanniterJohanneshaus.Invoicing
{
DateTime? startAbw = at.Start;
DateTime? endAbw = at.End;
if (at.Start.HasValue && (at.End.HasValue && at.End.Value.Date.Subtract(at.Start.Value.Date).TotalDays > 4)
if (!at.AbsenceReason.Description.ToLower().Contains("tsh") && at.Start.HasValue && (at.End.HasValue && at.End.Value.Date.Subtract(at.Start.Value.Date).TotalDays > 4)
|| (!at.End.HasValue && ende.Subtract(at.Start.Value.Date).TotalDays > 4))
{
if (at.End.HasValue)

View File

@@ -0,0 +1,246 @@
using System;
using System.Collections.Generic;
using System.Linq;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Service.DCEntityMapper;
using BeWo.Service.Invoicing;
using BeWo.Service.Plugins;
using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Compact;
using BS.Shared.Extensions;
using BS.Shared.Services;
namespace MalteserJohanniterJohanneshaus.Invoicing
{
public class CollectiveInvoiceTSHCreation : InvoiceCreation
{
private DateTime? accountingPeriodStart = null;
private DateTime? accountingPeriodEnd = null;
private decimal abwesenheitsReduzierung = 0.75m;
public override void SetInvoiceId(ServiceInvoice invoice)
{
invoice.InvoiceBase.InvoiceId = "RgTagesstaette";
invoice.InvoiceBase.InvoiceTypeText = "RgTSH";
}
// die haben 2 Standorte für TSH, die über Kostenstellen unter Notiz im Hilfeplan identifiziert werden
// Es werden grundsätzlich volle Tagessätze aus der Verwaltung abgerechnet
// alle Abwesenheitstage werden nur mit 75 % berechnet
public override List<ServiceInvoiceDC> GenerateServiceInvoices(long costBearerOid,
DateTimeSpan invoicePeriod,
Dictionary<CompactSupportConceptDC, List<ServiceRecordDC>> supportConcepts2ServiceRecords)
{
var costBearer = DAOFactory.GenericDAO.LoadByID<CostBearer>(costBearerOid);
//FuegeAbgelaufeneHilfeplaeneMitAktuellenBewilligungenHinzu(costBearer, invoicePeriod, supportConcepts2ServiceRecords);
var invoiceList = new List<ServiceInvoice>();
ServiceInvoice invoice;
Dictionary<CompactSupportConceptDC, List<ServiceRecordDC>> Aulholf = new Dictionary<CompactSupportConceptDC, List<ServiceRecordDC>>();
Dictionary<CompactSupportConceptDC, List<ServiceRecordDC>> Hannes = new Dictionary<CompactSupportConceptDC, List<ServiceRecordDC>>();
foreach (var sc in supportConcepts2ServiceRecords.Keys)
{
var c2s = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(sc.CostBearerRelOids[0]);
if (c2s.Notice.IsNotNullOrEmpty() && c2s.Notice.Contains("45"))
{
Aulholf.Add(sc, supportConcepts2ServiceRecords[sc]);
}
else if (c2s.Notice.IsNotNullOrEmpty() && c2s.Notice.Contains("50"))
{
Hannes.Add(sc, supportConcepts2ServiceRecords[sc]);
}
}
invoice = CreateCollectiveBilling2(costBearer, invoicePeriod, Aulholf);
if (invoice != null)
{
invoice.InvoiceBase.InvoiceTypeText = "KSt.45";
invoiceList.Add(invoice);
}
invoice = CreateCollectiveBilling2(costBearer, invoicePeriod, Hannes);
if (invoice != null)
{
invoice.InvoiceBase.InvoiceTypeText = "KSt.50";
invoiceList.Add(invoice);
}
var result = invoiceList.Select(item => MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewDC(item)).ToList();
return result.Count > 1 ? result.OrderBy(i => i.InvoiceBase.CustomerLastName).ToList() : result;
}
private ServiceInvoice CreateCollectiveBilling2(CostBearer costBearer, DateTimeSpan invoicePeriod, Dictionary<CompactSupportConceptDC, List<ServiceRecordDC>> supportConcepts2ServiceRecords)
{
var invoice = new ServiceInvoice();
var newDict = new Dictionary<CompactSupportConceptDC, List<ServiceRecordDC>>();
foreach (var sc2sr in supportConcepts2ServiceRecords)
{
if (!sc2sr.Key.IsArchived && !sc2sr.Key.IsDeleted)
newDict.Add(sc2sr.Key, sc2sr.Value);
}
SetRecipientInformation(invoice, costBearer);
SetSenderInformation(invoice);
SetInvoiceBaseData(0, invoice, costBearer, invoicePeriod, newDict.Keys.ToList());
SetCollectiveBillingBaseData(0, invoice, costBearer, invoicePeriod, newDict);
SetCollectiveBillingServiceInvoicePeriods(invoice, invoicePeriod, newDict);
SetServiceInvoicePeriodAmounts(invoice);
SetAmountAdvancePayments(invoice);
return invoice;
}
public override void SetInvoiceBaseData(int invoiceCounter, ServiceInvoice invoice, CostBearer costBearer, DateTimeSpan invoicePeriod,
IList<CompactSupportConceptDC> supportConceptList)
{
if (invoicePeriod != null)
{
accountingPeriodStart = invoicePeriod.StartDate;
accountingPeriodEnd = invoicePeriod.EndDate;
}
base.SetInvoiceBaseData(invoiceCounter, invoice, costBearer, invoicePeriod, supportConceptList);
}
public override void SetInvoiceItems(ServiceInvoice invoice,
ServiceInvoicePeriod serviceInvoicePeriod,
SupportConceptApprovalPeriodDC supportConceptApprovalPeriod,
CostBearer2SupportConcept cb2sc,
DateTimeSpan invoicePeriod,
List<ServiceRecordDC> serviceRecords)
{
CreateFixedAmounts(serviceInvoicePeriod, supportConceptApprovalPeriod, cb2sc);
}
public override void CreateFixedAmounts(ServiceInvoicePeriod serviceInvoicePeriod, SupportConceptApprovalPeriodDC supportConceptApprovalPeriod, CostBearer2SupportConcept cb2sc)
{
var calc = PluginLoader.FindClass<BS.Shared.Services.Calculations>(_SpecificID) ?? BS.Shared.Services.Calculations.GetInstance(_SpecificID);
var data = calc.GetFixedBillingData(supportConceptApprovalPeriod, serviceInvoicePeriod.Start, serviceInvoicePeriod.End);
var scap = supportConceptApprovalPeriod;
if (scap != null && scap.ServiceCategory != null)
{
IList<InvoiceItem> ergebnis = new List<InvoiceItem>();
var customer = cb2sc.SupportConcept.Customer;
DateTime start;
DateTime ende;
if (scap.StartDate <= serviceInvoicePeriod.Start)
{
start = serviceInvoicePeriod.Start.Value;
}
else
{
start = (DateTime)scap.StartDate;
}
if (scap.EndDate >= serviceInvoicePeriod.End)
{
ende = serviceInvoicePeriod.End.Value;
}
else
{
ende = (DateTime)scap.EndDate.Value;
}
decimal tagessatz = 0;
var crList = scap.ServiceCategory.CostRatePeriods;
var cr = crList.GetCostRatePeriodForDate(BS.Shared.CostRatePeriodType.AmountOfMoney, start);
if (cr != null && cr.CostRateValue.HasValue)
{
tagessatz = cr.CostRateValue.Value;
}
while (start <= ende)
{
DateTime monatStart = start; //new DateTime(start.Year, start.Month, 1);
DateTime monatEnde = monatStart.AddMonths(1); //ende.AddDays(1);
if (ende.AddDays(2) < monatStart.AddMonths(1))
{
monatEnde = ende.AddDays(1);
}
var tageMonat = monatEnde.Subtract(start).Days;
decimal? sumCustomerMonth = 0;
int tageAbwesendImMonat = 0;
foreach (var at in customer.AbsenceTimes)
{
DateTime? startAbw = at.Start;
DateTime? endAbw = at.End;
if (at.AbsenceReason.Description.ToLower().Contains("tsh") && at.Start.HasValue)
{
if (at.End.HasValue)
{
endAbw = at.End.Value;
}
else
{
endAbw = ende;
}
if (startAbw.HasValue && startAbw.Value < monatEnde && (!endAbw.HasValue || endAbw.Value >= monatStart))
{
DateTime abwStart = at.Start.Value;
if (start > abwStart)
{
abwStart = start.AddDays(-1);
}
DateTime abwEnd = monatEnde.AddDays(-1);
if (endAbw.HasValue && endAbw < monatEnde)
{
abwEnd = endAbw.Value;
}
DateTime dt = abwStart;
while (dt.Date <= abwEnd.Date)
{
tageAbwesendImMonat++;
dt = dt.AddDays(1);
}
}
}
}
var ii = new InvoiceItem();
ii.UnitCount = tageMonat - tageAbwesendImMonat;
ii.AmountPerUnit = tagessatz;
ii.AmountTotal = ii.UnitCount * ii.AmountPerUnit;
ii.GrossAmountTotal = ii.AmountTotal;
sumCustomerMonth += ii.AmountTotal;
ii.MaxApprovedAmount = null;
ii.ItemDescription = "Klientenname";
ii.UnitDescription = scap.ServiceCategory.Name;
ii.ItemPeriodStart = monatStart;
ii.Notice = String.Format("{0:dd.MM.yyyy} - {1:dd.MM.yyyy}", monatStart, monatEnde.AddDays(-1));
ii.SupportConceptApprovalPeriodOid = scap.SupportConceptApprovalPeriodOid;
ii.ItemDescription = "";
serviceInvoicePeriod.InvoiceItemList.Add(ii);
if (tageAbwesendImMonat > 0)
{
ii = new InvoiceItem();
ii.UnitCount = tageAbwesendImMonat;
ii.AmountPerUnit = Math.Round(abwesenheitsReduzierung * tagessatz, 2, MidpointRounding.AwayFromZero);
ii.AmountTotal = ii.UnitCount * ii.AmountPerUnit;
ii.GrossAmountTotal = ii.AmountTotal;
sumCustomerMonth += ii.AmountTotal;
ii.MaxApprovedAmount = null;
ii.ItemDescription = "Klientenname";
ii.UnitDescription = scap.ServiceCategory.Name + "- Abw";
ii.ItemPeriodStart = monatStart;
ii.Notice = String.Format("{0:dd.MM.yyyy} - {1:dd.MM.yyyy}", monatStart, monatEnde.AddDays(-1));
ii.SupportConceptApprovalPeriodOid = scap.SupportConceptApprovalPeriodOid;
ii.ItemDescription = "";
serviceInvoicePeriod.InvoiceItemList.Add(ii);
}
start = start.AddMonths(1);
start = new DateTime(start.Year, start.Month, 1);
}
}
}
}
}

View File

@@ -21,6 +21,10 @@ namespace MalteserJohanniterJohanneshaus.Invoicing
{
return new CollectiveInvoiceCreation();
}
if (sr.CostBearer.Name == "LVR")
{
return new CollectiveInvoiceTSHCreation();
}
}
var sd = sr.ServiceDescription.Category;
var ic = GetInvoiceCreatorForCategory(sd);

View File

@@ -107,6 +107,7 @@
<DependentUpon>InvoiceCustomerReport.cs</DependentUpon>
</Compile>
<Compile Include="Invoicing\AnwesenheitenZeiterfassungRO.cs" />
<Compile Include="Invoicing\CollectiveInvoiceTSHCreation.cs" />
<Compile Include="Invoicing\CollectiveInvoiceCreation.cs" />
<Compile Include="Invoicing\CustomInvoiceCreation.cs" />
<Compile Include="Invoicing\CustomInvoiceFactory.cs" />

View File

@@ -105,6 +105,9 @@ namespace MalteserJohanniterJohanneshaus
this.xrTableCell6 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell7 = new DevExpress.XtraReports.UI.XRTableCell();
this.Month = new DevExpress.XtraReports.UI.CalculatedField();
this.lblUeberschriftHeader = new DevExpress.XtraReports.UI.ReportHeaderBand();
this.lblDruckName = new DevExpress.XtraReports.UI.XRLabel();
this.lblUeberschrift = new DevExpress.XtraReports.UI.XRLabel();
this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components);
((System.ComponentModel.ISupportInitialize)(this.xrTable4)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.xrTableAbwesenheiten)).BeginInit();
@@ -881,7 +884,8 @@ namespace MalteserJohanniterJohanneshaus
this.DetailReport.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] {
this.Detail1,
this.DetailReport2,
this.GroupHeader1});
this.GroupHeader1,
this.lblUeberschriftHeader});
this.DetailReport.DataMember = "ServiceInvoicePeriods";
this.DetailReport.DataSource = this.bindingSource1;
this.DetailReport.Level = 0;
@@ -1170,11 +1174,53 @@ namespace MalteserJohanniterJohanneshaus
this.Month.FieldType = DevExpress.XtraReports.UI.FieldType.DateTime;
this.Month.Name = "Month";
//
// lblUeberschriftHeader
//
this.lblUeberschriftHeader.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
this.lblUeberschrift,
this.lblDruckName});
this.lblUeberschriftHeader.HeightF = 65.83303F;
this.lblUeberschriftHeader.Name = "lblUeberschriftHeader";
this.lblUeberschriftHeader.Visible = false;
//
// lblDruckName
//
this.lblDruckName.BackColor = System.Drawing.Color.Transparent;
this.lblDruckName.CanShrink = true;
this.lblDruckName.Font = new DevExpress.Drawing.DXFont("Arial", 9F, DevExpress.Drawing.DXFontStyle.Bold);
this.lblDruckName.LocationFloat = new DevExpress.Utils.PointFloat(898.8223F, 21.66646F);
this.lblDruckName.Multiline = true;
this.lblDruckName.Name = "lblDruckName";
this.lblDruckName.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
this.lblDruckName.SizeF = new System.Drawing.SizeF(123.176F, 22.50007F);
this.lblDruckName.StylePriority.UseBackColor = false;
this.lblDruckName.StylePriority.UseFont = false;
this.lblDruckName.StylePriority.UseTextAlignment = false;
this.lblDruckName.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopCenter;
this.lblDruckName.Visible = false;
this.lblDruckName.WordWrap = false;
//
// lblUeberschrift
//
this.lblUeberschrift.BackColor = System.Drawing.Color.Transparent;
this.lblUeberschrift.CanShrink = true;
this.lblUeberschrift.Font = new DevExpress.Drawing.DXFont("calibri", 11.25F, DevExpress.Drawing.DXFontStyle.Bold);
this.lblUeberschrift.LocationFloat = new DevExpress.Utils.PointFloat(0F, 21.66646F);
this.lblUeberschrift.Multiline = true;
this.lblUeberschrift.Name = "lblUeberschrift";
this.lblUeberschrift.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
this.lblUeberschrift.SizeF = new System.Drawing.SizeF(694.0436F, 22.50007F);
this.lblUeberschrift.StylePriority.UseBackColor = false;
this.lblUeberschrift.StylePriority.UseFont = false;
this.lblUeberschrift.StylePriority.UseTextAlignment = false;
this.lblUeberschrift.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopCenter;
this.lblUeberschrift.WordWrap = false;
//
// bindingSource1
//
this.bindingSource1.DataSource = typeof(BeWo.Report.ReportObjects.ServiceInvoiceRO);
//
// RechnungTagesstaetten
// RechnungBesWohnformen
//
this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] {
this.Detail,
@@ -1286,5 +1332,8 @@ namespace MalteserJohanniterJohanneshaus
private DevExpress.XtraReports.UI.XRLabel lblFuss2;
private DevExpress.XtraReports.UI.XRLabel lblFuss1;
private DevExpress.XtraReports.UI.XRLabel lblFuss9;
private DevExpress.XtraReports.UI.ReportHeaderBand lblUeberschriftHeader;
private DevExpress.XtraReports.UI.XRLabel lblUeberschrift;
private DevExpress.XtraReports.UI.XRLabel lblDruckName;
}
}

View File

@@ -29,11 +29,11 @@ namespace MalteserJohanniterJohanneshaus
string prevMonth = null;
var counter = 0;
string grund = null;
lblDruckName.Text = "ÄnderungsmitteilungBesondereWohnformen";
if (pRO.ServiceInvoicePeriods != null)
{
SetzeWohnheim(pRO);
foreach (var sip in pRO.ServiceInvoicePeriods)
{
counter += 1;
@@ -106,6 +106,22 @@ namespace MalteserJohanniterJohanneshaus
{
team = "Johanneshaus Siegburg";
}
else if (c2s.Notice.IsNotNullOrEmpty() && c2s.Notice.Contains("45"))
{
team = "Aulhof - Kostenstelle 45";
Page1.Visible = false;
lblUeberschriftHeader.Visible = true;
lblUeberschrift.Text = team;
lblDruckName.Text = "AbgrenzungTSH";
}
else if (c2s.Notice.IsNotNullOrEmpty() && c2s.Notice.Contains("50"))
{
team = "Hannes - Kostenstelle 50";
Page1.Visible = false;
lblUeberschriftHeader.Visible = true;
lblUeberschrift.Text = team;
lblDruckName.Text = "AbgrenzungTSH";
}
lblAdresse.Text = team;
}
@@ -190,7 +206,7 @@ namespace MalteserJohanniterJohanneshaus
private void ChangeName(object sender, System.ComponentModel.CancelEventArgs e)
{
PrintingSystem.Document.Name = "ÄnderungsmitteilungBesondereWohnformen";
PrintingSystem.Document.Name = lblDruckName.Text;
}
}
}