/** * Busca a aliquota por servico [Json] */ public function emissaoManualBuscarDadosServicoAction() { try { // Perfil do usuario $iIdPerfil = $this->oUsuario->getPerfil()->getId(); $iIdServico = $this->getParam('id_servico'); $aRetornoJson = array(); // Ignora se for prestador eventual if ($iIdPerfil != 6) { $aServicos = Contribuinte_Model_Servico::getByIm($this->oContribuinte->getInscricaoMunicipal(), FALSE); if (is_array($aServicos)) { foreach ($aServicos as $oServico) { if ($oServico->attr('cod_atividade') == $iIdServico) { $aRetornoJson = array('item_servico' => $oServico->attr('desc_item_servico'), 'cod_item_servico' => $oServico->attr('cod_item_servico'), 'estrut_cnae' => $oServico->attr('estrut_cnae'), 'deducao' => $oServico->attr('deducao'), 'aliq' => DBSeller_Helper_Number_Format::toMoney($oServico->attr('aliq'))); break; } } } } echo $this->getHelper('json')->sendJson($aRetornoJson); } catch (Exception $e) { $aRetorno['erro'] = TRUE; if ($e->getCode() == Global_Lib_Model_WebService::CODIGO_ERRO_CONSULTA_WEBSERVICE) { $aRetorno['mensagem'] = "E-cidade temporariamente insdisponível. Emissão bloqueada!"; } else { $aRetorno['mensagem'] = $e->getMessage(); } echo $this->getHelper('json')->sendJson($aRetorno); } }
/** * Retorna todas guias pagas pelo contribuinte optante pelo simples nacional * @param Contribuinte_Model_ContribuinteAbstract $oContribuinte contribuinte optante pelo simples * @return array */ public static function getGuiasPagasOptanteSimples(Contribuinte_Model_ContribuinteAbstract $oContribuinte) { $aCampos = array('competencia', 'data_vencimento', 'valor_historico', 'valor_corrigido', 'valor_pago'); $aParametros = array(array('inscricao_municipal' => $oContribuinte->getInscricaoMunicipal(), 'tipo_debito' => 3), $aCampos); $aGuiasPagas = WebService_Model_Ecidade::consultar('getPagamentosEfetuadosOptanteSimples', $aParametros); $sRetorno = ''; if (empty($aGuiasPagas)) { $aGuiasPagas = array(); } else { $sRetorno = print_r($aGuiasPagas, true); if (count($aGuiasPagas) == 1 && trim($aGuiasPagas[0]) == 'N') { $aGuiasPagas = array(); } else { if (trim($sRetorno) === "Não houve retorno do WebService") { $aGuiasPagas = array(); } else { //Reverte a ordenação para DESC $aGuiasPagas = array_reverse($aGuiasPagas); } } } return $aGuiasPagas; }