Merge branch 'master' of ssh://float.beyondsoft.de/git/beyondSoft/BeWo
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using BeWo.Data.Access;
|
||||
using BeWo.Data.Entities;
|
||||
using BeWo.Service.DCEntityMapper;
|
||||
using BeWo.Service.Plugins;
|
||||
using BS.Shared;
|
||||
using BS.Shared.Core;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.Extensions;
|
||||
using BS.Shared.Services;
|
||||
|
||||
namespace LebenshilfeBadKreuznach.Invoicing
|
||||
{
|
||||
public class CustomCalculations : BS.Shared.Services.Calculations
|
||||
{
|
||||
public override decimal GetHoursNotBillableDueToAbsenceTimes(SupportConceptApprovalPeriodDC scap,
|
||||
List<CostRatePeriodDC> costRates,
|
||||
List<ServiceRecordDC> records,
|
||||
Dictionary<DateTimeSpan, decimal> absenceTimes,
|
||||
bool doRemoveFromRecordsList,
|
||||
bool doCrop)
|
||||
{
|
||||
if (scap.ApprovedFixedAmount.HasValue)
|
||||
{
|
||||
return 0m;
|
||||
}
|
||||
|
||||
var hoursNotBillableAbsence = 0m;
|
||||
foreach (var iRecord in records.ToList())
|
||||
{
|
||||
//if (!iRecord.Start.Value.InBetween(scap.Span, true))
|
||||
//{
|
||||
// if (doRemoveFromRecordsList)
|
||||
// {
|
||||
// records.Remove(iRecord);
|
||||
// }
|
||||
|
||||
// continue;
|
||||
//}
|
||||
|
||||
var absenceSpan = absenceTimes.FirstOrDefault(i => iRecord.Start.Value.InBetween(i.Key, true)).Key;
|
||||
|
||||
if (absenceSpan != null)
|
||||
{
|
||||
var rd = base.GetBillableDurationInMinutes(iRecord, false);
|
||||
|
||||
if (absenceTimes[absenceSpan] == 0)
|
||||
{
|
||||
if (doRemoveFromRecordsList)
|
||||
{
|
||||
records.Remove(iRecord);
|
||||
}
|
||||
|
||||
hoursNotBillableAbsence += rd / 60m;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (absenceTimes[absenceSpan] - rd >= 0)
|
||||
{
|
||||
absenceTimes[absenceSpan] -= rd;
|
||||
continue;
|
||||
}
|
||||
|
||||
hoursNotBillableAbsence += (rd - absenceTimes[absenceSpan]) / 60;
|
||||
|
||||
if (!doCrop)
|
||||
{
|
||||
if (doRemoveFromRecordsList)
|
||||
{
|
||||
records.Remove(iRecord);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
hoursNotBillableAbsence += (rd - absenceTimes[absenceSpan]) / 60;
|
||||
iRecord.End = iRecord.Start.Value.AddMinutes(Convert.ToDouble(absenceTimes[absenceSpan]));
|
||||
|
||||
var minuteInterval = costRates.GetCostRatePeriodForDate(CostRatePeriodType.MinutesIntervall, iRecord.Start.Value);
|
||||
var duration = Convert.ToDecimal((iRecord.End - iRecord.Start).Value.TotalMinutes);
|
||||
|
||||
//###CB 5min
|
||||
if (minuteInterval != null && minuteInterval.CostRateValue.HasValue && minuteInterval.CostRateValue.Value > 0)
|
||||
{
|
||||
iRecord.RoundedDuration = GetRoundedDuration((int)minuteInterval.CostRateValue.Value, duration);
|
||||
}
|
||||
|
||||
absenceTimes[absenceSpan] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return hoursNotBillableAbsence;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user