orderProductPriceUtils = $orderProductPriceUtils ; } //Inclus les ReductionCatalog des OrderProducts public function getTotalOrderProducts(OrderShopInterface $orderShop):float { // A tester calculer ce montant en faisant TotalOrderWithTax - TotalOrderTaxes $total = 0; foreach ($orderShop->getOrderProducts() as $orderProduct) { $total += $this->orderProductPriceUtils->getTotalWithReduction($orderProduct); } return $total; } public function getTotalOrderProductsWithTax(OrderShopInterface $orderShop):float { $total = 0; foreach ($orderShop->getOrderProducts() as $orderProduct) { $total += $this->orderProductPriceUtils->getTotalWithTaxAndReduction($orderProduct); } return $total; } public function getTotalOrderProductsTaxes(OrderShopInterface $orderShop):float { } public function getOrderProductsTaxesAsArray(OrderShopInterface $orderShop):array { $orderProductsTaxes = []; foreach ($orderShop->getOrderProducts() as $orderProduct) { $idTaxRate = $orderProduct->getTaxRate()->getId() ; if(!isset($orderProductsTaxes[$idTaxRate])) { $orderProductsTaxes[$idTaxRate] = [ 'label' => $orderProduct->getTaxRate()->getValue() . '%', 'totalOrderProducts' => 0, 'totalTaxes' => 0, ]; } $orderProductsTaxes[$idTaxRate]['totalOrderProducts'] += $this->orderProductPriceUtils->getTotalWithReduction($orderProduct) * $this->getReductionsCoef($orderShop); $orderProductsTaxes[$idTaxRate]['totalTaxes'] += $this->orderProductPriceUtils->getTotalTaxes($orderProduct) * $this->getReductionsCoef($orderShop) ; } return $orderProductsTaxes ; } private function getReductionsCoef(OrderShopInterface $orderShop) :float { return $this->getTotalOrderProducts($orderShop) / $this->getTotalOrderProductsWithReductions($orderShop); } private function getTaxRateAverage(OrderShopInterface $order):float { return $this->getTotalOrderProductsWithTax() / $this->getTotalOrderProducts(); } public function getTotalOrderProductsWithReductions(OrderShopInterface $orderShop) { $total = $this->getTotalOrderProducts($orderShop) ; $totalReductionAmount = 0 ; foreach ($orderShop->getOrderReductionCarts() as $orderReductionCart) { $totalReductionAmount += $this->amountOrderProductsReductionCart($orderShop,$orderReductionCart); } $total -= $totalReductionAmount ; return $total ; } public function getTotalWithTaxAndReductions(OrderShopInterface $orderShop) { } public function getOrderProductsReductionCartAmountWithoutTax(OrderShopInterface $order, $orderReductionCart) { if($orderReductionCart->getAppliedTo() === ReductionCart::APPLIED_TO_ORDER_PRODUCTS) { if ($orderReductionCart->getUnit() == 'percent') { $price = $this->amountReductionByPercentValue( $this->getTotalOrderProducts($order), $orderReductionCart->getValue() ); } else if ($orderReductionCart->getUnit() == 'amount') { if ($orderReductionCart->getBehaviorTaxRate() == 'tax-excluded') { $price = $orderReductionCart->getValue(); } else if ($orderReductionCart->getBehaviorTaxRate() == 'tax-included') { $price = $orderReductionCart->getValue() / $this->getTaxRateAverage(); } } } } public function getOrderProductsReductionCartAmountWithTax(OrderShopInterface $order, $orderReductionCart) { if($orderReductionCart->getAppliedTo() === ReductionCart::APPLIED_TO_ORDER_PRODUCTS) { if ($orderReductionCart->getUnit() == 'percent') { $price = $this->amountReductionByPercentValue( $this->getTotalOrderProductsWithTax($order), $orderReductionCart->getValue() ); } else if ($orderReductionCart->getUnit() == 'amount') { if ($orderReductionCart->getBehaviorTaxRate() == 'tax-excluded') { $price = $orderReductionCart->getValue() * $this->getTaxRateAverage(); } else if ($orderReductionCart->getBehaviorTaxRate() == 'tax-included') { $price = $orderReductionCart->getValue() ; } } } } public function getOrderProductsReductionCreditAmountWithoutTax(OrderShopInterface $order, OrderReductionCreditInterface $orderReductionCredit) { if ($orderReductionCredit->getBehaviorTaxRate() == 'tax-excluded') { $amount = $orderReductionCredit->getValue(); } else if ($orderReductionCredit->getBehaviorTaxRate() == 'tax-included') { $amount = $orderReductionCredit->getValue() / $this->getTaxRateAverage(); } return $amount; } public function getOrderProductsReductionCreditAmountWithTax(OrderShopInterface $order, OrderReductionCreditInterface $orderReductionCredit) { if ($orderReductionCredit->getBehaviorTaxRate() == 'tax-excluded') { $amountWithTax = $orderReductionCredit->getValue() * $this->getTaxRateAverage(); } else if ($orderReductionCredit->getBehaviorTaxRate() == 'tax-included') { $amountWithTax = $orderReductionCredit->getValue(); } return $amountWithTax; } }