components/FcrnRate.php
public function convertFromTo($from_fcrn_id,$to_fcrn_id,$amt,  $date,$round = 6, $source = false) {
        
        
        Yii::log("Converting from ".$this->convId2Code($from_fcrn_id)." to ".$this->convId2Code($to_fcrn_id));
        //default source - syscompany source
        if(!$source){
            $source = $this->getSysCcmpCurrencySource($date);
        }
        
        $from_rate = $this->getCurrencyRate($from_fcrn_id, $date,$source);
        if ($from_rate === FALSE) {
            return FALSE;
        }        
        
        $to_rate = $this->getCurrencyRate($to_fcrn_id, $date,$source);
        if ($to_rate === FALSE) {
            return FALSE;
        }
        
        /**
         * @todo add convert type to fcsr_courrency_source as definition
         */
        
        if ($source == self::SOURCE_BANK_RU){
            return round($to_rate*$from_rate * $amt, $round);
        } else {
             return round($to_rate/$from_rate * $amt, $round);
        }
            
    }
public function convertFromTo($from_fcrn_id,$to_fcrn_id,$amt,  $date,$round = 6, $source = false) {
        
        
        Yii::log("Converting from ".$this->convId2Code($from_fcrn_id)." to ".$this->convId2Code($to_fcrn_id));
        //default source - syscompany source
        if(!$source){
            $source = $this->getSysCcmpCurrencySource($date);
        }
        
        $from_rate = $this->getCurrencyRate($from_fcrn_id, $date,$source);
        if ($from_rate === FALSE) {
            return FALSE;
        }        
        
        $to_rate = $this->getCurrencyRate($to_fcrn_id, $date,$source);
        if ($to_rate === FALSE) {
            return FALSE;
        }
        
        /**
         * @todo add convert type to fcsr_courrency_source as definition
         */
        
        if ($source == self::SOURCE_BANK_RU){
            return round($to_rate*$from_rate * $amt, $round);
        } else {
             return round($to_rate/$from_rate * $amt, $round);
        }
            
    }
public function convertFromTo ( $ from_fcrn_id , $ to_fcrn_id , $ amt , $ date , $ round = 6 , $ source = false ) { Yii :: log ( "Converting from " . $ this -> convId2Code ( $ from_fcrn_id ) . " to " . $ this -> convId2Code ( $ to_fcrn_id ) ) ; //default source - syscompany source if ( ! $ source ) { $ source = $ this -> getSysCcmpCurrencySource ( $ date ) ; } $ from_rate = $ this -> getCurrencyRate ( $ from_fcrn_id , $ date , $ source ) ; if ( $ from_rate === FALSE ) { return FALSE ; } $ to_rate = $ this -> getCurrencyRate ( $ to_fcrn_id , $ date , $ source ) ; if ( $ to_rate === FALSE ) { return FALSE ; } /**
         * @todo add convert type to fcsr_courrency_source as definition
         */ if ( $ source == self :: SOURCE_BANK_RU ) { return round ( $ to_rate * $ from_rate * $ amt , $ round ) ; } else { return round ( $ to_rate / $ from_rate * $ amt , $ round ) ; } }
convert from one currency to other
@param int $from_fcrn_id
@param int $to_fcrn_id
@param decimal $amt
@param date $date
@return boolean/amt
convert from one currency to other