Conflicts:
	core/lib/Thelia/Core/Event/TheliaEvents.php
	templates/admin/default/admin-layout.tpl
This commit is contained in:
franck
2013-09-12 13:04:12 +02:00
78 changed files with 2887 additions and 1001 deletions

View File

@@ -319,6 +319,7 @@ try {
for($i=0; $i<rand(1,7); $i++) {
$stock = new \Thelia\Model\ProductSaleElements();
$stock->setProductId($productId);
$stock->setRef($productId . '_' . $i . '_' . $faker->randomNumber(8));
$stock->setQuantity($faker->randomNumber(1,50));
$stock->setPromo($faker->randomNumber(0,1));
$stock->setNewness($faker->randomNumber(0,1));

View File

@@ -17,9 +17,10 @@ INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updat
('image_cache_dir_from_web_root', 'cache/images', 0, 0, NOW(), NOW()),
('currency_rate_update_url', 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml', 0, 0, NOW(), NOW()),
('page_not_found_view', '404.html', 0, 0, NOW(), NOW()),
('use_tax_free_amounts', '1', 0, 0, NOW(), NOW());
('use_tax_free_amounts', 0, 1, 0, NOW(), NOW()),
('process_assets', '1', 0, 0, NOW(), NOW());
INSERT INTO `module` (`id`, `code`, `type`, `activate`, `position`, `full_namespace`, `created_at`, `updated_at`) VALUES
(1, 'DebugBar', 1, 1, 1, 'DebugBar\\DebugBar', NOW(), NOW());
@@ -1112,9 +1113,9 @@ INSERT INTO `country_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `po
(268, 'es_ES', 'USA - Alabama', '', '', ''),
(268, 'fr_FR', 'USA - Alabama', '', '', '');
INSERT INTO `tax` (`id`, `rate`, `created_at`, `updated_at`)
INSERT INTO `tax` (`id`, `type`, `serialized_requirements`, `created_at`, `updated_at`)
VALUES
(1, '19.6', NOW(), NOW());
(1, 'PricePercentTaxType', 'eyJwZXJjZW50IjoxOS42fQ==', NOW(), NOW());
INSERT INTO `tax_i18n` (`id`, `locale`, `title`)
VALUES

116
install/tax_faker.php Executable file
View File

@@ -0,0 +1,116 @@
<?php
use Thelia\Constraint\ConstraintFactory;
use Thelia\Constraint\ConstraintManager;
use Thelia\Constraint\Rule\AvailableForTotalAmount;
use Thelia\Constraint\Rule\AvailableForTotalAmountManager;
use Thelia\Constraint\Rule\AvailableForXArticlesManager;
use Thelia\Constraint\Rule\Operators;
use Thelia\Coupon\CouponRuleCollection;
use Thelia\Model\ProductImage;
use Thelia\Model\CategoryImage;
use Thelia\Model\FolderImage;
use Thelia\Model\ContentImage;
use Imagine\Image\Color;
use Imagine\Image\Point;
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();
$currency = \Thelia\Model\CurrencyQuery::create()->filterByCode('EUR')->findOne();
try {
$stmt = $con->prepare("SET foreign_key_checks = 0");
$stmt->execute();
\Thelia\Model\TaxQuery::create()
->find()
->delete();
\Thelia\Model\Base\TaxRuleQuery::create()
->find()
->delete();
\Thelia\Model\Base\TaxRuleCountryQuery::create()
->find()
->delete();
$stmt = $con->prepare("SET foreign_key_checks = 1");
$stmt->execute();
/* 10% tax */
$tax10p = new \Thelia\Model\Tax();
$tax10p->setType('PricePercentTaxType')
->setRequirements(array('percent' => 10))
->save();
/* 8% tax */
$tax8p = new \Thelia\Model\Tax();
$tax8p->setType('PricePercentTaxType')
->setRequirements(array('percent' => 8))
->save();
/* fix 5 tax */
$tax5 = new \Thelia\Model\Tax();
$tax5->setType('FixAmountTaxType')
->setRequirements(array('amount' => 5))
->save();
/* 1% tax */
$tax1p = new \Thelia\Model\Tax();
$tax1p->setType('PricePercentTaxType')
->setRequirements(array('percent' => 1))
->save();
/* tax rule */
$taxRule = new \Thelia\Model\TaxRule();
$taxRule->save();
/* add 4 taxes to the rule for France (64) */
$taxRuleCountry = new \Thelia\Model\TaxRuleCountry();
$taxRuleCountry->setTaxRule($taxRule)
->setCountryId(64)
->setTax($tax10p)
->setPosition(1)
->save();
$taxRuleCountry = new \Thelia\Model\TaxRuleCountry();
$taxRuleCountry->setTaxRule($taxRule)
->setCountryId(64)
->setTax($tax8p)
->setPosition(1)
->save();
$taxRuleCountry = new \Thelia\Model\TaxRuleCountry();
$taxRuleCountry->setTaxRule($taxRule)
->setCountryId(64)
->setTax($tax5)
->setPosition(2)
->save();
$taxRuleCountry = new \Thelia\Model\TaxRuleCountry();
$taxRuleCountry->setTaxRule($taxRule)
->setCountryId(64)
->setTax($tax1p)
->setPosition(3)
->save();
foreach(\Thelia\Model\ProductQuery::create()->find() as $productActiveRecord) {
$productActiveRecord->setTaxRule($taxRule)
->save();
}
$con->commit();
} catch (Exception $e) {
echo "error : ".$e->getMessage()."\n";
$con->rollBack();
}

View File

@@ -111,7 +111,8 @@ DROP TABLE IF EXISTS `tax`;
CREATE TABLE `tax`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`rate` FLOAT NOT NULL,
`type` VARCHAR(255) NOT NULL,
`serialized_requirements` TEXT NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`)
@@ -348,6 +349,7 @@ CREATE TABLE `product_sale_elements`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`product_id` INTEGER NOT NULL,
`ref` VARCHAR(45) NOT NULL,
`quantity` FLOAT NOT NULL,
`promo` TINYINT DEFAULT 0,
`newness` TINYINT DEFAULT 0,
@@ -355,6 +357,7 @@ CREATE TABLE `product_sale_elements`
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`),
UNIQUE INDEX `ref_UNIQUE` (`ref`),
INDEX `idx_product_sale_element_product_id` (`product_id`),
CONSTRAINT `fk_product_sale_element_product_id`
FOREIGN KEY (`product_id`)