示例#1
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'];
 }