Jump to content

[FREE MODULE] Vat checker


Inform-All
 Share

Recommended Posts

This module is all you need for intra-Community supply orders.
The module does the following:

  • Automatically checks an VAT number for delivery address
  • Checks if it's a valid VAT number on the official VIES database
  • Gives 0% tax if a VAT is verified

 

761431932_vatoptions.thumb.png.92617c389f74b1e7c2d298f93b1cf869.png

In the settings of the module you fill in your companies Origin Country. Because you can't ship with 0% tax in the same country your company is based.
Every order is checked for their shipping address, NOT the invoice address.

Since the VIES database has some reoccurring offline time, there is an option in how to handle this.
 

Prestashop 1.7

vatchecker.zip

Got any ideas or updates? 
Feel free to commit on GIT.

Latest update: 29-09-2022

 

Edited by Inform-All
update (see edit history)
  • Like 3

Share this post


Link to post
Share on other sites

On 8/4/2022 at 8:16 AM, WorDym said:

Looks like it works great so far! I'd just like to ask - am I just blind, or is the phrase "EU VIES server not responding" not available for translation in the administration?

The translation should just be there.

International > Translations > Translation of modules > Vat Checker > your language

Share this post


Link to post
Share on other sites

On 8/10/2022 at 7:08 AM, WorDym said:

Yes, I checked the traslation settings, but still can't see the phrase "EU VIES server not responding" over there in either "vatchecker" category or "configure".

image.png

image.png

That is actually really weird. I've tested it in multiple stores, and it always in the list of your screenshot.
Please reinstall the module to check if that helps.

Share this post


Link to post
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
  • 2 weeks later...
	private $euVatFormats = array(
		'AT' => '(AT)?U[0-9]{8}',                              # Austria
		'BE' => '(BE)?0[0-9]{9}',                              # Belgium
		'BG' => '(BG)?[0-9]{9,10}',                            # Bulgaria
		'CY' => '(CY)?[0-9]{8}[A-Z]',                          # Cyprus
		'CZ' => '(CZ)?[0-9]{8,10}',                            # Czech Republic
		'DE' => '(DE)?[0-9]{9}',                               # Germany
		'DK' => '(DK)?[0-9]{8}',                               # Denmark
		'EE' => '(EE)?[0-9]{9}',                               # Estonia
		'GR' => '(EL)?[0-9]{9}',                               # Greece
		'ES' => '(ES)?[A-Z][0-9]{7}(?:[0-9]|[A-Z])',              # Spain
		'FI' => '(FI)?[0-9]{8}',                               # Finland
		'FR' => '(FR)?[0-9A-Z]{2}[0-9]{9}',                    # France
		//'GB' => '(GB)?([0-9]{9}([0-9]{3})?|[A-Z]{2}[0-9]{3})', # United Kingdom // Brexit!
		'HR' => '(HR)?[0-9]{11}',                              # Croatia
		'HU' => '(HU)?[0-9]{8}',                               # Hungary
		'IE' => '(IE)?[0-9]{7}[A-Z]{1,2}',                     # Ireland
		'IE2' => '(IE)?[0-9][A-Z][0-9]{5}[A-Z]',               # Ireland (2)
		'IT' => '(IT)?[0-9]{11}',                              # Italy
		'LT' => '(LT)?([0-9]{9}|[0-9]{12})',                   # Lithuania
		'LU' => '(LU)?[0-9]{8}',                               # Luxembourg
		'LV' => '(LV)?[0-9]{11}',                              # Latvia
		'MT' => '(MT)?[0-9]{8}',                               # Malta
		'NL' => '(NL)?[0-9]{9}B[0-9]{2}',                      # Netherlands
		'PL' => '(PL)?[0-9]{10}',                              # Poland
		'PT' => '(PT)?[0-9]{9}',                               # Portugal
		'RO' => '(RO)?[0-9]{2,10}',                            # Romania
		'SE' => '(SE)?[0-9]{12}',                              # Sweden
		'SI' => '(SI)?[0-9]{8}',                               # Slovenia
		'SK' => '(SK)?[0-9]{10}',                              # Slovakia
	);

