From 96d4155e7b9e2ad4d1b060d9e2f73cb3674cbe70 Mon Sep 17 00:00:00 2001 From: Alexandra Date: Wed, 22 May 2024 14:26:24 +0200 Subject: [PATCH] SKMAachen/Invoicing/CustomInvoiceNumberGenerator - Rechnungsschema mit Hauptbetreuer --- .../Invoicing/CustomInvoiceNumberGenerator.cs | 57 +++++++++ ReportImp/SKMAachen/RechnungBeWo67.cs | 120 +++++++++--------- ReportImp/SKMAachen/SKMAachen.csproj | 1 + 3 files changed, 118 insertions(+), 60 deletions(-) create mode 100644 ReportImp/SKMAachen/Invoicing/CustomInvoiceNumberGenerator.cs diff --git a/ReportImp/SKMAachen/Invoicing/CustomInvoiceNumberGenerator.cs b/ReportImp/SKMAachen/Invoicing/CustomInvoiceNumberGenerator.cs new file mode 100644 index 000000000..4bff9a5d4 --- /dev/null +++ b/ReportImp/SKMAachen/Invoicing/CustomInvoiceNumberGenerator.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.Eventing.Reader; +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.Services; + +namespace SKMAachen.Invoicing +{ + internal class CustomInvoiceNumberGenerator : InvoiceNumberGenerator + { + public override string GetNextInvoiceNumber(int increment, InvoiceBase invoiceBase) + { + string next = base.GetNextInvoiceNumber(increment, invoiceBase); + String maAbb = ""; + Customer c = null; + + if (invoiceBase.Type == InvoiceType.General && invoiceBase.RecipientCustomerOid.HasValue + || invoiceBase.Type == InvoiceType.CustomerEquity && invoiceBase.RecipientCustomerOid.HasValue) + { + c = DAOFactory.GenericDAO.LoadByID(invoiceBase.RecipientCustomerOid.Value); + } + else if (invoiceBase.CostBearer2SupportConcept != null) + { + c = invoiceBase.CostBearer2SupportConcept.SupportConcept.Customer; + } + if (c != null) + { + var hauptbetreuer = c.Employee2CustomerList.FirstOrDefault( + e2c => e2c.ValueList.Any(ve => ve.Entry.SystemEntryID.HasValue + && ve.Entry.SystemEntryID.Value == SystemEntryID.EmployeeRoleMainAttendant)); + if (hauptbetreuer != null) + { + if (hauptbetreuer.Employee.Person.Abbreviation != null) + { + maAbb = hauptbetreuer.Employee.Person.Abbreviation; + } + else + { + maAbb = String.Format("{0}{1}", hauptbetreuer.Employee.Person.LastName, hauptbetreuer.Employee.Person.FirstName); + } + } + next = next.Replace("{MA}", maAbb); + } + + return next; + } + } +} diff --git a/ReportImp/SKMAachen/RechnungBeWo67.cs b/ReportImp/SKMAachen/RechnungBeWo67.cs index e26b2d941..5fff424ff 100644 --- a/ReportImp/SKMAachen/RechnungBeWo67.cs +++ b/ReportImp/SKMAachen/RechnungBeWo67.cs @@ -1,64 +1,64 @@ -using System; -using BeWo.Data.Access; -using BeWo.Data.Entities; -using BeWo.Report; -using BeWo.Report.ReportObjects; -using BS.Shared.Core; -using DevExpress.XtraReports.UI; - -namespace SKMAachen -{ - [IDSpecificClass(Identifier = "BeWo67")] - public partial class RechnungBeWo67 : XtraReport, IBeWoReport - { - public RechnungBeWo67() - { - this.InitializeComponent(); - } - - public void SetReportDataSource(ServiceInvoiceRO pRO) - { - decimal hourlyRate = 0; - decimal hours = 0; - if (pRO.ServiceInvoicePeriods != null && pRO.ServiceInvoicePeriods.Count > 0) - { - foreach (var p in pRO.ServiceInvoicePeriods) - { - - if (p.ServiceInvoiceItems != null && p.ServiceInvoiceItems.Count > 0) - { - - foreach (var i in p.ServiceInvoiceItems) - { - if (i.HourlyRate.HasValue) - { - hourlyRate = i.HourlyRate.Value; - - if (!String.IsNullOrEmpty(i.RateFactor)) - { - var rfStr = i.RateFactor.Replace("%", "").Replace(",00", "").Trim(); - int rfInt = 0; - Int32.TryParse(rfStr, out rfInt); - } - } - +using System; +using BeWo.Data.Access; +using BeWo.Data.Entities; +using BeWo.Report; +using BeWo.Report.ReportObjects; +using BS.Shared.Core; +using DevExpress.XtraReports.UI; + +namespace SKMAachen +{ + [IDSpecificClass(Identifier = "BeWo67")] + public partial class RechnungBeWo67 : XtraReport, IBeWoReport + { + public RechnungBeWo67() + { + this.InitializeComponent(); + } + + public void SetReportDataSource(ServiceInvoiceRO pRO) + { + decimal hourlyRate = 0; + decimal hours = 0; + if (pRO.ServiceInvoicePeriods != null && pRO.ServiceInvoicePeriods.Count > 0) + { + foreach (var p in pRO.ServiceInvoicePeriods) + { + + if (p.ServiceInvoiceItems != null && p.ServiceInvoiceItems.Count > 0) + { + + foreach (var i in p.ServiceInvoiceItems) + { + if (i.HourlyRate.HasValue) + { + hourlyRate = i.HourlyRate.Value; + + if (!String.IsNullOrEmpty(i.RateFactor)) + { + var rfStr = i.RateFactor.Replace("%", "").Replace(",00", "").Trim(); + int rfInt = 0; + Int32.TryParse(rfStr, out rfInt); + } + } + if (i.Hours.HasValue) { hours += i.Hours.Value; - } - } - } - } - } - - lblForderung.Text = - String.Format("Hieraus ergibt sich eine Forderung von {0:0.00} Std. x {1:0.00} EUR = {2:0.00} EUR.", hours, hourlyRate, pRO.NetClaim); - - lblAbrechnungszeitraum.Text = - String.Format( - "Im Zeitraum vom {0:dd.MM.yyyy} bis {1:dd.MM.yyyy} wurden {2:0.00} Dienstleistungsstunden unmittelbare Betreuungsleistungen des Ambulant Betreuten Wohnens erbracht.", - pRO.AccountingPeriodStart, pRO.AccountingPeriodEnd, hours); - this.bindingSource1.DataSource = pRO; - } - } + } + } + } + } + } + + lblForderung.Text = + String.Format("Hieraus ergibt sich eine Forderung von {0:0.00} Std. x {1:0.00} EUR = {2:0.00} EUR.", hours, hourlyRate, pRO.NetClaim); + + lblAbrechnungszeitraum.Text = + String.Format( + "Im Zeitraum vom {0:dd.MM.yyyy} bis {1:dd.MM.yyyy} wurden {2:0.00} Dienstleistungsstunden unmittelbare Betreuungsleistungen des Ambulant Betreuten Wohnens erbracht.", + pRO.AccountingPeriodStart, pRO.AccountingPeriodEnd, hours); + this.bindingSource1.DataSource = pRO; + } + } } \ No newline at end of file diff --git a/ReportImp/SKMAachen/SKMAachen.csproj b/ReportImp/SKMAachen/SKMAachen.csproj index 551b2ae80..8b7f2d69d 100644 --- a/ReportImp/SKMAachen/SKMAachen.csproj +++ b/ReportImp/SKMAachen/SKMAachen.csproj @@ -61,6 +61,7 @@ + Component