From 420ff4138b0fccf8866469f30d6921d9407ccd2a Mon Sep 17 00:00:00 2001 From: Alexandra Date: Mon, 18 May 2026 11:29:06 +0200 Subject: [PATCH 1/6] =?UTF-8?q?PerspektivenEV/Export/DatevExporterBthg=20-?= =?UTF-8?q?=20Debitor=20bei=20Eigenanteilsrg=20angef=C3=BCgt=20SupportOID?= =?UTF-8?q?=3D161986?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Export/DatevExporterBthg.cs | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/ReportImp/PerspektivenEV/Export/DatevExporterBthg.cs b/ReportImp/PerspektivenEV/Export/DatevExporterBthg.cs index bfd157a34..f84c85d05 100644 --- a/ReportImp/PerspektivenEV/Export/DatevExporterBthg.cs +++ b/ReportImp/PerspektivenEV/Export/DatevExporterBthg.cs @@ -180,7 +180,9 @@ namespace PerspektivenEV.Export 12 ii.Notice, 13 ii.AmountPerUnit, 14 ii.UnitCount, - 15 ii.AmountTotal + 15 ii.AmountTotal, + 16 ib.CustomerOid, + 17 ib.CostbearerOid */ //Kontonummer; Umsatz; Gegenkonto; Belegdatum; Kost 1; Belegfeld 1; Buchungstext; Festschreibung @@ -193,6 +195,8 @@ namespace PerspektivenEV.Export String itemDescription = ""; String unitDescription = ""; String isApproved = ""; + long? cOid = null; + if (row[8] != null) orgaName = row[8].ToString(); @@ -206,14 +210,35 @@ namespace PerspektivenEV.Export if (row[12] != null) isApproved = row[12].ToString(); + if (row[16] != null) + cOid = long.Parse(row[16].ToString()); + if (sb.Length > 0) sb.AppendLine(); DateTime lastDate = new DateTime(date.Year, date.Month, 1); lastDate = lastDate.AddMonths(1).AddDays(-1); - + var debitor = "999998"; + if (cOid != null) + { + var scs = DAOFactory.SearchDAO.GetAllActiveSupportConceptsByCustomers(new List() { cOid.Value }, false).ToList(); + if (scs != null && scs.Count != 0 && scs[0].CostBearer2SupportConceptList != null) + { + var sc = scs[0]; + if (scs.Count > 1) + { + sc = scs.Where(p => p.StartDate < lastDate && p.EndDate > new DateTime(date.Year, date.Month, 1)).FirstOrDefault(); + } + var cb2sc = sc.CostBearer2SupportConceptList.Where(sc => sc.CostBearer.Organisation.Name != "EIGENANTEIL" && sc.CostBearer.Organisation.Name != "SELBSTZAHLER").FirstOrDefault(); + if (cb2sc != null && cb2sc.KontoHilfeplan != null && cb2sc.KontoHilfeplan.Length > 0) + { + debitor = cb2sc.KontoHilfeplan; + } + } + + } //sb.Append(String.Format("{0}", row[1])); //Debitornr. als Kontonummer - sb.Append("999998;"); + sb.Append(debitor + ";"); sb.Append(String.Format("{0:0.00}", row[15])); //Umsatz - der Rechnungsposition sb.Append(";"); //var gegenkto = GetErloeskonto(itemDescription, unitDescription, orgaName, isApproved); @@ -573,7 +598,9 @@ namespace PerspektivenEV.Export ii.Notice, ii.AmountPerUnit, ii.UnitCount, - ii.AmountTotal + ii.AmountTotal, + ib.RecipientCustomerOid, + ib.RecipientCostbearerOid from invoicebase ib inner join invoiceitem ii on ii.InvoiceBaseOid = ib.Oid From 3293d82f91e6a4cc75229023165581951742ed3e Mon Sep 17 00:00:00 2001 From: Alexandra Date: Tue, 19 May 2026 08:56:55 +0200 Subject: [PATCH 2/6] =?UTF-8?q?LebenshilfeBadKreuznach/Invoicing/CustomInv?= =?UTF-8?q?oiceCreation=20-=20=C3=84nderung=20zum=2001.01.26=20mit=20Wegep?= =?UTF-8?q?auschalen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Invoicing/CustomInvoiceCreation.cs | 121 +++++++++++------- 1 file changed, 73 insertions(+), 48 deletions(-) diff --git a/ReportImp/LebenshilfeBadKreuznach/Invoicing/CustomInvoiceCreation.cs b/ReportImp/LebenshilfeBadKreuznach/Invoicing/CustomInvoiceCreation.cs index 11f445a3b..522c53e98 100644 --- a/ReportImp/LebenshilfeBadKreuznach/Invoicing/CustomInvoiceCreation.cs +++ b/ReportImp/LebenshilfeBadKreuznach/Invoicing/CustomInvoiceCreation.cs @@ -241,62 +241,87 @@ namespace LebenshilfeBadKreuznach.Invoicing var preise = DAOFactory.GenericDAO.GetAllActive(); int countWegeBG1 = 0; int countWegeBG2 = 0; - - if (invoicePeriod.StartDate < new DateTime(2025, 03, 01)) // alter Weg - Anzahl aller Zeiterfassungseinträge + if (invoicePeriod.StartDate > new DateTime(2025, 12, 31)) // neue Berechnung hat für alle Entfernungen einen Preis, die glauben aber noch nicht, dass das so bleibt { - foreach (var sr in serviceRecordsInPeriod) + countWegeBG1 = serviceRecordsInPeriod.GroupBy(r => r.Start.Value.Date).Count(); // es darf für jeden Tag maximal einmal abgerechnet werden + + if (countWegeBG1 > 0) { - if (sr.ServiceDescription.CategoryName.ToLower().StartsWith("bg1")) + wegepauschale = GetPreis(preise, "Wegevergütung BG1", km, invoicePeriod.StartDate); + decimal anzahlWege = countWegeBG1; + var invoiceItem = new InvoiceItem(); + invoiceItem.AmountPerUnit = wegepauschale; + invoiceItem.UnitCount = anzahlWege; + invoiceItem.AmountTotal = anzahlWege * wegepauschale; + invoiceItem.ItemPeriodStart = invoicePeriod.StartDate; + invoiceItem.ItemPeriodEnd = invoicePeriod.EndDate; + invoiceItem.RateFactor = null; + invoiceItem.GrossAmountTotal = invoiceItem.AmountTotal; + invoiceItem.ItemDescription = "Wegevergütung"; + if (scap != null) + invoiceItem.SupportConceptApprovalPeriodOid = scap.Oid; + + items.Add(invoiceItem); + } + } + else + { + if (invoicePeriod.StartDate < new DateTime(2025, 03, 01)) // alter Weg - Anzahl aller Zeiterfassungseinträge + { + foreach (var sr in serviceRecordsInPeriod) { - countWegeBG1++; - } - if (sr.ServiceDescription.CategoryName.ToLower().StartsWith("bg2")) - { - countWegeBG2++; + if (sr.ServiceDescription.CategoryName.ToLower().StartsWith("bg1")) + { + countWegeBG1++; + } + if (sr.ServiceDescription.CategoryName.ToLower().StartsWith("bg2")) + { + countWegeBG2++; + } } } - } - else // neuer Weg - Anzahl der Tage wo die Zeiterfassungseinträge vorkommen (max. 1 pro Tag) - { - countWegeBG1 = serviceRecordsInPeriod.Where(r => r.ServiceDescription.CategoryName.ToLower().StartsWith("bg1")).GroupBy(r => r.Start.Value.Date).Count(); - countWegeBG2 = serviceRecordsInPeriod.Where(r => r.ServiceDescription.CategoryName.ToLower().StartsWith("bg2")).GroupBy(r => r.Start.Value.Date).Count(); - } + else // neuer Weg - Anzahl der Tage wo die Zeiterfassungseinträge vorkommen (max. 1 pro Tag) + { + countWegeBG1 = serviceRecordsInPeriod.Where(r => r.ServiceDescription.CategoryName.ToLower().StartsWith("bg1")).GroupBy(r => r.Start.Value.Date).Count(); + countWegeBG2 = serviceRecordsInPeriod.Where(r => r.ServiceDescription.CategoryName.ToLower().StartsWith("bg2")).GroupBy(r => r.Start.Value.Date).Count(); + } - if (countWegeBG1 > 0) - { - wegepauschale = GetPreis(preise, "Wegevergütung BG1", km, invoicePeriod.StartDate); - decimal anzahlWege = countWegeBG1; - var invoiceItem = new InvoiceItem(); - invoiceItem.AmountPerUnit = wegepauschale; - invoiceItem.UnitCount = anzahlWege; - invoiceItem.AmountTotal = anzahlWege * wegepauschale; - invoiceItem.ItemPeriodStart = invoicePeriod.StartDate; - invoiceItem.ItemPeriodEnd = invoicePeriod.EndDate; - invoiceItem.RateFactor = null; - invoiceItem.GrossAmountTotal = invoiceItem.AmountTotal; - invoiceItem.ItemDescription = "Wegevergütung BG1"; - if (scap != null) - invoiceItem.SupportConceptApprovalPeriodOid = scap.Oid; + if (countWegeBG1 > 0) + { + wegepauschale = GetPreis(preise, "Wegevergütung BG1", km, invoicePeriod.StartDate); + decimal anzahlWege = countWegeBG1; + var invoiceItem = new InvoiceItem(); + invoiceItem.AmountPerUnit = wegepauschale; + invoiceItem.UnitCount = anzahlWege; + invoiceItem.AmountTotal = anzahlWege * wegepauschale; + invoiceItem.ItemPeriodStart = invoicePeriod.StartDate; + invoiceItem.ItemPeriodEnd = invoicePeriod.EndDate; + invoiceItem.RateFactor = null; + invoiceItem.GrossAmountTotal = invoiceItem.AmountTotal; + invoiceItem.ItemDescription = "Wegevergütung BG1"; + if (scap != null) + invoiceItem.SupportConceptApprovalPeriodOid = scap.Oid; - items.Add(invoiceItem); - } - if (countWegeBG2 > 0) - { - wegepauschale = GetPreis(preise, "Wegevergütung BG2", km, invoicePeriod.StartDate); - decimal anzahlWege = countWegeBG2; - var invoiceItem = new InvoiceItem(); - invoiceItem.AmountPerUnit = wegepauschale; - invoiceItem.UnitCount = anzahlWege; - invoiceItem.AmountTotal = anzahlWege * wegepauschale; - invoiceItem.ItemPeriodStart = invoicePeriod.StartDate; - invoiceItem.ItemPeriodEnd = invoicePeriod.EndDate; - invoiceItem.RateFactor = null; - invoiceItem.GrossAmountTotal = invoiceItem.AmountTotal; - invoiceItem.ItemDescription = "Wegevergütung BG2"; - if (scap != null) - invoiceItem.SupportConceptApprovalPeriodOid = scap.Oid; + items.Add(invoiceItem); + } + if (countWegeBG2 > 0) + { + wegepauschale = GetPreis(preise, "Wegevergütung BG2", km, invoicePeriod.StartDate); + decimal anzahlWege = countWegeBG2; + var invoiceItem = new InvoiceItem(); + invoiceItem.AmountPerUnit = wegepauschale; + invoiceItem.UnitCount = anzahlWege; + invoiceItem.AmountTotal = anzahlWege * wegepauschale; + invoiceItem.ItemPeriodStart = invoicePeriod.StartDate; + invoiceItem.ItemPeriodEnd = invoicePeriod.EndDate; + invoiceItem.RateFactor = null; + invoiceItem.GrossAmountTotal = invoiceItem.AmountTotal; + invoiceItem.ItemDescription = "Wegevergütung BG2"; + if (scap != null) + invoiceItem.SupportConceptApprovalPeriodOid = scap.Oid; - items.Add(invoiceItem); + items.Add(invoiceItem); + } } return items; } From f9b1ffbb0eaa5cda4c287fc278ace6e382328c6b Mon Sep 17 00:00:00 2001 From: Alexandra Date: Tue, 19 May 2026 08:58:24 +0200 Subject: [PATCH 3/6] FeidPartnerReports/CustomSupportConceptAnalysisCreator und CustomServiceRecordStatisticFactory - Fehler bei Buchhungen Anfang der Woche SupportOID=163175 --- .../CustomSupportConceptAnalysisCreator.cs | 2 +- .../Statistics/CustomServiceRecordStatisticFactory.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ReportImp/FeidPartnerReports/CustomSupportConceptAnalysisCreator.cs b/ReportImp/FeidPartnerReports/CustomSupportConceptAnalysisCreator.cs index 80808f7ca..4e0898652 100644 --- a/ReportImp/FeidPartnerReports/CustomSupportConceptAnalysisCreator.cs +++ b/ReportImp/FeidPartnerReports/CustomSupportConceptAnalysisCreator.cs @@ -130,7 +130,7 @@ namespace FeidPartnerReports bool vorhandeneEintraege = false; if (serviceRecords != null && serviceRecords.Count > 0) { - vorhandeneEintraege = serviceRecords.Any(s => s.Start.Value.Date >= start.Date && s.Start.Value.Date <= end.Date && s.RoundedDuration > 0 && s.ServiceDescription.Category.IsBillable); + vorhandeneEintraege = serviceRecords.Any(s => s.Start.Value.Date >= start.Date && s.Start.Value.Date < end.Date && s.RoundedDuration > 0 && s.ServiceDescription.Category.IsBillable); } return vorhandeneEintraege; } diff --git a/ReportImp/FeidPartnerReports/Statistics/CustomServiceRecordStatisticFactory.cs b/ReportImp/FeidPartnerReports/Statistics/CustomServiceRecordStatisticFactory.cs index ef6a1f04c..1cb6d5de0 100644 --- a/ReportImp/FeidPartnerReports/Statistics/CustomServiceRecordStatisticFactory.cs +++ b/ReportImp/FeidPartnerReports/Statistics/CustomServiceRecordStatisticFactory.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using BeWo.Data.Access; @@ -21,7 +21,7 @@ namespace FeidPartnerReports.Statistics try { - // Fahrtzeiten nicht in Ministatistik nur für Abrechnung + // Fahrtzeiten nicht in Ministatistik nur für Abrechnung stat.PeriodStatistics = stat.PeriodStatistics.Where(p => p.SupportConceptApprovalPeriod.ServiceCategory == null || String.IsNullOrEmpty(p.SupportConceptApprovalPeriod.ServiceCategory.Abbreviation) || !p.SupportConceptApprovalPeriod.ServiceCategory.Abbreviation.Contains("FZQA")).ToList(); @@ -135,7 +135,7 @@ namespace FeidPartnerReports.Statistics catch (Exception) { - //Mach nichts. Das ist für den alten Mok bei dem die Felder MinutesFreePerWeekStatisticDate noch nicht in der alten Shared.dll existieren + //Mach nichts. Das ist für den alten Mok bei dem die Felder MinutesFreePerWeekStatisticDate noch nicht in der alten Shared.dll existieren } } @@ -156,7 +156,7 @@ namespace FeidPartnerReports.Statistics bool vorhandeneEintraege = false; if (serviceRecords != null && serviceRecords.Count > 0) { - vorhandeneEintraege = serviceRecords.Any(s => s.Start.Value.Date >= start.Date && s.Start.Value.Date <= end.Date && s.RoundedDuration > 0 && s.ServiceDescription.Category.IsBillable); + vorhandeneEintraege = serviceRecords.Any(s => s.Start.Value.Date >= start.Date && s.Start.Value.Date < end.Date && s.RoundedDuration > 0 && s.ServiceDescription.Category.IsBillable); } return vorhandeneEintraege; } From 33ee437122a7c51e97bde9f06c2324c30ee513ab Mon Sep 17 00:00:00 2001 From: Alexandra Date: Tue, 19 May 2026 11:06:00 +0200 Subject: [PATCH 4/6] VSDHammReports/CustomSettlementInvoiceCreation. - JA kann Fehlkontakte mit anderen % Abrechenbarkeit haben SupportOID=163156 --- .../CustomSettlementInvoiceCreation.cs | 35 +++++++++++++------ ReportImp/VSDHammReports/SettlementReport.cs | 9 +++-- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/ReportImp/VSDHammReports/CustomSettlementInvoiceCreation.cs b/ReportImp/VSDHammReports/CustomSettlementInvoiceCreation.cs index 8733b9513..c798a4d29 100644 --- a/ReportImp/VSDHammReports/CustomSettlementInvoiceCreation.cs +++ b/ReportImp/VSDHammReports/CustomSettlementInvoiceCreation.cs @@ -1,12 +1,14 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using BeWo.Data.Access; using BeWo.Data.Entities; using BeWo.Service.Invoicing; using BeWo.Service.Plugins; using BS.Shared.Core; using BS.Shared.DataContracts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using static BeWo.Report.ReportObjects.SettlementRO; namespace VSDHammReports { @@ -27,15 +29,16 @@ namespace VSDHammReports public override List CreateInvoiceItems(Settlement2DC si, IList apList, bool schneideBeiMaxAb) { - //var items = base.CreateInvoiceItems(si, apList, true); + //var items = base.CreateInvoiceItems(si, apList, true); - //return items; + //return items; - //Übergangslösung um Fehlkontakte auch bei JA mit 0 % Ratefaktor zu identifzieren. Nur ii.ItemDesc = "Fehlkontakte" weicht vom Standard ab... - schneideBeiMaxAb = true; + // Übergangslösung um Fehlkontakte auch bei JA mit 0 % Ratefaktor zu identifzieren. + // AB, 19.05.2026: Anders als im Standard kann bei JA ein Fehlkontakt auch mit 100 % abgerechnet werden. + // Erkennung Abrechenbarkeit nachträglich eingeführt: if (!String.IsNullOrEmpty(approvalPeriod.Notice) && approvalPeriod.Notice == "Fehlkontakte") ff. + schneideBeiMaxAb = true; List iiList = new List(); var apsByHourlyRate = new Dictionary>(); - foreach (var ap in apList) { IList list = null; @@ -84,8 +87,18 @@ namespace VSDHammReports rf = approvalPeriod.RateFactor.Value; } if (!String.IsNullOrEmpty(approvalPeriod.Notice) && approvalPeriod.Notice == "Fehlkontakte") - { - hr *= 0.8m; + { + var c2s = DAOFactory.GenericDAO.LoadByID(si.CostBearer2SupportConceptOid.Value); + var records = c2s.ServiceRecords; + if (records.Any(s => s.ServiceDescription.Name.Contains("Fehlkontakt"))) + { + var fk = records.Where(s => s.ServiceDescription.Name.Contains("Fehlkontakt")).FirstOrDefault(); + if (fk.ServiceDescription.ProzentAbrechnung.HasValue && fk.ServiceDescription.ProzentAbrechnung != 100) + { + var anteil = fk.ServiceDescription.ProzentAbrechnung.Value / 100; + hr *= anteil; + } + } ii.ItemDescription = "Fehlkontakte"; } } diff --git a/ReportImp/VSDHammReports/SettlementReport.cs b/ReportImp/VSDHammReports/SettlementReport.cs index cc892cd20..f9d192da5 100644 --- a/ReportImp/VSDHammReports/SettlementReport.cs +++ b/ReportImp/VSDHammReports/SettlementReport.cs @@ -39,9 +39,12 @@ namespace VSDHammReports.Alt hasFehlkontakte = true; ii.ItemDescription = String.Format("{0:dd.MM.yyyy} bis {1:dd.MM.yyyy}", ii.ItemPeriodStart, ii.ItemPeriodEnd); ii.ItemDescription += String.Format(": {0:0.##} Std. x {1:c}", ii.UnitCount, ii.AmountPerUnit); - ii.Notice = "Fehlkontakte - 80 % abrechenbar"; - - } + ii.Notice = "Fehlkontakte"; + if (String.IsNullOrEmpty(pRO.RecipientOrganisation) || pRO.RecipientOrganisation.ToLower().StartsWith("lwl")) + { + ii.Notice += " - 80 % abrechenbar"; + } + } else { ii.ItemDescription = String.Format("{0:dd.MM.yyyy} bis {1:dd.MM.yyyy}", ii.ItemPeriodStart, ii.ItemPeriodEnd); From b04142d52e25bdbc7fcf57b6821ce626c6d23442 Mon Sep 17 00:00:00 2001 From: Alexandra Date: Tue, 19 May 2026 11:06:47 +0200 Subject: [PATCH 5/6] =?UTF-8?q?VSDHammReports/VsdHammReportCreator.cs=20-?= =?UTF-8?q?=20Unterscheidung=20QB=20um=202.=20Funktion=20erg=C3=A4nzt=20Su?= =?UTF-8?q?pportOID=3D163156?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VSDHammReports/VsdHammReportCreator.cs | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/ReportImp/VSDHammReports/VsdHammReportCreator.cs b/ReportImp/VSDHammReports/VsdHammReportCreator.cs index f63dcadff..d8174f1e0 100644 --- a/ReportImp/VSDHammReports/VsdHammReportCreator.cs +++ b/ReportImp/VSDHammReports/VsdHammReportCreator.cs @@ -112,18 +112,22 @@ namespace VSDHammReports { report = new VSDHammReports.QuittierungsbelegJA(); } - else if (kt.Contains("Jugendamt") || kt.Contains("jugendamt") || kt.Contains("Jugendamt der Stadt Hamm") || kt == "Jugendamt der Stadt Aachen" - || kt == "Stadt Hamm Jugendamt Clearing" || kt == "Jugendamt Ahlen Wohnprojekt" || kt.Contains("Wohnprojekt") + else if (function == "LWL") + { + report = new VSDHammReports.Stundenzettel(); + } + else if (kt.Contains("Jugendamt") || kt.Contains("jugendamt") || kt.Contains("Jugendamt der Stadt Hamm") || kt == "Jugendamt der Stadt Aachen" + || kt == "Stadt Hamm Jugendamt Clearing" || kt == "Jugendamt Ahlen Wohnprojekt" || kt.Contains("Wohnprojekt") || function == "Jugendamt") { - if (ro.StartDate < new DateTime(2016, 7, 1)) - { - report = new VSDHammReports.QuittierungsbelegJA(); - } - else - { - report = new VSDHammReports.LeistungsnachweisJA(); - } + if (ro.StartDate < new DateTime(2016, 7, 1)) + { + report = new VSDHammReports.QuittierungsbelegJA(); + } + else + { + report = new VSDHammReports.LeistungsnachweisJA(); + } } if (report == null) From 7ec291da32caaa47d6745355d27a826bed12d800 Mon Sep 17 00:00:00 2001 From: Alexandra Date: Tue, 19 May 2026 11:46:09 +0200 Subject: [PATCH 6/6] =?UTF-8?q?LwlPrueflisteRO.cs=20-=20Abfangen=20falls?= =?UTF-8?q?=20Mitarbeiterk=C3=BCrzel=20null=20oder=20leer=20ist=20SupportO?= =?UTF-8?q?ID=3D163138?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Report/ReportObjects/LwlPrueflisteRO.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Report/ReportObjects/LwlPrueflisteRO.cs b/Report/ReportObjects/LwlPrueflisteRO.cs index 6011d52a4..c4553635c 100644 --- a/Report/ReportObjects/LwlPrueflisteRO.cs +++ b/Report/ReportObjects/LwlPrueflisteRO.cs @@ -55,7 +55,7 @@ sr.ServiceDescriptionOid, (select CONCAT(emp1p.`FirstName`, ' ', emp1p.`LastName`) from employee emp1 join `person` emp1p on emp1p.`Oid` = emp1.`PersonOid` where emp1.`Oid` in (select employeeoid from `employee2customer` e2c1 join `valuelistentry2object` vl2o on e2c1.`Oid` = vl2o.`ObjectOid` join `valuelistentry` vle on vl2o.`ValueListEntryOid` = vle.`Oid` where e2c1.`CustomerOid` = sc.CustomerOid and vle.`SystemEntryID` = 3) LIMIT 1) as 'Bezugsbetreuung', (select name from ServiceDescription sd where sd.Oid = sr.ServiceDescriptionOid), (select distinct zeitstempel from signature sig where sig.ServiceRecordOid = sr.Oid AND sig.IsActive = 1 order by zeitstempel desc limit 1), -(select emp2p.Abbreviation from employee emp2 join `person` emp2p on emp2p.`Oid` = emp2.`PersonOid` where emp2.`Oid` = sr.EmployeeOid), +(select COALESCE(NULLIF(emp2p.Abbreviation, ''), CONCAT(LEFT(emp2p.LastName, 4), LEFT(emp2p.FirstName, 1))) from employee emp2 join `person` emp2p on emp2p.`Oid` = emp2.`PersonOid` where emp2.`Oid` = sr.EmployeeOid), (select cs.InsTs from confirmationreceiptsignature2servicerecord cs2s join confirmationreceiptsignature cs where cs.Oid = cs2s.ConfirmationReceiptSignatureOid and cs.IsActive = 1 and cs.EmployeeOid Is not null and cs2s.ServiceRecordOid = sr.oid LIMIT 1), (select cs.InsTs from confirmationreceiptsignature2servicerecord cs2s join confirmationreceiptsignature cs where cs.Oid = cs2s.ConfirmationReceiptSignatureOid and cs.IsActive = 1 and cs.CustomerOid = c.Oid and cs2s.ServiceRecordOid = sr.oid LIMIT 1) FROM servicerecord sr