-
-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UnitCodes updated with full PEPPOL list as of 2025-01-06 #538
Conversation
The component intentionally not covers all available codes since this makes creating or processing invoices almost impossible as you can't find anything. |
Moin Stephan, |
ja, das ist richtig. Sollten Codes fehlen, ergänze ich die jederzeit gerne oder nehme den Pull Request an. An einem schlüssigen Konzept, wie die enums übersichtlich bleiben aber man trotzdem alles verarbeiten kann, arbeite ich aktuell. |
Was hältst du von der Idee, im Source oberhalb vom Enum einfach einen längeren Kommentarblock mit den gängigsten Codes mit deren deutschen Beschreibung aufzuführen (pro Zeile ein Code + Kurzbeschreibung)? |
das ist eine gute Idee. Auch die gleiche Beschreibung auf der readme-Seite wäre sicher sinnvoll.
bestehender Code wäre weiterverwendbar und man könnte einen Umgang finden mit Kategorien, die nicht als static readonly-Variable vorhanden sind. |
Ich finde, dass Enums für diese Werte z.T. kaum hilfreich sind, es sei denn man programmiert mit expliziten Werten, Hier wäre eine Alternative zu der obigen TaxCategoryCode Klasse, die ich einfach mal o1 habe schreiben lassen: using System;
public static class TaxCategoryCodeExtensions
{
/// <summary>
/// Prüft, ob der übergebene Code ein gültiger TaxCategoryCode ist.
/// </summary>
/// <param name="code">Der Code, z.B. "AA" oder "AB".</param>
/// <returns>true, wenn vorhanden, sonst false.</returns>
public static bool IsValidTaxCategory(this string code)
{
return TaxCategoryCodes.IsValidCode(code);
}
/// <summary>
/// Ruft die Beschreibung eines bestimmten Codes ab,
/// oder "Unknown Code", falls nicht vorhanden.
/// </summary>
/// <param name="code">Der Code, z.B. "AA" oder "AB".</param>
/// <returns>Die Beschreibung des Codes oder "Unknown Code".</returns>
public static string GetTaxCategoryDescription(this string code)
{
return TaxCategoryCodes.GetDescription(code);
}
}
public static class TaxCategoryCodes
{
// Beispiel-Inhalte aus dem vorigen Beitrag
private static readonly SortedDictionary<string, string> _codes
= new SortedDictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
{ "Unknown", "Default value, not specified" },
{ "A", "Mixed tax rate" },
{ "AA", "Lower rate" },
{ "AB", "Exempt for resale" },
{ "AC", "VAT not now due for payment" },
{ "AD", "VAT due from a previous invoice" }
};
public static IReadOnlyDictionary<string, string> Codes => _codes;
public static bool IsValidCode(string code) => _codes.ContainsKey(code);
public static string GetDescription(string code)
{
return _codes.TryGetValue(code, out var description)
? description
: "Unknown Code";
}
}
class Program
{
static void Main()
{
Console.WriteLine("AA".IsValidTaxCategory()); // true
Console.WriteLine("ZZZZ".IsValidTaxCategory()); // false
Console.WriteLine("AA".GetTaxCategoryDescription()); // "Lower rate"
Console.WriteLine("ZZZZ".GetTaxCategoryDescription()); // "Unknown Code"
}
} In deiner Variante fände ich es schwierig, einen gültigen Code zu finden/suchen, wenn du einen Wert gelesen hast. Aber das ist jetzt nicht als Änderungswunsch von mir zu verstehen, einfach nur eine Idee. |
Ich habe mal "Most commonly used codes" als Kommentar hinzugefügt im Code. |
Closing for now. |
Resolves #493
into a full enum list including comments (used a small Python script to automate that). 😄