public function getTaxRateForLocation($countryCode, $postalCode = null, $company = false, $type = null)
    {
        if ($company && strtoupper($countryCode) !== strtoupper($this->businessCountryCode)) {
            return 0;
        }
        $taxKey = 'vat_calculator.rules.'.strtoupper($countryCode);
        if (isset($this->config) && $this->config->has($taxKey)) {
            return $this->config->get($taxKey, 0);
        }

        if (isset($this->postalCodeExceptions[$countryCode]) && $postalCode !== null) {
            foreach ($this->postalCodeExceptions[$countryCode] as $postalCodeException) {
                if (!preg_match($postalCodeException['postalCode'], $postalCode)) {
                    continue;
                }
                if (isset($postalCodeException['name'])) {
                    return $this->taxRules[$postalCodeException['code']]['exceptions'][$postalCodeException['name']];
                }

                return $this->taxRules[$postalCodeException['code']]['rate'];
            }
        }

        if ($type !== null) {
            return isset($this->taxRules[strtoupper($countryCode)]['rates'][$type]) ? $this->taxRules[strtoupper($countryCode)]['rates'][$type] : 0;
        }

        return isset($this->taxRules[strtoupper($countryCode)]['rate']) ? $this->taxRules[strtoupper($countryCode)]['rate'] : 0;
    }