in this list missing XI that is North Ireland and IE2 what is it?

 

Quote

As of 01/01/2021, the VoW service to validate UK (GB) VAT numbers ceased to exist while a new service to validate VAT numbers of businesses operating under the Protocol on Ireland and Northern Ireland appeared. These VAT numbers are starting with the “XI” prefix, which may be found in the “Member State / Northern Ireland” drop down under the new entry “XI-Northern Ireland”. Moreover, any quote of “Member State” is replaced by “Member State / Northern Ireland” and any quote of “MS” is replaced by “MS / XI”. All traders seeking to validate UK (GB) VAT numbers may address their request to the UK Tax Administration.

https://ec.europa.eu/taxation_customs/vies/#/vat-validation

 

XI has same VAT syntax of GB VAT:

(XI)?([0-9]{9}([0-9]{3})?|[A-Z]{2}[0-9]{3})

 

please avoid the VIES check if the VAT code is in the same country of the Shop.

 

 

Edited by Hart (see edit history)

Share this post


Link to post
Share on other sites

  • 1 month later...
  • 3 weeks later...

I get the following message when calling up e.g. the shopping cart:

Unknown error in Zeile 719 der Datei /is/htdocs/wp1131087_P0JXD1MK8I/www/shop/modules/vatchecker/vatchecker.php
[8192] ltrim(): Passing null to parameter #1 ($string) of type string is deprecated

Unknown error in Zeile 719 der Datei /is/htdocs/wp1131087_P0JXD1MK8I/www/shop/modules/vatchecker/vatchecker.php
[8192] ltrim(): Passing null to parameter #1 ($string) of type string is deprecated

There have been no changes to the vatchecker. php 

Share this post


Link to post
Share on other sites

45 minutes ago, Ritter said:

I get the following message when calling up e.g. the shopping cart:

Unknown error in Zeile 719 der Datei /is/htdocs/wp1131087_P0JXD1MK8I/www/shop/modules/vatchecker/vatchecker.php
[8192] ltrim(): Passing null to parameter #1 ($string) of type string is deprecated

Unknown error in Zeile 719 der Datei /is/htdocs/wp1131087_P0JXD1MK8I/www/shop/modules/vatchecker/vatchecker.php
[8192] ltrim(): Passing null to parameter #1 ($string) of type string is deprecated

There have been no changes to the vatchecker. php 

Has been bug fixed on git.

Share this post


Link to post
Share on other sites

  • 3 weeks later...

There is a problem with the VATChecker, the entered gross price suddenly is not accepted and strange behavior when changing the tax rule.
Shop country: Germany, VAT 19%
Uninstalled and reinstalled modules VATChecker, changed vatchecker.php as described on Github.


NCafmRJwTM.thumb.gif.0bad70751846ee702802af3c51258dd6.gif

Share this post


Link to post
Share on other sites

On 1/2/2023 at 3:48 PM, Ritter said:

There is a problem with the VATChecker, the entered gross price suddenly is not accepted and strange behavior when changing the tax rule.
Shop country: Germany, VAT 19%
Uninstalled and reinstalled modules VATChecker, changed vatchecker.php as described on Github.

This bug is not related to the vat checker module. The moment you edit your tax incl price it should also edit the tax excl price. You have a different module/edit because your price edit display page is not the Prestashop's default. And besides that the Vatchecker module does not interfere with the product edit pages.

Share this post


Link to post
Share on other sites

Thank you for the information.
Prestashop runs with the default theme and settings, only VAT Checker is installed as third-party module.
Presta is present on the European market, so I expected that the different VAT rates would incorporated in PS 8 - this is unfortunately not the case, a thrid-party module is nessesary .

Since it is not due to the VAT checker module, I am opening a new thread with the problem of incorrectly gross prices by saving.

Share this post


Link to post
Share on other sites

  • 3 weeks later...

there is something i don't understand here on this code (override) in your module

 

