/**
  * This function verify if exist all needded exchange rates to calculate a import in one currency
  * 
  * @author Erick Guevara Mart�nez
  * @param RequisitionEntryCollection $requisitionEntries
  * @param Currency $currencyTo
  * @param ExchangeRateCollection $currenciesExchanges
  * @return array
  */
 public function validateExchangeRates(RequisitionEntryCollection $requisitionEntries, Currency $currencyTo, CurrencyExchangeCollection $currenciesExchanges)
 {
     $validation["valid"] = true;
     $requisitionEntries->rewind();
     while ($requisitionEntries->valid()) {
         $requisitionEntry = $requisitionEntries->read();
         if ($requisitionEntry->getIdCurrency() != $currencyTo->getCurrCode()) {
             if (!$currenciesExchanges->hasCurrency($requisitionEntry->getIdCurrency()) || !$currenciesExchanges->hasCurrency($currencyTo->getCurrCode())) {
                 $validation["valid"] = false;
                 $validation["from"] = $requisitionEntry->getIdCurrency();
                 $validation["to"] = $currencyTo->getCurrCode();
                 break;
             }
         }
     }
     $requisitionEntries->rewind();
     return $validation;
 }
 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;
 }