Merge branch 'master' of https://github.com/thelia/thelia into coupon

* 'master' of https://github.com/thelia/thelia: (38 commits)
  add propel connection in transactions
  remove area to area_delivery_module
  add an area to a delivery module
  create shipping zone area form
  update readme
  start shipping zone management
  complete admin log message
  allow to create a new area
  delete area
  add pre/post methods in Area model
  display error message
  update area postage
  add missinf files
  remove country from area and start creating postage management
  add country to as area
  start area configuration tempalte
  choices access through smarty
  tax rule creation
  downgrade smarty version
  create all area events
  ...
This commit is contained in:
gmorel
2013-10-15 22:51:27 +02:00
72 changed files with 4426 additions and 381 deletions

128
install/faker_add_ecotax.php Executable file
View File

@@ -0,0 +1,128 @@
<?php
use Symfony\Component\DependencyInjection\ContainerInterface;
use Thelia\Condition\ConditionFactory;
use Thelia\Condition\Implementation\MatchForEveryoneManager;
use Thelia\Condition\Implementation\MatchForTotalAmountManager;
use Thelia\Condition\Implementation\MatchForXArticlesManager;
use Thelia\Condition\Operators;
use Thelia\Coupon\AdapterInterface;
use Thelia\Coupon\ConditionCollection;
require __DIR__ . '/../core/bootstrap.php';
$thelia = new Thelia\Core\Thelia("dev", true);
$thelia->boot();
$faker = Faker\Factory::create();
$con = \Propel\Runtime\Propel::getConnection(
Thelia\Model\Map\ProductTableMap::DATABASE_NAME
);
$con->beginTransaction();
// Intialize URL management
try {
$options = getopt('f::e::');
$forceEcotaxFeatureId = $options['f'];
if(null !== $forceEcotaxFeatureId && !filter_var($forceEcotaxFeatureId, FILTER_VALIDATE_INT)) {
exit('[ERROR] bad value for f option\n');
}
$forceEcotaxId = $options['e'];
if(null !== $forceEcotaxId && !filter_var($forceEcotaxId, FILTER_VALIDATE_INT)) {
exit('[ERROR] bad value for e option\n');
}
echo "Adding Ecotax feature\n";
$feature = null;
if(null !== $forceEcotaxFeatureId) {
$feature = \Thelia\Model\FeatureQuery::create()->findPk($forceEcotaxFeatureId);
if(null === $feature) {
echo "Feature `$forceEcotaxFeatureId` not found\n";
}
}
if(null === $feature) {
$feature = new \Thelia\Model\Feature();
$feature->setVisible(1);
$feature->save();
echo sprintf("Ecotax feature added with ID \n", $feature->getId());
}
$fr = \Thelia\Model\Base\FeatureI18nQuery::create()
->filterByLocale('fr_FR')
->filterByFeature($feature)
->findOne();
if(null === $fr) {
$fr = new \Thelia\Model\FeatureI18n();
$fr->setLocale('fr_FR')
->setFeature($feature);
}
$fr->setTitle('Ecotaxe');
$fr->save($con);
$us = \Thelia\Model\Base\FeatureI18nQuery::create()
->filterByLocale('en_US')
->filterByFeature($feature)
->findOne();
if(null === $us) {
$us = new \Thelia\Model\FeatureI18n();
$us->setLocale('en_US')
->setFeature($feature);
}
$us->setTitle('Ecotax');
$us->save($con);
echo "Adding ecotax\n";
$tax = null;
if(null !== $forceEcotaxId) {
$tax = \Thelia\Model\TaxQuery::create()->findPk($forceEcotaxId);
if(null === $tax) {
echo "Tax `$forceEcotaxId` not found\n";
}
}
if(null === $tax) {
$tax = new \Thelia\Model\Tax();
$tax->setType('FeatureFixAmountTaxType')
->setSerializedRequirements(
base64_encode(sprintf('{"feature":%s}', $feature->getId()))
);
$tax->save();
echo sprintf("Ecotax added with ID \n", $tax->getId());
}
$fr = \Thelia\Model\Base\TaxI18nQuery::create()
->filterByLocale('fr_FR')
->filterByTax($tax)
->findOne();
if(null === $fr) {
$fr = new \Thelia\Model\TaxI18n();
$fr->setLocale('fr_FR')
->setTax($tax);
}
$fr->setTitle('Ecotaxe');
$fr->save($con);
$us = \Thelia\Model\Base\TaxI18nQuery::create()
->filterByLocale('en_US')
->filterByTax($tax)
->findOne();
if(null === $us) {
$us = new \Thelia\Model\TaxI18n();
$us->setLocale('en_US')
->setTax($tax);
}
$us->setTitle('Ecotax');
$us->save($con);
$con->commit();
echo "Successfully terminated.\n";
} catch (Exception $e) {
echo "error : ".$e->getMessage()."\n";
$con->rollBack();
}

View File

@@ -1149,25 +1149,31 @@ INSERT INTO `country_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `po
INSERT INTO `tax` (`id`, `type`, `serialized_requirements`, `created_at`, `updated_at`)
VALUES
(1, 'PricePercentTaxType', 'eyJwZXJjZW50IjoxOS42fQ==', NOW(), NOW());
(1, 'PricePercentTaxType', 'eyJwZXJjZW50IjoxOS42fQ==', NOW(), NOW()),
(2, 'PricePercentTaxType', 'eyJwZXJjZW50Ijo1LjV9', NOW(), NOW());
INSERT INTO `tax_i18n` (`id`, `locale`, `title`)
VALUES
(1, 'fr_FR', 'TVA française à 19.6%'),
(1, 'en_US', 'French 19.6% VAT');
(1, 'en_US', 'French 19.6% VAT'),
(2, 'fr_FR', 'TVA française à 5.5%'),
(2, 'en_US', 'French 5.5% VAT');
INSERT INTO `tax_rule` (`id`, `is_default`, `created_at`, `updated_at`)
VALUES
(1, 1, NOW(), NOW());
(1, 1, NOW(), NOW()),
(2, 0, NOW(), NOW());
INSERT INTO `tax_rule_i18n` (`id`, `locale`, `title`)
VALUES
(1, 'fr_FR', 'TVA française à 19.6%'),
(1, 'en_US', 'French 19.6% VAT');
(1, 'en_US', 'French 19.6% VAT'),
(2, 'fr_FR', 'TVA française à 5.5%'),
(2, 'en_US', 'French 5.5% VAT');
INSERT INTO `tax_rule_country` (`tax_rule_id`, `country_id`, `tax_id`, `position`, `created_at`, `updated_at`)
VALUES
(1, 64, 1, 1, NOW(), NOW());
(1, 64, 1, 1, NOW(), NOW()),
(2, 64, 2, 1, NOW(), NOW());
INSERT INTO `order_status`(`id`, `code`, `created_at`, `updated_at`) VALUES
(1, 'not_paid', NOW(), NOW()),