Fix Decimal precision issue
This commit is contained in:
parent
9da25d4197
commit
afe5575b34
@ -67,8 +67,7 @@ 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.
|
Internally, all money values are euros as decimal. 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} €"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user