Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

OrderShopResolver.php 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. }