class SwissVat in Commerce Core 8.2
Provides the Swiss VAT tax type.
Plugin annotation
@CommerceTaxType(
id = "swiss_vat",
label = "Swiss VAT",
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\commerce_tax\Plugin\Commerce\TaxType\TaxTypeBase implements TaxTypeInterface, ContainerFactoryPluginInterface
- class \Drupal\commerce_tax\Plugin\Commerce\TaxType\LocalTaxTypeBase implements LocalTaxTypeInterface
- class \Drupal\commerce_tax\Plugin\Commerce\TaxType\SwissVat
- class \Drupal\commerce_tax\Plugin\Commerce\TaxType\LocalTaxTypeBase implements LocalTaxTypeInterface
- class \Drupal\commerce_tax\Plugin\Commerce\TaxType\TaxTypeBase implements TaxTypeInterface, ContainerFactoryPluginInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of SwissVat
File
- modules/
tax/ src/ Plugin/ Commerce/ TaxType/ SwissVat.php, line 16
Namespace
Drupal\commerce_tax\Plugin\Commerce\TaxTypeView source
class SwissVat 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['ch'] = new TaxZone([
'id' => 'ch',
'label' => $this
->t('Switzerland'),
'display_label' => $this
->t('VAT'),
'territories' => [
[
'country_code' => 'CH',
],
[
'country_code' => 'LI',
],
// Büsingen.
[
'country_code' => 'DE',
'included_postal_codes' => '78266',
],
// Lake Lugano.
[
'country_code' => 'IT',
'included_postal_codes' => '22060',
],
],
'rates' => [
[
'id' => 'standard',
'label' => $this
->t('Standard'),
'percentages' => [
[
'number' => '0.08',
'start_date' => '2011-01-01',
'end_date' => '2017-12-31',
],
[
'number' => '0.077',
'start_date' => '2018-01-01',
],
],
'default' => TRUE,
],
[
'id' => 'hotel',
'label' => $this
->t('Hotel'),
'percentages' => [
[
'number' => '0.038',
'start_date' => '2011-01-01',
'end_date' => '2017-12-31',
],
[
'number' => '0.037',
'start_date' => '2018-01-01',
],
],
],
[
'id' => 'reduced',
'label' => $this
->t('Reduced'),
'percentages' => [
[
'number' => '0.025',
'start_date' => '2011-01-01',
],
],
],
],
]);
return $zones;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
LocalTaxTypeBase:: |
protected | property | The chain tax rate resolver. | |
LocalTaxTypeBase:: |
protected | property | The matched zones. | |
LocalTaxTypeBase:: |
protected | property | The rounder. | |
LocalTaxTypeBase:: |
protected | property | The zones. | |
LocalTaxTypeBase:: |
public | function |
Checks whether the tax type applies to the given order. Overrides TaxTypeBase:: |
|
LocalTaxTypeBase:: |
public | function |
Applies the tax type to the given order. Overrides TaxTypeInterface:: |
|
LocalTaxTypeBase:: |
protected | function | Builds the summary of all available tax rates. | |
LocalTaxTypeBase:: |
protected | function | Checks whether the store is registered to collect taxes in the given zone. | |
LocalTaxTypeBase:: |
public static | function |
Creates an instance of the plugin. Overrides TaxTypeBase:: |
1 |
LocalTaxTypeBase:: |
public | function |
Gets the tax zones which match the given address. Overrides LocalTaxTypeInterface:: |
|
LocalTaxTypeBase:: |
public | function |
Gets the tax zones. Overrides LocalTaxTypeInterface:: |
|
LocalTaxTypeBase:: |
protected | function | Checks whether the tax type matches the store's billing address. | 1 |
LocalTaxTypeBase:: |
protected | function | Checks whether the tax type matches the store's tax registrations. | 1 |
LocalTaxTypeBase:: |
protected | function | Resolves the tax rates for the given order item and customer profile. | |
LocalTaxTypeBase:: |
protected | function | Resolves the tax zones for the given order item and customer profile. | 2 |
LocalTaxTypeBase:: |
public | function |
Gets whether tax should be rounded at the order item level. Overrides LocalTaxTypeInterface:: |
1 |
LocalTaxTypeBase:: |
public | function |
Constructs a new LocalTaxTypeBase object. Overrides TaxTypeBase:: |
1 |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
SwissVat:: |
public | function |
Form constructor. Overrides TaxTypeBase:: |
|
SwissVat:: |
public | function |
Builds the tax zones. Overrides LocalTaxTypeBase:: |
|
TaxTypeBase:: |
protected | property | The ID of the parent config entity. | |
TaxTypeBase:: |
protected | property | The entity type manager. | |
TaxTypeBase:: |
protected | property | The event dispatcher. | |
TaxTypeBase:: |
protected | property | The parent config entity. | |
TaxTypeBase:: |
protected | property | A cache of prepared customer profiles, keyed by order ID. | |
TaxTypeBase:: |
protected | function | Builds a customer profile for the given order. | |
TaxTypeBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
TaxTypeBase:: |
public | function |
Gets default configuration for this plugin. Overrides ConfigurableInterface:: |
1 |
TaxTypeBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
TaxTypeBase:: |
public | function |
Gets the tax type label. Overrides TaxTypeInterface:: |
|
TaxTypeBase:: |
protected | function | Gets the taxable type for the given order item. | |
TaxTypeBase:: |
public | function |
Gets the tax type weight. Overrides TaxTypeInterface:: |
|
TaxTypeBase:: |
public | function |
Gets whether the tax type is display inclusive. Overrides TaxTypeInterface:: |
|
TaxTypeBase:: |
protected | function | Resolves the customer profile for the given order item. | |
TaxTypeBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
1 |
TaxTypeBase:: |
public | function |
Form submission handler. Overrides PluginFormInterface:: |
1 |
TaxTypeBase:: |
public | function |
Form validation handler. Overrides PluginFormInterface:: |
1 |
TaxTypeBase:: |
public | function |
Overrides DependencySerializationTrait:: |
|
TaxTypeBase:: |
public | function |
Overrides DependencySerializationTrait:: |