diff --git a/ReportImp/ChristinaFrommen/ChristinaFrommen.csproj b/ReportImp/ChristinaFrommen/ChristinaFrommen.csproj index e99ca6290..9c8d4c581 100644 --- a/ReportImp/ChristinaFrommen/ChristinaFrommen.csproj +++ b/ReportImp/ChristinaFrommen/ChristinaFrommen.csproj @@ -63,6 +63,8 @@ InvoiceCustomerReport.cs + + Component @@ -173,5 +175,6 @@ Teamstundenkonto.cs + \ No newline at end of file diff --git a/ReportImp/ChristinaFrommen/Invoicing/CustomInvoiceFactory.cs b/ReportImp/ChristinaFrommen/Invoicing/CustomInvoiceFactory.cs new file mode 100644 index 000000000..2bc56451c --- /dev/null +++ b/ReportImp/ChristinaFrommen/Invoicing/CustomInvoiceFactory.cs @@ -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(); + } + } +} diff --git a/ReportImp/ChristinaFrommen/Invoicing/CustomSettlementInvoiceCreation.cs b/ReportImp/ChristinaFrommen/Invoicing/CustomSettlementInvoiceCreation.cs new file mode 100644 index 000000000..c3449f490 --- /dev/null +++ b/ReportImp/ChristinaFrommen/Invoicing/CustomSettlementInvoiceCreation.cs @@ -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; + } + } +}