MH: EndartFabrik Kappung Finalisierung
This commit is contained in:
@@ -3,6 +3,7 @@ using BeWo.Service.Invoicing;
|
||||
using BS.Shared;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.Services;
|
||||
using DevExpress.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -16,6 +17,22 @@ namespace EndartFabrik.Invoicing
|
||||
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)
|
||||
{
|
||||
InvoiceItemDC ii = new InvoiceItemDC();
|
||||
@@ -50,6 +67,7 @@ namespace EndartFabrik.Invoicing
|
||||
|
||||
if (accountingPeriod.ServiceRecordsInPeriod != null)
|
||||
{
|
||||
// Claude: Kappung nur wenn wöchentliche Bewilligung ohne Stundenübertragung konfiguriert ist
|
||||
bool weeklyKappung = accountingPeriod.ApprovalUnit != null
|
||||
&& accountingPeriod.ApprovalUnit == AccountingIntervalType.Weekly
|
||||
&& accountingPeriod.ApprovedPerUnit.HasValue
|
||||
@@ -57,6 +75,7 @@ namespace EndartFabrik.Invoicing
|
||||
|
||||
if (weeklyKappung)
|
||||
{
|
||||
// Claude: Wochenlimit in Minuten umrechnen (ApprovedPerUnit ist in Stunden)
|
||||
decimal approvedMinutesPerWeek = accountingPeriod.ApprovedPerUnit.Value * 60;
|
||||
var weeklyRaw = new Dictionary<DateTime, decimal>();
|
||||
var weeklyBudget = new Dictionary<DateTime, decimal>();
|
||||
@@ -65,6 +84,7 @@ namespace EndartFabrik.Invoicing
|
||||
{
|
||||
if (!ar.Start.HasValue) continue;
|
||||
|
||||
// Claude: Montag der jeweiligen Woche als Dictionary-Schlüssel
|
||||
int daysSinceMonday = ((int)ar.Start.Value.DayOfWeek + 6) % 7;
|
||||
var weekStart = ar.Start.Value.Date.AddDays(-daysSinceMonday);
|
||||
|
||||
@@ -73,6 +93,7 @@ namespace EndartFabrik.Invoicing
|
||||
prozent = ar.ServiceDescription.ProzentAbrechnung.Value;
|
||||
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;
|
||||
if (ar.ServiceDescription.ProzentBudget.HasValue)
|
||||
budgetProzent = ar.ServiceDescription.ProzentBudget.Value;
|
||||
@@ -84,11 +105,17 @@ namespace EndartFabrik.Invoicing
|
||||
weeklyBudget[weekStart] += ar.RoundedDuration * budgetProzent / 100;
|
||||
}
|
||||
|
||||
// Claude: Jede Woche einzeln auf das Wochenlimit kappen, dann summieren
|
||||
foreach (var kvp in weeklyRaw)
|
||||
minutesTotal += Math.Min(kvp.Value, approvedMinutesPerWeek);
|
||||
|
||||
foreach (var kvp in weeklyBudget)
|
||||
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
|
||||
{
|
||||
|
||||
@@ -591,6 +591,7 @@ namespace EndartFabrik
|
||||
this.xrTableCell52.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom)));
|
||||
this.xrTableCell52.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
|
||||
new DevExpress.XtraReports.UI.XRBinding("Text", null, "InvoiceItems.AbrechnungsText")});
|
||||
this.xrTableCell52.Multiline = true;
|
||||
this.xrTableCell52.Name = "xrTableCell52";
|
||||
this.xrTableCell52.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
|
||||
this.xrTableCell52.StylePriority.UseBorderColor = false;
|
||||
|
||||
@@ -48,10 +48,9 @@ namespace EndartFabrik
|
||||
{
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user