'Quantize the decimal value to the configured precision.'

def quantize(self, value):

    if (self.decimal_places is None):
        return value
    context = decimal.getcontext().copy()
    if (self.max_digits is not None):
        context.prec = self.max_digits
    return value.quantize((decimal.Decimal(u'.1') ** self.decimal_places), context=context)
