MH: Lebenswert Spitzabrechnungserstellung

This commit is contained in:
2023-10-23 14:58:33 +02:00
parent 7aa760f93f
commit dc02be27b7
4 changed files with 294 additions and 29 deletions

View File

@@ -0,0 +1,142 @@
using BeWo.Data.Entities;
using BeWo.Service.Invoicing;
using BS.Shared.DataContracts;
using BS.Shared.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LebensWert.Invoicing
{
public class CustomSettlementInvoiceCreation : SettlementInvoiceCreation
{
public override bool CanCreateInvoiceTheOldWay(Settlement2DC si, CostBearer2SupportConcept c2s)
{
return false;
}
public override InvoiceItemDC CreateInvoiceItemForAccountingPeriod(AccountingPeriod accountingPeriod)
{
var item = base.CreateInvoiceItemForAccountingPeriod(accountingPeriod);
var mins = accountingPeriod.CostRatesInPeriod.FirstOrDefault(p => p.CostRateType == BS.Shared.CostRatePeriodType.MinutesPerServiceUnit);
if (mins != null && mins.CostRateValue != null)
{
item.UnitCount *= 60 / mins.CostRateValue;
item.UnitCountBudget *= 60 / mins.CostRateValue;
//item.AmountTotal *= 60 / mins.CostRateValue;
//item.GrossAmountTotal *= 60 / mins.CostRateValue;
}
return item;
}
public override List<InvoiceItemDC> CreateInvoiceItemsForAccountingPeriods(Settlement2DC si, List<AccountingPeriod> accountingPeriods,
List<CostRatePeriodDC> costRatePeriods, Calculations calc)
{
Dictionary<long, SupportConceptApprovalPeriodDC> oid2Scap = new Dictionary<long, SupportConceptApprovalPeriodDC>();
List<InvoiceItemDC> invoiceItems = new List<InvoiceItemDC>();
foreach (var ap in accountingPeriods)
{
InvoiceItemDC ii = CreateInvoiceItemForAccountingPeriod(ap);
invoiceItems.Add(ii);
// ANPASSUNG
InvoiceItemDC pauschalenItem = CreateKontaktpauschalenItem(ap, si.RecipientOrganisation);
if (pauschalenItem != null)
invoiceItems.Add(pauschalenItem);
var scap = ap.SupportConceptApprovalPeriod;
SupportConceptApprovalPeriodDC scapHelper = null;
if (scap != null)
{
if (oid2Scap.ContainsKey(scap.SupportConceptApprovalPeriodOid.Value))
scapHelper = oid2Scap[scap.SupportConceptApprovalPeriodOid.Value];
else
{
scapHelper = new SupportConceptApprovalPeriodDC();
scapHelper.ApprovedBETotal = scap.ApprovedBETotal;
if (!scapHelper.ApprovedBETotal.HasValue)
scapHelper.ApprovedBETotal = calc.GetApprovedBETotal(scap, costRatePeriods);
oid2Scap[scap.SupportConceptApprovalPeriodOid.Value] = scapHelper;
}
}
if (!si.ApprovedFLS.HasValue)
{
if (scapHelper.ApprovedBETotal.HasValue && ii.UnitCount.HasValue)
{
if (scapHelper.ApprovedBETotal >= ii.UnitCount.Value)
{
scapHelper.ApprovedBETotal -= ii.UnitCount.Value;
ii.MaxApprovedUnitCount = null;
}
else
{
ii.MaxApprovedUnitCount = scapHelper.ApprovedBETotal;
}
}
CalculateInvoiceItemAmounts(ii);
}
if (ii.UnitCount.HasValue)
{
si.RecordedBillableFLSBrutto = (si.RecordedBillableFLSBrutto ?? 0) + ii.UnitCount;
si.RecordedBillableFLSNetto = si.RecordedBillableFLSBrutto ?? 0;
}
var list = CreateAdditionalInvoiceItems(ap);
invoiceItems.AddRange(list);
}
return invoiceItems;
}
private static InvoiceItemDC CreateKontaktpauschalenItem(AccountingPeriod accountingPeriod, string recipientOrganisation)
{
InvoiceItemDC invoiceItem = null;
decimal unitCount = 0;
foreach (var sr in accountingPeriod.ServiceRecordsInPeriod)
{
if (sr.ServiceDescription.Name.ToLower() == "face-to-face" || sr.ServiceDescription.Name.ToLower() == "face to face" ||
sr.ServiceDescription.Name.ToLower() == "begleitende maßnahmen" || sr.ServiceDescription.Name.ToLower() == "arztbesuch")
{
unitCount++;
}
}
if (unitCount > 0)
{
decimal pauschale = 0;
if (recipientOrganisation.ToLower().Contains("hannover"))
pauschale = PauschalenHelper.HANNOVER_AMOUNT_SINCE_2023;
else if (recipientOrganisation.ToLower().Contains("hildesheim"))
pauschale = PauschalenHelper.HILDESHEIM_AMOUNT_SINCE_2023;
else if (recipientOrganisation.ToLower().Contains("nienburg"))
pauschale = PauschalenHelper.NIENBURG_AMOUNT_SINCE_2023;
invoiceItem = new InvoiceItemDC()
{
UnitCount = unitCount,
ItemDescription = "Kontaktpauschale",
UnitDescription = "Pauschale pro direktem Kontakt",
AmountPerUnit = pauschale,
AmountTotal = pauschale * unitCount * accountingPeriod.RateFactor,
GrossAmountTotal = pauschale * unitCount * accountingPeriod.RateFactor,
ItemPeriodStart = accountingPeriod.PeriodStart,
ItemPeriodEnd = accountingPeriod.PeriodEnd,
RateFactor = accountingPeriod.RateFactor,
};
}
return invoiceItem;
}
}
}

