InputFamilienhilfe/Invoicing/AwsInvoiceCreation.cs - neue Logik für ehemals ABW
This commit is contained in:
@@ -88,6 +88,7 @@
|
||||
<DependentUpon>InvoiceCustomerReport.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Invoicing\CustomSettlementInvoiceCreation.cs" />
|
||||
<Compile Include="Invoicing\AwsInvoiceCreation.cs" />
|
||||
<Compile Include="Invoicing\SgaInvoiceCreation.cs" />
|
||||
<Compile Include="Invoicing\UnterbringungInvoiceCreation.cs" />
|
||||
<Compile Include="Invoicing\IonInvoiceCreation.cs" />
|
||||
|
||||
158
ReportImp/InputFamilienhilfe/Invoicing/AwsInvoiceCreation.cs
Normal file
158
ReportImp/InputFamilienhilfe/Invoicing/AwsInvoiceCreation.cs
Normal file
@@ -0,0 +1,158 @@
|
||||
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 BeWo.Service.Plugins;
|
||||
using BS.Shared;
|
||||
using BS.Shared.Core;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.DataContracts.Compact;
|
||||
using BS.Shared.Extensions;
|
||||
using BS.Shared.Services;
|
||||
using DevExpress.Data.Filtering.Helpers;
|
||||
|
||||
namespace InputFamilienhilfe.Invoicing
|
||||
{
|
||||
public class AwsInvoiceCreation : DefaultInvoiceCreation
|
||||
{
|
||||
// ab 07/2024 muss zusätzlich eine Position gemäß der Leistung erzeugt werden sowie ggf. anfallende Extra-FLS aus Einträgen mit Betrag abgerechnet werden
|
||||
public override void SetInvoiceItems(ServiceInvoice invoice,
|
||||
ServiceInvoicePeriod serviceInvoicePeriod,
|
||||
SupportConceptApprovalPeriodDC supportConceptApprovalPeriod,
|
||||
CostBearer2SupportConcept cb2sc,
|
||||
DateTimeSpan invoicePeriod,
|
||||
List<ServiceRecordDC> serviceRecords)
|
||||
{
|
||||
Calculations calc = PluginLoader.FindClass<Calculations>(_SpecificID) ?? Calculations.GetInstance(_SpecificID);
|
||||
|
||||
if (ShouldCreateFixedAmounts(serviceInvoicePeriod, supportConceptApprovalPeriod, cb2sc))
|
||||
{
|
||||
CreateFixedAmounts(serviceInvoicePeriod, supportConceptApprovalPeriod, cb2sc);
|
||||
if (serviceInvoicePeriod.Start > new DateTime(2024, 06, 30))
|
||||
{
|
||||
List<ServiceRecordDC> serviceRecordsInPeriod = serviceRecords.Where(i =>
|
||||
{
|
||||
bool valid = i.Start.Value.InBetween(serviceInvoicePeriod.Start.Value, serviceInvoicePeriod.End.Value, true);
|
||||
|
||||
if (valid && serviceInvoicePeriod.SupportConceptApprovalPeriod != null && serviceInvoicePeriod.SupportConceptApprovalPeriod.ServiceCategory != null)
|
||||
valid = serviceInvoicePeriod.SupportConceptApprovalPeriod.ServiceCategory.Oid == i.ServiceDescription.Category.ServiceCategoryOid;
|
||||
return valid;
|
||||
}).ToList();
|
||||
|
||||
if (serviceRecordsInPeriod.Count > 0)
|
||||
{
|
||||
var itemList = base.CreateSonstigeKosten(serviceInvoicePeriod.SupportConceptApprovalPeriod, calc, serviceRecordsInPeriod, invoicePeriod);
|
||||
serviceInvoicePeriod.InvoiceItemList.AddRange(itemList);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
List<ServiceRecordDC> serviceRecordsInPeriod = serviceRecords.Where(
|
||||
i =>
|
||||
{
|
||||
bool valid = i.Start.Value.InBetween(serviceInvoicePeriod.Start.Value,
|
||||
serviceInvoicePeriod.End.Value, true);
|
||||
|
||||
if (valid && serviceInvoicePeriod.SupportConceptApprovalPeriod != null && serviceInvoicePeriod.SupportConceptApprovalPeriod.ServiceCategory != null)
|
||||
valid = serviceInvoicePeriod.SupportConceptApprovalPeriod.ServiceCategory.Oid ==
|
||||
i.ServiceDescription.Category.ServiceCategoryOid;
|
||||
return valid;
|
||||
}).ToList();
|
||||
|
||||
if (serviceRecordsInPeriod.Count > 0)
|
||||
{
|
||||
//var approvalPeriodDC = DAOFactory.GenericDAO
|
||||
// .LoadByID<SupportConceptApprovalPeriod>(serviceInvoicePeriod.SupportConceptApprovalPeriodOid.Value)
|
||||
// .MapToNewDC();
|
||||
|
||||
//Dictionary<DateTimeSpan, decimal> span2HoursTest = cb2sc.SupportConcept.Customer.GetAbsencesTimesNotBillableWholeWeeks();
|
||||
var absenceTimes = MapperFactory.AbsenceTimeDC_AbsenceTime.MapToNewDCs(cb2sc.SupportConcept.Customer.AbsenceTimes);
|
||||
Dictionary<DateTimeSpan, decimal> span2Hours = calc.GetAbsencesTimesNotBillable(absenceTimes);
|
||||
|
||||
serviceInvoicePeriod.HoursNotBillableAbsence +=
|
||||
calc.GetHoursNotBillableDueToAbsenceTimes(supportConceptApprovalPeriod,
|
||||
cb2sc.CostBearer.CostRatePeriods.MapToNewDCs(),
|
||||
serviceRecordsInPeriod,
|
||||
span2Hours,
|
||||
true, true);
|
||||
if (!supportConceptApprovalPeriod.IsApprovedBEShifting)
|
||||
{
|
||||
serviceInvoicePeriod.HoursNotBillableNotApproved +=
|
||||
calc.GetHoursNotBillableDueToMoreThanApproved(supportConceptApprovalPeriod,
|
||||
cb2sc.CostBearer.CostRatePeriods.MapToNewDCs(),
|
||||
serviceRecordsInPeriod,
|
||||
true, true);
|
||||
}
|
||||
|
||||
|
||||
var itemList = CreateInvoiceItems(serviceRecordsInPeriod, invoicePeriod, serviceInvoicePeriod.SupportConceptApprovalPeriod, calc);
|
||||
serviceInvoicePeriod.InvoiceItemList.AddRange(itemList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void CreateFixedAmounts(ServiceInvoicePeriod serviceInvoicePeriod, SupportConceptApprovalPeriodDC supportConceptApprovalPeriod, CostBearer2SupportConcept cb2sc)
|
||||
{
|
||||
base.CreateFixedAmounts(serviceInvoicePeriod, supportConceptApprovalPeriod, cb2sc);
|
||||
foreach (var ii in serviceInvoicePeriod.InvoiceItemList)
|
||||
{
|
||||
if (supportConceptApprovalPeriod.ServiceCategory != null)
|
||||
{
|
||||
ii.ItemDescription = supportConceptApprovalPeriod.ServiceCategory.Name;
|
||||
}
|
||||
}
|
||||
if (serviceInvoicePeriod.Start > new DateTime(2024, 06, 30))
|
||||
{
|
||||
if (serviceInvoicePeriod.InvoiceItemList != null && serviceInvoicePeriod.InvoiceItemList.Count > 0)
|
||||
{
|
||||
var ii = serviceInvoicePeriod.InvoiceItemList.FirstOrDefault();
|
||||
decimal pauschale = 132.55m;
|
||||
var addService = DAOFactory.GenericDAO.GetByID<ServiceDescription>(81); // 81 für debug sonst 86
|
||||
var crpDcList = MapperFactory.CostRatePeriodDC_CostRatePeriod.MapToNewDCs(addService.CostRatePeriods);
|
||||
var crp = crpDcList.GetCostRatePeriodForDate(CostRatePeriodType.AmountOfMoney, serviceInvoicePeriod.Start.Value);
|
||||
if (crp != null)
|
||||
{
|
||||
pauschale = crp.CostRateValue.Value;
|
||||
}
|
||||
serviceInvoicePeriod.InvoiceItemList.Add(new InvoiceItem
|
||||
{
|
||||
AmountTotal = pauschale,
|
||||
GrossAmountTotal = pauschale,
|
||||
ItemPeriodStart = ii.ItemPeriodStart,
|
||||
ItemPeriodEnd = ii.ItemPeriodEnd,
|
||||
AccountingInterval = ii.AccountingInterval,
|
||||
AmountPerUnit = pauschale,
|
||||
UnitCount = 1,
|
||||
ItemDescription = addService.Name
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetServiceInvoicePeriodAmounts(ServiceInvoice invoice)
|
||||
{
|
||||
|
||||
foreach (ServiceInvoicePeriod iPeriod in invoice.ServiceInvoicePeriodList)
|
||||
{
|
||||
iPeriod.Claim = 0;
|
||||
foreach (InvoiceItem item in iPeriod.InvoiceItemList)
|
||||
{
|
||||
if (item.GrossAmountTotal.HasValue)
|
||||
iPeriod.Claim += item.GrossAmountTotal;
|
||||
}
|
||||
|
||||
iPeriod.Claim = Math.Round(iPeriod.Claim.Value, 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
|
||||
public override void CheckMaxApprovedAmount(ServiceInvoice invoice, ServiceInvoicePeriod sip, SupportConceptApprovalPeriodDC scap, CostBearer2SupportConcept costBearer2SupportConcept, DateTimeSpan invoicePeriod, List<ServiceRecordDC> serviceRecords)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,11 @@ namespace InputFamilienhilfe.Invoicing
|
||||
{
|
||||
return new IonInvoiceCreation();
|
||||
}
|
||||
|
||||
if (name.Contains("aws") || name.Contains("abw"))
|
||||
{
|
||||
return new AwsInvoiceCreation();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user