tax engine
This commit is contained in:
@@ -66,10 +66,16 @@ abstract class Tax implements ActiveRecordInterface
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* The value for the rate field.
|
||||
* @var double
|
||||
* The value for the type field.
|
||||
* @var string
|
||||
*/
|
||||
protected $rate;
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* The value for the serialized_requirements field.
|
||||
* @var string
|
||||
*/
|
||||
protected $serialized_requirements;
|
||||
|
||||
/**
|
||||
* The value for the created_at field.
|
||||
@@ -395,14 +401,25 @@ abstract class Tax implements ActiveRecordInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [rate] column value.
|
||||
* Get the [type] column value.
|
||||
*
|
||||
* @return double
|
||||
* @return string
|
||||
*/
|
||||
public function getRate()
|
||||
public function getType()
|
||||
{
|
||||
|
||||
return $this->rate;
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [serialized_requirements] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSerializedRequirements()
|
||||
{
|
||||
|
||||
return $this->serialized_requirements;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -467,25 +484,46 @@ abstract class Tax implements ActiveRecordInterface
|
||||
} // setId()
|
||||
|
||||
/**
|
||||
* Set the value of [rate] column.
|
||||
* Set the value of [type] column.
|
||||
*
|
||||
* @param double $v new value
|
||||
* @param string $v new value
|
||||
* @return \Thelia\Model\Tax The current object (for fluent API support)
|
||||
*/
|
||||
public function setRate($v)
|
||||
public function setType($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (double) $v;
|
||||
$v = (string) $v;
|
||||
}
|
||||
|
||||
if ($this->rate !== $v) {
|
||||
$this->rate = $v;
|
||||
$this->modifiedColumns[] = TaxTableMap::RATE;
|
||||
if ($this->type !== $v) {
|
||||
$this->type = $v;
|
||||
$this->modifiedColumns[] = TaxTableMap::TYPE;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
} // setRate()
|
||||
} // setType()
|
||||
|
||||
/**
|
||||
* Set the value of [serialized_requirements] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return \Thelia\Model\Tax The current object (for fluent API support)
|
||||
*/
|
||||
public function setSerializedRequirements($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (string) $v;
|
||||
}
|
||||
|
||||
if ($this->serialized_requirements !== $v) {
|
||||
$this->serialized_requirements = $v;
|
||||
$this->modifiedColumns[] = TaxTableMap::SERIALIZED_REQUIREMENTS;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
} // setSerializedRequirements()
|
||||
|
||||
/**
|
||||
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
|
||||
@@ -569,16 +607,19 @@ abstract class Tax implements ActiveRecordInterface
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : TaxTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->id = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxTableMap::translateFieldName('Rate', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->rate = (null !== $col) ? (double) $col : null;
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxTableMap::translateFieldName('Type', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->type = (null !== $col) ? (string) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxTableMap::translateFieldName('SerializedRequirements', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->serialized_requirements = (null !== $col) ? (string) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : TaxTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : TaxTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : TaxTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
@@ -591,7 +632,7 @@ abstract class Tax implements ActiveRecordInterface
|
||||
$this->ensureConsistency();
|
||||
}
|
||||
|
||||
return $startcol + 4; // 4 = TaxTableMap::NUM_HYDRATE_COLUMNS.
|
||||
return $startcol + 5; // 5 = TaxTableMap::NUM_HYDRATE_COLUMNS.
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating \Thelia\Model\Tax object", 0, $e);
|
||||
@@ -852,8 +893,11 @@ abstract class Tax implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(TaxTableMap::ID)) {
|
||||
$modifiedColumns[':p' . $index++] = 'ID';
|
||||
}
|
||||
if ($this->isColumnModified(TaxTableMap::RATE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'RATE';
|
||||
if ($this->isColumnModified(TaxTableMap::TYPE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'TYPE';
|
||||
}
|
||||
if ($this->isColumnModified(TaxTableMap::SERIALIZED_REQUIREMENTS)) {
|
||||
$modifiedColumns[':p' . $index++] = 'SERIALIZED_REQUIREMENTS';
|
||||
}
|
||||
if ($this->isColumnModified(TaxTableMap::CREATED_AT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
|
||||
@@ -875,8 +919,11 @@ abstract class Tax implements ActiveRecordInterface
|
||||
case 'ID':
|
||||
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'RATE':
|
||||
$stmt->bindValue($identifier, $this->rate, PDO::PARAM_STR);
|
||||
case 'TYPE':
|
||||
$stmt->bindValue($identifier, $this->type, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'SERIALIZED_REQUIREMENTS':
|
||||
$stmt->bindValue($identifier, $this->serialized_requirements, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'CREATED_AT':
|
||||
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
|
||||
@@ -950,12 +997,15 @@ abstract class Tax implements ActiveRecordInterface
|
||||
return $this->getId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getRate();
|
||||
return $this->getType();
|
||||
break;
|
||||
case 2:
|
||||
return $this->getCreatedAt();
|
||||
return $this->getSerializedRequirements();
|
||||
break;
|
||||
case 3:
|
||||
return $this->getCreatedAt();
|
||||
break;
|
||||
case 4:
|
||||
return $this->getUpdatedAt();
|
||||
break;
|
||||
default:
|
||||
@@ -988,9 +1038,10 @@ abstract class Tax implements ActiveRecordInterface
|
||||
$keys = TaxTableMap::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getId(),
|
||||
$keys[1] => $this->getRate(),
|
||||
$keys[2] => $this->getCreatedAt(),
|
||||
$keys[3] => $this->getUpdatedAt(),
|
||||
$keys[1] => $this->getType(),
|
||||
$keys[2] => $this->getSerializedRequirements(),
|
||||
$keys[3] => $this->getCreatedAt(),
|
||||
$keys[4] => $this->getUpdatedAt(),
|
||||
);
|
||||
$virtualColumns = $this->virtualColumns;
|
||||
foreach($virtualColumns as $key => $virtualColumn)
|
||||
@@ -1043,12 +1094,15 @@ abstract class Tax implements ActiveRecordInterface
|
||||
$this->setId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setRate($value);
|
||||
$this->setType($value);
|
||||
break;
|
||||
case 2:
|
||||
$this->setCreatedAt($value);
|
||||
$this->setSerializedRequirements($value);
|
||||
break;
|
||||
case 3:
|
||||
$this->setCreatedAt($value);
|
||||
break;
|
||||
case 4:
|
||||
$this->setUpdatedAt($value);
|
||||
break;
|
||||
} // switch()
|
||||
@@ -1076,9 +1130,10 @@ abstract class Tax implements ActiveRecordInterface
|
||||
$keys = TaxTableMap::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setRate($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setType($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setSerializedRequirements($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
|
||||
if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1091,7 +1146,8 @@ abstract class Tax implements ActiveRecordInterface
|
||||
$criteria = new Criteria(TaxTableMap::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(TaxTableMap::ID)) $criteria->add(TaxTableMap::ID, $this->id);
|
||||
if ($this->isColumnModified(TaxTableMap::RATE)) $criteria->add(TaxTableMap::RATE, $this->rate);
|
||||
if ($this->isColumnModified(TaxTableMap::TYPE)) $criteria->add(TaxTableMap::TYPE, $this->type);
|
||||
if ($this->isColumnModified(TaxTableMap::SERIALIZED_REQUIREMENTS)) $criteria->add(TaxTableMap::SERIALIZED_REQUIREMENTS, $this->serialized_requirements);
|
||||
if ($this->isColumnModified(TaxTableMap::CREATED_AT)) $criteria->add(TaxTableMap::CREATED_AT, $this->created_at);
|
||||
if ($this->isColumnModified(TaxTableMap::UPDATED_AT)) $criteria->add(TaxTableMap::UPDATED_AT, $this->updated_at);
|
||||
|
||||
@@ -1157,7 +1213,8 @@ abstract class Tax implements ActiveRecordInterface
|
||||
*/
|
||||
public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
|
||||
{
|
||||
$copyObj->setRate($this->getRate());
|
||||
$copyObj->setType($this->getType());
|
||||
$copyObj->setSerializedRequirements($this->getSerializedRequirements());
|
||||
$copyObj->setCreatedAt($this->getCreatedAt());
|
||||
$copyObj->setUpdatedAt($this->getUpdatedAt());
|
||||
|
||||
@@ -1729,7 +1786,8 @@ abstract class Tax implements ActiveRecordInterface
|
||||
public function clear()
|
||||
{
|
||||
$this->id = null;
|
||||
$this->rate = null;
|
||||
$this->type = null;
|
||||
$this->serialized_requirements = null;
|
||||
$this->created_at = null;
|
||||
$this->updated_at = null;
|
||||
$this->alreadyInSave = false;
|
||||
|
||||
@@ -23,12 +23,14 @@ use Thelia\Model\Map\TaxTableMap;
|
||||
*
|
||||
*
|
||||
* @method ChildTaxQuery orderById($order = Criteria::ASC) Order by the id column
|
||||
* @method ChildTaxQuery orderByRate($order = Criteria::ASC) Order by the rate column
|
||||
* @method ChildTaxQuery orderByType($order = Criteria::ASC) Order by the type column
|
||||
* @method ChildTaxQuery orderBySerializedRequirements($order = Criteria::ASC) Order by the serialized_requirements column
|
||||
* @method ChildTaxQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
|
||||
* @method ChildTaxQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
|
||||
*
|
||||
* @method ChildTaxQuery groupById() Group by the id column
|
||||
* @method ChildTaxQuery groupByRate() Group by the rate column
|
||||
* @method ChildTaxQuery groupByType() Group by the type column
|
||||
* @method ChildTaxQuery groupBySerializedRequirements() Group by the serialized_requirements column
|
||||
* @method ChildTaxQuery groupByCreatedAt() Group by the created_at column
|
||||
* @method ChildTaxQuery groupByUpdatedAt() Group by the updated_at column
|
||||
*
|
||||
@@ -48,12 +50,14 @@ use Thelia\Model\Map\TaxTableMap;
|
||||
* @method ChildTax findOneOrCreate(ConnectionInterface $con = null) Return the first ChildTax matching the query, or a new ChildTax object populated from the query conditions when no match is found
|
||||
*
|
||||
* @method ChildTax findOneById(int $id) Return the first ChildTax filtered by the id column
|
||||
* @method ChildTax findOneByRate(double $rate) Return the first ChildTax filtered by the rate column
|
||||
* @method ChildTax findOneByType(string $type) Return the first ChildTax filtered by the type column
|
||||
* @method ChildTax findOneBySerializedRequirements(string $serialized_requirements) Return the first ChildTax filtered by the serialized_requirements column
|
||||
* @method ChildTax findOneByCreatedAt(string $created_at) Return the first ChildTax filtered by the created_at column
|
||||
* @method ChildTax findOneByUpdatedAt(string $updated_at) Return the first ChildTax filtered by the updated_at column
|
||||
*
|
||||
* @method array findById(int $id) Return ChildTax objects filtered by the id column
|
||||
* @method array findByRate(double $rate) Return ChildTax objects filtered by the rate column
|
||||
* @method array findByType(string $type) Return ChildTax objects filtered by the type column
|
||||
* @method array findBySerializedRequirements(string $serialized_requirements) Return ChildTax objects filtered by the serialized_requirements column
|
||||
* @method array findByCreatedAt(string $created_at) Return ChildTax objects filtered by the created_at column
|
||||
* @method array findByUpdatedAt(string $updated_at) Return ChildTax objects filtered by the updated_at column
|
||||
*
|
||||
@@ -144,7 +148,7 @@ abstract class TaxQuery extends ModelCriteria
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, RATE, CREATED_AT, UPDATED_AT FROM tax WHERE ID = :p0';
|
||||
$sql = 'SELECT ID, TYPE, SERIALIZED_REQUIREMENTS, CREATED_AT, UPDATED_AT FROM tax WHERE ID = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
@@ -275,44 +279,61 @@ abstract class TaxQuery extends ModelCriteria
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the rate column
|
||||
* Filter the query on the type column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByRate(1234); // WHERE rate = 1234
|
||||
* $query->filterByRate(array(12, 34)); // WHERE rate IN (12, 34)
|
||||
* $query->filterByRate(array('min' => 12)); // WHERE rate > 12
|
||||
* $query->filterByType('fooValue'); // WHERE type = 'fooValue'
|
||||
* $query->filterByType('%fooValue%'); // WHERE type LIKE '%fooValue%'
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $rate 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 $type 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 ChildTaxQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByRate($rate = null, $comparison = null)
|
||||
public function filterByType($type = null, $comparison = null)
|
||||
{
|
||||
if (is_array($rate)) {
|
||||
$useMinMax = false;
|
||||
if (isset($rate['min'])) {
|
||||
$this->addUsingAlias(TaxTableMap::RATE, $rate['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($rate['max'])) {
|
||||
$this->addUsingAlias(TaxTableMap::RATE, $rate['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
if (null === $comparison) {
|
||||
if (is_array($type)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $type)) {
|
||||
$type = str_replace('*', '%', $type);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(TaxTableMap::RATE, $rate, $comparison);
|
||||
return $this->addUsingAlias(TaxTableMap::TYPE, $type, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the serialized_requirements column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterBySerializedRequirements('fooValue'); // WHERE serialized_requirements = 'fooValue'
|
||||
* $query->filterBySerializedRequirements('%fooValue%'); // WHERE serialized_requirements LIKE '%fooValue%'
|
||||
* </code>
|
||||
*
|
||||
* @param string $serializedRequirements 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 ChildTaxQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterBySerializedRequirements($serializedRequirements = null, $comparison = null)
|
||||
{
|
||||
if (null === $comparison) {
|
||||
if (is_array($serializedRequirements)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $serializedRequirements)) {
|
||||
$serializedRequirements = str_replace('*', '%', $serializedRequirements);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(TaxTableMap::SERIALIZED_REQUIREMENTS, $serializedRequirements, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user