class TaxRulesTaxManager extends TaxRulesTaxManagerCore
{
	/**
	 * Return the tax calculator associated to this address.
	 *
	 * @return TaxCalculator
	 */
	public function getTaxCalculator()
	{
		static $tax_enabled = null;

		if ( isset( $this->tax_calculator ) ) {
			return $this->tax_calculator;
		}

		if ( null === $tax_enabled ) {
			$tax_enabled = Configuration::get( 'PS_TAX' );
		}

		if ( $tax_enabled && $this->address ) {
			/** @var Vatchecker $vatchecker */
			$vatchecker = Module::getInstanceByName('vatchecker');
			if ( $vatchecker && $vatchecker->canOrderWithoutVat( $this->address ) ) {
				// Disable TAX.
				$tax_enabled = false;
			}
		}

		if ( ! $tax_enabled ) {
			return new TaxCalculator( array() );
		}

		return parent::getTaxCalculator();
	}
}

in BO config of the module you can select countries from EU where you can order without VAT (based on the note here)

image.png.3f72829679938b177e8541e887a6f5a5.png

 

Looking inside the code if i disable a country TAXATION is not applied?

Was mopre logical instead that if i dsable Spain flag in config i can order from there only if the customer as a VALID VAT number, because the UX and the message seems to indicate that i will forcing only VAT purcasing not liek i see in the code that is added or not the tax.

There is something i still misunderstanding here?

 

Thanks!

 

 

 

 

Share this post


Link to post
Share on other sites

20 hours ago, Hart said:

there is something i don't understand here on this code (override) in your module

 

class TaxRulesTaxManager extends TaxRulesTaxManagerCore
{
	/**
	 * Return the tax calculator associated to this address.
	 *
	 * @return TaxCalculator
	 */
	public function getTaxCalculator()
	{
		static $tax_enabled = null;

		if ( isset( $this->tax_calculator ) ) {
			return $this->tax_calculator;
		}

		if ( null === $tax_enabled ) {
			$tax_enabled = Configuration::get( 'PS_TAX' );
		}

		if ( $tax_enabled && $this->address ) {
			/** @var Vatchecker $vatchecker */
			$vatchecker = Module::getInstanceByName('vatchecker');
			if ( $vatchecker && $vatchecker->canOrderWithoutVat( $this->address ) ) {
				// Disable TAX.
				$tax_enabled = false;
			}
		}

		if ( ! $tax_enabled ) {
			return new TaxCalculator( array() );
		}

		return parent::getTaxCalculator();
	}
}

in BO config of the module you can select countries from EU where you can order without VAT (based on the note here)

image.png.3f72829679938b177e8541e887a6f5a5.png

 

Looking inside the code if i disable a country TAXATION is not applied?

Was mopre logical instead that if i dsable Spain flag in config i can order from there only if the customer as a VALID VAT number, because the UX and the message seems to indicate that i will forcing only VAT purcasing not liek i see in the code that is added or not the tax.

There is something i still misunderstanding here?

 

Thanks!

 

 

 

 

I responded on Git :)

Share this post


Link to post
Share on other sites

Hi, I just installed your module on my 1.7.8.8 and it gives me an errror when debug is ON

I'm afraid I can't give you access, because I'm working on localhost

 

PS: thank you for bringing back this feature free of charge, really appreciate it

Firefox_Screenshot_2023-01-30T15-37-50.887Z.png

Share this post


Link to post
Share on other sites

1 hour ago, Shin_P said:

Hi, I just installed your module on my 1.7.8.8 and it gives me an errror when debug is ON

I'm afraid I can't give you access, because I'm working on localhost

 

PS: thank you for bringing back this feature free of charge, really appreciate it

Firefox_Screenshot_2023-01-30T15-37-50.887Z.png

What PHP version are you using?
Are you sure you can do a Soap call to the external VIES database?
It's a rather odd error message, please send me a DM if you need more help.

Share this post


Link to post
Share on other sites

well it doesnt matter. on production seems to be working: debug is off and that was just a notice right? not an error, so nothing to worry about I hope

i also turned off the "Validation required" option and it works great, I will validate manually

thank you again, coffee is on me this morning 🤪

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More