feat: deutsche Betragsanzeige (eur-Filter) und deutsche GUI-Labels
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
30
finance/app/formats.py
Normal file
30
finance/app/formats.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""Deutsche Anzeige-Formate fuer die GUI (Ausbaustufe 5).
|
||||
|
||||
Bewusst ohne locale-Modul: Container-Locales sind nicht garantiert
|
||||
installiert, und die Ausgabe hinge sonst vom Host ab. Reine
|
||||
Decimal-Formatierung; die JSON-API bleibt Punkt-Dezimal.
|
||||
"""
|
||||
from decimal import Decimal, ROUND_HALF_UP
|
||||
|
||||
DE_LABELS = {
|
||||
"monthly": "monatlich",
|
||||
"quarterly": "vierteljährlich",
|
||||
"yearly": "jährlich",
|
||||
"annuity": "Annuität",
|
||||
"bullet": "endfällig",
|
||||
"percent": "Prozent",
|
||||
"absolute": "Absolut",
|
||||
"remove": "Entfällt",
|
||||
"ende": "Ende",
|
||||
}
|
||||
|
||||
|
||||
def eur(value) -> str:
|
||||
"""Decimal("-2474.5") -> "-2.474,50" (ohne Euro-Zeichen, das setzt das Template)."""
|
||||
d = Decimal(str(value)).quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)
|
||||
s = f"{d:,.2f}" # US-Trenner: "-2,474.50"
|
||||
return s.replace(",", "\x00").replace(".", ",").replace("\x00", ".")
|
||||
|
||||
|
||||
def de_label(value: str) -> str:
|
||||
return DE_LABELS.get(value, value)
|
||||
Reference in New Issue
Block a user