[*] Project : US + CA TaxSystem
This commit is contained in:
Executable
+43
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class VATNumberTaxManager implements TaxManagerInterface
|
||||
{
|
||||
public static function isAvailableForThisAddress(Address $address)
|
||||
{
|
||||
return (!empty($address->vat_number)
|
||||
AND $address->id_country != Configuration::get('VATNUMBER_COUNTRY')
|
||||
AND Configuration::get('VATNUMBER_MANAGEMENT'));
|
||||
}
|
||||
|
||||
public function getTaxCalculator()
|
||||
{
|
||||
// No tax
|
||||
return new TaxCalculator(array(0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
@@ -28,7 +28,7 @@
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
class VatNumber extends Module
|
||||
class VatNumber extends TaxManagerModule
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
@@ -37,35 +37,37 @@ class VatNumber extends Module
|
||||
$this->version = 1.0;
|
||||
$this->author = 'PrestaShop';
|
||||
$this->need_instance = 0;
|
||||
|
||||
|
||||
$this->tax_manager_class = 'VATNumberTaxManager';
|
||||
|
||||
parent::__construct();
|
||||
|
||||
|
||||
$this->displayName = $this->l('European VAT number');
|
||||
$this->description = $this->l('Enable entering of the VAT intra-community number when creating the address (You must fill in the company field to allow keyboarding VAT number)');
|
||||
}
|
||||
|
||||
|
||||
public function install()
|
||||
{
|
||||
return (parent::install() AND Configuration::updateValue('VATNUMBER_MANAGEMENT', 1));
|
||||
}
|
||||
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
return (parent::uninstall() AND Configuration::updateValue('VATNUMBER_MANAGEMENT', 0));
|
||||
}
|
||||
|
||||
|
||||
public function enable($forceAll = false)
|
||||
{
|
||||
parent::enable();
|
||||
Configuration::updateValue('VATNUMBER_MANAGEMENT', 1);
|
||||
}
|
||||
|
||||
|
||||
public function disable($forceAll = false)
|
||||
{
|
||||
parent::disable();
|
||||
Configuration::updateValue('VATNUMBER_MANAGEMENT', 0);
|
||||
}
|
||||
|
||||
|
||||
public static function getPrefixIntracomVAT()
|
||||
{
|
||||
$intracom_array = array(
|
||||
@@ -95,13 +97,13 @@ class VatNumber extends Module
|
||||
'SK'=>'SK', //Slovakia
|
||||
'CZ'=>'CZ', //Czech Republic
|
||||
'SI'=>'SI', //Slovenia
|
||||
'RO'=>'RO', //Romania
|
||||
'BG'=>'BG' //Bulgaria
|
||||
'RO'=>'RO', //Romania
|
||||
'BG'=>'BG' //Bulgaria
|
||||
);
|
||||
return $intracom_array;
|
||||
}
|
||||
|
||||
public static function isApplicable($id_country)
|
||||
public static function isApplicable($id_country)
|
||||
{
|
||||
return (((int)$id_country AND in_array(Country::getIsoById($id_country), self::getPrefixIntracomVAT())) ? 1 : 0);
|
||||
}
|
||||
@@ -144,7 +146,7 @@ class VatNumber extends Module
|
||||
public function getContent()
|
||||
{
|
||||
$echo = '';
|
||||
|
||||
|
||||
if (Tools::isSubmit('submitVatNumber'))
|
||||
{
|
||||
if (Configuration::updateValue('VATNUMBER_COUNTRY', (int)(Tools::getValue('vatnumber_country'))))
|
||||
@@ -178,6 +180,4 @@ class VatNumber extends Module
|
||||
</fieldset>';
|
||||
return $echo;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user