Compute VAT Amount from the Price and system configured VAT
8374
def getVATAmount(self):
        
        price, vat = self.getPrice(), self.getVAT()
        return float(price) * (float(vat) / 100)
1290265
def getTotalPrice(self):
        
        price = self.getPrice()
        vat = self.getVAT()
        price = price and price or 0
        vat = vat and vat or 0
        return float(price) + (float(price) * float(vat)) / 100
1237149
public function calculateGrossPrice(Request $request)
    {
        if (!$request->has('netPrice')) {
            return Response::json([
                'error' => "The 'netPrice' parameter is missing",
            ], 422);
        }

        $valid_vat_id = null;
        $valid_company = false;
        if ($request->has('vat_number')) {
            $valid_company = $this->validateVATID($request->get('vat_number'));
            $valid_company = $valid_company['is_valid'];
            $valid_vat_id = $valid_company;
        }

        return [
            'gross_price'   => $this->calculator->calculate($request->get('netPrice'), $request->get('country'), $request->get('postal_code'), $valid_company),
            'net_price'     => $this->calculator->getNetPrice(),
            'tax_rate'      => $this->calculator->getTaxRate(),
            'tax_value'     => $this->calculator->getTaxValue(),
            'valid_vat_id'  => $valid_vat_id,
        ];
    }
766436
public function calculatePriceTax()
    {
        $expression = $this->tax->calculator;

        $parser = new StdMathParser();
        $AST = $parser->parse($this->tax->calculator);
        $evaluator = new Evaluator();
        $evaluator->setVariables(['x' => $this->calculatePriceTaxable()->getAmount() / 100]);
        $value = $AST->accept($evaluator);
        $money = new Money(round($value, 2, PHP_ROUND_HALF_UP) * 100, new Currency($this->invoice->currency));

        return $money;
    }
1022843
def compute(self):
        
        if self.mode == 'spark':
            self.values.tordd().count()
        else:
            notsupported(self.mode)
831892
def _calc_adu(self):
        """"""
        res = super()._calc_adu()
        self.ensure_one()
        dafs_to_apply = self.env['ddmrp.adjustment'].search(
            self._daf_to_apply_domain())
        if dafs_to_apply:
            daf = 1
            values = dafs_to_apply.mapped('value')
            for val in values:
                daf *= val
            prev = self.adu
            self.adu *= daf
            _logger.debug(
                "DAF=%s applied to %s. ADU: %s -> %s" %
                (daf, self.name, prev, self.adu))
        # Compute generated demand to be applied to components:
        dafs_to_explode = self.env['ddmrp.adjustment'].search(
            self._daf_to_apply_domain(False))
        for daf in dafs_to_explode:
            prev = self.adu
            increased_demand = prev * daf.value - prev
            self.explode_demand_to_components(
                daf, increased_demand, self.product_uom)
        return res
178471
def _get_tax(self, order_book_id, _, cost_money):
        
        instrument = Environment.get_instance().get_instrument(order_book_id)
        if instrument.type != 'CS':
            return 0
        tax = cost_money * self.tax_rate
        if tax < 1:
            tax = 1
        else:
            tax = round(tax, 2)
        return tax + 5
223993
def getTotalPrice(self):
        
        price, vat = self.getAnalysisProfilePrice(), self.getVATAmount()
        return float(price) + float(vat)
554900
def get_total_paid(self) -> Decimal:
        
        query = (
            self.get_splits_query()
        )
        splits = query.all()

        total = Decimal(0)
        for split in splits:
            total += split.value

        return total
714274
function isVATKnown()
    {
        $result = true;
        foreach ( $this->items() as $item )
        {
            if ( $item['vat_value'] == -1 )
                return false;
        }

        return true;
    }
686993
def _calc_cost(self, *args, **kwargs):
        

        return np.sum([op.cost(*args, **kwargs) for op in self._operators])
1132840
def compute_total(self, precision=None):
        '''
        
        '''
        return quantize((self.compute_gross(precision) +
                        self.compute_taxes(precision) -
                        self.compute_discounts(precision)),
                        places=precision)
1289521
def get_cumulative_spend(key):
    
    query = ('ROUND(SUM(total_ex_vat), 2) AS total '
             'FROM {table} '
             'WHERE date <= "{year}-{month:02}-01" '
             'AND lot="{lot}" '
             'AND customer_sector="{sector}" '
             'AND supplier_type="{sme_large}"'.format(
                 table=_RAW_SALES_TABLE,
                 year=key.year,
                 month=key.month,
                 lot=key.lot,
                 sector=key.sector,
                 sme_large=key.sme_large))
    logging.debug(query)
    result = scraperwiki.sqlite.select(query)
    logging.debug(result)
    value = result[0]['total']
    return float(result[0]['total']) if value is not None else 0.0
