45 lines
1.5 KiB
C#
45 lines
1.5 KiB
C#
using BeWo.Data.Entities;
|
|
using BeWo.Service.Invoicing;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.Services;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BS.Shared.Extensions;
|
|
|
|
|
|
namespace BeWo.SKFAlsdorf.Invoicing
|
|
{
|
|
public class CustomSettlementInvoiceCreation : SettlementInvoiceCreation
|
|
{
|
|
public override void CalculateAdvancedPayments(Settlement2DC settlementInvoice, CostBearer2SupportConcept cb2sc)
|
|
{
|
|
// die haben eine Spitzabrechnung nach 2 Jahren ohne eine Buchung, wollen aber die Avise ausweisen, daher if invoiceItems != null entfernt
|
|
decimal amountTotal = 0;
|
|
var bookingList = cb2sc.AccountingTransactions;
|
|
|
|
foreach (var item in bookingList)
|
|
{
|
|
if (item.GueltigkeitsDatum.HasValue)
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
}
|