PHP Класс Mpociot\VatCalculator\VatCalculator

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$businessCountryCode string
$company boolean
$config Illuminate\Contracts\Config\Repository
$countryCode string
$netPrice float
$postalCode string
$postalCodeExceptions array All possible postal code exceptions.
$soapClient
$taxRate float
$taxRules array Taken from: http://ec.europa.eu/taxation_customs/resources/documents/taxation/vat/how_vat_works/rates/vat_rates_en.pdf
$taxValue float
$value float The calculate net + tax value.

Открытые методы

Метод Описание
__construct ( $config = null )
calculate ( integer | float $netPrice, null | string $countryCode = null, null | string $postalCode = null, null | boolean $company = null ) : float Calculate the VAT based on the net price, country code and indication if the customer is a company or not.
getCountryCode ( ) : string
getIPBasedCountry ( ) : boolean | string Returns the ISO 3166-1 alpha-2 two letter country code for the client IP. If the IP can't be resolved it returns false.
getNetPrice ( ) : float
getPostalCode ( ) : string
getTaxRate ( ) : float
getTaxRateForCountry ( $countryCode, boolean $company = false ) : float Returns the tax rate for the given country code.
getTaxRateForLocation ( string $countryCode, string | null $postalCode = null, boolean | false $company = false ) : float Returns the tax rate for the given country code.
getTaxValue ( ) : float
isCompany ( ) : boolean
isValidVATNumber ( $vatNumber ) : boolean
setBusinessCountryCode ( string $businessCountryCode )
setCompany ( boolean $company )
setCountryCode ( mixed $countryCode )
setPostalCode ( mixed $postalCode )
setSoapClient ( SoapClient $soapClient )
shouldCollectVAT ( $countryCode ) : boolean Determines if you need to collect VAT for the given country code.

Приватные методы

Метод Описание
getClientIP ( ) : mixed Finds the client IP address.

Описание методов

__construct() публичный метод

public __construct ( $config = null )

calculate() публичный метод

Calculate the VAT based on the net price, country code and indication if the customer is a company or not.
public calculate ( integer | float $netPrice, null | string $countryCode = null, null | string $postalCode = null, null | boolean $company = null ) : float
$netPrice integer | float The net price to use for the calculation
$countryCode null | string The country code to use for the rate lookup
$postalCode null | string The postal code to use for the rate exception lookup
$company null | boolean
Результат float

getCountryCode() публичный метод

public getCountryCode ( ) : string
Результат string

getIPBasedCountry() публичный метод

Returns the ISO 3166-1 alpha-2 two letter country code for the client IP. If the IP can't be resolved it returns false.
public getIPBasedCountry ( ) : boolean | string
Результат boolean | string

getNetPrice() публичный метод

public getNetPrice ( ) : float
Результат float

getPostalCode() публичный метод

public getPostalCode ( ) : string
Результат string

getTaxRate() публичный метод

public getTaxRate ( ) : float
Результат float

getTaxRateForCountry() публичный метод

This method is used to allow backwards compatibility.
public getTaxRateForCountry ( $countryCode, boolean $company = false ) : float
$countryCode
$company boolean
Результат float

getTaxRateForLocation() публичный метод

If a postal code is provided, it will try to lookup the different postal code exceptions that are possible.
public getTaxRateForLocation ( string $countryCode, string | null $postalCode = null, boolean | false $company = false ) : float
$countryCode string
$postalCode string | null
$company boolean | false
Результат float

getTaxValue() публичный метод

public getTaxValue ( ) : float
Результат float

isCompany() публичный метод

public isCompany ( ) : boolean
Результат boolean

isValidVATNumber() публичный метод

public isValidVATNumber ( $vatNumber ) : boolean
$vatNumber
Результат boolean

setBusinessCountryCode() публичный метод

public setBusinessCountryCode ( string $businessCountryCode )
$businessCountryCode string

setCompany() публичный метод

public setCompany ( boolean $company )
$company boolean

setCountryCode() публичный метод

public setCountryCode ( mixed $countryCode )
$countryCode mixed

setPostalCode() публичный метод

public setPostalCode ( mixed $postalCode )
$postalCode mixed

setSoapClient() публичный метод

public setSoapClient ( SoapClient $soapClient )
$soapClient SoapClient

shouldCollectVAT() публичный метод

Determines if you need to collect VAT for the given country code.
public shouldCollectVAT ( $countryCode ) : boolean
$countryCode
Результат boolean

Описание свойств

$businessCountryCode защищенное свойство

protected string $businessCountryCode
Результат string

$company защищенное свойство

protected bool $company
Результат boolean

$config защищенное свойство

protected Repository,Illuminate\Contracts\Config $config
Результат Illuminate\Contracts\Config\Repository

$countryCode защищенное свойство

protected string $countryCode
Результат string

$netPrice защищенное свойство

protected float $netPrice
Результат float

$postalCode защищенное свойство

protected string $postalCode
Результат string

$postalCodeExceptions защищенное свойство

All possible postal code exceptions.
protected array $postalCodeExceptions
Результат array

$soapClient защищенное свойство

protected $soapClient

$taxRate защищенное свойство

protected float $taxRate
Результат float

$taxRules защищенное свойство

Taken from: http://ec.europa.eu/taxation_customs/resources/documents/taxation/vat/how_vat_works/rates/vat_rates_en.pdf
protected array $taxRules
Результат array

$taxValue защищенное свойство

protected float $taxValue
Результат float

$value защищенное свойство

The calculate net + tax value.
protected float $value
Результат float