Fix Decimal precision issue

This commit is contained in:
tcprod 2025-02-06 15:40:09 +01:00
parent 3655e8eb53
commit cf9b39ba0a
2 changed files with 6 additions and 6 deletions

View File

@ -11,10 +11,8 @@ from src.ez_lan_manager.types.News import News
DEMO_USERS = [ DEMO_USERS = [
{"user_name": "manfred", "user_mail": "manfred@demomail.com", "password_clear_text": "manfred"}, # Gast {"user_name": "manfred", "user_mail": "manfred@demomail.com", "password_clear_text": "manfred"}, # Gast
{"user_name": "gustav", "user_mail": "gustav@demomail.com", "password_clear_text": "gustav"}, {"user_name": "gustav", "user_mail": "gustav@demomail.com", "password_clear_text": "gustav"}, # Gast + Ticket(NORMAL)
# Gast + Ticket(NORMAL) {"user_name": "jason", "user_mail": "juergen@demomail.com", "password_clear_text": "jason"}, # Gast + Ticket(NORMAL) + Sitzplatz
{"user_name": "jason", "user_mail": "juergen@demomail.com", "password_clear_text": "jason"},
# Gast + Ticket(NORMAL) + Sitzplatz
{"user_name": "lisa", "user_mail": "lisa@demomail.com", "password_clear_text": "lisa"}, # Teamler {"user_name": "lisa", "user_mail": "lisa@demomail.com", "password_clear_text": "lisa"}, # Teamler
{"user_name": "thomas", "user_mail": "thomas@demomail.com", "password_clear_text": "thomas"} # Teamler + Admin {"user_name": "thomas", "user_mail": "thomas@demomail.com", "password_clear_text": "thomas"} # Teamler + Admin
] ]

View File

@ -66,7 +66,9 @@ class AccountingService:
@staticmethod @staticmethod
def make_euro_string_from_decimal(euros: Decimal) -> str: def make_euro_string_from_decimal(euros: Decimal) -> str:
""" Internally, all money values are cents as ints. Only when showing them to the user we generate a string. """
Prevents float inaccuracy.""" Internally, all money values are cents as ints. Only when showing them to the user we generate a string.
Prevents float inaccuracy.
"""
rounded_decimal = str(euros.quantize(Decimal(".01"), rounding=ROUND_DOWN)) rounded_decimal = str(euros.quantize(Decimal(".01"), rounding=ROUND_DOWN))
return f"{rounded_decimal}" return f"{rounded_decimal}"