forked from CGM_Public/pretix_original
* Refs #99 -- Fix stripe support for zero-decimal currencies * Add new money formatting method * Force decimal places in many places * Locale-aware currency rendering * Fix currencies in more places * More currency fixes
13 lines
362 B
Python
13 lines
362 B
Python
from decimal import ROUND_HALF_UP, Decimal
|
|
|
|
from django.conf import settings
|
|
|
|
|
|
def round_decimal(dec, currency=None):
|
|
if currency:
|
|
places = settings.CURRENCY_PLACES.get(currency, 2)
|
|
return Decimal(dec).quantize(
|
|
Decimal('1') / 10 ** places, ROUND_HALF_UP
|
|
)
|
|
return Decimal(dec).quantize(Decimal('0.01'), ROUND_HALF_UP)
|