Skip to content

Commit

Permalink
First launch PHP CS Fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
micka-fdz committed Oct 20, 2023
1 parent a539f14 commit 10dd3e1
Show file tree
Hide file tree
Showing 9 changed files with 334 additions and 358 deletions.
68 changes: 34 additions & 34 deletions VATNumberTaxManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,48 +26,48 @@

class VATNumberTaxManager implements TaxManagerInterface
{
public static function isAvailableForThisAddress(Address $address)
{
/*
HOTFIX
For some reason, this check is called 6 times (?)
public static function isAvailableForThisAddress(Address $address)
{
/*
HOTFIX
1 w. the real address
2 w.o. the real address
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]
1 w. the real address
2 w.o. the real address
So we need to filter out the weird calls...
=> [1 0 0 1 0 0]
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.
*/
So we need to filter out the weird calls...
static $cached_address = NULL;
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.
*/

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

// 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')
);
}
if ($address->id_customer != null) {
$cached_address = $address;
}

public function getTaxCalculator()
{
// If the address matches the european vat number criterias no taxes are applied
$tax = new Tax();
$tax->rate = 0;
// 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')
;
}

return new TaxCalculator(array($tax));
}
public function getTaxCalculator()
{
// If the address matches the european vat number criterias no taxes are applied
$tax = new Tax();
$tax->rate = 0;

return new TaxCalculator([$tax]);
}
}
6 changes: 3 additions & 3 deletions ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../init.php');
include(dirname(__FILE__).'/vatnumber.php');
include dirname(__FILE__) . '/../../config/config.inc.php';
include dirname(__FILE__) . '/../../init.php';
include dirname(__FILE__) . '/vatnumber.php';

echo VatNumber::isApplicable(Tools::getValue('id_country'));
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
Expand Down
18 changes: 9 additions & 9 deletions translations/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header('Location: ../');
exit;
7 changes: 4 additions & 3 deletions upgrade/install-2.0.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

if (!defined('_PS_VERSION_'))
exit;
if (!defined('_PS_VERSION_')) {
exit;
}

function upgrade_module_2_0($object)
{
return ($object->registerHook('actionValidateCustomerAddressForm'));
return $object->registerHook('actionValidateCustomerAddressForm');
}
Loading

0 comments on commit 10dd3e1

Please sign in to comment.