|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
-
- namespace Lc\CaracoleBundle\Resolver;
-
- use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
- use Lc\CaracoleBundle\Solver\Order\OrderShopSolver;
- use Lc\CaracoleBundle\Solver\Price\PriceSolver;
-
- class OrderShopResolver
- {
- protected PriceSolver $priceSolver;
- protected OrderShopSolver $orderShopSolver;
-
- public function __construct(PriceSolver $priceSolver, OrderShopSolver $orderShopSolver)
- {
- $this->priceSolver = $priceSolver;
- $this->orderShopSolver = $orderShopSolver;
- }
-
- public function getTotalRemainingToBePaid(OrderShopInterface $orderShop): float
- {
- return $this->priceSolver->getTotalWithTax($orderShop) - $this->orderShopSolver->getTotalOrderPayments(
- $orderShop
- );
- }
-
- // isOrderShopPositiveAmount
- public function isPositiveAmount(OrderShopInterface $orderShop): bool
- {
- return $this->priceSolver->getTotalWithTax($orderShop) >= 0;
- }
-
- public function isPaid(OrderShopInterface $orderShop, $mergeComplementaryOrderShop = false): bool
- {
- $totalOrderPayments = $this->orderShopSolver->getTotalOrderPayments($orderShop, $mergeComplementaryOrderShop);
- $totalOrder = $this->priceSolver->getTotalWithTax($orderShop);
-
- if ((abs($totalOrderPayments - $totalOrder) < 0.00001
- || $totalOrderPayments >= $totalOrder)
- && $totalOrder > 0) {
- return true;
- } else {
- return false;
- }
- }
-
- // isOrderShopPositiveAmountRemainingToBePaid
- public function isPositiveAmountRemainingToBePaid(OrderShopInterface $orderShop): bool
- {
- return $this->getTotalRemainingToBePaid($orderShop) > 0;
- }
-
- }
|