From ef6c73c6551b3ef1e99e9ebf49b5e654da45f6a1 Mon Sep 17 00:00:00 2001 From: TheCoreDev Date: Wed, 9 Dec 2020 15:43:03 +0100 Subject: [PATCH] =?UTF-8?q?Rajout=20de=20la=20gestion=20du=20d=C3=A9tail?= =?UTF-8?q?=20de=20TVA=20sur=20les=20frais=20de=20port=20Colissimo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- local/modules/ColissimoWs/ColissimoWs.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/local/modules/ColissimoWs/ColissimoWs.php b/local/modules/ColissimoWs/ColissimoWs.php index 9b81e2f7..eb5778ad 100644 --- a/local/modules/ColissimoWs/ColissimoWs.php +++ b/local/modules/ColissimoWs/ColissimoWs.php @@ -27,10 +27,13 @@ use Thelia\Model\Message; use Thelia\Model\MessageQuery; use Thelia\Model\ModuleQuery; use Thelia\Model\Order; +use Thelia\Model\OrderPostage; +use Thelia\Model\TaxRuleQuery; use Thelia\Module\AbstractDeliveryModule; use Thelia\Module\BaseModule; use Thelia\Module\DeliveryModuleInterface; use Thelia\Module\Exception\DeliveryException; +use Thelia\TaxEngine\Calculator; class ColissimoWs extends AbstractDeliveryModule { @@ -242,6 +245,21 @@ class ColissimoWs extends AbstractDeliveryModule if (null === $postage = $this->getMinPostage($areaIdArray, $cartWeight, $cartAmount)) { throw new DeliveryException("Colissimo delivery unavailable for your cart weight or delivery country"); } + + /* TheCoreDev le 9/12/2020 : Tout ceci pour gérer l'affichage dans la facture de la TVA sur les frais de port Colissimo */ + $orderPostage = new OrderPostage(); + $taxRule = TaxRuleQuery::create()->findOneByIsDefault(true); + $tax = (new Calculator()) + ->loadTaxRuleWithoutProduct($taxRule, $country) + ->getTaxAmountFromTaxedPrice($postage); + + $orderPostage->setAmount($postage); + $orderPostage->setAmountTax($tax); + $orderPostage->setTaxRuleTitle( + $taxRule->setLocale($this->getRequest()->getSession()->getLang()->getLocale())->getTitle() + ); + + return $orderPostage; } return $postage;