Example #1
0
 public function setChangedMoney($event)
 {
     if ($this->owner->{$this->currency_prop} == 35) {
         $curs = CurrHistory::find()->where(['currency_id' => $this->owner->{$this->currency_out_prop}])->all();
         $value = round($this->owner->{$this->money_in_rub} / $curs[0]->value / $curs[0]->nominal, 3, PHP_ROUND_HALF_EVEN);
     } else {
         $curs_in = CurrHistory::find()->where(['currency_id' => $this->owner->{$this->currency_prop}])->all();
         $curs_out = CurrHistory::find()->where(['currency_id' => $this->owner->{$this->currency_out_prop}])->all();
         $value = round($this->owner->{$this->money_in_rub} * ($curs_out[0]->value / $curs_out[0]->nominal) / ($curs_in[0]->value / $curs_in[0]->nominal), 3, PHP_ROUND_HALF_EVEN);
     }
     $this->makeAndSetInHumanUnderstoodView($value);
 }
Example #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCurrHistories()
 {
     return $this->hasMany(CurrHistory::className(), ['currency_id' => 'id']);
 }