MH: EndartFabrik Kappung Finalisierung

This commit is contained in:
2026-06-02 16:07:15 +02:00
parent c51a651063
commit 421d885786
3 changed files with 30 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ using BeWo.Service.Invoicing;
using BS.Shared; using BS.Shared;
using BS.Shared.DataContracts; using BS.Shared.DataContracts;
using BS.Shared.Services; using BS.Shared.Services;
using DevExpress.Data;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -16,6 +17,22 @@ namespace EndartFabrik.Invoicing
return false; return false;
} }
public override List<InvoiceItemDC> CreateInvoiceItemsForAccountingPeriods(Settlement2DC si, List<AccountingPeriod> accountingPeriods,
List<CostRatePeriodDC> costRatePeriods, Calculations calc)
{
var list = base.CreateInvoiceItemsForAccountingPeriods(si, accountingPeriods, costRatePeriods, calc);
foreach (var item in list)
{
if (item.CustomString1 != null && item.CustomString1.Contains("gekappte, zu viel geleistete Stunden:"))
{
item.ItemDescription += item.CustomString1;
}
}
return list;
}
public override InvoiceItemDC CreateInvoiceItemForAccountingPeriod(AccountingPeriod accountingPeriod) public override InvoiceItemDC CreateInvoiceItemForAccountingPeriod(AccountingPeriod accountingPeriod)
{ {
InvoiceItemDC ii = new InvoiceItemDC(); InvoiceItemDC ii = new InvoiceItemDC();
@@ -50,6 +67,7 @@ namespace EndartFabrik.Invoicing
if (accountingPeriod.ServiceRecordsInPeriod != null) if (accountingPeriod.ServiceRecordsInPeriod != null)
{ {
// Claude: Kappung nur wenn wöchentliche Bewilligung ohne Stundenübertragung konfiguriert ist
bool weeklyKappung = accountingPeriod.ApprovalUnit != null bool weeklyKappung = accountingPeriod.ApprovalUnit != null
&& accountingPeriod.ApprovalUnit == AccountingIntervalType.Weekly && accountingPeriod.ApprovalUnit == AccountingIntervalType.Weekly
&& accountingPeriod.ApprovedPerUnit.HasValue && accountingPeriod.ApprovedPerUnit.HasValue
@@ -57,6 +75,7 @@ namespace EndartFabrik.Invoicing
if (weeklyKappung) if (weeklyKappung)
{ {
// Claude: Wochenlimit in Minuten umrechnen (ApprovedPerUnit ist in Stunden)
decimal approvedMinutesPerWeek = accountingPeriod.ApprovedPerUnit.Value * 60; decimal approvedMinutesPerWeek = accountingPeriod.ApprovedPerUnit.Value * 60;
var weeklyRaw = new Dictionary<DateTime, decimal>(); var weeklyRaw = new Dictionary<DateTime, decimal>();
var weeklyBudget = new Dictionary<DateTime, decimal>(); var weeklyBudget = new Dictionary<DateTime, decimal>();
@@ -65,6 +84,7 @@ namespace EndartFabrik.Invoicing
{ {
if (!ar.Start.HasValue) continue; if (!ar.Start.HasValue) continue;
// Claude: Montag der jeweiligen Woche als Dictionary-Schlüssel
int daysSinceMonday = ((int)ar.Start.Value.DayOfWeek + 6) % 7; int daysSinceMonday = ((int)ar.Start.Value.DayOfWeek + 6) % 7;
var weekStart = ar.Start.Value.Date.AddDays(-daysSinceMonday); var weekStart = ar.Start.Value.Date.AddDays(-daysSinceMonday);
@@ -73,6 +93,7 @@ namespace EndartFabrik.Invoicing
prozent = ar.ServiceDescription.ProzentAbrechnung.Value; prozent = ar.ServiceDescription.ProzentAbrechnung.Value;
ii.ProzentAbrechenbar = prozent; ii.ProzentAbrechenbar = prozent;
// Claude: ProzentBudget nur für das Budget-Feld berücksichtigen, nicht für die Rohminuten
decimal budgetProzent = ar.ServiceDescription.Category.ProzentBudget ?? 100; decimal budgetProzent = ar.ServiceDescription.Category.ProzentBudget ?? 100;
if (ar.ServiceDescription.ProzentBudget.HasValue) if (ar.ServiceDescription.ProzentBudget.HasValue)
budgetProzent = ar.ServiceDescription.ProzentBudget.Value; budgetProzent = ar.ServiceDescription.ProzentBudget.Value;
@@ -84,11 +105,17 @@ namespace EndartFabrik.Invoicing
weeklyBudget[weekStart] += ar.RoundedDuration * budgetProzent / 100; weeklyBudget[weekStart] += ar.RoundedDuration * budgetProzent / 100;
} }
// Claude: Jede Woche einzeln auf das Wochenlimit kappen, dann summieren
foreach (var kvp in weeklyRaw) foreach (var kvp in weeklyRaw)
minutesTotal += Math.Min(kvp.Value, approvedMinutesPerWeek); minutesTotal += Math.Min(kvp.Value, approvedMinutesPerWeek);
foreach (var kvp in weeklyBudget) foreach (var kvp in weeklyBudget)
minutesTotalBudget += Math.Min(kvp.Value, approvedMinutesPerWeek); minutesTotalBudget += Math.Min(kvp.Value, approvedMinutesPerWeek);
if (minutesTotal < accountingPeriod.ServiceRecordsInPeriod.Sum(s => s.RoundedDuration))
{
ii.CustomString1 = string.Format("gekappte, zu viel geleistete Stunden: {0:0.00}", (accountingPeriod.ServiceRecordsInPeriod.Sum(s => s.RoundedDuration) - minutesTotal) / 60);
}
} }
else else
{ {

View File

@@ -591,6 +591,7 @@ namespace EndartFabrik
this.xrTableCell52.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom))); this.xrTableCell52.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom)));
this.xrTableCell52.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { this.xrTableCell52.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
new DevExpress.XtraReports.UI.XRBinding("Text", null, "InvoiceItems.AbrechnungsText")}); new DevExpress.XtraReports.UI.XRBinding("Text", null, "InvoiceItems.AbrechnungsText")});
this.xrTableCell52.Multiline = true;
this.xrTableCell52.Name = "xrTableCell52"; this.xrTableCell52.Name = "xrTableCell52";
this.xrTableCell52.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); this.xrTableCell52.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
this.xrTableCell52.StylePriority.UseBorderColor = false; this.xrTableCell52.StylePriority.UseBorderColor = false;

View File

@@ -48,10 +48,9 @@ namespace EndartFabrik
{ {
ii.ItemDescription = "Fachleistungsstunden"; ii.ItemDescription = "Fachleistungsstunden";
} }
else if (ii.ItemDescription.Contains("(zu viel geleistet)")) else if (ii.ItemDescription.Contains("gekappte, zu viel geleistete Stunden:"))
{ {
ii.AbrechnungsText = "(zu viel geleistet) " + ii.AbrechnungsText; ii.AbrechnungsText += "\n(" + ii.ItemDescription + ")";
} }
} }
// Claude: Items mit "(zu viel geleistet)" ans Ende sortieren, damit sie nach den regulären Positionen erscheinen // Claude: Items mit "(zu viel geleistet)" ans Ende sortieren, damit sie nach den regulären Positionen erscheinen