-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit cef02eb
Showing
23 changed files
with
5,975 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.idea/ | ||
composer.lock | ||
vendor/ | ||
exemples/certs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
if (! function_exists('now')) { | ||
/** | ||
* Create a new Carbon instance for the current time. | ||
* | ||
* @param \DateTimeZone|string|null $tz | ||
* @return \Carbon\Carbon | ||
*/ | ||
function now($tz = null) | ||
{ | ||
return \Carbon\Carbon::now($tz); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# NFSe Padrão Nacional | ||
|
||
Pacote para geração de NFSe Padrão Nacional (https://www.nfse.gov.br/) usando componentes NFePHP (https://github.com/nfephp-org). | ||
|
||
Este pacote foi desenvolvido para atender algumas das minhas necessidades, implementei o que utilizei e a toque de caixa. Se quiser colaborar envie seu PR. | ||
|
||
**Em desenvolvimento. Use por sua conta e risco.** | ||
|
||
## Install | ||
|
||
**Este pacote é desenvolvido para uso do [Composer](https://getcomposer.org/), então não terá nenhuma explicação de instalação alternativa.** | ||
|
||
```bash | ||
composer require hadder/nfse-nacional | ||
``` | ||
|
||
|
||
### Serviços implementados | ||
- consultarNfseChave | ||
- consultarDpsChave | ||
- consultarNfseEventos | ||
- consultarDanfse | ||
- enviaDps | ||
- cancelaNfse | ||
|
||
## Requerimentos | ||
- PHP 8.2+ | ||
- ext-zlib | ||
- ext-openssl | ||
- ext-dom | ||
- ext-curl | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"name": "hadder/nfse-nacional", | ||
"description": "Pacote para geração de NFSe Nacional usando componentes NFePHP (https://github.com/nfephp-org)", | ||
"keywords": [ | ||
"nfse-nacional", | ||
"nfse", | ||
"mei" | ||
], | ||
"license": "MIT", | ||
"autoload": { | ||
"psr-4": { | ||
"Hadder\\NfseNacional\\": "src/" | ||
}, | ||
"files": [ | ||
"Helpers.php" | ||
] | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Fernando Friedrich", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"require": { | ||
"php": "^8.2", | ||
"symfony/var-dumper": "^7.1", | ||
"tecnickcom/tcpdf": "^6.7", | ||
"nfephp-org/sped-common": "^5.1", | ||
"ext-dom": "*", | ||
"nesbot/carbon": "^3.8", | ||
"ext-curl": "*", | ||
"ext-zlib": "*", | ||
"ext-openssl": "*" | ||
}, | ||
"config": { | ||
"optimize-autoloader": true | ||
}, | ||
"prefer-stable": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
error_reporting(E_ALL); | ||
ini_set('display_errors', 'On'); | ||
date_default_timezone_set('America/Sao_Paulo'); | ||
include __DIR__ . '/../vendor/autoload.php'; | ||
|
||
try { | ||
$config = new stdClass(); | ||
$config->tpamb = 1; //1 - Produção, 2 - Homologação | ||
$configJson = json_encode($config); | ||
$content = file_get_contents('certificado.pfx'); | ||
$password = 'senha_certificado'; | ||
$cert = \NFePHP\Common\Certificate::readPfx($content, $password); | ||
$tools = new \Hadder\NfseNacional\Tools($configJson, $cert); | ||
|
||
$std = new stdClass(); | ||
$std->nPedRegEvento = 1; //Número do Pedido de Registro do Evento (nPedRegEvento) (3) | ||
$std->infPedReg = new stdClass(); | ||
$std->infPedReg->chNFSe = '00000000000000000000000000000000000000000000000000'; //Chaveda NFS-e a qual o evento será vinculada. | ||
$std->infPedReg->CNPJAutor = '00000000000000'; | ||
//$std->infPedReg->CPFAutor = '00000000000'; | ||
$std->infPedReg->dhEvento = now()->format('Y-m-d\TH:i:sP'); | ||
$std->infPedReg->tpAmb = 1; //1 - Produção; 2 - Homologação | ||
$std->infPedReg->verAplic = 'Nome_Sistema_V1.0'; | ||
|
||
//Evento e101101 - Cancelamento | ||
$std->infPedReg->e101101 = new stdClass(); | ||
$std->infPedReg->e101101->xDesc = 'Cancelamento de NFS-e';// Descrição do evento | ||
$std->infPedReg->e101101->cMotivo = 9;// Código de cancelamento: 1 - Erro na Emissão; 2 - Serviço não Prestado; 9 - Outros; | ||
$std->infPedReg->e101101->xMotivo = 'Teste de cancelamento da NFSe em produção pois em homologação não funciona!';// Descrição para explicitar o motivo indicado neste evento. | ||
|
||
//Evento e105102 - Cancelamento por Substituição | ||
/* | ||
* Código de cancelamento | ||
* 1 - Desenquadramento de NFS-e do Simples Nacional; | ||
* 2 - Enquadramento de NFS-e no Simples Nacional; | ||
* 3 - Inclusão Retroativa de Imunidade/Isenção para NFS-e; | ||
* 4 - Exclusão Retroativa de Imunidade/Isenção para NFS-e; | ||
* 5 - Rejeição de NFS-e pelo tomador ou pelo intermediário se responsável pelo recolhimento do tributo; | ||
* 9 - Outros; | ||
* Obtido do campo da DPS ""DPS/infDPS/subst/cMotivo""." | ||
*/ | ||
// $std->infPedReg->e105102 = new stdClass(); | ||
// $std->infPedReg->e105102->xDesc = 'Cancelamento de NFS-e por Substituição';// Descrição do evento | ||
// $std->infPedReg->e105102->cMotivo = 1;// Código de cancelamento | ||
// $std->infPedReg->e105102->xMotivo = '';// Descrição para explicitar o motivo indicado neste evento. Obtido do campo da DPS DPS/infDPS/subst/xMotivo | ||
// $std->infPedReg->e105102->chSubstituta = '00000000000000000000000000000000000000000000000000';// Chave de Acesso da NFS-e substituta. | ||
|
||
$response = $tools->cancelaNfse($std); | ||
dd($response); | ||
|
||
} catch (Exception $e) { | ||
dd($e->getMessage(), $e); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
error_reporting(E_ALL); | ||
ini_set('display_errors', 'On'); | ||
date_default_timezone_set('America/Sao_Paulo'); | ||
include __DIR__ . '/../vendor/autoload.php'; | ||
|
||
try { | ||
$config = new stdClass(); | ||
$config->tpamb = 1; //1 - Produção, 2 - Homologação | ||
//$config->formatOutput = true; // Para debug retorna XML formatado | ||
$configJson = json_encode($config); | ||
$content = file_get_contents('certificado.pfx'); | ||
$password = 'senha_certificado'; | ||
$cert = \NFePHP\Common\Certificate::readPfx($content, $password); | ||
$tools = new \Hadder\NfseNacional\Tools($configJson, $cert); | ||
//Informar chave NFSe | ||
$response = $tools->consultarDanfse('00000000000000000000000000000000000000000000000000'); | ||
header("Content-Type: application/pdf"); | ||
header('Content-Disposition: inline; filename="NFSe.pdf"'); | ||
header('Content-Transfer-Encoding: binary'); | ||
// header('Content-Length: ' . filesize($file)); | ||
header('Accept-Ranges: bytes'); | ||
|
||
echo $response; | ||
} catch (Exception $e) { | ||
dd($e->getMessage(), $e); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
error_reporting(E_ALL); | ||
ini_set('display_errors', 'On'); | ||
date_default_timezone_set('America/Sao_Paulo'); | ||
include __DIR__ . '/../vendor/autoload.php'; | ||
|
||
try { | ||
$config = new stdClass(); | ||
$config->tpamb = 1; //1 - Produção, 2 - Homologação | ||
$configJson = json_encode($config); | ||
$content = file_get_contents('certificado.pfx'); | ||
$password = 'senha_certificado'; | ||
$cert = \NFePHP\Common\Certificate::readPfx($content, $password); | ||
$tools = new \Hadder\NfseNacional\Tools($configJson, $cert); | ||
//Informar chave da DPS para obter a chave da NFSe | ||
$response = $tools->consultarDpsChave('DPS000000000000000000000000000000000000000000'); | ||
|
||
dd($response); | ||
|
||
} catch (Exception $e) { | ||
dd($e->getMessage(), $e); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
error_reporting(E_ALL); | ||
ini_set('display_errors', 'On'); | ||
date_default_timezone_set('America/Sao_Paulo'); | ||
include __DIR__ . '/../vendor/autoload.php'; | ||
|
||
try { | ||
$config = new stdClass(); | ||
$config->tpamb = 1; //1 - Produção, 2 - Homologação | ||
$configJson = json_encode($config); | ||
$content = file_get_contents('certificado.pfx'); | ||
$password = 'senha_certificado'; | ||
$cert = \NFePHP\Common\Certificate::readPfx($content, $password); | ||
$tools = new \Hadder\NfseNacional\Tools($configJson, $cert); | ||
|
||
//Informar chave da NFSe, retorna XML | ||
$response = $tools->consultarNfseChave('00000000000000000000000000000000000000000000000000'); | ||
dd($response); | ||
|
||
} catch (Exception $e) { | ||
dd($e->getMessage(), $e); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
error_reporting(E_ALL); | ||
ini_set('display_errors', 'On'); | ||
date_default_timezone_set('America/Sao_Paulo'); | ||
include __DIR__ . '/../vendor/autoload.php'; | ||
|
||
try { | ||
$config = new stdClass(); | ||
$config->tpamb = 1; //1 - Produção, 2 - Homologação | ||
$configJson = json_encode($config); | ||
$content = file_get_contents('certificado.pfx'); | ||
$password = 'senha_certificado'; | ||
$cert = \NFePHP\Common\Certificate::readPfx($content, $password); | ||
$tools = new \Hadder\NfseNacional\Tools($configJson, $cert); | ||
|
||
/* | ||
* Existem as pesquisas: | ||
* Apenas chave (retornaria todos eventos) | ||
* Chave + tipo de evento (retornaria todos os eventos daquele tipo) | ||
* Chave + tipo de evento + numero sequencial (este é o único que funciona) | ||
*/ | ||
$response = $tools->consultarNfseEventos('00000000000000000000000000000000000000000000000000', '101101', 1); | ||
dd($response); | ||
|
||
} catch (Exception $e) { | ||
dd($e->getMessage(), $e); | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.