MH x Claude: HwHilfswerkInklusionUndTeilhabe automatische Stundengutschrift für Vertragsart Ambulant im Stundenkonto
SupportOID=167700
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using BeWo.Data.Entities;
|
using BeWo.Data.Entities;
|
||||||
using BeWo.Report.ReportObjects;
|
using BeWo.Report.ReportObjects;
|
||||||
|
using BS.Shared; // Claude: für ActivationTypeId
|
||||||
using BS.Shared.Core;
|
using BS.Shared.Core;
|
||||||
using BS.Shared.Extensions;
|
using BS.Shared.Extensions;
|
||||||
using DevExpress.Utils.Filtering.Internal;
|
using DevExpress.Utils.Filtering.Internal;
|
||||||
@@ -38,6 +39,19 @@ namespace HwHilfswerkInklusionUndTeilhabe
|
|||||||
dd.BreakMinutes2 = 0;
|
dd.BreakMinutes2 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Claude: Feiertagsgutschrift (WeeklyTotalHours / WeeklyDays bei Ambulant-Vertrag)
|
||||||
|
// auch in der Tagesansicht als Arbeitszeit darstellen.
|
||||||
|
if (dd.Feiertag != null)
|
||||||
|
{
|
||||||
|
var gutschrift = GetFeiertagsGutschriftStunden(ed != null ? ed.Employee : null, date) * GetFeiertagsFaktor(date);
|
||||||
|
if (gutschrift > 0 && MussAnTagGearbeitetWerden(ed, date))
|
||||||
|
{
|
||||||
|
dd.MinutesTotal = gutschrift * 60;
|
||||||
|
TimeSpan tspan = TimeSpan.FromMinutes((double)dd.MinutesTotal);
|
||||||
|
dd.TimeTotal = String.Format("{0:00}:{1:00}", tspan.Hours, tspan.Minutes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return dd;
|
return dd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,10 +140,91 @@ namespace HwHilfswerkInklusionUndTeilhabe
|
|||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Feiertagsgutschrift (nur Vertragsart "Ambulant")
|
||||||
|
|
||||||
|
// Claude: Bei Vertragsart "Ambulant" wird an Feiertagen automatisch
|
||||||
|
// contract.WeeklyTotalHours / contract.WeeklyDays als Arbeitszeit gutgeschrieben -
|
||||||
|
// aber nur, wenn an dem Tag laut Vertrag/Arbeitszeiten überhaupt gearbeitet werden
|
||||||
|
// müsste (Tagessoll ohne Feiertagsbetrachtung > 0). Ein Feiertag an einem Samstag
|
||||||
|
// (z.B. 03.10.2026) erzeugt bei einer Mo-Fr-Woche also keine Gutschrift.
|
||||||
|
// Die Gutschrift läuft über BerechneGesamtArbeitszeitDurchFeiertage und wird in der
|
||||||
|
// Basisklasse auf StundenGesamtIst addiert (bzw. in der Vormonatsberechnung vom Soll
|
||||||
|
// abgezogen) - sie wirkt damit direkt auf die Überstunden, nicht nur auf die Anzeige.
|
||||||
|
// Das Monatssoll bleibt unverändert (Standardverhalten der Basisklasse).
|
||||||
|
|
||||||
|
// Claude: Schalter nur für MussAnTagGearbeitetWerden: Die Basisklasse setzt das
|
||||||
|
// Tagessoll an Feiertagen sonst immer auf 0, für die Prüfung "müsste an dem Tag
|
||||||
|
// gearbeitet werden?" muss der Feiertag aber ausgeblendet werden.
|
||||||
|
private bool feiertagBeiSollBerechnungIgnorieren = false;
|
||||||
|
|
||||||
|
public override bool BerechneFeiertageAlsArbeitszeit()
|
||||||
|
{
|
||||||
|
return feiertagBeiSollBerechnungIgnorieren;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Claude: true, wenn der Mitarbeiter an dem Tag laut Vertrag/Arbeitszeiten arbeiten
|
||||||
|
// müsste, d.h. das Tagessoll (ohne Feiertagsbetrachtung) größer 0 ist.
|
||||||
|
private bool MussAnTagGearbeitetWerden(MitarbeiterstundenkontoRO.EmployeeDetail ed, DateTime tag)
|
||||||
|
{
|
||||||
|
feiertagBeiSollBerechnungIgnorieren = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return BerechneSollStundenFuerTag(ed, tag) > 0;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
feiertagBeiSollBerechnungIgnorieren = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Claude: Gutschrift-Stunden für einen Feiertag laut Vertrag; 0, wenn an dem Tag kein
|
||||||
|
// Ambulant-Vertrag gilt oder keine Wochenstunden hinterlegt sind.
|
||||||
|
private decimal GetFeiertagsGutschriftStunden(Employee emp, DateTime tag)
|
||||||
|
{
|
||||||
|
if (emp == null)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
var contract = emp.GetValidContractForDate(tag);
|
||||||
|
if (!HatEmployeeAmbulantContract(contract))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!contract.WeeklyTotalHours.HasValue || contract.WeeklyTotalHours.Value <= 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
decimal weeklyDays = 5;
|
||||||
|
if (contract.WeeklyDays.HasValue && contract.WeeklyDays.Value > 0)
|
||||||
|
{
|
||||||
|
weeklyDays = contract.WeeklyDays.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return contract.WeeklyTotalHours.Value / weeklyDays;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override decimal BerechneGesamtArbeitszeitDurchFeiertage(MitarbeiterstundenkontoRO.EmployeeDetail ed, DateTime start, DateTime ende)
|
||||||
|
{
|
||||||
|
decimal az = 0;
|
||||||
|
if (ed != null && ed.Employee != null && ed.Employee.IsActive == ActivationTypeId.Active)
|
||||||
|
{
|
||||||
|
DateTime dt = start;
|
||||||
|
while (dt < ende)
|
||||||
|
{
|
||||||
|
var faktor = GetFeiertagsFaktor(dt);
|
||||||
|
if (faktor > 0 && MussAnTagGearbeitetWerden(ed, dt))
|
||||||
|
{
|
||||||
|
az += GetFeiertagsGutschriftStunden(ed.Employee, dt) * faktor;
|
||||||
|
}
|
||||||
|
dt = dt.AddDays(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return az;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
private bool HatEmployeeAmbulantContract(Contract contract)
|
private bool HatEmployeeAmbulantContract(Contract contract)
|
||||||
{
|
{
|
||||||
bool ambulant = false;
|
bool ambulant = false;
|
||||||
if (contract.ContractTypeValueListEntry != null && contract.ContractTypeValueListEntry.Value.IsNotNullOrEmpty())
|
if (contract != null && contract.ContractTypeValueListEntry != null && contract.ContractTypeValueListEntry.Value.IsNotNullOrEmpty())
|
||||||
{
|
{
|
||||||
if (contract.ContractTypeValueListEntry.Value.ToLower().Contains("ambulant"))
|
if (contract.ContractTypeValueListEntry.Value.ToLower().Contains("ambulant"))
|
||||||
ambulant = true;
|
ambulant = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user