View File

@@ -59,6 +59,7 @@
<Compile Include="Invoicing\CustomInvoiceCreationHI.cs" />
<Compile Include="Invoicing\CustomInvoiceFactory.cs" />
<Compile Include="Invoicing\CustomInvoiceCreationNI.cs" />
<Compile Include="Invoicing\CustomSettlementInvoiceCreation.cs" />
<Compile Include="Invoicing\PauschalenHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Quittierungsbeleg.cs">

View File

@@ -31,6 +31,7 @@ namespace LebensWert
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Spitzabrechnung));
DevExpress.XtraReports.UI.XRSummary xrSummary1 = new DevExpress.XtraReports.UI.XRSummary();
this.Detail = new DevExpress.XtraReports.UI.DetailBand();
this.ReportHeader = new DevExpress.XtraReports.UI.ReportHeaderBand();
this.xrRichText5 = new DevExpress.XtraReports.UI.XRRichText();
@@ -64,6 +65,8 @@ namespace LebensWert
this.topMarginBand1 = new DevExpress.XtraReports.UI.TopMarginBand();
this.bottomMarginBand1 = new DevExpress.XtraReports.UI.BottomMarginBand();
this.GroupHeader1 = new DevExpress.XtraReports.UI.GroupHeaderBand();
this.lblPostHI = new DevExpress.XtraReports.UI.XRLabel();
this.lblAbsenderHI = new DevExpress.XtraReports.UI.XRRichText();
this.xrLabel2 = new DevExpress.XtraReports.UI.XRLabel();
this.xrLabel5 = new DevExpress.XtraReports.UI.XRLabel();
this.lblPostNI = new DevExpress.XtraReports.UI.XRLabel();
@@ -79,7 +82,6 @@ namespace LebensWert
this.xrTableRow33 = new DevExpress.XtraReports.UI.XRTableRow();
this.xrTableCell52 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell53 = new DevExpress.XtraReports.UI.XRTableCell();
this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components);
this.GroupFooter1 = new DevExpress.XtraReports.UI.GroupFooterBand();
this.xrTable5 = new DevExpress.XtraReports.UI.XRTable();
this.xrTableRow30 = new DevExpress.XtraReports.UI.XRTableRow();
@@ -100,16 +102,23 @@ namespace LebensWert
this.xrTableRow37 = new DevExpress.XtraReports.UI.XRTableRow();
this.xrTableCell59 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell60 = new DevExpress.XtraReports.UI.XRTableCell();
this.lblAbsenderHI = new DevExpress.XtraReports.UI.XRRichText();
this.lblPostHI = new DevExpress.XtraReports.UI.XRLabel();
this.Zwischensumme = new DevExpress.XtraReports.UI.GroupFooterBand();
this.xrTable6 = new DevExpress.XtraReports.UI.XRTable();
this.xrTableRow12 = new DevExpress.XtraReports.UI.XRTableRow();
this.xrTableCell9 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell10 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableRow10 = new DevExpress.XtraReports.UI.XRTableRow();
this.xrTableCell7 = new DevExpress.XtraReports.UI.XRTableCell();
this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components);
((System.ComponentModel.ISupportInitialize)(this.xrRichText5)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.xrTable1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.xrTable3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.lblAbsenderHI)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.lblAbsenderNI)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.xrTable4)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.xrTable5)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.lblAbsenderHI)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.xrTable6)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
//
// Detail
@@ -430,6 +439,26 @@ namespace LebensWert
this.GroupHeader1.Name = "GroupHeader1";
this.GroupHeader1.StylePriority.UseFont = false;
//
// lblPostHI
//
this.lblPostHI.Font = new System.Drawing.Font("Verdana", 8F);
this.lblPostHI.LocationFloat = new DevExpress.Utils.PointFloat(0.0001271566F, 32.72915F);
this.lblPostHI.Name = "lblPostHI";
this.lblPostHI.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
this.lblPostHI.SizeF = new System.Drawing.SizeF(317F, 18.54166F);
this.lblPostHI.StylePriority.UseFont = false;
this.lblPostHI.Text = "Kai Lippel, Paulischstraße 5, 31028 Gronau";
//
// lblAbsenderHI
//
this.lblAbsenderHI.Font = new System.Drawing.Font("Arial", 8F);
this.lblAbsenderHI.LocationFloat = new DevExpress.Utils.PointFloat(413.1947F, 10.00001F);
this.lblAbsenderHI.Name = "lblAbsenderHI";
this.lblAbsenderHI.SerializableRtfString = resources.GetString("lblAbsenderHI.SerializableRtfString");
this.lblAbsenderHI.SizeF = new System.Drawing.SizeF(287.2637F, 262.5F);
this.lblAbsenderHI.StylePriority.UseBackColor = false;
this.lblAbsenderHI.StylePriority.UseFont = false;
//
// xrLabel2
//
this.xrLabel2.BackColor = System.Drawing.Color.Transparent;
@@ -548,7 +577,8 @@ namespace LebensWert
// DetailReport
//
this.DetailReport.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] {
this.Detail1});
this.Detail1,
this.Zwischensumme});
this.DetailReport.DataMember = "InvoiceItems";
this.DetailReport.DataSource = this.bindingSource1;
this.DetailReport.Level = 0;
@@ -612,10 +642,6 @@ namespace LebensWert
this.xrTableCell53.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight;
this.xrTableCell53.Weight = 0.21685899000901443D;
//
// bindingSource1
//
this.bindingSource1.DataSource = typeof(BeWo.Report.ReportObjects.Settlement2RO);
//
// GroupFooter1
//
this.GroupFooter1.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
@@ -834,25 +860,91 @@ namespace LebensWert
this.xrTableCell60.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight;
this.xrTableCell60.Weight = 0.21685899000901443D;
//
// lblAbsenderHI
// Zwischensumme
//
this.lblAbsenderHI.Font = new System.Drawing.Font("Arial", 8F);
this.lblAbsenderHI.LocationFloat = new DevExpress.Utils.PointFloat(413.1947F, 10.00001F);
this.lblAbsenderHI.Name = "lblAbsenderHI";
this.lblAbsenderHI.SerializableRtfString = resources.GetString("lblAbsenderHI.SerializableRtfString");
this.lblAbsenderHI.SizeF = new System.Drawing.SizeF(287.2637F, 262.5F);
this.lblAbsenderHI.StylePriority.UseBackColor = false;
this.lblAbsenderHI.StylePriority.UseFont = false;
this.Zwischensumme.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
this.xrTable6});
this.Zwischensumme.HeightF = 34F;
this.Zwischensumme.Name = "Zwischensumme";
this.Zwischensumme.Visible = false;
//
// lblPostHI
// xrTable6
//
this.lblPostHI.Font = new System.Drawing.Font("Verdana", 8F);
this.lblPostHI.LocationFloat = new DevExpress.Utils.PointFloat(0.0001271566F, 32.72915F);
this.lblPostHI.Name = "lblPostHI";
this.lblPostHI.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
this.lblPostHI.SizeF = new System.Drawing.SizeF(317F, 18.54166F);
this.lblPostHI.StylePriority.UseFont = false;
this.lblPostHI.Text = "Kai Lippel, Paulischstraße 5, 31028 Gronau";
this.xrTable6.LocationFloat = new DevExpress.Utils.PointFloat(0.0001271566F, 0F);
this.xrTable6.Name = "xrTable6";
this.xrTable6.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] {
this.xrTableRow12,
this.xrTableRow10});
this.xrTable6.SizeF = new System.Drawing.SizeF(650F, 34F);
this.xrTable6.StylePriority.UseFont = false;
//
// xrTableRow12
//
this.xrTableRow12.Cells.AddRange(new DevExpress.XtraReports.UI.XRTableCell[] {
this.xrTableCell9,
this.xrTableCell10});
this.xrTableRow12.Name = "xrTableRow12";
this.xrTableRow12.Weight = 0.40476190476190466D;
//
// xrTableCell9
//
this.xrTableCell9.BorderColor = System.Drawing.SystemColors.ControlLight;
this.xrTableCell9.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom)));
this.xrTableCell9.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.xrTableCell9.Name = "xrTableCell9";
this.xrTableCell9.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
this.xrTableCell9.StylePriority.UseBorderColor = false;
this.xrTableCell9.StylePriority.UseBorders = false;
this.xrTableCell9.StylePriority.UseFont = false;
this.xrTableCell9.StylePriority.UsePadding = false;
this.xrTableCell9.Text = "Zwischensumme [ItemDescription]:";
this.xrTableCell9.Weight = 2.5080772986778848D;
//
// xrTableCell10
//
this.xrTableCell10.BorderColor = System.Drawing.SystemColors.ControlLight;
this.xrTableCell10.Borders = ((DevExpress.XtraPrinting.BorderSide)(((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right)
| DevExpress.XtraPrinting.BorderSide.Bottom)));
this.xrTableCell10.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
new DevExpress.XtraReports.UI.XRBinding("Text", null, "InvoiceItems.GrossAmountTotal")});
this.xrTableCell10.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.xrTableCell10.Name = "xrTableCell10";
this.xrTableCell10.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
this.xrTableCell10.StylePriority.UseBorderColor = false;
this.xrTableCell10.StylePriority.UseBorders = false;
this.xrTableCell10.StylePriority.UseFont = false;
this.xrTableCell10.StylePriority.UsePadding = false;
this.xrTableCell10.StylePriority.UseTextAlignment = false;
xrSummary1.FormatString = "{0:c}";
xrSummary1.Running = DevExpress.XtraReports.UI.SummaryRunning.Group;
this.xrTableCell10.Summary = xrSummary1;
this.xrTableCell10.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight;
this.xrTableCell10.Weight = 0.4919227013221153D;
//
// xrTableRow10
//
this.xrTableRow10.Cells.AddRange(new DevExpress.XtraReports.UI.XRTableCell[] {
this.xrTableCell7});
this.xrTableRow10.Name = "xrTableRow10";
this.xrTableRow10.Weight = 0.40476190476190466D;
//
// xrTableCell7
//
this.xrTableCell7.BorderColor = System.Drawing.SystemColors.ControlLight;
this.xrTableCell7.Borders = ((DevExpress.XtraPrinting.BorderSide)(((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right)
| DevExpress.XtraPrinting.BorderSide.Bottom)));
this.xrTableCell7.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.xrTableCell7.Name = "xrTableCell7";
this.xrTableCell7.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
this.xrTableCell7.StylePriority.UseBorderColor = false;
this.xrTableCell7.StylePriority.UseBorders = false;
this.xrTableCell7.StylePriority.UseFont = false;
this.xrTableCell7.StylePriority.UsePadding = false;
this.xrTableCell7.Weight = 3D;
//
// bindingSource1
//
this.bindingSource1.DataSource = typeof(BeWo.Report.ReportObjects.Settlement2RO);
//
// Spitzabrechnung
//
@@ -879,11 +971,12 @@ namespace LebensWert
((System.ComponentModel.ISupportInitialize)(this.xrRichText5)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.xrTable1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.xrTable3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.lblAbsenderHI)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.lblAbsenderNI)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.xrTable4)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.xrTable5)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.lblAbsenderHI)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.xrTable6)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this)).EndInit();
}
@@ -961,5 +1054,12 @@ namespace LebensWert
private DevExpress.XtraReports.UI.XRLabel xrLabel3;
private DevExpress.XtraReports.UI.XRRichText lblAbsenderHI;
private DevExpress.XtraReports.UI.XRLabel lblPostHI;
private DevExpress.XtraReports.UI.GroupFooterBand Zwischensumme;
private DevExpress.XtraReports.UI.XRTable xrTable6;
private DevExpress.XtraReports.UI.XRTableRow xrTableRow12;
private DevExpress.XtraReports.UI.XRTableCell xrTableCell9;
private DevExpress.XtraReports.UI.XRTableCell xrTableCell10;
private DevExpress.XtraReports.UI.XRTableRow xrTableRow10;
private DevExpress.XtraReports.UI.XRTableCell xrTableCell7;
}
}

