public function calculate($netPrice, $countryCode = null, $postalCode = null, $company = null, $type = null)
    {
        if ($countryCode) {
            $this->setCountryCode($countryCode);
        }
        if ($postalCode) {
            $this->setPostalCode($postalCode);
        }
        if (!is_null($company) && $company !== $this->isCompany()) {
            $this->setCompany($company);
        }
        $this->netPrice = floatval($netPrice);
        $this->taxRate = $this->getTaxRateForLocation($this->getCountryCode(), $this->getPostalCode(), $this->isCompany(), $type);
        $this->taxValue = $this->taxRate * $this->netPrice;
        $this->value = $this->netPrice + $this->taxValue;

        return $this->value;
    }
public function calculate($netPrice, $countryCode = null, $postalCode = null, $company = null, $type = null)
    {
        if ($countryCode) {
            $this->setCountryCode($countryCode);
        }
        if ($postalCode) {
            $this->setPostalCode($postalCode);
        }
        if (!is_null($company) && $company !== $this->isCompany()) {
            $this->setCompany($company);
        }
        $this->netPrice = floatval($netPrice);
        $this->taxRate = $this->getTaxRateForLocation($this->getCountryCode(), $this->getPostalCode(), $this->isCompany(), $type);
        $this->taxValue = $this->taxRate * $this->netPrice;
        $this->value = $this->netPrice + $this->taxValue;

        return $this->value;
    }
public function calculate ( $ netPrice , $ countryCode = null , $ postalCode = null , $ company = null , $ type = null ) { if ( $ countryCode ) { $ this -> setCountryCode ( $ countryCode ) ; } if ( $ postalCode ) { $ this -> setPostalCode ( $ postalCode ) ; } if ( ! is_null ( $ company ) && $ company !== $ this -> isCompany ( ) ) { $ this -> setCompany ( $ company ) ; } $ this -> netPrice = floatval ( $ netPrice ) ; $ this -> taxRate = $ this -> getTaxRateForLocation ( $ this -> getCountryCode ( ) , $ this -> getPostalCode ( ) , $ this -> isCompany ( ) , $ type ) ; $ this -> taxValue = $ this -> taxRate * $ this -> netPrice ; $ this -> value = $ this -> netPrice + $ this -> taxValue ; return $ this -> value ; }
Calculate the VAT based on the net price, country code and indication if the
customer is a company or not.

@param int|float   $netPrice    The net price to use for the calculation
@param null|string $countryCode The country code to use for the rate lookup
@param null|string $postalCode  The postal code to use for the rate exception lookup
@param null|bool   $company
@param null|string $type        The type can be low or high

@return float
Calculate the VAT based on the net price country code and indication if the customer is a company or not .