|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- <?php
-
- namespace Lc\CaracoleBundle\Resolver\Price;
-
- use Lc\CaracoleBundle\Model\Order\OrderProductInterface;
-
- class OrderProductPriceResolver
- {
- use PriceResolverTrait;
-
- protected $ProductPriceResolver;
-
- public function __construct(ProductPriceResolver $ProductPriceResolver)
- {
- $this->ProductPriceResolver = $ProductPriceResolver;
- }
-
- public function getPrice(OrderProductInterface $orderProduct, $round = false)
- {
- if ($round) {
- return $this->round($orderProduct->getPrice());
- } else {
- return $orderProduct->getPrice();
- }
- }
-
- public function getBuyingPrice(OrderProductInterface $orderProduct, $round = false)
- {
- if ($round) {
- return $this->round($orderProduct->getBuyingPrice());
- } else {
- return $orderProduct->getBuyingPrice();
- }
- }
-
- public function getPriceWithTax(OrderProductInterface $orderProduct)
- {
- return $this->applyTax(
- $this->getPrice($orderProduct),
- $orderProduct->getTaxRate()->getValue()
- );
- }
-
- public function getPriceWithTaxAndReduction(OrderProductInterface $orderProduct)
- {
- return $this->applyReductionCatalog(
- $orderProduct,
- $this->getPrice($orderProduct),
- $this->getPriceWithTax($orderProduct)
- );
- }
-
- public function getPriceWithReduction(OrderProductInterface $orderProduct, $round = true)
- {
- return $this->applyReductionCatalog(
- $orderProduct,
- $this->getPrice($orderProduct),
- $this->getPriceWithTax($orderProduct),
- 1,
- null,
- false,
- $round
- );
- }
-
- public function getTotal(OrderProductInterface $orderProduct)
- {
- return $orderProduct->getQuantityOrder() * $this->getPrice($orderProduct);
- }
-
- public function getTotalBuyingPrice(OrderProductInterface $orderProduct)
- {
- return $orderProduct->getQuantityOrder() * $this->getBuyingPrice($orderProduct);
- }
-
- public function getMargin(OrderProductInterface $orderProduct)
- {
- return $this->round($this->getPriceWithReduction($orderProduct, false) - $this->getBuyingPrice($orderProduct));
- }
-
- public function getMarginPercent(OrderProductInterface $orderProduct)
- {
- if ($this->getBuyingPrice($orderProduct) && $this->getPriceWithReduction($orderProduct)) {
- return $this->round(($this->getMargin($orderProduct) / $this->getPriceWithReduction($orderProduct)) * 100);
- } else {
- return 0;
- }
- }
-
- public function getTotalMargin(OrderProductInterface $orderProduct)
- {
- return $orderProduct->getQuantityOrder() * $this->getMargin($orderProduct);
- }
-
-
- public function getTotalWithReduction(OrderProductInterface $orderProduct)
- {
- return $this->applyReductionCatalog(
- $orderProduct,
- $this->getTotal($orderProduct),
- $this->getTotalWithTax($orderProduct),
- $orderProduct->getQuantityOrder(),
- null,
- false
- );
- }
-
- public function getTotalWithTax(OrderProductInterface $orderProduct)
- {
- return $this->applyTax(
- $this->getTotal($orderProduct),
- $orderProduct->getTaxRateInherited()->getValue()
- );
- }
-
- public function getTotalWithTaxAndReduction(OrderProductInterface $orderProduct)
- {
- return $this->applyReductionCatalog(
- $orderProduct,
- $this->getTotal($orderProduct),
- $this->getTotalWithTax($orderProduct),
- $orderProduct->getQuantityOrder()
- );
- }
-
- public function getTotalBuyingPriceWithTax(OrderProductInterface $orderProduct)
- {
- return $this->applyTax(
- $this->getTotalBuyingPrice($orderProduct),
- $orderProduct->getTaxRateInherited()->getValue()
- );
- }
-
- //inclus toujours les réductions catalogues
- public function getTotalTaxes(OrderProductInterface $orderProduct)
- {
- return $this->getTotalWithTaxAndReduction($orderProduct) - $this->getTotalWithReduction($orderProduct);
- }
- }
-
|