Comments (8)
@maisonsakamoto olha essa funcao mas na biblioteca do NFePHP, talvez de para implementar no sped-cte também.
/**
* sefazDistDFe
* Serviço destinado à distribuição de informações
* resumidas e documentos fiscais eletrônicos de interesse de um ator.
* @param string $fonte sigla da fonte dos dados 'AN'
* e para alguns casos pode ser 'RS'
* @param string $tpAmb tiupo de ambiente
* @param string $cnpj
* @param integer $ultNSU ultimo numero NSU que foi consultado
* @param integer $numNSU numero de NSU que se quer consultar
* @param array $aRetorno array com os dados do retorno
* @param boolean $descompactar se true irá descompactar os dados retornados,
* se não os dados serão retornados da forma que foram recebidos
* @return string contento o xml retornado pela SEFAZ
* @internal function zLoadServico (Common\Base\BaseTools)
*/
public function sefazDistDFe(
$fonte = 'AN',
$tpAmb = '2',
$cnpj = '',
$ultNSU = 0,
$numNSU = 0,
&$aRetorno = array()
) {
if ($tpAmb == '') {
$tpAmb = $this->aConfig['tpAmb'];
}
$siglaUF = $this->aConfig['siglaUF'];
if ($cnpj == '') {
$cnpj = $this->aConfig['cnpj'];
}
//carrega serviço
$servico = 'NFeDistribuicaoDFe';
$this->zLoadServico(
'nfe',
$servico,
$fonte,
$tpAmb
);
if ($this->urlService == '') {
$msg = "A distribuição de documento DFe não está disponível na SEFAZ $fonte!!!";
throw new Exception\RuntimeException($msg);
}
$cUF = self::zGetcUF($siglaUF);
$ultNSU = str_pad($ultNSU, 15, '0', STR_PAD_LEFT);
$tagNSU = "<distNSU><ultNSU>$ultNSU</ultNSU></distNSU>";
if ($numNSU != 0) {
$numNSU = str_pad($numNSU, 15, '0', STR_PAD_LEFT);
$tagNSU = "<consNSU><NSU>$numNSU</NSU></consNSU>";
}
//monta a consulta
$cons = "<distDFeInt xmlns=\"$this->urlPortal\" versao=\"$this->urlVersion\">"
. "<tpAmb>$tpAmb</tpAmb>"
. "<cUFAutor>$cUF</cUFAutor>"
. "<CNPJ>$cnpj</CNPJ>$tagNSU</distDFeInt>";
//validar mensagem com xsd
//if (! $this->validarXml($cons)) {
// $msg = 'Falha na validação. '.$this->error;
// throw new Exception\RuntimeException($msg);
//}
//montagem dos dados da mensagem SOAP
$body = "<nfeDistDFeInteresse xmlns=\"$this->urlNamespace\">"
. "<nfeDadosMsg xmlns=\"$this->urlNamespace\">$cons</nfeDadosMsg>"
. "</nfeDistDFeInteresse>";
//envia dados via SOAP e verifica o retorno este webservice não requer cabeçalho
$this->urlHeader = '';
$retorno = $this->oSoap->send(
$this->urlService,
$this->urlNamespace,
$this->urlHeader,
$body,
$this->urlMethod
);
$lastMsg = $this->oSoap->lastMsg;
$this->soapDebug = $this->oSoap->soapDebug;
//salva mensagens
$tipoNSU = (int) ($numNSU != 0 ? $numNSU : $ultNSU);
$datahora = date('Ymd_His');
$filename = "$tipoNSU-$datahora-distDFeInt.xml";
$this->zGravaFile('nfe', $tpAmb, $filename, $lastMsg);
$filename = "$tipoNSU-$datahora-retDistDFeInt.xml";
$this->zGravaFile('nfe', $tpAmb, $filename, $retorno);
//tratar dados de retorno
$aRetorno = ReturnNFe::readReturnSefaz($servico, $retorno);
return (string) $retorno;
}
from sped-cte.
Perfeito Samuel existe um serviço (CTeDistribuicaoDFe) que é o equivalente à esse que tu postou (NFeDistribuicaoDFe) então é possível sim, vou entrar no Desenv. agora e mando o Pull Request quando estiver funcional, obrigado !
from sped-cte.
@maisonsakamoto perfeito. Muito obrigado.
from sped-cte.
@maisonsakamoto chegaram a implementar o CTeDistribuicaoDFe ?
from sped-cte.
from sped-cte.
Eu criei o método em nosso projeto atual para que tenhamos como baixar os CTe's pelo ambiente nacional.
<UF>
<sigla>AN</sigla>
<homologacao>
<CTeDistribuicaoDFe method='CTeDistribuicaoDFe' operation='CTeDistribuicaoDFe' version='3.00'>https://homologacao.cte.fazenda.gov.br/CTeDistribuicaoDFe/CTeDistribuicaoDFe.asmx</CTeDistribuicaoDFe>
</homologacao>
<producao>
<CTeDistribuicaoDFe method='CTeDistribuicaoDFe' operation='CTeDistribuicaoDFe' version='3.00'>https://www1.cte.fazenda.gov.br/CTeDistribuicaoDFe/CTeDistribuicaoDFe.asmx</CTeDistribuicaoDFe>
</producao>
</UF>
/**
* cteDownload
* Solicita o download de CTes
*
* @param string $chNFe
* @param string $tpAmb
* @param string $cnpj
* @param array $aRetorno
* @return string
* @throws Exception\RuntimeException
*/
public function cteDownload(
$chCTe='',
$tpAmb = '',
$cnpj = '',
&$aRetorno = array(),
$ultimoNSU = 0
) {
if ($tpAmb == '') {
$tpAmb = $this->aConfig['tpAmb'];
}
$siglaUF = $this->aConfig['siglaUF'];
if ($cnpj == '') {
$cnpj = $this->aConfig['cnpj'];
}
//carrega serviço
$servico = 'CTeDistribuicaoDFe';
$this->zLoadServico(
'cte',
$servico,
'AN',
$tpAmb
);
if ($this->urlService == '') {
$msg = "A distribuição de documento Cte não está disponível na SEFAZ !!!";
throw new Exception\RuntimeException($msg);
}
$cUF = self::getcUF($siglaUF);
$ultimoNSU = str_pad($ultimoNSU, 15, '0', STR_PAD_LEFT);
$body = "";
$body .= "<cteDistDFeInteresse xmlns='http://www.portalfiscal.inf.br/cte/wsdl/CTeDistribuicaoDFe'>";
$body .= " <cteDadosMsg><distDFeInt xmlns='http://www.portalfiscal.inf.br/cte' versao='1.00'>";
$body .= " <tpAmb>{$tpAmb}</tpAmb>";
$body .= " <cUFAutor>{$cUF}</cUFAutor>";
$body .= " <CNPJ>{$cnpj}</CNPJ>";
$body .= " <distNSU><ultNSU>{$ultimoNSU}</ultNSU></distNSU>";
$body .= " </distDFeInt></cteDadosMsg>";
$body .= "</cteDistDFeInteresse>";
//envia dados via SOAP e verifica o retorno este webservice não requer cabeçalho
$retorno = $this->oSoap->send(
$this->urlService,
$this->urlNamespace,
$this->urlHeader,
$body,
$this->urlMethod
);
$lastMsg = $this->oSoap->lastMsg;
//salva mensagens
$filename = "$chCTe-downCTe.xml";
$this->zGravaFile('cte', $tpAmb, $filename, $lastMsg);
$filename = "$chCTe-retCTe.xml";
$this->zGravaFile('cte', $tpAmb, $filename, $retorno);
//tratar dados de retorno
$aRetorno = Response::readReturnSefaz($servico, $retorno);
return (string) $retorno;
}
from sped-cte.
from sped-cte.
@maisonsakamoto estou recebendo CTe para uma Empresa que é de Ribeirão Preto - SP e esses CTe's vem de diversos estados, pelo que pude notar, há cte's de SP, SC, RJ, MG, BA, SC
from sped-cte.
Related Issues (20)
- Download via chave de acesso [57] HOT 2
- Download CTE
- manifestar cte HOT 4
- Montagem Errada Tag "Entrega" HOT 4
- Prestação de Serviço em Desacordo HOT 11
- CteRecepcaoEvento SVSP HOT 2
- Erro ao baixar CTe HOT 4
- Ajuda HOT 2
- "Class 'SOAPHeader' not found" na chamada do método 'sefazDistDFe' HOT 1
- Suporte para PHP 8
- a biblioteca sped-cte vai estrar preparada para o novo documento de transporte DT-e? HOT 2
- Trabalhar com documentos GTVe HOT 1
- Auxílio para inserir tagobsCont
- sefazDownload volta erro de SOAP HOT 4
- CT-e 4.0 HOT 19
- Contingência EPEC HOT 1
- Teste utilizando a branch dev-master HOT 1
- Branch 4 - Remocao de caracteres estranhos no arquivo wscte_4.00_mod57.xml HOT 1
- Consulta Recibo HOT 1
- CONTINGENCIA PARA O ESTADO DE RN E PI HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sped-cte.