function CALCULA_REAL() { $moeda = new Moeda(); $valorCalculo = $this->valor; if ($this->moeda->id == $moeda->REAL()) { return $valorCalculo; } else { return $valorCalculo * $this->cotacaoReal; } }
function getValorReal() { $moeda = new Moeda(); if ($this->participante->grupo->moeda->id == $moeda->REAL()) { return $this->valor; } else { return $this->valor * $this->pagamento->cotacaoReal; } }
$cont = 1; foreach ($rs as $key => $p) { $tpl->ID = $cont; $tpl->PARTICIPANTE = $p->cliente->nomeCompleto; $tpl->STATUS = $p->status->descricao; //calcula custo: $custo = $p->custoTotal; if ($oGrupo->moeda->id == $oMoeda->DOLLAR()) { $custoDollar = $custo; $custoReal = $custo * $oGrupo->cotacaoCusto; } else { $custoDollar = $custo / $oGrupo->cotacaoCusto; $custoReal = $custo; } $recebimentosDollar = $p->recuperaValorTodosAbatimentos($oMoeda->DOLLAR()); $recebimentosReal = $p->recuperaValorTodosAbatimentos($oMoeda->REAL()); //alimenta a primeira linha do relatorio $tpl->CAMBIO_CUSTO = $oMoeda->money($oGrupo->cotacaoCusto, "atb"); $tpl->CUSTO_DOLLAR = $oMoeda->money($custoDollar, "atb"); $tpl->CUSTO_REAL = $oMoeda->money($custoReal, "atb"); $tpl->RECEBIMENTOS_DOLLAR = $oMoeda->money($recebimentosDollar, "atb"); $tpl->RECEBIMENTOS_REAL = $oMoeda->money($recebimentosReal, "atb"); //SOMATORIOS DE VALORES $TOTAL_RECEBIMENTO_DOLLAR += $recebimentosDollar; $TOTAL_RECEBIMENTO_REAL += $recebimentosReal; $TOTAL_CUSTO_DOLLAR += $custoDollar; $TOTAL_CUSTO_REAL += $custoReal; //busca os pagamentos ativos do participante $rsAbat = $oAbatimento->getRows(0, 999, array(), array("participante" => "=" . $p->id)); foreach ($rsAbat as $keyAbat => $abat) { $pag = $abat->pagamento;
function CALCULA_MOEDA($valor, $idMoeda) { $moeda = new Moeda(); if ($idMoeda == $moeda->DOLLAR()) { // do dollar para moeda do pagamento if ($this->moeda->id == $moeda->DOLLAR()) { return $this->arredondar_dois_decimal($valor); } else { if ($this->moeda->id == $moeda->REAL()) { return $this->arredondar_dois_decimal($valor * $this->cotacaoReal); } else { return $this->arredondar_dois_decimal($valor * $this->cotacaoReal / $this->cotacaoMoedaReal); } } } else { //do real para moeda do pagamento if ($this->moeda->id == $moeda->REAL()) { return $this->arredondar_dois_decimal($valor); } else { if ($this->moeda->id == $moeda->DOLLAR()) { return $this->arredondar_dois_decimal($valor / $this->cotacaoReal); } else { return $this->arredondar_dois_decimal($valor / $this->cotacaoMoedaReal); } } } }