- * $obj = $c->findPk(12, $con);
+ * $obj = $c->findPk(array(12, 34, 56), $con);
*
*
- * @param mixed $key Primary key to use for the query
+ * @param array[$tax_rule_id, $country_id, $tax_id] $key Primary key to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ChildTaxRuleCountry|array|mixed the result, formatted by the current formatter
@@ -131,7 +127,7 @@ abstract class TaxRuleCountryQuery extends ModelCriteria
if ($key === null) {
return null;
}
- if ((null !== ($obj = TaxRuleCountryTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ if ((null !== ($obj = TaxRuleCountryTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))))) && !$this->formatter) {
// the object is already in the instance pool
return $obj;
}
@@ -159,10 +155,12 @@ abstract class TaxRuleCountryQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
- $sql = 'SELECT ID, TAX_RULE_ID, COUNTRY_ID, TAX_ID, NONE, CREATED_AT, UPDATED_AT FROM tax_rule_country WHERE ID = :p0';
+ $sql = 'SELECT TAX_RULE_ID, COUNTRY_ID, TAX_ID, POSITION, CREATED_AT, UPDATED_AT FROM tax_rule_country WHERE TAX_RULE_ID = :p0 AND COUNTRY_ID = :p1 AND TAX_ID = :p2';
try {
$stmt = $con->prepare($sql);
- $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
+ $stmt->bindValue(':p2', $key[2], PDO::PARAM_INT);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
@@ -172,7 +170,7 @@ abstract class TaxRuleCountryQuery extends ModelCriteria
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
$obj = new ChildTaxRuleCountry();
$obj->hydrate($row);
- TaxRuleCountryTableMap::addInstanceToPool($obj, (string) $key);
+ TaxRuleCountryTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1], (string) $key[2])));
}
$stmt->closeCursor();
@@ -201,7 +199,7 @@ abstract class TaxRuleCountryQuery extends ModelCriteria
/**
* Find objects by primary key
*
- * $objs = $c->findPks(array(12, 56, 832), $con);
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
*
* @param array $keys Primary keys to use for the query
* @param ConnectionInterface $con an optional connection object
@@ -231,8 +229,11 @@ abstract class TaxRuleCountryQuery extends ModelCriteria
*/
public function filterByPrimaryKey($key)
{
+ $this->addUsingAlias(TaxRuleCountryTableMap::TAX_RULE_ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(TaxRuleCountryTableMap::COUNTRY_ID, $key[1], Criteria::EQUAL);
+ $this->addUsingAlias(TaxRuleCountryTableMap::TAX_ID, $key[2], Criteria::EQUAL);
- return $this->addUsingAlias(TaxRuleCountryTableMap::ID, $key, Criteria::EQUAL);
+ return $this;
}
/**
@@ -244,49 +245,19 @@ abstract class TaxRuleCountryQuery extends ModelCriteria
*/
public function filterByPrimaryKeys($keys)
{
-
- return $this->addUsingAlias(TaxRuleCountryTableMap::ID, $keys, Criteria::IN);
- }
-
- /**
- * Filter the query on the id column
- *
- * Example usage:
- *
- * $query->filterById(1234); // WHERE id = 1234
- * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
- * $query->filterById(array('min' => 12)); // WHERE id > 12
- *
- *
- * @param mixed $id The value to use as filter.
- * Use scalar values for equality.
- * Use array values for in_array() equivalent.
- * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return ChildTaxRuleCountryQuery The current query, for fluid interface
- */
- public function filterById($id = null, $comparison = null)
- {
- if (is_array($id)) {
- $useMinMax = false;
- if (isset($id['min'])) {
- $this->addUsingAlias(TaxRuleCountryTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
- $useMinMax = true;
- }
- if (isset($id['max'])) {
- $this->addUsingAlias(TaxRuleCountryTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
- $useMinMax = true;
- }
- if ($useMinMax) {
- return $this;
- }
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(TaxRuleCountryTableMap::TAX_RULE_ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(TaxRuleCountryTableMap::COUNTRY_ID, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $cton2 = $this->getNewCriterion(TaxRuleCountryTableMap::TAX_ID, $key[2], Criteria::EQUAL);
+ $cton0->addAnd($cton2);
+ $this->addOr($cton0);
}
- return $this->addUsingAlias(TaxRuleCountryTableMap::ID, $id, $comparison);
+ return $this;
}
/**
@@ -419,16 +390,16 @@ abstract class TaxRuleCountryQuery extends ModelCriteria
}
/**
- * Filter the query on the none column
+ * Filter the query on the position column
*
* Example usage:
*
- * $query->filterByNone(1234); // WHERE none = 1234
- * $query->filterByNone(array(12, 34)); // WHERE none IN (12, 34)
- * $query->filterByNone(array('min' => 12)); // WHERE none > 12
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
*
*
- * @param mixed $none The value to use as filter.
+ * @param mixed $position The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@@ -436,16 +407,16 @@ abstract class TaxRuleCountryQuery extends ModelCriteria
*
* @return ChildTaxRuleCountryQuery The current query, for fluid interface
*/
- public function filterByNone($none = null, $comparison = null)
+ public function filterByPosition($position = null, $comparison = null)
{
- if (is_array($none)) {
+ if (is_array($position)) {
$useMinMax = false;
- if (isset($none['min'])) {
- $this->addUsingAlias(TaxRuleCountryTableMap::NONE, $none['min'], Criteria::GREATER_EQUAL);
+ if (isset($position['min'])) {
+ $this->addUsingAlias(TaxRuleCountryTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
- if (isset($none['max'])) {
- $this->addUsingAlias(TaxRuleCountryTableMap::NONE, $none['max'], Criteria::LESS_EQUAL);
+ if (isset($position['max'])) {
+ $this->addUsingAlias(TaxRuleCountryTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
@@ -456,7 +427,7 @@ abstract class TaxRuleCountryQuery extends ModelCriteria
}
}
- return $this->addUsingAlias(TaxRuleCountryTableMap::NONE, $none, $comparison);
+ return $this->addUsingAlias(TaxRuleCountryTableMap::POSITION, $position, $comparison);
}
/**
@@ -578,7 +549,7 @@ abstract class TaxRuleCountryQuery extends ModelCriteria
*
* @return ChildTaxRuleCountryQuery The current query, for fluid interface
*/
- public function joinTax($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ public function joinTax($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Tax');
@@ -613,7 +584,7 @@ abstract class TaxRuleCountryQuery extends ModelCriteria
*
* @return \Thelia\Model\TaxQuery A secondary query class using the current class as primary query
*/
- public function useTaxQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ public function useTaxQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinTax($relationAlias, $joinType)
@@ -653,7 +624,7 @@ abstract class TaxRuleCountryQuery extends ModelCriteria
*
* @return ChildTaxRuleCountryQuery The current query, for fluid interface
*/
- public function joinTaxRule($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ public function joinTaxRule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('TaxRule');
@@ -688,7 +659,7 @@ abstract class TaxRuleCountryQuery extends ModelCriteria
*
* @return \Thelia\Model\TaxRuleQuery A secondary query class using the current class as primary query
*/
- public function useTaxRuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ public function useTaxRuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinTaxRule($relationAlias, $joinType)
@@ -728,7 +699,7 @@ abstract class TaxRuleCountryQuery extends ModelCriteria
*
* @return ChildTaxRuleCountryQuery The current query, for fluid interface
*/
- public function joinCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ public function joinCountry($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Country');
@@ -763,7 +734,7 @@ abstract class TaxRuleCountryQuery extends ModelCriteria
*
* @return \Thelia\Model\CountryQuery A secondary query class using the current class as primary query
*/
- public function useCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ public function useCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinCountry($relationAlias, $joinType)
@@ -780,7 +751,10 @@ abstract class TaxRuleCountryQuery extends ModelCriteria
public function prune($taxRuleCountry = null)
{
if ($taxRuleCountry) {
- $this->addUsingAlias(TaxRuleCountryTableMap::ID, $taxRuleCountry->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond0', $this->getAliasedColName(TaxRuleCountryTableMap::TAX_RULE_ID), $taxRuleCountry->getTaxRuleId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(TaxRuleCountryTableMap::COUNTRY_ID), $taxRuleCountry->getCountryId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond2', $this->getAliasedColName(TaxRuleCountryTableMap::TAX_ID), $taxRuleCountry->getTaxId(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1', 'pruneCond2'), Criteria::LOGICAL_OR);
}
return $this;
diff --git a/core/lib/Thelia/Model/Base/TaxRuleI18n.php b/core/lib/Thelia/Model/Base/TaxRuleI18n.php
index b1efadd6a..711dba307 100644
--- a/core/lib/Thelia/Model/Base/TaxRuleI18n.php
+++ b/core/lib/Thelia/Model/Base/TaxRuleI18n.php
@@ -66,6 +66,18 @@ abstract class TaxRuleI18n implements ActiveRecordInterface
*/
protected $locale;
+ /**
+ * The value for the title field.
+ * @var string
+ */
+ protected $title;
+
+ /**
+ * The value for the description field.
+ * @var string
+ */
+ protected $description;
+
/**
* @var TaxRule
*/
@@ -368,6 +380,28 @@ abstract class TaxRuleI18n implements ActiveRecordInterface
return $this->locale;
}
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
/**
* Set the value of [id] column.
*
@@ -414,6 +448,48 @@ abstract class TaxRuleI18n implements ActiveRecordInterface
return $this;
} // setLocale()
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\TaxRuleI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = TaxRuleI18nTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\TaxRuleI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = TaxRuleI18nTableMap::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
/**
* Indicates whether the columns in this object are only set to default values.
*
@@ -460,6 +536,12 @@ abstract class TaxRuleI18n implements ActiveRecordInterface
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxRuleI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
$this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxRuleI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : TaxRuleI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
$this->resetModified();
$this->setNew(false);
@@ -468,7 +550,7 @@ abstract class TaxRuleI18n implements ActiveRecordInterface
$this->ensureConsistency();
}
- return $startcol + 2; // 2 = TaxRuleI18nTableMap::NUM_HYDRATE_COLUMNS.
+ return $startcol + 4; // 4 = TaxRuleI18nTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\TaxRuleI18n object", 0, $e);
@@ -695,6 +777,12 @@ abstract class TaxRuleI18n implements ActiveRecordInterface
if ($this->isColumnModified(TaxRuleI18nTableMap::LOCALE)) {
$modifiedColumns[':p' . $index++] = 'LOCALE';
}
+ if ($this->isColumnModified(TaxRuleI18nTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(TaxRuleI18nTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
$sql = sprintf(
'INSERT INTO tax_rule_i18n (%s) VALUES (%s)',
@@ -712,6 +800,12 @@ abstract class TaxRuleI18n implements ActiveRecordInterface
case 'LOCALE':
$stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
}
}
$stmt->execute();
@@ -773,6 +867,12 @@ abstract class TaxRuleI18n implements ActiveRecordInterface
case 1:
return $this->getLocale();
break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ break;
default:
return null;
break;
@@ -804,6 +904,8 @@ abstract class TaxRuleI18n implements ActiveRecordInterface
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getLocale(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
);
$virtualColumns = $this->virtualColumns;
foreach($virtualColumns as $key => $virtualColumn)
@@ -855,6 +957,12 @@ abstract class TaxRuleI18n implements ActiveRecordInterface
case 1:
$this->setLocale($value);
break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($value);
+ break;
} // switch()
}
@@ -881,6 +989,8 @@ abstract class TaxRuleI18n implements ActiveRecordInterface
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
}
/**
@@ -894,6 +1004,8 @@ abstract class TaxRuleI18n implements ActiveRecordInterface
if ($this->isColumnModified(TaxRuleI18nTableMap::ID)) $criteria->add(TaxRuleI18nTableMap::ID, $this->id);
if ($this->isColumnModified(TaxRuleI18nTableMap::LOCALE)) $criteria->add(TaxRuleI18nTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(TaxRuleI18nTableMap::TITLE)) $criteria->add(TaxRuleI18nTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(TaxRuleI18nTableMap::DESCRIPTION)) $criteria->add(TaxRuleI18nTableMap::DESCRIPTION, $this->description);
return $criteria;
}
@@ -966,6 +1078,8 @@ abstract class TaxRuleI18n implements ActiveRecordInterface
{
$copyObj->setId($this->getId());
$copyObj->setLocale($this->getLocale());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
if ($makeNew) {
$copyObj->setNew(true);
}
@@ -1051,6 +1165,8 @@ abstract class TaxRuleI18n implements ActiveRecordInterface
{
$this->id = null;
$this->locale = null;
+ $this->title = null;
+ $this->description = null;
$this->alreadyInSave = false;
$this->clearAllReferences();
$this->applyDefaultValues();
diff --git a/core/lib/Thelia/Model/Base/TaxRuleI18nQuery.php b/core/lib/Thelia/Model/Base/TaxRuleI18nQuery.php
index 02667f4ac..dfb3e100c 100644
--- a/core/lib/Thelia/Model/Base/TaxRuleI18nQuery.php
+++ b/core/lib/Thelia/Model/Base/TaxRuleI18nQuery.php
@@ -23,9 +23,13 @@ use Thelia\Model\Map\TaxRuleI18nTableMap;
*
* @method ChildTaxRuleI18nQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildTaxRuleI18nQuery orderByLocale($order = Criteria::ASC) Order by the locale column
+ * @method ChildTaxRuleI18nQuery orderByTitle($order = Criteria::ASC) Order by the title column
+ * @method ChildTaxRuleI18nQuery orderByDescription($order = Criteria::ASC) Order by the description column
*
* @method ChildTaxRuleI18nQuery groupById() Group by the id column
* @method ChildTaxRuleI18nQuery groupByLocale() Group by the locale column
+ * @method ChildTaxRuleI18nQuery groupByTitle() Group by the title column
+ * @method ChildTaxRuleI18nQuery groupByDescription() Group by the description column
*
* @method ChildTaxRuleI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildTaxRuleI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
@@ -40,9 +44,13 @@ use Thelia\Model\Map\TaxRuleI18nTableMap;
*
* @method ChildTaxRuleI18n findOneById(int $id) Return the first ChildTaxRuleI18n filtered by the id column
* @method ChildTaxRuleI18n findOneByLocale(string $locale) Return the first ChildTaxRuleI18n filtered by the locale column
+ * @method ChildTaxRuleI18n findOneByTitle(string $title) Return the first ChildTaxRuleI18n filtered by the title column
+ * @method ChildTaxRuleI18n findOneByDescription(string $description) Return the first ChildTaxRuleI18n filtered by the description column
*
* @method array findById(int $id) Return ChildTaxRuleI18n objects filtered by the id column
* @method array findByLocale(string $locale) Return ChildTaxRuleI18n objects filtered by the locale column
+ * @method array findByTitle(string $title) Return ChildTaxRuleI18n objects filtered by the title column
+ * @method array findByDescription(string $description) Return ChildTaxRuleI18n objects filtered by the description column
*
*/
abstract class TaxRuleI18nQuery extends ModelCriteria
@@ -131,7 +139,7 @@ abstract class TaxRuleI18nQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
- $sql = 'SELECT ID, LOCALE FROM tax_rule_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION FROM tax_rule_i18n WHERE ID = :p0 AND LOCALE = :p1';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
@@ -304,6 +312,64 @@ abstract class TaxRuleI18nQuery extends ModelCriteria
return $this->addUsingAlias(TaxRuleI18nTableMap::LOCALE, $locale, $comparison);
}
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleI18nQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleI18nTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleI18nQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleI18nTableMap::DESCRIPTION, $description, $comparison);
+ }
+
/**
* Filter the query by a related \Thelia\Model\TaxRule object
*
diff --git a/core/lib/Thelia/Model/Base/TaxRuleQuery.php b/core/lib/Thelia/Model/Base/TaxRuleQuery.php
index 2fb478b7a..8ee264415 100644
--- a/core/lib/Thelia/Model/Base/TaxRuleQuery.php
+++ b/core/lib/Thelia/Model/Base/TaxRuleQuery.php
@@ -23,16 +23,10 @@ use Thelia\Model\Map\TaxRuleTableMap;
*
*
* @method ChildTaxRuleQuery orderById($order = Criteria::ASC) Order by the id column
- * @method ChildTaxRuleQuery orderByCode($order = Criteria::ASC) Order by the code column
- * @method ChildTaxRuleQuery orderByTitle($order = Criteria::ASC) Order by the title column
- * @method ChildTaxRuleQuery orderByDescription($order = Criteria::ASC) Order by the description column
* @method ChildTaxRuleQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildTaxRuleQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
* @method ChildTaxRuleQuery groupById() Group by the id column
- * @method ChildTaxRuleQuery groupByCode() Group by the code column
- * @method ChildTaxRuleQuery groupByTitle() Group by the title column
- * @method ChildTaxRuleQuery groupByDescription() Group by the description column
* @method ChildTaxRuleQuery groupByCreatedAt() Group by the created_at column
* @method ChildTaxRuleQuery groupByUpdatedAt() Group by the updated_at column
*
@@ -56,16 +50,10 @@ use Thelia\Model\Map\TaxRuleTableMap;
* @method ChildTaxRule findOneOrCreate(ConnectionInterface $con = null) Return the first ChildTaxRule matching the query, or a new ChildTaxRule object populated from the query conditions when no match is found
*
* @method ChildTaxRule findOneById(int $id) Return the first ChildTaxRule filtered by the id column
- * @method ChildTaxRule findOneByCode(string $code) Return the first ChildTaxRule filtered by the code column
- * @method ChildTaxRule findOneByTitle(string $title) Return the first ChildTaxRule filtered by the title column
- * @method ChildTaxRule findOneByDescription(string $description) Return the first ChildTaxRule filtered by the description column
* @method ChildTaxRule findOneByCreatedAt(string $created_at) Return the first ChildTaxRule filtered by the created_at column
* @method ChildTaxRule findOneByUpdatedAt(string $updated_at) Return the first ChildTaxRule filtered by the updated_at column
*
* @method array findById(int $id) Return ChildTaxRule objects filtered by the id column
- * @method array findByCode(string $code) Return ChildTaxRule objects filtered by the code column
- * @method array findByTitle(string $title) Return ChildTaxRule objects filtered by the title column
- * @method array findByDescription(string $description) Return ChildTaxRule objects filtered by the description column
* @method array findByCreatedAt(string $created_at) Return ChildTaxRule objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildTaxRule objects filtered by the updated_at column
*
@@ -156,7 +144,7 @@ abstract class TaxRuleQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
- $sql = 'SELECT ID, CODE, TITLE, DESCRIPTION, CREATED_AT, UPDATED_AT FROM tax_rule WHERE ID = :p0';
+ $sql = 'SELECT ID, CREATED_AT, UPDATED_AT FROM tax_rule WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -286,93 +274,6 @@ abstract class TaxRuleQuery extends ModelCriteria
return $this->addUsingAlias(TaxRuleTableMap::ID, $id, $comparison);
}
- /**
- * Filter the query on the code column
- *
- * Example usage:
- *
- * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
- * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
- *
- *
- * @param string $code The value to use as filter.
- * Accepts wildcards (* and % trigger a LIKE)
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return ChildTaxRuleQuery The current query, for fluid interface
- */
- public function filterByCode($code = null, $comparison = null)
- {
- if (null === $comparison) {
- if (is_array($code)) {
- $comparison = Criteria::IN;
- } elseif (preg_match('/[\%\*]/', $code)) {
- $code = str_replace('*', '%', $code);
- $comparison = Criteria::LIKE;
- }
- }
-
- return $this->addUsingAlias(TaxRuleTableMap::CODE, $code, $comparison);
- }
-
- /**
- * Filter the query on the title column
- *
- * Example usage:
- *
- * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
- * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
- *
- *
- * @param string $title The value to use as filter.
- * Accepts wildcards (* and % trigger a LIKE)
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return ChildTaxRuleQuery The current query, for fluid interface
- */
- public function filterByTitle($title = null, $comparison = null)
- {
- if (null === $comparison) {
- if (is_array($title)) {
- $comparison = Criteria::IN;
- } elseif (preg_match('/[\%\*]/', $title)) {
- $title = str_replace('*', '%', $title);
- $comparison = Criteria::LIKE;
- }
- }
-
- return $this->addUsingAlias(TaxRuleTableMap::TITLE, $title, $comparison);
- }
-
- /**
- * Filter the query on the description column
- *
- * Example usage:
- *
- * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
- * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
- *
- *
- * @param string $description The value to use as filter.
- * Accepts wildcards (* and % trigger a LIKE)
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return ChildTaxRuleQuery The current query, for fluid interface
- */
- public function filterByDescription($description = null, $comparison = null)
- {
- if (null === $comparison) {
- if (is_array($description)) {
- $comparison = Criteria::IN;
- } elseif (preg_match('/[\%\*]/', $description)) {
- $description = str_replace('*', '%', $description);
- $comparison = Criteria::LIKE;
- }
- }
-
- return $this->addUsingAlias(TaxRuleTableMap::DESCRIPTION, $description, $comparison);
- }
-
/**
* Filter the query on the created_at column
*
@@ -563,7 +464,7 @@ abstract class TaxRuleQuery extends ModelCriteria
*
* @return ChildTaxRuleQuery The current query, for fluid interface
*/
- public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('TaxRuleCountry');
@@ -598,7 +499,7 @@ abstract class TaxRuleQuery extends ModelCriteria
*
* @return \Thelia\Model\TaxRuleCountryQuery A secondary query class using the current class as primary query
*/
- public function useTaxRuleCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ public function useTaxRuleCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinTaxRuleCountry($relationAlias, $joinType)
diff --git a/core/lib/Thelia/Model/Cart.php b/core/lib/Thelia/Model/Cart.php
index 7493546ae..55b697379 100755
--- a/core/lib/Thelia/Model/Cart.php
+++ b/core/lib/Thelia/Model/Cart.php
@@ -71,4 +71,9 @@ class Cart extends BaseCart
->findOne()
;
}
+
+ public function getTaxedAmount()
+ {
+
+ }
}
diff --git a/core/lib/Thelia/Model/Map/TaxRuleCountryTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleCountryTableMap.php
index 42b4e6f59..5282d67fa 100644
--- a/core/lib/Thelia/Model/Map/TaxRuleCountryTableMap.php
+++ b/core/lib/Thelia/Model/Map/TaxRuleCountryTableMap.php
@@ -57,7 +57,7 @@ class TaxRuleCountryTableMap extends TableMap
/**
* The total number of columns
*/
- const NUM_COLUMNS = 7;
+ const NUM_COLUMNS = 6;
/**
* The number of lazy-loaded columns
@@ -67,12 +67,7 @@ class TaxRuleCountryTableMap extends TableMap
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
- const NUM_HYDRATE_COLUMNS = 7;
-
- /**
- * the column name for the ID field
- */
- const ID = 'tax_rule_country.ID';
+ const NUM_HYDRATE_COLUMNS = 6;
/**
* the column name for the TAX_RULE_ID field
@@ -90,9 +85,9 @@ class TaxRuleCountryTableMap extends TableMap
const TAX_ID = 'tax_rule_country.TAX_ID';
/**
- * the column name for the NONE field
+ * the column name for the POSITION field
*/
- const NONE = 'tax_rule_country.NONE';
+ const POSITION = 'tax_rule_country.POSITION';
/**
* the column name for the CREATED_AT field
@@ -116,12 +111,12 @@ class TaxRuleCountryTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
- self::TYPE_PHPNAME => array('Id', 'TaxRuleId', 'CountryId', 'TaxId', 'None', 'CreatedAt', 'UpdatedAt', ),
- self::TYPE_STUDLYPHPNAME => array('id', 'taxRuleId', 'countryId', 'taxId', 'none', 'createdAt', 'updatedAt', ),
- self::TYPE_COLNAME => array(TaxRuleCountryTableMap::ID, TaxRuleCountryTableMap::TAX_RULE_ID, TaxRuleCountryTableMap::COUNTRY_ID, TaxRuleCountryTableMap::TAX_ID, TaxRuleCountryTableMap::NONE, TaxRuleCountryTableMap::CREATED_AT, TaxRuleCountryTableMap::UPDATED_AT, ),
- self::TYPE_RAW_COLNAME => array('ID', 'TAX_RULE_ID', 'COUNTRY_ID', 'TAX_ID', 'NONE', 'CREATED_AT', 'UPDATED_AT', ),
- self::TYPE_FIELDNAME => array('id', 'tax_rule_id', 'country_id', 'tax_id', 'none', 'created_at', 'updated_at', ),
- self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
+ self::TYPE_PHPNAME => array('TaxRuleId', 'CountryId', 'TaxId', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('taxRuleId', 'countryId', 'taxId', 'position', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(TaxRuleCountryTableMap::TAX_RULE_ID, TaxRuleCountryTableMap::COUNTRY_ID, TaxRuleCountryTableMap::TAX_ID, TaxRuleCountryTableMap::POSITION, TaxRuleCountryTableMap::CREATED_AT, TaxRuleCountryTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('TAX_RULE_ID', 'COUNTRY_ID', 'TAX_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('tax_rule_id', 'country_id', 'tax_id', 'position', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
);
/**
@@ -131,12 +126,12 @@ class TaxRuleCountryTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
- self::TYPE_PHPNAME => array('Id' => 0, 'TaxRuleId' => 1, 'CountryId' => 2, 'TaxId' => 3, 'None' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
- self::TYPE_STUDLYPHPNAME => array('id' => 0, 'taxRuleId' => 1, 'countryId' => 2, 'taxId' => 3, 'none' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
- self::TYPE_COLNAME => array(TaxRuleCountryTableMap::ID => 0, TaxRuleCountryTableMap::TAX_RULE_ID => 1, TaxRuleCountryTableMap::COUNTRY_ID => 2, TaxRuleCountryTableMap::TAX_ID => 3, TaxRuleCountryTableMap::NONE => 4, TaxRuleCountryTableMap::CREATED_AT => 5, TaxRuleCountryTableMap::UPDATED_AT => 6, ),
- self::TYPE_RAW_COLNAME => array('ID' => 0, 'TAX_RULE_ID' => 1, 'COUNTRY_ID' => 2, 'TAX_ID' => 3, 'NONE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
- self::TYPE_FIELDNAME => array('id' => 0, 'tax_rule_id' => 1, 'country_id' => 2, 'tax_id' => 3, 'none' => 4, 'created_at' => 5, 'updated_at' => 6, ),
- self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
+ self::TYPE_PHPNAME => array('TaxRuleId' => 0, 'CountryId' => 1, 'TaxId' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('taxRuleId' => 0, 'countryId' => 1, 'taxId' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
+ self::TYPE_COLNAME => array(TaxRuleCountryTableMap::TAX_RULE_ID => 0, TaxRuleCountryTableMap::COUNTRY_ID => 1, TaxRuleCountryTableMap::TAX_ID => 2, TaxRuleCountryTableMap::POSITION => 3, TaxRuleCountryTableMap::CREATED_AT => 4, TaxRuleCountryTableMap::UPDATED_AT => 5, ),
+ self::TYPE_RAW_COLNAME => array('TAX_RULE_ID' => 0, 'COUNTRY_ID' => 1, 'TAX_ID' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
+ self::TYPE_FIELDNAME => array('tax_rule_id' => 0, 'country_id' => 1, 'tax_id' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
);
/**
@@ -155,11 +150,10 @@ class TaxRuleCountryTableMap extends TableMap
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(false);
// columns
- $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addForeignKey('TAX_RULE_ID', 'TaxRuleId', 'INTEGER', 'tax_rule', 'ID', false, null, null);
- $this->addForeignKey('COUNTRY_ID', 'CountryId', 'INTEGER', 'country', 'ID', false, null, null);
- $this->addForeignKey('TAX_ID', 'TaxId', 'INTEGER', 'tax', 'ID', false, null, null);
- $this->addColumn('NONE', 'None', 'TINYINT', false, null, null);
+ $this->addForeignPrimaryKey('TAX_RULE_ID', 'TaxRuleId', 'INTEGER' , 'tax_rule', 'ID', true, null, null);
+ $this->addForeignPrimaryKey('COUNTRY_ID', 'CountryId', 'INTEGER' , 'country', 'ID', true, null, null);
+ $this->addForeignPrimaryKey('TAX_ID', 'TaxId', 'INTEGER' , 'tax', 'ID', true, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize()
@@ -169,7 +163,7 @@ class TaxRuleCountryTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Tax', '\\Thelia\\Model\\Tax', RelationMap::MANY_TO_ONE, array('tax_id' => 'id', ), 'SET NULL', 'RESTRICT');
+ $this->addRelation('Tax', '\\Thelia\\Model\\Tax', RelationMap::MANY_TO_ONE, array('tax_id' => 'id', ), 'CASCADE', 'RESTRICT');
$this->addRelation('TaxRule', '\\Thelia\\Model\\TaxRule', RelationMap::MANY_TO_ONE, array('tax_rule_id' => 'id', ), 'CASCADE', 'RESTRICT');
$this->addRelation('Country', '\\Thelia\\Model\\Country', RelationMap::MANY_TO_ONE, array('country_id' => 'id', ), 'CASCADE', 'RESTRICT');
} // buildRelations()
@@ -187,6 +181,59 @@ class TaxRuleCountryTableMap extends TableMap
);
} // getBehaviors()
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\TaxRuleCountry $obj A \Thelia\Model\TaxRuleCountry object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getTaxRuleId(), (string) $obj->getCountryId(), (string) $obj->getTaxId()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\TaxRuleCountry object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\TaxRuleCountry) {
+ $key = serialize(array((string) $value->getTaxRuleId(), (string) $value->getCountryId(), (string) $value->getTaxId()));
+
+ } elseif (is_array($value) && count($value) === 3) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1], (string) $value[2]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\TaxRuleCountry object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
@@ -201,11 +248,11 @@ class TaxRuleCountryTableMap extends TableMap
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
// If the PK cannot be derived from the row, return NULL.
- if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('TaxRuleId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('CountryId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('TaxId', TableMap::TYPE_PHPNAME, $indexType)] === null) {
return null;
}
- return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('TaxRuleId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('CountryId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('TaxId', TableMap::TYPE_PHPNAME, $indexType)]));
}
/**
@@ -223,11 +270,7 @@ class TaxRuleCountryTableMap extends TableMap
public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
- return (int) $row[
- $indexType == TableMap::TYPE_NUM
- ? 0 + $offset
- : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
- ];
+ return $pks;
}
/**
@@ -325,19 +368,17 @@ class TaxRuleCountryTableMap extends TableMap
public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
- $criteria->addSelectColumn(TaxRuleCountryTableMap::ID);
$criteria->addSelectColumn(TaxRuleCountryTableMap::TAX_RULE_ID);
$criteria->addSelectColumn(TaxRuleCountryTableMap::COUNTRY_ID);
$criteria->addSelectColumn(TaxRuleCountryTableMap::TAX_ID);
- $criteria->addSelectColumn(TaxRuleCountryTableMap::NONE);
+ $criteria->addSelectColumn(TaxRuleCountryTableMap::POSITION);
$criteria->addSelectColumn(TaxRuleCountryTableMap::CREATED_AT);
$criteria->addSelectColumn(TaxRuleCountryTableMap::UPDATED_AT);
} else {
- $criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.TAX_RULE_ID');
$criteria->addSelectColumn($alias . '.COUNTRY_ID');
$criteria->addSelectColumn($alias . '.TAX_ID');
- $criteria->addSelectColumn($alias . '.NONE');
+ $criteria->addSelectColumn($alias . '.POSITION');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
}
@@ -391,7 +432,18 @@ class TaxRuleCountryTableMap extends TableMap
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(TaxRuleCountryTableMap::DATABASE_NAME);
- $criteria->add(TaxRuleCountryTableMap::ID, (array) $values, Criteria::IN);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(TaxRuleCountryTableMap::TAX_RULE_ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(TaxRuleCountryTableMap::COUNTRY_ID, $value[1]));
+ $criterion->addAnd($criteria->getNewCriterion(TaxRuleCountryTableMap::TAX_ID, $value[2]));
+ $criteria->addOr($criterion);
+ }
}
$query = TaxRuleCountryQuery::create()->mergeWith($criteria);
diff --git a/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php
index 1f0ed1e96..012ad2e72 100644
--- a/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php
+++ b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php
@@ -57,7 +57,7 @@ class TaxRuleI18nTableMap extends TableMap
/**
* The total number of columns
*/
- const NUM_COLUMNS = 2;
+ const NUM_COLUMNS = 4;
/**
* The number of lazy-loaded columns
@@ -67,7 +67,7 @@ class TaxRuleI18nTableMap extends TableMap
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
- const NUM_HYDRATE_COLUMNS = 2;
+ const NUM_HYDRATE_COLUMNS = 4;
/**
* the column name for the ID field
@@ -79,6 +79,16 @@ class TaxRuleI18nTableMap extends TableMap
*/
const LOCALE = 'tax_rule_i18n.LOCALE';
+ /**
+ * the column name for the TITLE field
+ */
+ const TITLE = 'tax_rule_i18n.TITLE';
+
+ /**
+ * the column name for the DESCRIPTION field
+ */
+ const DESCRIPTION = 'tax_rule_i18n.DESCRIPTION';
+
/**
* The default string format for model objects of the related table
*/
@@ -91,12 +101,12 @@ class TaxRuleI18nTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
- self::TYPE_PHPNAME => array('Id', 'Locale', ),
- self::TYPE_STUDLYPHPNAME => array('id', 'locale', ),
- self::TYPE_COLNAME => array(TaxRuleI18nTableMap::ID, TaxRuleI18nTableMap::LOCALE, ),
- self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', ),
- self::TYPE_FIELDNAME => array('id', 'locale', ),
- self::TYPE_NUM => array(0, 1, )
+ self::TYPE_PHPNAME => array('Id', 'Locale', 'Title', 'Description', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', ),
+ self::TYPE_COLNAME => array(TaxRuleI18nTableMap::ID, TaxRuleI18nTableMap::LOCALE, TaxRuleI18nTableMap::TITLE, TaxRuleI18nTableMap::DESCRIPTION, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
);
/**
@@ -106,12 +116,12 @@ class TaxRuleI18nTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
- self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, ),
- self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, ),
- self::TYPE_COLNAME => array(TaxRuleI18nTableMap::ID => 0, TaxRuleI18nTableMap::LOCALE => 1, ),
- self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, ),
- self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, ),
- self::TYPE_NUM => array(0, 1, )
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, ),
+ self::TYPE_COLNAME => array(TaxRuleI18nTableMap::ID => 0, TaxRuleI18nTableMap::LOCALE => 1, TaxRuleI18nTableMap::TITLE => 2, TaxRuleI18nTableMap::DESCRIPTION => 3, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
);
/**
@@ -132,6 +142,8 @@ class TaxRuleI18nTableMap extends TableMap
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax_rule', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
} // initialize()
/**
@@ -331,9 +343,13 @@ class TaxRuleI18nTableMap extends TableMap
if (null === $alias) {
$criteria->addSelectColumn(TaxRuleI18nTableMap::ID);
$criteria->addSelectColumn(TaxRuleI18nTableMap::LOCALE);
+ $criteria->addSelectColumn(TaxRuleI18nTableMap::TITLE);
+ $criteria->addSelectColumn(TaxRuleI18nTableMap::DESCRIPTION);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
}
}
diff --git a/core/lib/Thelia/Model/Map/TaxRuleTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleTableMap.php
index cc5f628b9..391e23b6d 100644
--- a/core/lib/Thelia/Model/Map/TaxRuleTableMap.php
+++ b/core/lib/Thelia/Model/Map/TaxRuleTableMap.php
@@ -57,7 +57,7 @@ class TaxRuleTableMap extends TableMap
/**
* The total number of columns
*/
- const NUM_COLUMNS = 6;
+ const NUM_COLUMNS = 3;
/**
* The number of lazy-loaded columns
@@ -67,28 +67,13 @@ class TaxRuleTableMap extends TableMap
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
- const NUM_HYDRATE_COLUMNS = 6;
+ const NUM_HYDRATE_COLUMNS = 3;
/**
* the column name for the ID field
*/
const ID = 'tax_rule.ID';
- /**
- * the column name for the CODE field
- */
- const CODE = 'tax_rule.CODE';
-
- /**
- * the column name for the TITLE field
- */
- const TITLE = 'tax_rule.TITLE';
-
- /**
- * the column name for the DESCRIPTION field
- */
- const DESCRIPTION = 'tax_rule.DESCRIPTION';
-
/**
* the column name for the CREATED_AT field
*/
@@ -120,12 +105,12 @@ class TaxRuleTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
- self::TYPE_PHPNAME => array('Id', 'Code', 'Title', 'Description', 'CreatedAt', 'UpdatedAt', ),
- self::TYPE_STUDLYPHPNAME => array('id', 'code', 'title', 'description', 'createdAt', 'updatedAt', ),
- self::TYPE_COLNAME => array(TaxRuleTableMap::ID, TaxRuleTableMap::CODE, TaxRuleTableMap::TITLE, TaxRuleTableMap::DESCRIPTION, TaxRuleTableMap::CREATED_AT, TaxRuleTableMap::UPDATED_AT, ),
- self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TITLE', 'DESCRIPTION', 'CREATED_AT', 'UPDATED_AT', ),
- self::TYPE_FIELDNAME => array('id', 'code', 'title', 'description', 'created_at', 'updated_at', ),
- self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ self::TYPE_PHPNAME => array('Id', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(TaxRuleTableMap::ID, TaxRuleTableMap::CREATED_AT, TaxRuleTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, )
);
/**
@@ -135,12 +120,12 @@ class TaxRuleTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
- self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Title' => 2, 'Description' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
- self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'title' => 2, 'description' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
- self::TYPE_COLNAME => array(TaxRuleTableMap::ID => 0, TaxRuleTableMap::CODE => 1, TaxRuleTableMap::TITLE => 2, TaxRuleTableMap::DESCRIPTION => 3, TaxRuleTableMap::CREATED_AT => 4, TaxRuleTableMap::UPDATED_AT => 5, ),
- self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
- self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'title' => 2, 'description' => 3, 'created_at' => 4, 'updated_at' => 5, ),
- self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ self::TYPE_PHPNAME => array('Id' => 0, 'CreatedAt' => 1, 'UpdatedAt' => 2, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'createdAt' => 1, 'updatedAt' => 2, ),
+ self::TYPE_COLNAME => array(TaxRuleTableMap::ID => 0, TaxRuleTableMap::CREATED_AT => 1, TaxRuleTableMap::UPDATED_AT => 2, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'CREATED_AT' => 1, 'UPDATED_AT' => 2, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'created_at' => 1, 'updated_at' => 2, ),
+ self::TYPE_NUM => array(0, 1, 2, )
);
/**
@@ -160,9 +145,6 @@ class TaxRuleTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
- $this->addColumn('CODE', 'Code', 'VARCHAR', false, 45, null);
- $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
- $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize()
@@ -187,7 +169,7 @@ class TaxRuleTableMap extends TableMap
{
return array(
'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
- 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => '', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
);
} // getBehaviors()
/**
@@ -341,16 +323,10 @@ class TaxRuleTableMap extends TableMap
{
if (null === $alias) {
$criteria->addSelectColumn(TaxRuleTableMap::ID);
- $criteria->addSelectColumn(TaxRuleTableMap::CODE);
- $criteria->addSelectColumn(TaxRuleTableMap::TITLE);
- $criteria->addSelectColumn(TaxRuleTableMap::DESCRIPTION);
$criteria->addSelectColumn(TaxRuleTableMap::CREATED_AT);
$criteria->addSelectColumn(TaxRuleTableMap::UPDATED_AT);
} else {
$criteria->addSelectColumn($alias . '.ID');
- $criteria->addSelectColumn($alias . '.CODE');
- $criteria->addSelectColumn($alias . '.TITLE');
- $criteria->addSelectColumn($alias . '.DESCRIPTION');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
}
diff --git a/core/lib/Thelia/Model/Map/TaxTableMap.php b/core/lib/Thelia/Model/Map/TaxTableMap.php
index 6d43f20e9..11e5047ce 100644
--- a/core/lib/Thelia/Model/Map/TaxTableMap.php
+++ b/core/lib/Thelia/Model/Map/TaxTableMap.php
@@ -160,7 +160,7 @@ class TaxTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('TaxRuleCountry', '\\Thelia\\Model\\TaxRuleCountry', RelationMap::ONE_TO_MANY, array('id' => 'tax_id', ), 'SET NULL', 'RESTRICT', 'TaxRuleCountries');
+ $this->addRelation('TaxRuleCountry', '\\Thelia\\Model\\TaxRuleCountry', RelationMap::ONE_TO_MANY, array('id' => 'tax_id', ), 'CASCADE', 'RESTRICT', 'TaxRuleCountries');
$this->addRelation('TaxI18n', '\\Thelia\\Model\\TaxI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'TaxI18ns');
} // buildRelations()
diff --git a/core/lib/Thelia/Model/Product.php b/core/lib/Thelia/Model/Product.php
index 6c7ffbe44..06c4640d0 100755
--- a/core/lib/Thelia/Model/Product.php
+++ b/core/lib/Thelia/Model/Product.php
@@ -2,8 +2,10 @@
namespace Thelia\Model;
+use Propel\Runtime\Exception\PropelException;
use Thelia\Model\Base\Product as BaseProduct;
use Thelia\Tools\URL;
+use Thelia\TaxEngine\Calculator;
class Product extends BaseProduct
{
@@ -11,4 +13,21 @@ class Product extends BaseProduct
{
return URL::getInstance()->retrieve('product', $this->getId(), $locale)->toString();
}
+
+ public function getRealLowestPrice($virtualColumnName = 'real_lowest_price')
+ {
+ try {
+ $amount = $this->getVirtualColumn($virtualColumnName);
+ } catch(PropelException $e) {
+ throw new PropelException("Virtual column `$virtualColumnName` does not exist in Product::getRealLowestPrice");
+ }
+
+ return $amount;
+ }
+
+ public function getTaxedPrice(Country $country)
+ {
+ $taxCalculator = new Calculator();
+ return $taxCalculator->load($this, $country)->getTaxedPrice($this->getRealLowestPrice());
+ }
}
diff --git a/core/lib/Thelia/Model/ProductSaleElements.php b/core/lib/Thelia/Model/ProductSaleElements.php
index cec9c49a7..184e37d0a 100755
--- a/core/lib/Thelia/Model/ProductSaleElements.php
+++ b/core/lib/Thelia/Model/ProductSaleElements.php
@@ -3,8 +3,41 @@
namespace Thelia\Model;
use Thelia\Model\Base\ProductSaleElements as BaseProductSaleElements;
+use Thelia\TaxEngine\Calculator;
- class ProductSaleElements extends BaseProductSaleElements
+class ProductSaleElements extends BaseProductSaleElements
{
+ public function getPrice($virtualColumnName = 'price_PRICE')
+ {
+ try {
+ $amount = $this->getVirtualColumn($virtualColumnName);
+ } catch(PropelException $e) {
+ throw new PropelException("Virtual column `$virtualColumnName` does not exist in ProductSaleElements::getPrice");
+ }
+ return $amount;
+ }
+
+ public function getPromoPrice($virtualColumnName = 'price_PROMO_PRICE')
+ {
+ try {
+ $amount = $this->getVirtualColumn($virtualColumnName);
+ } catch(PropelException $e) {
+ throw new PropelException("Virtual column `$virtualColumnName` does not exist in ProductSaleElements::getPromoPrice");
+ }
+
+ return $amount;
+ }
+
+ public function getTaxedPrice(Country $country)
+ {
+ $taxCalculator = new Calculator();
+ return $taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPrice());
+ }
+
+ public function getTaxedPromoPrice(Country $country)
+ {
+ $taxCalculator = new Calculator();
+ return $taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPromoPrice());
+ }
}
diff --git a/core/lib/Thelia/Model/Tax.php b/core/lib/Thelia/Model/Tax.php
index ed61876ae..21efbae6a 100755
--- a/core/lib/Thelia/Model/Tax.php
+++ b/core/lib/Thelia/Model/Tax.php
@@ -2,8 +2,45 @@
namespace Thelia\Model;
+use Thelia\Exception\TaxEngineException;
use Thelia\Model\Base\Tax as BaseTax;
-class Tax extends BaseTax {
+class Tax extends BaseTax
+{
+ public function calculateTax($amount)
+ {
+ if(false === filter_var($amount, FILTER_VALIDATE_FLOAT)) {
+ throw new TaxEngineException('BAD AMOUNT FORMAT', TaxEngineException::BAD_AMOUNT_FORMAT);
+ }
+ $rate = $this->getRate();
+
+ if($rate === null) {
+ return 0;
+ }
+
+ return $amount * $rate * 0.01;
+ }
+
+ public function getTaxRuleCountryPosition()
+ {
+ try {
+ $taxRuleCountryPosition = $this->getVirtualColumn(TaxRuleQuery::ALIAS_FOR_TAX_RULE_COUNTRY_POSITION);
+ } catch(PropelException $e) {
+ throw new PropelException("Virtual column `" . TaxRuleQuery::ALIAS_FOR_TAX_RULE_COUNTRY_POSITION . "` does not exist in Tax::getTaxRuleCountryPosition");
+ }
+
+ return $taxRuleCountryPosition;
+ }
+
+ public function getTaxRuleRateSum()
+ {
+ try {
+ $taxRuleRateSum = $this->getVirtualColumn(TaxRuleQuery::ALIAS_FOR_TAX_RATE_SUM);
+ } catch(PropelException $e) {
+ throw new PropelException("Virtual column `" . TaxRuleQuery::ALIAS_FOR_TAX_RATE_SUM . "` does not exist in Tax::getTaxRuleRateSum");
+ }
+
+ return $taxRuleRateSum;
+ }
}
diff --git a/core/lib/Thelia/Model/TaxRuleQuery.php b/core/lib/Thelia/Model/TaxRuleQuery.php
index 8cb79562d..f9c6cf1e5 100755
--- a/core/lib/Thelia/Model/TaxRuleQuery.php
+++ b/core/lib/Thelia/Model/TaxRuleQuery.php
@@ -2,8 +2,10 @@
namespace Thelia\Model;
+use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Model\Base\TaxRuleQuery as BaseTaxRuleQuery;
-
+use Thelia\Model\Map\TaxRuleCountryTableMap;
+use Thelia\Model\Map\TaxTableMap;
/**
* Skeleton subclass for performing query and update operations on the 'tax_rule' table.
@@ -15,6 +17,26 @@ use Thelia\Model\Base\TaxRuleQuery as BaseTaxRuleQuery;
* long as it does not already exist in the output directory.
*
*/
-class TaxRuleQuery extends BaseTaxRuleQuery {
+class TaxRuleQuery extends BaseTaxRuleQuery
+{
+ const ALIAS_FOR_TAX_RULE_COUNTRY_POSITION = 'taxRuleCountryPosition';
+ const ALIAS_FOR_TAX_RATE_SUM = 'taxRateSum';
+ public function getTaxCalculatorGroupedCollection(Product $product, Country $country)
+ {
+ $search = TaxQuery::create()
+ ->filterByTaxRuleCountry(
+ TaxRuleCountryQuery::create()
+ ->filterByCountry($country, Criteria::EQUAL)
+ ->filterByTaxRuleId($product->getTaxRuleId())
+ ->groupByPosition()
+ ->orderByPosition()
+ ->find()
+ )
+ ->withColumn(TaxRuleCountryTableMap::POSITION, self::ALIAS_FOR_TAX_RULE_COUNTRY_POSITION)
+ ->withColumn('ROUND(SUM(' . TaxTableMap::RATE . '), 2)', self::ALIAS_FOR_TAX_RATE_SUM)
+ ;
+
+ return $search->find();
+ }
} // TaxRuleQuery
diff --git a/core/lib/Thelia/TaxEngine/Calculator.php b/core/lib/Thelia/TaxEngine/Calculator.php
new file mode 100755
index 000000000..66c4fcbbf
--- /dev/null
+++ b/core/lib/Thelia/TaxEngine/Calculator.php
@@ -0,0 +1,95 @@
+. */
+/* */
+/*************************************************************************************/
+namespace Thelia\TaxEngine;
+
+use Thelia\Exception\TaxEngineException;
+use Thelia\Model\Country;
+use Thelia\Model\Product;
+use Thelia\Model\TaxRuleQuery;
+
+/**
+ * Class Calculator
+ * @package Thelia\TaxEngine
+ * @author Etienne Roudeix > Racine | *}
+ {*
| Categories list | *} + {*
|---|
| *} + {* |
#DESCRIPTION
+Starting by #BEST_PRICE € HT (TAX : #BEST_PRICE_TAX ; #BEST_TAXED_PRICE € TTC)
+ {ifloop rel="ft"}#DESCRIPTION
+Starting by #BEST_PRICE € HT (TAX : #BEST_PRICE_TAX ; #BEST_TAXED_PRICE € TTC)
+ {ifloop rel="acc"}