mirumee / prices

Python price handling for humans.
Other
268 stars 39 forks source link

We shouldn't quantize prices to cents by default in discounts #20

Closed mociepka closed 6 years ago

mociepka commented 7 years ago

https://github.com/mirumee/prices/blob/master/prices/__init__.py#L350

I propose to add quantize=True to apply arguments in discounts and if it is True does quantization but not with hard coded value.

In some countries tere are zero decimal places in others can be three of them. I have function for qunatize already:

from babel.core import get_global

def get_quantize_value_for_currency(currency):
    fractions = get_global('currency_fractions')
    try:
        digits_number = fractions[currency][0]
    except KeyError:
        digits_number = fractions['DEFAULT'][0]
    return Decimal(10) ** -digits_number