You are here

class NorwegianVat in Commerce Core 8.2

Provides the Norwegian VAT tax type.

Plugin annotation


@CommerceTaxType(
  id = "norwegian_vat",
  label = "Norwegian VAT",
)

Hierarchy

Expanded class hierarchy of NorwegianVat

File

modules/tax/src/Plugin/Commerce/TaxType/NorwegianVat.php, line 16

Namespace

Drupal\commerce_tax\Plugin\Commerce\TaxType
View source
class NorwegianVat extends LocalTaxTypeBase {

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $form = parent::buildConfigurationForm($form, $form_state);
    $form['rates'] = $this
      ->buildRateSummary();

    // Replace the phrase "tax rates" with "VAT rates" to be more precise.
    $form['rates']['#markup'] = $this
      ->t('The following VAT rates are provided:');
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function buildZones() {
    $zones = [];
    $zones['no'] = new TaxZone([
      'id' => 'no',
      'label' => $this
        ->t('Norway'),
      'display_label' => $this
        ->t('VAT'),
      'territories' => [
        [
          'country_code' => 'NO',
        ],
      ],
      'rates' => [
        [
          'id' => 'standard',
          'label' => $this
            ->t('Standard'),
          'percentages' => [
            [
              'number' => '0.25',
              'start_date' => '2012-01-01',
            ],
          ],
          'default' => TRUE,
        ],
        [
          'id' => 'intermediate',
          'label' => $this
            ->t('Intermediate'),
          'percentages' => [
            [
              'number' => '0.15',
              'start_date' => '2012-01-01',
            ],
          ],
        ],
        [
          'id' => 'reduced',
          'label' => $this
            ->t('Reduced'),
          'percentages' => [
            [
              'number' => '0.08',
              'start_date' => '2012-01-01',
            ],
          ],
        ],
        [
          'id' => 'zero',
          'label' => $this
            ->t('Zero'),
          'percentages' => [
            [
              'number' => '0',
              'start_date' => '2012-01-01',
            ],
          ],
        ],
      ],
    ]);
    return $zones;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
LocalTaxTypeBase::$chainRateResolver protected property The chain tax rate resolver.
LocalTaxTypeBase::$matchedZones protected property The matched zones.
LocalTaxTypeBase::$rounder protected property The rounder.
LocalTaxTypeBase::$zones protected property The zones.
LocalTaxTypeBase::applies public function Checks whether the tax type applies to the given order. Overrides TaxTypeBase::applies
LocalTaxTypeBase::apply public function Applies the tax type to the given order. Overrides TaxTypeInterface::apply
LocalTaxTypeBase::buildRateSummary protected function Builds the summary of all available tax rates.
LocalTaxTypeBase::checkRegistrations protected function Checks whether the store is registered to collect taxes in the given zone.
LocalTaxTypeBase::create public static function Creates an instance of the plugin. Overrides TaxTypeBase::create 1
LocalTaxTypeBase::getMatchingZones public function Gets the tax zones which match the given address. Overrides LocalTaxTypeInterface::getMatchingZones
LocalTaxTypeBase::getZones public function Gets the tax zones. Overrides LocalTaxTypeInterface::getZones
LocalTaxTypeBase::matchesAddress protected function Checks whether the tax type matches the store's billing address. 1
LocalTaxTypeBase::matchesRegistrations protected function Checks whether the tax type matches the store's tax registrations. 1
LocalTaxTypeBase::resolveRates protected function Resolves the tax rates for the given order item and customer profile.
LocalTaxTypeBase::resolveZones protected function Resolves the tax zones for the given order item and customer profile. 2
LocalTaxTypeBase::shouldRound public function Gets whether tax should be rounded at the order item level. Overrides LocalTaxTypeInterface::shouldRound 1
LocalTaxTypeBase::__construct public function Constructs a new LocalTaxTypeBase object. Overrides TaxTypeBase::__construct 1
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
NorwegianVat::buildConfigurationForm public function Form constructor. Overrides TaxTypeBase::buildConfigurationForm
NorwegianVat::buildZones public function Builds the tax zones. Overrides LocalTaxTypeBase::buildZones
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
TaxTypeBase::$entityId Deprecated protected property The ID of the parent config entity.
TaxTypeBase::$entityTypeManager protected property The entity type manager.
TaxTypeBase::$eventDispatcher protected property The event dispatcher.
TaxTypeBase::$parentEntity protected property The parent config entity.
TaxTypeBase::$profiles protected property A cache of prepared customer profiles, keyed by order ID.
TaxTypeBase::buildCustomerProfile protected function Builds a customer profile for the given order.
TaxTypeBase::calculateDependencies public function Calculates dependencies for the configured plugin. Overrides DependentPluginInterface::calculateDependencies
TaxTypeBase::defaultConfiguration public function Gets default configuration for this plugin. Overrides ConfigurableInterface::defaultConfiguration 1
TaxTypeBase::getConfiguration public function Gets this plugin's configuration. Overrides ConfigurableInterface::getConfiguration
TaxTypeBase::getLabel public function Gets the tax type label. Overrides TaxTypeInterface::getLabel
TaxTypeBase::getTaxableType protected function Gets the taxable type for the given order item.
TaxTypeBase::getWeight public function Gets the tax type weight. Overrides TaxTypeInterface::getWeight
TaxTypeBase::isDisplayInclusive public function Gets whether the tax type is display inclusive. Overrides TaxTypeInterface::isDisplayInclusive
TaxTypeBase::resolveCustomerProfile protected function Resolves the customer profile for the given order item.
TaxTypeBase::setConfiguration public function Sets the configuration for this plugin instance. Overrides ConfigurableInterface::setConfiguration 1
TaxTypeBase::submitConfigurationForm public function Form submission handler. Overrides PluginFormInterface::submitConfigurationForm 1
TaxTypeBase::validateConfigurationForm public function Form validation handler. Overrides PluginFormInterface::validateConfigurationForm 1
TaxTypeBase::__sleep public function Overrides DependencySerializationTrait::__sleep
TaxTypeBase::__wakeup public function Overrides DependencySerializationTrait::__wakeup