mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
13 lines
387 B
Python
13 lines
387 B
Python
from decimal import ROUND_HALF_UP, Decimal
|
|
|
|
from django.conf import settings
|
|
|
|
|
|
def round_decimal(dec, currency=None, places_dict=settings.CURRENCY_PLACES):
|
|
if currency:
|
|
places = places_dict.get(currency, 2)
|
|
return Decimal(dec).quantize(
|
|
Decimal('1') / 10 ** places, ROUND_HALF_UP
|
|
)
|
|
return Decimal(dec).quantize(Decimal('0.01'), ROUND_HALF_UP)
|