Files
BeWoPlaner/ReportImp/WahlEv/WahlCalculations.cs

69 lines
2.7 KiB
C#
Raw Normal View History

2018-10-08 12:09:48 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using BS.Shared.Extensions;
using BS.Shared.Services;
namespace WahlEv
{
public class WahlCalculations : BS.Shared.Services.Calculations
{
public override decimal? GetApprovedHoursForPeriod(SupportConceptApprovalPeriodDC scap, List<CostRatePeriodDC> costRatePeriods, DateTime? pStart,
DateTime? pEnd)
{
if (!pStart.HasValue || !pEnd.HasValue)
{
return null;
}
if (scap.ApprovedBEInterval.HasValue && scap.ApprovedBEPerInterval.HasValue)
{
if (scap.ApprovedBEInterval.Value == SupportConceptApprovalInterval.Weekly)
{
var months = GetTotalMonths(pStart.Value, pEnd.Value);
return months * 4.33m * scap.ApprovedBEPerInterval.Value;
}
if (scap.ApprovedBEInterval.Value == SupportConceptApprovalInterval.Monthly)
{
var months = GetTotalMonths(pStart.Value, pEnd.Value);
return months * scap.ApprovedBEPerInterval.Value;
}
else if (scap.ApprovedBEInterval.Value == SupportConceptApprovalInterval.Quarterly)
{
var qs = GetTotalQuarters(pStart.Value, pEnd.Value);
return qs * scap.ApprovedBEPerInterval.Value;
}
}
var periodInDays = (pEnd.Value.Date - pStart.Value.Date).Days + 1;
return this.GetApprovedHoursPerDay(scap, costRatePeriods) * periodInDays;
}
public override decimal? GetApprovedHoursPerWeek(SupportConceptApprovalPeriodDC scap, List<CostRatePeriodDC> costRatePeriods)
{
if (scap.ApprovedBEPerInterval.HasValue && scap.ApprovedBEInterval.HasValue && scap.ApprovedBEInterval.Value == SupportConceptApprovalInterval.Weekly)
{
return scap.ApprovedBEPerInterval;
}
else if (!scap.ApprovedBEPerInterval.HasValue && scap.ApprovedBETotal.HasValue && scap.StartDate.HasValue && scap.EndDate.HasValue)
{
var months = GetTotalMonths(scap.StartDate.Value, scap.EndDate.Value);
if (months != 0)
{
var monatlich = scap.ApprovedBETotal.Value / months;
return monatlich / 4.33m;
}
}
return this.GetApprovedHoursPerDay(scap, costRatePeriods) * 7;
}
2018-10-08 12:09:48 +02:00
}
}