From 2defabd5473f56ae2edac0b1fdd2950726812f8f Mon Sep 17 00:00:00 2001 From: Alexandra Date: Mon, 21 Jul 2025 09:34:52 +0200 Subject: [PATCH] SBBMainzReports - Zwischenstand Invoicing --- .../Invoicing/CustomInvoiceCreation.cs | 57 +++++++++++++++++++ .../SBBMainzReports/SBBMainzReports.csproj | 2 + 2 files changed, 59 insertions(+) create mode 100644 ReportImp/SBBMainzReports/Invoicing/CustomInvoiceCreation.cs diff --git a/ReportImp/SBBMainzReports/Invoicing/CustomInvoiceCreation.cs b/ReportImp/SBBMainzReports/Invoicing/CustomInvoiceCreation.cs new file mode 100644 index 000000000..b5bf3b38f --- /dev/null +++ b/ReportImp/SBBMainzReports/Invoicing/CustomInvoiceCreation.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using BeWo.Data.Entities; +using BeWo.Service.DCEntityMapper; +using BeWo.Service.Invoicing; +using BeWo.Service.Plugins; +using BS.Shared.Core; +using BS.Shared.DataContracts; +using BS.Shared.DataContracts.Compact; +using BS.Shared.Extensions; +using BS.Shared.Services; + +namespace SbbMainzReports.Invoicing +{ + public class CustomInvoiceCreation : InvoiceCreation + { + public override void SetInvoiceItems(ServiceInvoice invoice, + ServiceInvoicePeriod serviceInvoicePeriod, + SupportConceptApprovalPeriodDC supportConceptApprovalPeriod, + CostBearer2SupportConcept cb2sc, + DateTimeSpan invoicePeriod, + List serviceRecords) + { + var calc = PluginLoader.FindClass(_SpecificID) ?? BS.Shared.Services.Calculations.GetInstance(_SpecificID); + + if (ShouldCreateFixedAmounts(serviceInvoicePeriod, supportConceptApprovalPeriod, cb2sc)) + { + CreateFixedAmounts(serviceInvoicePeriod, supportConceptApprovalPeriod, cb2sc); + } + else + { + List 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 = CreateInvoiceItems(serviceRecordsInPeriod, invoicePeriod, serviceInvoicePeriod.SupportConceptApprovalPeriod, calc); + serviceInvoicePeriod.InvoiceItemList.AddRange(itemList); + } + } + } + public override string GetSummaryItemKey(SupportConceptApprovalPeriod scap, InvoiceItem iitem, bool summaryPerMonth) + { + return String.Format("{0}_{1}_{2}", iitem.AmountPerUnit, iitem.RateFactor, iitem.ItemDescription); + } + } +} diff --git a/ReportImp/SBBMainzReports/SBBMainzReports.csproj b/ReportImp/SBBMainzReports/SBBMainzReports.csproj index 9a071760b..348b81e39 100644 --- a/ReportImp/SBBMainzReports/SBBMainzReports.csproj +++ b/ReportImp/SBBMainzReports/SBBMainzReports.csproj @@ -76,6 +76,8 @@ CustomerDataReport.cs + + Component