refactor sanitize function

This commit is contained in:
FH 2022-04-11 20:00:03 +02:00
parent 43f91bff65
commit 9e0dbfb18d

View file

@ -86,14 +86,14 @@ public static class VatUtils
private static string SanitizeVatNumber(string vatNumber) private static string SanitizeVatNumber(string vatNumber)
{ {
var washing = vatNumber.Replace(" ", "").Replace("-", "").ToUpperInvariant(); vatNumber = vatNumber.ToUpperInvariant();
var result = washing.Replace("DK", "").Replace("NO", "").Replace("SE","") ; return vatNumber
if (result.Contains("MVA")) .Replace(" ", "")
result = result.Replace("MVA", ""); .Replace("-", "")
return result.Length switch .Replace("DK", "")
{ .Replace("NO", "")
>= 10 => vatNumber[..10], .Replace("SE","")
< 10 => result .Replace("MVA", "");
};
} }
} }