Esempio n. 1
0
 public function testSearchById()
 {
     $tr = TaxRuleQuery::create()->findOne();
     if (null === $tr) {
         $tr = new \Thelia\Model\TaxRule();
         $tr->setTitle('foo');
         $tr->save();
     }
     $this->baseTestSearchById($tr->getId(), array('force_return' => true));
 }
Esempio n. 2
0
    $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) {