Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TotalsValidator.php
Go to the documentation of this file.
1 <?php
7 
10 
15 {
19  private $priceCurrency;
20 
26  public function __construct(PriceCurrencyInterface $priceCurrency)
27  {
28  $this->priceCurrency = $priceCurrency;
29  }
30 
34  public function validate($entity)
35  {
36  $messages = [];
37  $baseOrderRefund = $this->priceCurrency->round(
38  $entity->getOrder()->getBaseTotalRefunded() + $entity->getBaseGrandTotal()
39  );
40  if ($baseOrderRefund > $this->priceCurrency->round($entity->getOrder()->getBaseTotalPaid())) {
41  $baseAvailableRefund = $entity->getOrder()->getBaseTotalPaid()
42  - $entity->getOrder()->getBaseTotalRefunded();
43 
44  $messages[] = __(
45  'The most money available to refund is %1.',
46  $baseAvailableRefund
47  );
48  }
49 
50  return $messages;
51  }
52 }
__()
Definition: __.php:13
$entity
Definition: element.phtml:22