/**
  * Return a sum of all total imports converted to the currency selected
  * 
  * @author Erick Guevara Mart�nez
  * @param RequisitionEntryCollection $requisitionEntries
  * @param Currency $currency
  * @param ExchangeRateCollection $currenciesExchanges
  * @return float
  */
 public function getTotalImportToCurrency(RequisitionEntryCollection $requisitionEntries, Currency $currency, CurrencyExchangeCollection $currenciesExchanges)
 {
     $totalImport = 0;
     $requisitionEntries->rewind();
     while ($requisitionEntries->valid()) {
         $requisitionEntry = $requisitionEntries->read();
         if ($requisitionEntry->isNotCanceled()) {
             $price = $requisitionEntry->getPrice();
             if ($requisitionEntry->getIdCurrency() != $currency->getCurrCode()) {
                 if (!$currenciesExchanges->hasCurrency($requisitionEntry->getIdCurrency()) || !$currenciesExchanges->hasCurrency($currency->getCurrCode())) {
                     $totalImport = null;
                     break;
                 } else {
                     $exchange = $currenciesExchanges->getByFromAndTo($requisitionEntry->getIdCurrency(), $currency->getCurrCode());
                     $price = $price * $exchange->getRate();
                 }
             }
             $totalImport += $requisitionEntry->getQuantity() * $price;
         }
     }
     $requisitionEntries->rewind();
     return $totalImport;
 }
 public function calculatePurchases()
 {
     $this->restockEntries->rewind();
     while ($this->restockEntries->valid()) {
         $restockEntry = $this->restockEntries->read();
         $product = $this->products->getByPK($restockEntry->getIdProduct());
         $exhangeRate = $this->currencyExchages->getByFromAndTo($product->getCurrency(), Currency::$defaultCurrency);
         $purchases[$restockEntry->getIdRestockEntry()] = $this->quantities[$restockEntry->getIdRestockEntry()] * ($this->getMinTargetPriceUSDByIdProduct($restockEntry->getIdProduct()) * $exhangeRate->getRate());
     }
     return $purchases;
 }