Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

OrderProductPriceResolver.php 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. namespace Lc\CaracoleBundle\Resolver\Price;
  3. use Lc\CaracoleBundle\Model\Order\OrderProductInterface;
  4. class OrderProductPriceResolver
  5. {
  6. use PriceResolverTrait;
  7. protected $ProductPriceResolver;
  8. public function __construct(ProductPriceResolver $ProductPriceResolver)
  9. {
  10. $this->ProductPriceResolver = $ProductPriceResolver;
  11. }
  12. public function getPrice(OrderProductInterface $orderProduct, $round = false)
  13. {
  14. if ($round) {
  15. return $this->round($orderProduct->getPrice());
  16. } else {
  17. return $orderProduct->getPrice();
  18. }
  19. }
  20. public function getBuyingPrice(OrderProductInterface $orderProduct, $round = false)
  21. {
  22. if ($round) {
  23. return $this->round($orderProduct->getBuyingPrice());
  24. } else {
  25. return $orderProduct->getBuyingPrice();
  26. }
  27. }
  28. public function getPriceWithTax(OrderProductInterface $orderProduct)
  29. {
  30. return $this->applyTax(
  31. $this->getPrice($orderProduct),
  32. $orderProduct->getTaxRate()->getValue()
  33. );
  34. }
  35. public function getPriceWithTaxAndReduction(OrderProductInterface $orderProduct)
  36. {
  37. return $this->applyReductionCatalog(
  38. $orderProduct,
  39. $this->getPrice($orderProduct),
  40. $this->getPriceWithTax($orderProduct)
  41. );
  42. }
  43. public function getPriceWithReduction(OrderProductInterface $orderProduct, $round = true)
  44. {
  45. return $this->applyReductionCatalog(
  46. $orderProduct,
  47. $this->getPrice($orderProduct),
  48. $this->getPriceWithTax($orderProduct),
  49. 1,
  50. null,
  51. false,
  52. $round
  53. );
  54. }
  55. public function getTotal(OrderProductInterface $orderProduct)
  56. {
  57. return $orderProduct->getQuantityOrder() * $this->getPrice($orderProduct);
  58. }
  59. public function getTotalBuyingPrice(OrderProductInterface $orderProduct)
  60. {
  61. return $orderProduct->getQuantityOrder() * $this->getBuyingPrice($orderProduct);
  62. }
  63. public function getMargin(OrderProductInterface $orderProduct)
  64. {
  65. return $this->round($this->getPriceWithReduction($orderProduct, false) - $this->getBuyingPrice($orderProduct));
  66. }
  67. public function getMarginPercent(OrderProductInterface $orderProduct)
  68. {
  69. if ($this->getBuyingPrice($orderProduct) && $this->getPriceWithReduction($orderProduct)) {
  70. return $this->round(($this->getMargin($orderProduct) / $this->getPriceWithReduction($orderProduct)) * 100);
  71. } else {
  72. return 0;
  73. }
  74. }
  75. public function getTotalMargin(OrderProductInterface $orderProduct)
  76. {
  77. return $orderProduct->getQuantityOrder() * $this->getMargin($orderProduct);
  78. }
  79. public function getTotalWithReduction(OrderProductInterface $orderProduct)
  80. {
  81. return $this->applyReductionCatalog(
  82. $orderProduct,
  83. $this->getTotal($orderProduct),
  84. $this->getTotalWithTax($orderProduct),
  85. $orderProduct->getQuantityOrder(),
  86. null,
  87. false
  88. );
  89. }
  90. public function getTotalWithTax(OrderProductInterface $orderProduct)
  91. {
  92. return $this->applyTax(
  93. $this->getTotal($orderProduct),
  94. $orderProduct->getTaxRateInherited()->getValue()
  95. );
  96. }
  97. public function getTotalWithTaxAndReduction(OrderProductInterface $orderProduct)
  98. {
  99. return $this->applyReductionCatalog(
  100. $orderProduct,
  101. $this->getTotal($orderProduct),
  102. $this->getTotalWithTax($orderProduct),
  103. $orderProduct->getQuantityOrder()
  104. );
  105. }
  106. public function getTotalBuyingPriceWithTax(OrderProductInterface $orderProduct)
  107. {
  108. return $this->applyTax(
  109. $this->getTotalBuyingPrice($orderProduct),
  110. $orderProduct->getTaxRateInherited()->getValue()
  111. );
  112. }
  113. //inclus toujours les réductions catalogues
  114. public function getTotalTaxes(OrderProductInterface $orderProduct)
  115. {
  116. return $this->getTotalWithTaxAndReduction($orderProduct) - $this->getTotalWithReduction($orderProduct);
  117. }
  118. }