예제 #1
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCurrency()
 {
     return $this->hasOne(Currency::className(), ['code' => 'currency_code']);
 }
예제 #2
0
 /**
  * @param $currencyTo
  * @return Money
  */
 public function convertToCurrency($currencyTo)
 {
     $currencyTo = Currency::getInstance($currencyTo);
     if ($crossCourse = $this->getCurrency()->getCrossCourse($currencyTo)) {
         $newMoney = $this->multiply($crossCourse);
         return new static($newMoney->getAmount(), $currencyTo);
     } else {
         throw new InvalidArgumentException(\Yii::t('skeeks/money', 'Unable to get the cross rate for the currency') . ' ' . $currencyTo->getCurrencyCode());
     }
 }
예제 #3
0
 /**
  * Объект текущей валюты
  *
  * @return Currency
  */
 public function getCurrencyObject()
 {
     return Currency::getInstance(\Yii::$app->money->currencyCode);
 }