Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Calculator.php
Go to the documentation of this file.
1 <?php
7 
15 {
21  protected $_delta = 0.0;
22 
26  protected $priceCurrency;
27 
31  public function __construct(\Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency)
32  {
33  $this->priceCurrency = $priceCurrency;
34  }
35 
43  public function deltaRound($price, $negative = false)
44  {
45  $roundedPrice = $price;
46  if ($roundedPrice) {
47  if ($negative) {
48  $this->_delta = -$this->_delta;
49  }
51  $roundedPrice = $this->priceCurrency->round($price);
52  $this->_delta = $price - $roundedPrice;
53  if ($negative) {
54  $this->_delta = -$this->_delta;
55  }
56  }
57  return $roundedPrice;
58  }
59 }
$price
deltaRound($price, $negative=false)
Definition: Calculator.php:43
__construct(\Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency)
Definition: Calculator.php:31