This commit is contained in:
Manuel Raynaud
2014-01-22 12:52:36 +01:00
parent 9d1c1e3979
commit 1974d3e3c3
1201 changed files with 80 additions and 88 deletions

20
core/lib/Thelia/TaxEngine/BaseTaxType.php Executable file → Normal file
View File

@@ -24,7 +24,6 @@ namespace Thelia\TaxEngine;
use Thelia\Exception\TaxEngineException;
use Thelia\Model\Product;
use Thelia\Type\TypeInterface;
/**
*
@@ -48,7 +47,8 @@ abstract class BaseTaxType
*
* @return number
*/
public function pricePercentRetriever() {
public function pricePercentRetriever()
{
return 0;
}
@@ -59,7 +59,8 @@ abstract class BaseTaxType
*
* @return number
*/
public function fixAmountRetriever(Product $product) {
public function fixAmountRetriever(Product $product)
{
return 0;
}
@@ -74,7 +75,8 @@ abstract class BaseTaxType
*
* @return array of TaxTypeRequirementDefinition
*/
public function getRequirementsDefinition() {
public function getRequirementsDefinition()
{
return array();
}
@@ -90,9 +92,10 @@ abstract class BaseTaxType
/**
* @throws TaxEngineException
* @return array Return the requirements array.
* @return array Return the requirements array.
*/
public function getRequirements() {
public function getRequirements()
{
return $this->requirements;
}
@@ -120,7 +123,8 @@ abstract class BaseTaxType
}
}
public function setRequirement($key, $value) {
public function setRequirement($key, $value)
{
$this->requirements[$key] = $value;
return $this;
@@ -134,4 +138,4 @@ abstract class BaseTaxType
return $this->requirements[$key];
}
}
}

0
core/lib/Thelia/TaxEngine/Calculator.php Executable file → Normal file
View File

View File

15
core/lib/Thelia/TaxEngine/TaxEngine.php Executable file → Normal file
View File

@@ -57,10 +57,11 @@ class TaxEngine
* Add a directroy which contains tax types classes. The tax engine
* will scan this directory, and add all the tax type classes.
*
* @param unknown $namespace the namespace of the classes in the directory
* @param unknown $namespace the namespace of the classes in the directory
* @param unknown $path_to_tax_type_classes the path to the directory
*/
public function addTaxTypeDirectory($namespace, $path_to_tax_type_classes) {
public function addTaxTypeDirectory($namespace, $path_to_tax_type_classes)
{
$this->taxTypesDirectories[$namespace] = $path_to_tax_type_classes;
}
@@ -70,7 +71,8 @@ class TaxEngine
* @param unknown $fullyQualifiedclassName the fully qualified classname, su chas MyTaxes\Taxes\MyTaxType
*
*/
public function addTaxType($fullyQualifiedclassName) {
public function addTaxType($fullyQualifiedclassName)
{
$this->typeList[] = $fullyQualifiedclassName;
}
@@ -80,7 +82,7 @@ class TaxEngine
$this->typeList = array();
foreach($this->taxTypesDirectories as $namespace => $directory) {
foreach ($this->taxTypesDirectories as $namespace => $directory) {
try {
$directoryIterator = new \DirectoryIterator($directory);
@@ -100,8 +102,7 @@ class TaxEngine
if ($instance instanceof BaseTaxType) {
$this->addTaxType(get_class($instance));
}
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Nothing special to do
}
}
@@ -146,4 +147,4 @@ class TaxEngine
return $this->taxCountry;
}
}
}

View File

@@ -38,7 +38,8 @@ use Thelia\TaxEngine\TaxTypeRequirementDefinition;
*/
class FeatureFixAmountTaxType extends BaseTaxType
{
public function setFeature($featureId) {
public function setFeature($featureId)
{
$this->setRequirement('feature', $featureId);
return $this;

3
core/lib/Thelia/TaxEngine/TaxType/FixAmountTaxType.php Executable file → Normal file
View File

@@ -34,7 +34,8 @@ use Thelia\TaxEngine\TaxTypeRequirementDefinition;
*/
class FixAmountTaxType extends BaseTaxType
{
public function setAmount($amount) {
public function setAmount($amount)
{
$this->setRequirement('amount', $amount);
return $this;

View File

@@ -34,7 +34,8 @@ use Thelia\TaxEngine\BaseTaxType;
*/
class PricePercentTaxType extends BaseTaxType
{
public function setPercentage($percent) {
public function setPercentage($percent)
{
$this->setRequirement('percent', $percent);
return $this;

View File

@@ -44,7 +44,7 @@ class TaxTypeRequirementDefinition
/**
* Create a new Tax type requirement
*
* @param string $name the name of the requirement
* @param string $name the name of the requirement
* @param TypeInterface $type the type of the data
*/
public function __construct($name, TypeInterface $type)
@@ -63,7 +63,8 @@ class TaxTypeRequirementDefinition
return $this->type;
}
public function isValueValid($value) {
public function isValueValid($value)
{
return $this->type->isValid($value);
}
}