src/Invoice/Completor.php
protected function initPossibleVatRates()
    {
        $possibleVatRates = array();

        $shopSettings = $this->config->getShopSettings();
        $nature = $shopSettings['nature_shop'];
        $vatFreeProducts = $shopSettings['vatFreeProducts'];

        foreach ($this->possibleVatTypes as $vatType) {
            switch ($vatType) {
                case Api::VatType_National:
                case Api::VatType_MarginScheme:
                    $vatTypeVatRates = $this->getVatRatesByCountryAndDate('nl');
                    // Add vat free (-1):
                    // - if selling vat free products/services
                    // - OR if outside EU AND (services OR company).
                    if ($vatFreeProducts != PluginConfig::VatFreeProducts_No) {
                        $vatTypeVatRates[] = -1;
                    } elseif ($this->isOutsideEu() && ($nature !== PluginConfig::Nature_Products || $this->isCompany())) {
                        $vatTypeVatRates[] = -1;
                    }
                    break;
                case Api::VatType_NationalReversed:
                case Api::VatType_EuReversed:
                case Api::VatType_RestOfWorld:
                    $vatTypeVatRates = array(0);
                    break;
                case Api::VatType_ForeignVat:
                    $vatTypeVatRates = $this->getVatRatesByCountryAndDate($this->invoice[Tag::Customer][Tag::CountryCode]);
                    break;
                default:
                    $vatTypeVatRates = array();
                    $this->log->error('Completor::initPossibleVatRates(): unknown vat type %d', $vatType);
                    break;
            }
            // convert the list of vat rates to a list of vat rate infos.
            foreach ($vatTypeVatRates as &$vatRate) {
                $vatRate = array(Tag::VatRate => $vatRate, Tag::VatType => $vatType);
            }
            $possibleVatRates = array_merge($possibleVatRates, $vatTypeVatRates);
        }
        $this->possibleVatRates = $possibleVatRates;
    }
protected function initPossibleVatRates()
    {
        $possibleVatRates = array();

        $shopSettings = $this->config->getShopSettings();
        $nature = $shopSettings['nature_shop'];
        $vatFreeProducts = $shopSettings['vatFreeProducts'];

        foreach ($this->possibleVatTypes as $vatType) {
            switch ($vatType) {
                case Api::VatType_National:
                case Api::VatType_MarginScheme:
                    $vatTypeVatRates = $this->getVatRatesByCountryAndDate('nl');
                    // Add vat free (-1):
                    // - if selling vat free products/services
                    // - OR if outside EU AND (services OR company).
                    if ($vatFreeProducts != PluginConfig::VatFreeProducts_No) {
                        $vatTypeVatRates[] = -1;
                    } elseif ($this->isOutsideEu() && ($nature !== PluginConfig::Nature_Products || $this->isCompany())) {
                        $vatTypeVatRates[] = -1;
                    }
                    break;
                case Api::VatType_NationalReversed:
                case Api::VatType_EuReversed:
                case Api::VatType_RestOfWorld:
                    $vatTypeVatRates = array(0);
                    break;
                case Api::VatType_ForeignVat:
                    $vatTypeVatRates = $this->getVatRatesByCountryAndDate($this->invoice[Tag::Customer][Tag::CountryCode]);
                    break;
                default:
                    $vatTypeVatRates = array();
                    $this->log->error('Completor::initPossibleVatRates(): unknown vat type %d', $vatType);
                    break;
            }
            // convert the list of vat rates to a list of vat rate infos.
            foreach ($vatTypeVatRates as &$vatRate) {
                $vatRate = array(Tag::VatRate => $vatRate, Tag::VatType => $vatType);
            }
            $possibleVatRates = array_merge($possibleVatRates, $vatTypeVatRates);
        }
        $this->possibleVatRates = $possibleVatRates;
    }
protected function initPossibleVatRates ( ) { $ possibleVatRates = array ( ) ; $ shopSettings = $ this -> config -> getShopSettings ( ) ; $ nature = $ shopSettings [ 'nature_shop' ] ; $ vatFreeProducts = $ shopSettings [ 'vatFreeProducts' ] ; foreach ( $ this -> possibleVatTypes as $ vatType ) { switch ( $ vatType ) { case Api :: VatType_National : case Api :: VatType_MarginScheme : $ vatTypeVatRates = $ this -> getVatRatesByCountryAndDate ( 'nl' ) ; // Add vat free (-1): // - if selling vat free products/services // - OR if outside EU AND (services OR company). if ( $ vatFreeProducts != PluginConfig :: VatFreeProducts_No ) { $ vatTypeVatRates [ ] = - 1 ; } elseif ( $ this -> isOutsideEu ( ) && ( $ nature !== PluginConfig :: Nature_Products || $ this -> isCompany ( ) ) ) { $ vatTypeVatRates [ ] = - 1 ; } break ; case Api :: VatType_NationalReversed : case Api :: VatType_EuReversed : case Api :: VatType_RestOfWorld : $ vatTypeVatRates = array ( 0 ) ; break ; case Api :: VatType_ForeignVat : $ vatTypeVatRates = $ this -> getVatRatesByCountryAndDate ( $ this -> invoice [ Tag :: Customer ] [ Tag :: CountryCode ] ) ; break ; default : $ vatTypeVatRates = array ( ) ; $ this -> log -> error ( 'Completor::initPossibleVatRates(): unknown vat type %d' , $ vatType ) ; break ; } // convert the list of vat rates to a list of vat rate infos. foreach ( $ vatTypeVatRates as & $ vatRate ) { $ vatRate = array ( Tag :: VatRate => $ vatRate , Tag :: VatType => $ vatType ) ; } $ possibleVatRates = array_merge ( $ possibleVatRates , $ vatTypeVatRates ) ; } $ this -> possibleVatRates = $ possibleVatRates ; }
Initializes the list of possible vat rates.

The possible vat rates depend on:
- the possible vat types.
- optionally, the date of the invoice.
- optionally, the country of the client.
- optionally, the nature of the articles sold.

On finishing, $this->possibleVatRates will contain an array with possible
vat rates. A vat rate being an array with keys vatrate and vattype. This
is done so to be able to determine to which vat type(s) a vat rate
belongs.
Initializes the list of possible vat rates .