diff --git a/ReportImp/MobileEV/Invoicing/BetreuungsaufwandHelper.cs b/ReportImp/MobileEV/Invoicing/BetreuungsaufwandHelper.cs index 0891d7ef5..44cae2c4d 100644 --- a/ReportImp/MobileEV/Invoicing/BetreuungsaufwandHelper.cs +++ b/ReportImp/MobileEV/Invoicing/BetreuungsaufwandHelper.cs @@ -4,14 +4,17 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; namespace MobileEV.Invoicing { public class BetreuungsaufwandHelper { - public static decimal GetBetreuungsaufwand(ServiceRecordDC sr) + public static decimal GetBetreuungsaufwand(ServiceRecordDC sr) { + sr.Notice3 = FormatiereBetreuungsaufwand(sr.Notice3); + decimal amount = 0; if (sr != null && !sr.Notice3.IsNullOrEmpty()) { @@ -33,5 +36,31 @@ namespace MobileEV.Invoicing return 0; } + + // Die hauen manchmal die ganze Doku aus Versehen da rein, manche schreiben 10,00, manche 10,00 EUR, manche 10,00€... + // Daher wird Notice3 hier auseinandergenommen und nur der Geldbetrag reingesetzt. + private static string FormatiereBetreuungsaufwand(string notice3) + { + //string[] betreuungsaufwandArray = notice3.Split(' '); + string betreuungsaufwand = ""; + + string pattern = @"(\d+([.,]\d{1,2})?)\s?(€|Euro|EUR)?"; + + // Suche nach dem ersten Vorkommen eines Geldbetrags im Text + Match match = Regex.Match(notice3, pattern, RegexOptions.IgnoreCase); + + if (match.Success) + { + // Extrahiere nur den numerischen Teil des Geldbetrags + string geldbetrag = match.Groups[1].Value; + // Ersetze Punkt durch Komma, wenn nötig + geldbetrag = geldbetrag.Replace('.', ','); + betreuungsaufwand = geldbetrag; + } + if (betreuungsaufwand != "") + return string.Format("{0:c}", Convert.ToDecimal(betreuungsaufwand)); + else + return ""; + } } } diff --git a/ReportImp/MobileEV/Sammelrechnung.cs b/ReportImp/MobileEV/Sammelrechnung.cs index da93edc1b..5857c621b 100644 --- a/ReportImp/MobileEV/Sammelrechnung.cs +++ b/ReportImp/MobileEV/Sammelrechnung.cs @@ -8,6 +8,7 @@ using System.Linq; using BS.Shared.Extensions; using BS.Shared.DataContracts; using MobileEV.Invoicing; +using System.Text.RegularExpressions; namespace MobileEV { @@ -53,6 +54,9 @@ namespace MobileEV foreach (var item in ip.ServiceInvoiceItems) { + // Hier das Format von Notice3 (Betreuungsaufwand) anpassen. + //item.ServiceRecord.Notice3 = FormatiereBetreuungsaufwand(item.ServiceRecord.Notice3); + stundenZwischensumme += item.Hours.Value; betragZwischensumme += betrag != 0 ? GetGrossAmount(item) : 0;