MH: Frommen Rechnungen mit Abschlägen auch ohne ServiceRecords

This commit is contained in:
2023-06-23 13:47:29 +02:00
parent d209f15863
commit 8c815d05b4
3 changed files with 69 additions and 0 deletions

View File

@@ -63,6 +63,8 @@
<DependentUpon>InvoiceCustomerReport.cs</DependentUpon>
</Compile>
<Compile Include="CustomMitarbeiterstundenkontoBerechnung.cs" />
<Compile Include="Invoicing\CustomSettlementInvoiceCreation.cs" />
<Compile Include="Invoicing\CustomInvoiceFactory.cs" />
<Compile Include="Mitarbeiterarbeitszeitkonto.cs">
<SubType>Component</SubType>
</Compile>
@@ -173,5 +175,6 @@
<DependentUpon>Teamstundenkonto.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,18 @@
using BeWo.Data.Entities;
using BeWo.Service.Invoicing;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ChristinaFrommen.Invoicing
{
public class CustomInvoiceFactory : InvoiceFactory
{
public override SettlementInvoiceCreation CreateSettlementInvoiceCreator(string costbearerId, string tenant, CostBearer2SupportConcept lCb2Sc)
{
return new CustomSettlementInvoiceCreation();
}
}
}

View File

@@ -0,0 +1,48 @@
using BeWo.Data.Entities;
using BeWo.Service.Invoicing;
using BS.Shared.DataContracts;
using BS.Shared.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ChristinaFrommen.Invoicing
{
public class CustomSettlementInvoiceCreation : SettlementInvoiceCreation
{
// Rechnungen ohne ServiceRecords sollen trotzdem Abschlagszahlungen errechnen
public override void CalculateAdvancedPayments(Settlement2DC settlementInvoice, CostBearer2SupportConcept cb2sc)
{
decimal amountTotal = 0;
var bookingList = cb2sc.AccountingTransactions;
foreach (var item in bookingList)
{
if (item.GueltigkeitsDatum.HasValue)
{
if (settlementInvoice.InvoiceItems != null && settlementInvoice.InvoiceItems.Count > 0)
{
foreach (var ii in settlementInvoice.InvoiceItems)
{
if (ii.ItemPeriodStart.HasValue && ii.ItemPeriodEnd.HasValue)
{
if (item.GueltigkeitsDatum.Value.InBetween(ii.ItemPeriodStart.Value, ii.ItemPeriodEnd.Value, true))
{
ii.ReceivedAmount += item.Amount;
break;
}
}
}
}
}
amountTotal += item.Amount;
}
settlementInvoice.AmountAdvancedPayments = amountTotal;
}
}
}