Browse files

Moving tax related entities away from TaxationBundle

  • Loading branch information...
1 parent dc85d2b commit 585f64084ba7673989bf78cde9ab52e6f2675fab @inspiran inspiran committed with iampersistent Mar 5, 2013
View
59 lib/Vespolina/Entity/Tax/Category.php
@@ -0,0 +1,59 @@
+<?php
+/**
+ * (c) Vespolina Project http://www.vespolina-project.org
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Vespolina\Entity\Tax;
+
+use Vespolina\Entity\Tax\CategoryInterface;
+
+/**
+ * TaxCategory holds the basic tax classification for various entities such as
+ *
+ * - defining the customer tax category. eg. "wholesale customer"
+ * - defining the product tax category eg. "food", "luxary good"
+ *
+ * @author Daniel Kucharski <daniel@xerias.be>
+ */
+class Category implements CategoryInterface
+{
+ protected $code;
+ protected $name;
+
+ /**
+ * @inheritdoc
+ */
+ public function getCode()
+ {
+
+ return $this->code;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getName()
+ {
+
+ return $this->name;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setCode($code)
+ {
+ $this->code = $code;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ }
+}
View
47 lib/Vespolina/Entity/Tax/CategoryInterface.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * (c) Vespolina Project http://www.vespolina-project.org
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Vespolina\Entity\Tax;
+
+/**
+ * TaxCategory holds the basic tax classification for various entities such as
+ * - defining the customer tax category. eg. "wholesale customer"
+ * - defining the product tax category eg. "prepared food"
+ *
+ * @author Daniel Kucharski <daniel@xerias.be>
+ */
+interface CategoryInterface
+{
+ /**
+ * Get code
+ */
+ function getCode();
+
+ /**
+ * Name of the tax category
+ */
+ function getName();
+
+ /**
+ * Set the code
+ *
+ * @abstract
+ * @param $code
+ * @return void
+ */
+ function setCode($code);
+
+ /**
+ * Set the tax category name
+ *
+ * @abstract
+ * @param $name
+ * @return void
+ */
+ function setName($name);
+}
View
86 lib/Vespolina/Entity/Tax/Rate.php
@@ -0,0 +1,86 @@
+<?php
+/**
+ * (c) Vespolina Project http://www.vespolina-project.org
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Vespolina\Entity\Tax;
+
+use Vespolina\Entity\Tax\CategoryInterface;
+
+/**
+ * @author Daniel Kucharski <daniel@xerias.be>
+ */
+class Rate implements RateInterface
+{
+ protected $category;
+ protected $code;
+ protected $name;
+ protected $rate;
+
+ public function getCategory()
+ {
+
+ return $this->category;
+ }
+ /**
+ * @inheritdoc
+ */
+ public function getCode()
+ {
+
+ return $this->code;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getName()
+ {
+
+ return $this->name;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getRate()
+ {
+
+ return $this->rate;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setCategory(CategoryInterface $category)
+ {
+ $this->category = $category;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setCode($code)
+ {
+ $this->code = $code;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setRate($rate)
+ {
+ $this->rate = $rate;
+ }
+}
View
55 lib/Vespolina/Entity/Tax/RateInterface.php
@@ -0,0 +1,55 @@
+<?php
+/**
+ * (c) Vespolina Project http://www.vespolina-project.org
+ *
+ * (c) Daniel Kucharski <daniel@xerias.be>
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Vespolina\Entity\Tax;
+
+interface RateInterface
+{
+ /**
+ * Get unique code
+ */
+ public function getCode();
+
+ /**
+ * Name of the tax rate
+ */
+ public function getName();
+
+ /**
+ * Value of the tax rate
+ */
+ public function getRate();
+
+ /**
+ * Set the tax zone code
+ *
+ * @abstract
+ * @param $code
+ * @return void
+ */
+ public function setCode($code);
+
+ /**
+ * Set the tax rate name
+ *
+ * @abstract
+ * @param $name
+ * @return void
+ */
+ public function setName($name);
+
+ /**
+ * Set the tax rate value
+ *
+ * @abstract
+ * @param $rate
+ * @return void
+ */
+ public function setRate($rate);
+}
View
136 lib/Vespolina/Entity/Tax/Zone.php
@@ -0,0 +1,136 @@
+<?php
+/**
+ * (c) Vespolina Project http://www.vespolina-project.org
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Vespolina\Entity\Tax;
+
+use Doctrine\Common\Collections\ArrayCollection;
+
+use Vespolina\Entity\Tax\CategoryInterface;
+use Vespolina\Entity\Tax\RateInterface;
+
+/**
+ * @author Daniel Kucharski <daniel@xerias.be>
+ */
+class Zone implements ZoneInterface
+{
+ protected $code;
+ protected $country;
+ protected $defaultRate;
+ protected $name;
+ protected $rates;
+ protected $strategy;
+ protected $state;
+ protected $type;
+
+ public function __construct()
+ {
+ $this->rates = new ArrayCollection();
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function addRate(RateInterface $rate)
+ {
+
+ $this->rates->set($rate->getCode(), $rate);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getCode()
+ {
+
+ return $this->code;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getName()
+ {
+
+ return $this->name;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getRates(CategoryInterface $category = null)
+ {
+
+ return $this->rates;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setCode($code)
+ {
+ $this->code = $code;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ }
+
+ public function setStrategy($strategy)
+ {
+ $this->strategy = $strategy;
+ }
+
+ public function getStrategy()
+ {
+ return $this->strategy;
+ }
+
+ public function setType($type)
+ {
+ $this->type = $type;
+ }
+
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ public function setDefaultRate($defaultRate)
+ {
+ $this->defaultRate = $defaultRate;
+ }
+
+ public function getDefaultRate()
+ {
+ return $this->defaultRate;
+ }
+
+ public function setCountry($country)
+ {
+ $this->country = $country;
+ }
+
+ public function getCountry()
+ {
+ return $this->country;
+ }
+
+ public function setState($state)
+ {
+ $this->state = $state;
+ }
+
+ public function getState()
+ {
+ return $this->state;
+ }
+}
View
71 lib/Vespolina/Entity/Tax/ZoneInterface.php
@@ -0,0 +1,71 @@
+<?php
+/**
+ * (c) Vespolina Project http://www.vespolina-project.org
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Vespolina\Entity\Tax;
+
+use Vespolina\Entity\Tax\CategoryInterface;
+use Vespolina\Entity\Tax\RateInterface;
+
+/**
+ * @author Daniel Kucharski <daniel@xerias.be>
+ */
+interface ZoneInterface
+{
+
+ /**
+ * Add the given rate to this zone
+ *
+ * @abstract
+ * @param RateInterface $rate
+ * @return void
+ */
+ function addRate(RateInterface $rate);
+
+ /**
+ * Get tax zone code (should be unique)
+ */
+ function getCode();
+
+ /**
+ * Name of the tax zone
+ */
+ function getName();
+
+ /**
+ * Retrieve a list of available rates
+ *
+ * @abstract
+ * @return void
+ */
+ function getRates(CategoryInterface $category = null);
+
+ /**
+ * Return the strategy to be used for this zone to select a tax rate
+ *
+ * @return mixed
+ */
+ function getStrategy();
+
+ /**
+ * Set the tax zone code
+ *
+ * @abstract
+ * @param $code
+ * @return void
+ */
+ function setCode($code);
+
+ /**
+ * Set the tax zone name
+ *
+ * @abstract
+ * @param $name
+ * @return void
+ */
+ function setName($name);
+}

0 comments on commit 585f640

Please sign in to comment.