From 0a5281c1e683dc7bdc633c2e4ce1667e2b04befd Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Mon, 9 Sep 2013 10:48:41 +0200 Subject: [PATCH] tax engine model --- .../Thelia/Exception/TaxEngineException.php | 41 ++++++++++++ core/lib/Thelia/TaxEngine/Calculator.php | 65 +++++++++++++++++++ local/config/schema.xml | 14 ++-- 3 files changed, 113 insertions(+), 7 deletions(-) create mode 100755 core/lib/Thelia/Exception/TaxEngineException.php create mode 100755 core/lib/Thelia/TaxEngine/Calculator.php diff --git a/core/lib/Thelia/Exception/TaxEngineException.php b/core/lib/Thelia/Exception/TaxEngineException.php new file mode 100755 index 000000000..b51aeef44 --- /dev/null +++ b/core/lib/Thelia/Exception/TaxEngineException.php @@ -0,0 +1,41 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Exception; + +use Thelia\Log\Tlog; + +class TaxEngineException extends \RuntimeException +{ + const UNKNOWN_EXCEPTION = 0; + + const UNDEFINED_PRODUCT = 501; + const UNDEFINED_COUNTRY = 502; + + public function __construct($message, $code = null, $previous = null) { + if($code === null) { + $code = self::UNKNOWN_EXCEPTION; + } + parent::__construct($message, $code, $previous); + } +} diff --git a/core/lib/Thelia/TaxEngine/Calculator.php b/core/lib/Thelia/TaxEngine/Calculator.php new file mode 100755 index 000000000..0e1216783 --- /dev/null +++ b/core/lib/Thelia/TaxEngine/Calculator.php @@ -0,0 +1,65 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\TaxEngine; + +use Thelia\Exception\TaxEngineException; +use Thelia\Model\Country; +use Thelia\Model\Product; + +/** + * Class Calculator + * @package Thelia\TaxEngine + * @author Etienne Roudeix + */ +class Calculator +{ + protected $taxRulesCollection = null; + + protected $product = null; + protected $country = null; + + public function __construct() + { + return $this; + } + + public function load(Product $product, Country $country) + { + if($product->getId() === null) { + throw new TaxEngineException('Product id is empty in Calculator::load', TaxEngineException::UNDEFINED_PRODUCT); + } + if($country->getId() === null) { + throw new TaxEngineException('Country id is empty in Calculator::load', TaxEngineException::UNDEFINED_COUNTRY); + } + + $this->product = $product; + $this->country = $country; + + return $this; + } + + public function getTaxAmount() + { + + } +} diff --git a/local/config/schema.xml b/local/config/schema.xml index e6e68c4b2..55036197f 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -96,19 +96,19 @@ - - + + +
- - - + + - - + +