View File

@@ -8,6 +8,7 @@ using BeWo.Report;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BS.Shared;
using BS.Shared.Extensions;
namespace LebensWert
{
@@ -29,7 +30,28 @@ namespace LebensWert
foreach (var ii in pRO.InvoiceItems)
{
if (ii.RateFactor.HasValue)
if (!pRO.FehlkontakteString.IsNullOrEmpty() && ii.RateFactor == 0)
{
Zwischensumme.Visible = true;
//if (!ii.ItemDescription.IsNullOrEmpty())
//{
//ii.AbrechnungsText = Regex.Replace(ii.DetailDescription, ii.ItemDescription, "Fehlkontakte");
//}
ii.AbrechnungsText = ii.AbrechnungsText.Replace("FLS", "Std.");
ii.ItemDescription = "Fehlkontakte";
//ii.DetailDescription = "Fehlkontakte";
}
else if (ii.ItemDescription.IsNullOrEmpty())
{
ii.ItemDescription = "Fachleistungsstunden";
//ii.DetailDescription = "Fachleistungsstunden";
}
if (ii.DetailDescription.StartsWith(":"))
ii.DetailDescription = ii.ItemDescription + ii.DetailDescription;
if (ii.RateFactor.HasValue)
{
rateFactor = (100 + ii.RateFactor.Value) / 100;
}