You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OrderProductPriceUtils.php 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace Lc\ShopBundle\Services\Price;
  3. use Doctrine\Common\Collections\Collection;
  4. use Lc\ShopBundle\Context\OrderProductInterface;
  5. use Lc\ShopBundle\Context\OrderShopInterface;
  6. use Lc\ShopBundle\Context\ProductFamilyInterface;
  7. use Lc\ShopBundle\Context\ProductInterface;
  8. use Lc\ShopBundle\Context\ProductPropertyInterface;
  9. use Lc\ShopBundle\Context\ReductionCatalogInterface;
  10. class OrderProductPriceUtils
  11. {
  12. use PriceUtilsTrait ;
  13. protected $productPriceUtils ;
  14. public function __construct(ProductPriceUtils $productPriceUtils)
  15. {
  16. $this->productPriceUtils = $productPriceUtils ;
  17. }
  18. public function getPrice(OrderProductInterface $orderProduct)
  19. {
  20. return $orderProduct->getPrice();
  21. }
  22. public function getPriceWithTax(OrderProductInterface $orderProduct)
  23. {
  24. return $this->applyTax(
  25. $this->getPrice($orderProduct),
  26. $orderProduct->getTaxRate()->getValue()
  27. );
  28. }
  29. public function getPriceWithTaxAndReduction(OrderProductInterface $orderProduct)
  30. {
  31. return $this->applyReductionCatalog(
  32. $orderProduct,
  33. $this->getPrice($orderProduct),
  34. $this->getPriceWithTax($orderProduct)
  35. );
  36. }
  37. public function getTotal(OrderProductInterface $orderProduct)
  38. {
  39. return $orderProduct->getQuantityOrder() * $this->getPrice($orderProduct);
  40. }
  41. public function getTotalWithReduction(OrderProductInterface $orderProduct)
  42. {
  43. return $this->applyReductionCatalog(
  44. $orderProduct,
  45. $this->getTotal($orderProduct),
  46. $this->getTotalWithTax($orderProduct),
  47. null,
  48. false
  49. );
  50. }
  51. public function getTotalWithTax(OrderProductInterface $orderProduct)
  52. {
  53. return $this->applyTax(
  54. $this->getTotal($orderProduct),
  55. $orderProduct->getTaxRateInherited()->getValue()
  56. );
  57. }
  58. public function getTotalWithTaxAndReduction(OrderProductInterface $orderProduct)
  59. {
  60. return $this->applyReductionCatalog(
  61. $orderProduct,
  62. $this->getTotal($orderProduct),
  63. $this->getTotalWithTax($orderProduct)
  64. );
  65. }
  66. //inclus toujours les réductions catalogues
  67. public function getTotalTaxes(OrderProductInterface $orderProduct){
  68. return $this->getTotalWithTaxAndReduction($orderProduct) - $this->getTotalWithReduction($orderProduct);
  69. }
  70. }