226738
def getVATAmount(self):
        
        try:
            vatamount = self.getTotalPrice() - Decimal(self.getPrice())
        except:
            vatamount = Decimal('0.00')
        return vatamount.quantize(Decimal('0.00'))
1340020
def compute_taxes(self, precision=None):
        '''
        
        '''
        base = self.gross - self.total_discounts
        return quantize(sum([t.compute(base, precision) for t in self.__taxes]),
                        precision)
1100552
def compute_total(self, precision=None):
        '''
        
        '''
        return quantize(sum([group.compute_total(precision) for group
                             in self.__groups]), places=precision) or ZERO
848529
function itemsInfo()
    {
        $basketInfo = array();
        // Build a price summary for the items based on VAT.
        foreach ( $this->items() as $item )
        {
            $vatValue = $item['vat_value'];
            $itemCount = abs( $item['item_count'] );
            $priceExVAT = $item['price_ex_vat'];
            $priceIncVAT = $item['price_inc_vat'];
            $totalPriceExVAT = $item['total_price_ex_vat'];
            $totalPriceIncVAT = $item['total_price_inc_vat'];

            if ( !isset( $basketInfo['price_info'][$vatValue]['price_ex_vat'] ) )
            {
                $basketInfo['price_info'][$vatValue]['price_ex_vat'] = ( $priceExVAT * $itemCount );
                $basketInfo['price_info'][$vatValue]['price_inc_vat'] = ( $priceIncVAT * $itemCount );
                $basketInfo['price_info'][$vatValue]['price_vat'] = ( $priceIncVAT - $priceExVAT ) * $itemCount;

                $basketInfo['price_info'][$vatValue]['total_price_ex_vat'] = $totalPriceExVAT;
                $basketInfo['price_info'][$vatValue]['total_price_inc_vat'] = $totalPriceIncVAT;
                $basketInfo['price_info'][$vatValue]['total_price_vat'] = $totalPriceIncVAT - $totalPriceExVAT;
            }
            else
            {
                $basketInfo['price_info'][$vatValue]['price_ex_vat'] += ( $priceExVAT * $itemCount );
                $basketInfo['price_info'][$vatValue]['price_inc_vat'] += ( $priceIncVAT * $itemCount );
                $basketInfo['price_info'][$vatValue]['price_vat'] += ( $priceIncVAT - $priceExVAT ) * $itemCount;

                $basketInfo['price_info'][$vatValue]['total_price_ex_vat'] += $totalPriceExVAT;
                $basketInfo['price_info'][$vatValue]['total_price_inc_vat'] += $totalPriceIncVAT;
                $basketInfo['price_info'][$vatValue]['total_price_vat'] += ( $totalPriceIncVAT - $totalPriceExVAT );
            }

            if ( !isset( $basketInfo['total_price_info']['total_price_ex_vat'] ) )
            {
                $basketInfo['total_price_info']['price_ex_vat'] = ( $priceExVAT * $itemCount );
                $basketInfo['total_price_info']['price_inc_vat'] = ( $priceIncVAT * $itemCount );
                $basketInfo['total_price_info']['price_vat'] = ( ( $priceIncVAT - $priceExVAT ) * $itemCount );

                $basketInfo['total_price_info']['total_price_ex_vat'] = $totalPriceExVAT;
                $basketInfo['total_price_info']['total_price_inc_vat'] = $totalPriceIncVAT;
                $basketInfo['total_price_info']['total_price_vat'] = ( $totalPriceIncVAT - $totalPriceExVAT );
            }
            else
            {
                $basketInfo['total_price_info']['price_ex_vat'] += ( $priceExVAT * $itemCount );
                $basketInfo['total_price_info']['price_inc_vat'] += ( $priceIncVAT * $itemCount );
                $basketInfo['total_price_info']['price_vat'] += ( ( $priceIncVAT - $priceExVAT ) * $itemCount );

                $basketInfo['total_price_info']['total_price_ex_vat'] += $totalPriceExVAT;
                $basketInfo['total_price_info']['total_price_inc_vat'] += $totalPriceIncVAT;
                $basketInfo['total_price_info']['total_price_vat'] += ( $totalPriceIncVAT - $totalPriceExVAT );
            }
        }

        // Add shipping cost to the total items price and add / update additional price information.
        $productCollectionID = $this->attribute( 'productcollection_id' );

        // Add additional calculated information to the basketInfo array, that can be used in the template.
        $shippingUpdateStatus = eZShippingManager::updatePriceInfo( $productCollectionID, $basketInfo );

        ksort( $basketInfo['price_info'] );
        return $basketInfo;
    }