Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
Merge pull request #8 from PrestaShop/dev
Browse files Browse the repository at this point in the history
Deploy v2.1.0 of vatnumber module
  • Loading branch information
Quetzacoalt91 authored Jan 23, 2019
2 parents 8268c01 + 84a31fd commit 99ead06
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
34 changes: 31 additions & 3 deletions VATNumberTaxManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,37 @@ class VATNumberTaxManager implements TaxManagerInterface
{
public static function isAvailableForThisAddress(Address $address)
{
return (!empty($address->vat_number)
&& $address->id_country != Configuration::get('VATNUMBER_COUNTRY')
&& Configuration::get('VATNUMBER_MANAGEMENT')
/*
HOTFIX
For some reason, this check is called 6 times (?)
1 w. the real address
2 w.o. the real address
1 w. the real address
2 w.o. the real address
=> [1 0 0 1 0 0]
So we need to filter out the weird calls...
We do this by caching the correct calls between calls;
by creating a static variable, which we save the address to,
if it does not contain NULL in some of the other fields.
*/

static $cached_address = NULL;

if ($address->id_customer != NULL) {
$cached_address = $address;
}

// Now, check on the cached address object
return (!empty($cached_address->vat_number)
&& !empty($cached_address->id_country)
&& $cached_address->id_country != Configuration::get('VATNUMBER_COUNTRY')
&& Configuration::get('VATNUMBER_MANAGEMENT')
);
}

Expand Down
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>vatnumber</name>
<displayName><![CDATA[European VAT number]]></displayName>
<version><![CDATA[2.0.0]]></version>
<version><![CDATA[2.1.0]]></version>
<description><![CDATA[Enables you to enter the intra-community VAT number when creating the address. You must fill in the company field to allow entering the VAT number.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[billing_invoicing]]></tab>
Expand Down
2 changes: 1 addition & 1 deletion vatnumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct()
{
$this->name = 'vatnumber';
$this->tab = 'billing_invoicing';
$this->version = '2.0.0';
$this->version = '2.1.0';
$this->author = 'PrestaShop';
$this->need_instance = 0;

Expand Down

0 comments on commit 99ead06

Please sign in to comment.