Files
BeWoPlaner/Service/Invoicing/KuKLWLSettlementInvoiceCreation.cs
Christian 9c97d6fe79 CB Merge
2019-07-12 17:36:37 +02:00

62 lines
2.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BeWo.Data.Entities;
using BS.Shared.Core;
using BS.Shared.DataContracts;
namespace BeWo.Service.Invoicing
{
[IDSpecificClass(Identifier = "LWLMaxAmount")]
class KuKLWLSettlementInvoiceCreation : SettlementInvoiceCreation
{
public override decimal? CalculateMaxAmount(Settlement2DC si)
{
decimal approvedCurrentHourlyRate = 0;
decimal approvedLastHourlyRate = 0;
decimal approved3RdHourlyRate = 0;
if (si.DifferentHourlyRateCount == 1)
{
if (si.ApprovedFLS != null)
{
approvedCurrentHourlyRate = si.ApprovedFLS.Value;
}
}
else
{
approvedCurrentHourlyRate = (si.ApprovedFLSWeekly ?? 0) * si.WeeksWithNewHourlyRate;
}
approvedLastHourlyRate = (si.ApprovedFLSWeekly ?? 0) * si.WeeksWithOldHourlyRate;
approved3RdHourlyRate = (si.ApprovedFLSWeekly ?? 0) * si.WeeksWithHourlyRate3;
approvedCurrentHourlyRate = Math.Round(approvedCurrentHourlyRate, 2, MidpointRounding.AwayFromZero);
approvedLastHourlyRate = Math.Round(approvedLastHourlyRate, 2, MidpointRounding.AwayFromZero);
approved3RdHourlyRate = Math.Round(approved3RdHourlyRate, 2, MidpointRounding.AwayFromZero);
decimal rf = 1;
if (si.RateFactor.HasValue && si.RateFactor.Value != 0)
{
rf = si.RateFactor.Value;
rf = (100 + rf) / 100;
}
decimal maxAmount = Math.Round(approved3RdHourlyRate * si.HourlyRate3 * rf, 2, MidpointRounding.AwayFromZero);
maxAmount += Math.Round(approvedLastHourlyRate * (si.HourlyRateOld ?? 0) * rf, 2, MidpointRounding.AwayFromZero);
maxAmount += Math.Round(approvedCurrentHourlyRate * (si.HourlyRateNew ?? 0) * rf, 2, MidpointRounding.AwayFromZero);
maxAmount = Math.Round(maxAmount, 2, MidpointRounding.AwayFromZero);
return maxAmount;
}
public override IList<ApprovalPeriod> CreateApprovalPeriods(Settlement2DC si, CostBearer2SupportConcept c2s)
{
var list = base.CreateApprovalPeriods(si, c2s);
return list;
}
}
}