Returns the total amount of discounts for this line with a specific
        number of decimals.
        @param precision:int number of decimal places
        @return: Decimal
177680
def compute_discounts(self, precision=None):
        '''
        
        '''
        gross = self.compute_gross(precision)
        return min(gross,
                   sum([d.compute(gross, precision) for d in self.__discounts]))
53604
public function total($decimals = null, $decimalPoint = null, $thousandSeperator = null)
    {
        $content = $this->getContent();

        $total = $content->reduce(function ($total, CartItem $cartItem) {
            return $total + ($cartItem->qty * $cartItem->priceTax);
        }, 0);

        return $this->numberFormat($total, $decimals, $decimalPoint, $thousandSeperator);
    }
451139
public function getDiscount() : ?float 
    {
        if ( ! $this->hasDiscount()) {
            $this->setDiscount($this->getDefaultDiscount());
        }
        return $this->discount;
    }
87219
public function discountAmount()
    {
        $totalDiscount = 0;

        foreach ($this->transaction->discounts as $discount) {
            $totalDiscount += $discount->amount;
        }

        return (float) $totalDiscount;
    }
900440
def line_amount
      total = quantity * unit_amount
      total = total * (1 - (discount_rate / BigDecimal(100))) if discount_rate
      total
    end
41270
def _precision(self, value):
        
        value = str(value)
        decimal = value.rfind('.')
        if decimal == -1:
            return 0
        return len(value) - decimal - 1
454229
def float_to_decimal(f):
    
    n, d = f.as_integer_ratio()
    numerator, denominator = Decimal(n), Decimal(d)
    ctx = Context(prec=60)
    result = ctx.divide(numerator, denominator)
    while ctx.flags[Inexact]:
        ctx.flags[Inexact] = False
        ctx.prec *= 2
        result = ctx.divide(numerator, denominator)
    return result
1036478
def visitMultiplicationOrDivisionExpression(self, ctx):
        
        is_mul = ctx.TIMES() is not None

        arg1 = conversions.to_decimal(self.visit(ctx.expression(0)), self._eval_context)
        arg2 = conversions.to_decimal(self.visit(ctx.expression(1)), self._eval_context)

        if not is_mul and arg2 == Decimal(0):
            raise EvaluationError("Division by zero")

        return arg1 * arg2 if is_mul else arg1 / arg2
254784
def round(self, ndigits=0):
        
        if ndigits is None:
            ndigits = 0
        return self.__class__(
            amount=self.amount.quantize(Decimal('1e' + str(-ndigits))),
            currency=self.currency)
502027
def get_value(self) -> Decimal:
        
        quantity = self.get_quantity()
        price = self.get_last_available_price()
        if not price:
            # raise ValueError("no price found for", self.full_symbol)
            return Decimal(0)

        value = quantity * price.value
        return value
1317976
def trim_decimals(s, precision=-3):
        
        encoded = s.encode('ascii', 'ignore')
        str_val = ""
        if six.PY3:
            str_val = str(encoded, encoding='ascii', errors='ignore')[:precision]
        else:
            # If precision is 0, this must be handled seperately
            if precision == 0:
                str_val = str(encoded)
            else:
                str_val = str(encoded)[:precision]
        if len(str_val) > 0:
            return float(str_val)
        else:
            return 0
577398
public Integer getPrecision()
   {
      if(childNode.getAttribute("precision") != null && !childNode.getAttribute("precision").equals("null"))
      {
         return Integer.valueOf(childNode.getAttribute("precision"));
      }
      return null;
   }
226738
def getVATAmount(self):
        
        try:
            vatamount = self.getTotalPrice() - Decimal(self.getPrice())
        except:
            vatamount = Decimal('0.00')
        return vatamount.quantize(Decimal('0.00'))
1136516
public function toDecimal($value, int $precision = 12): float
    {
        if (is_numeric($value) === false) {
            return 0.0;
        }

        return round((float) $value, $precision);
    }
1246908
public static float trunc(Float number, int precision) {
        if (number < 0f) {
            return (float)(Math.ceil(number.doubleValue()*Math.pow(10,precision))/Math.pow(10,precision));
        }
        return (float)(Math.floor(number.doubleValue()*Math.pow(10,precision))/Math.pow(10,precision));
    }
462508
def roundup(ctx, number, num_digits):
    
    number = conversions.to_decimal(number, ctx)
    num_digits = conversions.to_integer(num_digits, ctx)

    return decimal_round(number, num_digits, ROUND_UP)
1205467
def _round_frac(x, precision):
    
    if not np.isfinite(x) or x == 0:
        return x
    else:
        frac, whole = np.modf(x)
        if whole == 0:
            digits = -int(np.floor(np.log10(abs(frac)))) - 1 + precision
        else:
            digits = precision
        return np.around(x, digits)