Skip to content

Commit

Permalink
Readme and composer php extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
PauloAK committed Feb 15, 2023
1 parent fcf3583 commit d1bc122
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 3 deletions.
135 changes: 135 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
## Brief
This package currently supports creating, retrieving and canceling NFS-e (RPS) in the WebService of the city of Lajeado/RS - Brazil.

## Package
You can install it through composer
```bash
composer require pauloak/nfse-lajeado
```

## Observation
To be able to use the package, you'll need to have a valid .pfx certificate and the password to access it, it's used to sign the XML before sending it to the city WebService.

## Usage
You can check some usage examples in the [examples](examples) folder, but here's a quick overview.

### Create NFS-e
_Needs a .pfx certificate_

```php
use PauloAK\NfseLajeado\EnviarLoteRpsEnvio;
use PauloAK\NfseLajeado\Common\Rps;
use PauloAK\NfseLajeado\Common\Rps\Endereco;
use PauloAK\NfseLajeado\Common\Rps\Prestador;
use PauloAK\NfseLajeado\Common\Rps\Servico;
use PauloAK\NfseLajeado\Common\Rps\Tomador;
use PauloAK\NfseLajeado\Helpers\Constants;

const CERTIFICATE_PATH = '/path/to/certificate.pfx';
const CERTIFICATE_PASS = 'rand_pass';

$tomador = (new Tomador)
->cpfCnpj('000.000.000-00')
->telefone('51 99999-9999')
->email('email@example.com')
->razaoSocial('Example')
->endereco(
(new Endereco)
->rua('Av. Test')
->numero('0000')
->bairro('Centro')
->codigoMunicipio('4311403') // IBGE Code
->uf('RS')
->cep('95900-000')
->complemento('')
);

$servico = (new Servico)
->codigoCnae('0000000')
->itemListaServico('000')
->discriminacao('Test RPS')
->issRetido(Constants::NAO)
->valorServicos(99.99);

$prestador = (new Prestador)
->cnpj('00.000.0000/0001-00')
->im('00000');

$rps = (new Rps)
->tomador($tomador)
->prestador($prestador)
->servico($servico)
->serie('00000')
->numero(1)
->naturezaOperacao(Constants::NATUREZA_OPERACAO_IMPOSTO_RECOLHIDO_PELO_REGIME_UNICO_TRIBUTACAO)
->optanteSimplesNacional(Constants::SIM);

$lote = (new EnviarLoteRpsEnvio(CERTIFICATE_PATH, CERTIFICATE_PASS))
->numeroLote(2)
->cnpj('00.000.000/0001-00')
->im('00000')
->rps($rps);

// Sends to Homologation
$data = $lote->sendHml();

// Sends to Production
// $data = $lote->send();
```

If your call is successful, you'll receive an array with the next lote number, next rps number and the protocol number to retrieve the NFS-e.
```php
$returnedData = [
'numeroLote' => 50, // Number - Next lote number, you can store and use in the next NFS-e creation
'numeroRps' => 101, // Number - Next rps number, you can store and use in the next NFS-e creation
'protocolo' => '000000000' // String - Protocol number to retrieve the NFS-e
];
```

### Retrieve NFS-e
_Does NOT need a .pfx certificate_
After you create an NFS-e, you'll receive a protocol number which you can use to retrieve the NFS-e.
Currently, this package only returns the NFS-e number and the verification code.
```php
use PauloAK\NfseLajeado\Common\Rps\Prestador;
use PauloAK\NfseLajeado\ConsultarLoteRpsEnvio;

$consulta = (new ConsultarLoteRpsEnvio)
->prestador(
(new Prestador)
->cnpj('00.000.000/0001-00')
->im('00000')
)
->protocolo('00000'); // The protocol number returned in the creation call

// Sends to homologation
$data = $consulta->sendHml();
```

If your call is successful, you'll receive an array with the NFS-e number and the verification code.
```php
$returnedData = [
'numero' => 20231, // Number - NFS-e number
'codigoVerificacao' = 'ABC12346' // String - Verification code
];
```

### Cancel NFS-e
_Needs a .pfx certificate_
To cancel an NFS-e, you'll need the NFS-e number and the certificate.
```php
use PauloAK\NfseLajeado\CancelarRps;

const CERTIFICATE_PATH = '/path/to/certificate.pfx';
const CERTIFICATE_PASS = 'rand_pass';

$cancelamento = (new CancelarRps(CERTIFICATE_PATH, CERTIFICATE_PASS))
->cnpj('00.000.000/0001-00')
->im('00000')
->numero('00000');

// Sends to homologation
$data = $cancelamento->sendHml();
```

If your call is successful it should return `true`.
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
"php": ">=7",
"guzzlehttp/guzzle": "^7.5",
"spatie/array-to-xml": "^3.1",
"nfephp-org/sped-common": "^5.1"
"nfephp-org/sped-common": "^5.1",
"ext-dom": "*",
"ext-soap": "*",
"ext-openssl": "*",
"ext-mbstring": "*"
},
"license": "MIT",
"autoload": {
Expand Down
8 changes: 6 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d1bc122

Please sign in to comment.