diff --git a/core/lib/Thelia/Action/Tax.php b/core/lib/Thelia/Action/Tax.php
index d17433362..c35d87bbe 100644
--- a/core/lib/Thelia/Action/Tax.php
+++ b/core/lib/Thelia/Action/Tax.php
@@ -41,11 +41,12 @@ class Tax extends BaseAction implements EventSubscriberInterface
$tax
->setDispatcher($this->getDispatcher())
+ ->setRequirements($event->getRequirements())
->setType($event->getType())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setDescription($event->getDescription())
- ;
+ ;
$tax->save();
@@ -66,9 +67,10 @@ class Tax extends BaseAction implements EventSubscriberInterface
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setDescription($event->getDescription())
- ->save()
;
+ $tax->save();
+
$event->setTax($tax);
}
}
@@ -97,7 +99,6 @@ class Tax extends BaseAction implements EventSubscriberInterface
TheliaEvents::TAX_CREATE => array("create", 128),
TheliaEvents::TAX_UPDATE => array("update", 128),
TheliaEvents::TAX_DELETE => array("delete", 128),
-
);
}
}
diff --git a/core/lib/Thelia/Action/TaxRule.php b/core/lib/Thelia/Action/TaxRule.php
index 4b24f8cb9..b3f1d23ae 100644
--- a/core/lib/Thelia/Action/TaxRule.php
+++ b/core/lib/Thelia/Action/TaxRule.php
@@ -27,6 +27,7 @@ use Propel\Runtime\ActiveQuery\Criteria;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\Tax\TaxRuleEvent;
use Thelia\Core\Event\TheliaEvents;
+use Thelia\Model\Map\TaxRuleTableMap;
use Thelia\Model\TaxRuleCountry;
use Thelia\Model\TaxRuleCountryQuery;
use Thelia\Model\TaxRule as TaxRuleModel;
@@ -134,6 +135,23 @@ class TaxRule extends BaseAction implements EventSubscriberInterface
}
}
+ /**
+ * @param TaxRuleEvent $event
+ */
+ public function setDefault(TaxRuleEvent $event)
+ {
+ if (null !== $taxRule = TaxRuleQuery::create()->findPk($event->getId())) {
+
+ TaxRuleQuery::create()->update(array(
+ "IsDefault" => 0
+ ));
+
+ $taxRule->setIsDefault(1)->save();
+
+ $event->setTaxRule($taxRule);
+ }
+ }
+
/**
* {@inheritDoc}
*/
@@ -144,7 +162,7 @@ class TaxRule extends BaseAction implements EventSubscriberInterface
TheliaEvents::TAX_RULE_UPDATE => array("update", 128),
TheliaEvents::TAX_RULE_TAXES_UPDATE => array("updateTaxes", 128),
TheliaEvents::TAX_RULE_DELETE => array("delete", 128),
-
+ TheliaEvents::TAX_RULE_SET_DEFAULT => array("setDefault", 128),
);
}
}
diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml
index 72fa1cd15..865c14484 100755
--- a/core/lib/Thelia/Config/Resources/routing/admin.xml
+++ b/core/lib/Thelia/Config/Resources/routing/admin.xml
@@ -870,6 +870,11 @@
-
{intl l="Name"}
- {intl l="Description"}
- {intl l="Actions"}
+ {intl l="Name"}
+ {intl l="Description"}
+ {intl l="Actions"}