MH: Mobile Betreuungsaufwand

This commit is contained in:
2024-02-08 16:52:10 +01:00
parent 0298043d1b
commit 8266b03e77
2 changed files with 34 additions and 1 deletions

View File

@@ -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 "";
}
}
}

View File

@@ -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;