Created on 12 January 2023, almost 2 years ago
Updated 17 January 2023, almost 2 years ago

Problem/Motivation

Since January first, in Spain there are two new taxes for products.

Proposed resolution

I have changed those files to check if It could work good:
commerce/modules/tax/src/Plugin/Commerce/TaxNumberType/EuropeanUnionVat.php
commerce/modules/tax/src/Plugin/Commerce/TaxType/EuropeanUnionVat.php
In order to add the two new taxes (funtion buidZones() in both):

/**
   * {@inheritdoc}
   */
  public function buildZones() {
    // Avoid instantiating the same labels dozens of times.
    $labels = [
      'standard' => $this->t('Standard'),
      'intermediate' => $this->t('Intermediate'),
      'reduced' => $this->t('Reduced'), 
      'second_reduced' => $this->t('Second Reduced'),
      'super_reduced' => $this->t('Super Reduced'),
      'special' => $this->t('Special'),
      'zero' => $this->t('Zero'),
      'vat' => $this->t('VAT'),
      'aceites_pasta' => $this->t('Aceites y pastas'),
      'exento_alm' => $this->t('Exento alimentaciรณn'),
    ];
   ......

$zones['es'] = new TaxZone([
      'id' => 'es',
      'label' => $this->t('Spain'),
      'display_label' => $labels['vat'],
      'territories' => [
        // Spain without Canary Islands, Ceuta and Melilla.
        ['country_code' => 'ES', 'excluded_postal_codes' => '/(35|38|51|52)[0-9]{3}/'],
      ],
      'rates' => [
        [
          'id' => 'standard',
          'label' => $labels['standard'],
          'percentages' => [
            ['number' => '0.21', 'start_date' => '2012-09-01'],
          ],
          'default' => TRUE,
        ],
        [
          'id' => 'reduced',
          'label' => $labels['reduced'],
          'percentages' => [
            ['number' => '0.1', 'start_date' => '2012-09-01'],
          ],
        ],
        [
          'id' => 'super_reduced',
          'label' => $labels['super_reduced'],
          'percentages' => [
            ['number' => '0.04', 'start_date' => '1995-01-01'],
          ],
        ],
        [
          'id' => 'aceites_pasta',
          'label' => $labels['aceites_pasta'],
          'percentages' => [ 
            ['number' => '0.1', 'start_date' => '2023-01-01'],
          ],
        ],
        [
          'id' => 'exento_alm',
          'label' => $labels['exento_alm'],
          'percentages' => [ 
            ['number' => '0.00', 'start_date' => '2023-01-01'], 
          ],
        ],
      ],
    ]);
.....

It works good, and new taxes can be assigned to products, and It calculates the taxes right.

Problem

After those changes are done, I don't know why but it hits on tax number field in customer profile. While with browser you can change this field, If you try to update this field using json-api It throws an error:

"title": "Unprocessable Entity",
"status": "422",
"detail": "tax_number.0.type: Specific type not valid.",

If I revert the changes, json-api updates works good again.
Perhaps there are more files that should be changed in order to include those new taxes. I don't know.

โœจ Feature request
Status

Active

Version

2.0

Component

Tax

Created by

๐Ÿ‡ช๐Ÿ‡ธSpain briantes

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to Closed: won't fix about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ฑIsrael jsacksick

    According to https://www.avalara.com/vatlive/en/country-guides/europe/spain/spanish-v..., I think we're already covered. Commerce defines the rates described there: 21%, 10% and 4%.

    So marking this as "won't fix".

  • ๐Ÿ‡ช๐Ÿ‡ธSpain briantes

    Sorry for the long response delay. @jacsick The page you are referring to is outdated. You should read the current taxes in the official government website: https://sede.agenciatributaria.gob.es/Sede/en_gb/iva/calculo-iva-repercu...
    Since the beginning of October (2024), there is a new tax for bread and other kind of food (2%).

    I have changed two files for the new conditions and mantain the others:

    $zones['es'] = new TaxZone([
          'id' => 'es',
          'label' => $this->t('Spain'),
          'display_label' => $labels['vat'],
          'territories' => [
            // Spain without Canary Islands, Ceuta and Melilla.
            ['country_code' => 'ES', 'excluded_postal_codes' => '/(35|38|51|52)[0-9]{3}/'],
          ],
          'rates' => [
            [
              'id' => 'standard',
              'label' => $labels['standard'],
              'percentages' => [
                ['number' => '0.21', 'start_date' => '2012-09-01'],
              ],
              'default' => TRUE,
            ],
            [
              'id' => 'reduced',
              'label' => $labels['reduced'],
              'percentages' => [
                ['number' => '0.1', 'start_date' => '2012-09-01'],
              ],
            ],
            [
              'id' => 'super_reduced',
              'label' => $labels['super_reduced'],
              'percentages' => [
                ['number' => '0.04', 'start_date' => '1995-01-01'],
              ],
            ],
            [
              'id' => 'second_reduced',
              'label' => $labels['second_reduced'],
              'percentages' => [
                ['number' => '0.02', 'start_date' => '2024-10-01'],
              ],
            ],
            [
              'id' => 'aceites_pasta',
              'label' => $labels['aceites_pasta'],
              'percentages' => [ 
                ['number' => '0.1', 'start_date' => '2023-01-01'],
              ],
            ],
            [
              'id' => 'exento_alm',
              'label' => $labels['exento_alm'],
              'percentages' => [ 
                ['number' => '0.00', 'start_date' => '2023-01-01'],
              ],
            ],
          ],
        ]);

    It works good on the website, but the problem with JSON:API isn't solved.

  • ๐Ÿ‡ช๐Ÿ‡ธSpain briantes

    I have reopened the issue because It isn't solved.

  • ๐Ÿ‡ฎ๐Ÿ‡ฑIsrael jsacksick

    You already have a reduced rate... Why not using tax? What would be missing would be the 0% tax, but if we add it it'd have "zero" as its id... We don't typically localize the rate IDS.

  • ๐Ÿ‡ช๐Ÿ‡ธSpain briantes

    Hi. Thanks for your help.
    We have products in all kind of rates. We can't use "reduced rate" because it is different to "aceites_pasta". At this moment It has the same percentage, but It may change sooner. The tax rate is assigned individually to each product and I have to assign the right tax to every one base on the kind of tax and not by the percentage. It works good with this rates.
    But actually, my problem is with json:api. When I add the new rates to those files, I don't know why It throws an error. If I remove my new rates, I works good. Investigating the problem, I have found that in the validate function in TaxNumberConstraintValidator class, $tax_number_type returns "other" type instead of "european_union_vat". And then, $tax_number_type instanceof SupportsVerificationInterface returns false.

Production build 0.71.5 2024