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.

39 lines
1.4KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Builder\Order;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use Lc\CaracoleBundle\Model\Order\OrderProductInterface;
  5. use Lc\CaracoleBundle\Repository\Order\OrderProductStore;
  6. use Lc\CaracoleBundle\Resolver\Price\PriceResolver;
  7. use Lc\CaracoleBundle\Solver\Price\PriceSolver;
  8. class OrderProductBuilder
  9. {
  10. protected EntityManagerInterface $entityManager;
  11. protected PriceSolver $priceSolver;
  12. protected OrderProductStore $orderProductStore;
  13. public function __construct(
  14. EntityManagerInterface $entityManager,
  15. PriceSolver $priceSolver,
  16. OrderProductStore $orderProductStore
  17. ) {
  18. $this->entityManager = $entityManager;
  19. $this->priceSolver = $priceSolver;
  20. $this->orderProductStore = $orderProductStore;
  21. }
  22. public function init(OrderProductInterface $orderProduct) :OrderProductInterface
  23. {
  24. $orderProduct->setTitle($orderProduct->getTitleOrderShop());
  25. $orderProduct->setPrice($this->priceSolver->getPrice($orderProduct->getProduct()));
  26. $orderProduct->setBuyingPrice($this->priceSolver->getBuyingPrice($orderProduct->getProduct()));
  27. $orderProduct->setUnit($orderProduct->getProduct()->getUnitInherited());
  28. $orderProduct->setTaxRate($orderProduct->getProduct()->getTaxRateInherited());
  29. $orderProduct->setQuantityProduct($orderProduct->getProduct()->getQuantityInherited());
  30. return $orderProduct;
  31. }
  32. }