Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

53 lines
1.7KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Resolver;
  3. use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
  4. use Lc\CaracoleBundle\Solver\Order\OrderShopSolver;
  5. use Lc\CaracoleBundle\Solver\Price\PriceSolver;
  6. class OrderShopResolver
  7. {
  8. protected PriceSolver $priceSolver;
  9. protected OrderShopSolver $orderShopSolver;
  10. public function __construct(PriceSolver $priceSolver, OrderShopSolver $orderShopSolver)
  11. {
  12. $this->priceSolver = $priceSolver;
  13. $this->orderShopSolver = $orderShopSolver;
  14. }
  15. public function getTotalRemainingToBePaid(OrderShopInterface $orderShop): float
  16. {
  17. return $this->priceSolver->getTotalWithTax($orderShop) - $this->orderShopSolver->getTotalOrderPayments(
  18. $orderShop
  19. );
  20. }
  21. // isOrderShopPositiveAmount
  22. public function isPositiveAmount(OrderShopInterface $orderShop): bool
  23. {
  24. return $this->priceSolver->getTotalWithTax($orderShop) >= 0;
  25. }
  26. public function isPaid(OrderShopInterface $orderShop, $mergeComplementaryOrderShop = false): bool
  27. {
  28. $totalOrderPayments = $this->orderShopSolver->getTotalOrderPayments($orderShop, $mergeComplementaryOrderShop);
  29. $totalOrder = $this->priceSolver->getTotalWithTax($orderShop);
  30. if ((abs($totalOrderPayments - $totalOrder) < 0.00001
  31. || $totalOrderPayments >= $totalOrder)
  32. && $totalOrder > 0) {
  33. return true;
  34. } else {
  35. return false;
  36. }
  37. }
  38. // isOrderShopPositiveAmountRemainingToBePaid
  39. public function isPositiveAmountRemainingToBePaid(OrderShopInterface $orderShop): bool
  40. {
  41. return $this->getTotalRemainingToBePaid($orderShop) > 0;
  42. }
  43. }