82 lines
2.9 KiB
C#
82 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BeWo.Service.Invoicing;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.Extensions;
|
|
using BS.Shared.Services;
|
|
|
|
namespace BhsSolingen.Invoicing
|
|
{
|
|
internal class CustomSettlementInvoiceCreation : SettlementInvoiceCreation
|
|
{
|
|
public override IList<ServiceRecord> GetBillableServiceRecords(CostBearer2SupportConcept c2s)
|
|
{
|
|
return c2s.ServiceRecords.Where(IsServiceRecordBillable).ToList();
|
|
}
|
|
|
|
public override bool IsServiceRecordBillable(ServiceRecord iRecord)
|
|
{
|
|
if (iRecord.ServiceDescription.ServiceCategory.Name.StartsWith("Assistenz"))
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public override bool CanCreateInvoiceTheOldWay(Settlement2DC si, CostBearer2SupportConcept c2s)
|
|
{
|
|
var relDC = c2s.MapToNewDC();
|
|
var hourlyRatesInSpanList = relDC.CostBearer.CostRatePeriods.GetSpans(CostRatePeriodType.HourlyRate,
|
|
si.AccountingPeriodStart.Value.Date, si.AccountingPeriodEnd.Value.Date).ToList();
|
|
if (hourlyRatesInSpanList.Count > 3)
|
|
return false;
|
|
|
|
var factorInSpanList = relDC.CostBearer.CostRatePeriods.GetSpans(CostRatePeriodType.RateFactor,
|
|
si.AccountingPeriodStart.Value.Date, si.AccountingPeriodEnd.Value.Date).ToList();
|
|
if (factorInSpanList.Count > 1)
|
|
return false;
|
|
|
|
|
|
foreach (var sr in GetBillableServiceRecords(c2s))
|
|
{
|
|
if (IsServiceRecordBillable(sr) && sr.DurationMinutes > 0)
|
|
{
|
|
if (sr.ServiceDescription.Name.ToLower().Contains("fehlkontakt") || (sr.ServiceDescription.ProzentAbrechnung.HasValue && sr.ServiceDescription.ProzentAbrechnung.Value < 100))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public override void CalculateSettlementInvoiceApprovedAmounts(Settlement2DC si, SupportConceptCostBearerRelDC relDC,
|
|
Calculations calc)
|
|
{
|
|
si.ApprovedFLSWeekly = 0;
|
|
si.ApprovedFLS = 0;
|
|
foreach (var sp in relDC.ApprovalPeriodList)
|
|
{
|
|
if (sp.ServiceCategory == null || !sp.ServiceCategory.Name.StartsWith("Assistenz"))
|
|
{
|
|
si.ApprovedFLSWeekly += calc.GetApprovedHoursPerWeek(sp, relDC.CostBearer.CostRatePeriods) ?? 0m;
|
|
|
|
decimal flsTotal = calc.GetApprovedHoursTotal(sp, relDC.CostBearer.CostRatePeriods) ?? 0m;
|
|
flsTotal = Math.Round(flsTotal, 2, MidpointRounding.AwayFromZero);
|
|
|
|
si.ApprovedFLS += flsTotal;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|