Ejemplo n.º 1
0
 /**
  * @param $reservations SaleStatisticsItem[]
  * @return string
  */
 public function getTotalPriceInEuroForSaleStatistics($reservations)
 {
     /**
      * @var CurrencyDAO $currencyDao
      */
     $currencyDao = $this->getServiceLocator()->get('dao_currency_currency');
     $currencyExchangeUtility = new \Library\Utility\Currency($currencyDao);
     $totalPriceInEuro = 0;
     foreach ($reservations as $reservation) {
         $reservationApartmentCurrencyIsoCode = $reservation->getApartmentCurrencyIsoCode();
         $reservationPriceInApartmentCurrency = $reservation->getReservationPriceInApartmentCurrency();
         if ($reservationApartmentCurrencyIsoCode == 'EUR') {
             $totalPriceInEuro += $reservationPriceInApartmentCurrency;
         } else {
             $totalPriceInEuro += $currencyExchangeUtility->convert($reservationPriceInApartmentCurrency, $reservationApartmentCurrencyIsoCode, 'EUR');
         }
     }
     return number_format($totalPriceInEuro, 2, '.', '');
 }
Ejemplo n.º 2
0
 /**
  * @param $ticketId
  * @param $price
  * @param $currencyId
  * @return array
  */
 public function checkPoForOrderItem($ticketId, $price, $currencyId)
 {
     $expenseDao = new Expenses($this->getServiceLocator());
     $basicInfo = $expenseDao->getBasicInfoForOrderManagement($ticketId);
     if (!$basicInfo) {
         return ['status' => 'error', 'msg' => 'PO with mentioned ID does not exist'];
     }
     if ($basicInfo['status'] != Helper::STATUS_GRANTED) {
         return ['status' => 'error', 'msg' => 'Purchase order is not approved'];
     }
     $PoCurrency = $basicInfo['currency_id'];
     $PoItemBalance = $basicInfo['item_balance'];
     $PoLimit = $basicInfo['limit'];
     $currencyExchange = new \Library\Utility\Currency($this->getServiceLocator()->get('dao_currency_currency'));
     $priceInTicketCurrency = $currencyExchange->convert($price, intval($currencyId), intval($PoCurrency));
     if ($priceInTicketCurrency + $PoItemBalance > $PoLimit) {
         return ['status' => 'error', 'msg' => 'Can not exceed the limit'];
     }
     return ['status' => 'success'];
 }