-
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 d67db7e
Showing
9 changed files
with
493 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,2 @@ | ||
.idea | ||
vendor |
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,110 @@ | ||
# EDI Proceda | ||
Ferramenta para interpretar estruturas de dados EDI no padrão **PROCEDA** na versão ``3.1``. | ||
Esta ferramenta é para ser usada pela embarcadora para interpretar estruturas de dados EDI geradas por transportadoras. | ||
|
||
## Uso: | ||
|
||
``` | ||
$file_contents = file_get_contents('OCO10032021_160647.txt'); | ||
$ocoren = new \EdiProceda\Ocoren($file_contents); | ||
print_r($ocoren); | ||
``` | ||
|
||
#### * Exemplo de retorno: | ||
``` | ||
EdiProceda\Ocoren Object | ||
( | ||
[intercambio] => EdiProceda\Registros\Intercambio Object | ||
( | ||
[identificacao_do_remetente] => IDENTIFICAÇÃO DA TRANSPORTADORA | ||
[identificacao_do_destinatario] => IDENTIFICAÇÃO DA EMBARCADORA | ||
[identificacao_do_intercambio] => OCO100321160 | ||
[data] => DateTime Object | ||
( | ||
[date] => 2021-03-10 16:06:00.000000 | ||
[timezone_type] => 3 | ||
[timezone] => UTC | ||
) | ||
) | ||
[documento] => EdiProceda\Registros\Documento Object | ||
( | ||
[identificacao_do_documento] => OCORR100316060 | ||
) | ||
[transportadora] => EdiProceda\Registros\Transportadora Object | ||
( | ||
[cnpj] => 12345678901234 | ||
[razao_social] => RAZÃO SOCIAL DA TRANSPORTADORA | ||
) | ||
[ocorrencias] => Array | ||
( | ||
[0] => EdiProceda\Registros\Ocorrencia Object | ||
( | ||
[cnpj_remetente] => 12345678000123 | ||
[nfe_serie] => 1 | ||
[nfe_numero] => 12345 | ||
[ocorrencia_codigo] => 1 | ||
[data] => DateTime Object | ||
( | ||
[date] => 2021-03-10 07:09:00.000000 | ||
[timezone_type] => 3 | ||
[timezone] => UTC | ||
) | ||
[observacao_codigo] => 3 | ||
[texto_livre] => ENTREGA REALIZADA NORMALMENTE | ||
) | ||
[1] => EdiProceda\Registros\Ocorrencia Object | ||
( | ||
[cnpj_remetente] => 12345678000123 | ||
[nfe_serie] => 1 | ||
[nfe_numero] => 12346 | ||
[ocorrencia_codigo] => 1 | ||
[data] => DateTime Object | ||
( | ||
[date] => 2021-03-10 07:57:00.000000 | ||
[timezone_type] => 3 | ||
[timezone] => UTC | ||
) | ||
[observacao_codigo] => 3 | ||
[texto_livre] => ENTREGA REALIZADA NORMALMENTE | ||
) | ||
[2] => EdiProceda\Registros\Ocorrencia Object | ||
( | ||
[cnpj_remetente] => 12345678000123 | ||
[nfe_serie] => 1 | ||
[nfe_numero] => 12347 | ||
[ocorrencia_codigo] => 21 | ||
[data] => DateTime Object | ||
( | ||
[date] => 2021-03-10 08:00:00.000000 | ||
[timezone_type] => 3 | ||
[timezone] => UTC | ||
) | ||
[observacao_codigo] => 0 | ||
[texto_livre] => ESTABELECIMENTO FECHADO | ||
) | ||
) | ||
) | ||
``` | ||
|
||
Para os objetos de ``Ocorrencia`` também há os métodos públicos ``getDescricao`` e ``getObservacao``. | ||
|
||
``` | ||
echo $ocoren->ocorrencias[0]->getDescricao(); // Retornará "Entrega realizada normalmente" | ||
echo $ocoren->ocorrencias[0]->getObservacao(); // Retornará "Aceite/entrega de acordo" | ||
``` | ||
|
||
## Próximos passos: | ||
|
||
Atualmente o pacote interpreta apenas o layout [**OCOREN**](https://documentacao.senior.com.br/gestaodefretesfis/7.0.0/arquivos/ocoren.pdf). | ||
O próximo passo será adicionar funcionalidade para layout [**CONEMB**](https://documentacao.senior.com.br/gestaodefretesfis/7.0.0/arquivos/conemb.pdf). |
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,11 @@ | ||
{ | ||
"name": "hfoletto/edi-proceda", | ||
"description": "Ferramenta para interpretar estruturas de dados EDI no padrão PROCEDA", | ||
"type": "library", | ||
"require": {}, | ||
"autoload": { | ||
"psr-4": { | ||
"EdiProceda\\": "src/" | ||
} | ||
} | ||
} |
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,65 @@ | ||
<?php | ||
|
||
|
||
namespace EdiProceda; | ||
|
||
use EdiProceda\Registros\Intercambio; | ||
use EdiProceda\Registros\Documento; | ||
use EdiProceda\Registros\Transportadora; | ||
use EdiProceda\Registros\Ocorrencia; | ||
|
||
/** | ||
* @property-read Intercambio $intercambio | ||
* @property-read Documento $documento | ||
* @property-read Transportadora $transportadora | ||
* @property-read Ocorrencia[] $ocorrencias | ||
*/ | ||
class Ocoren | ||
{ | ||
|
||
public $intercambio; | ||
|
||
public $documento; | ||
|
||
public $transportadora; | ||
|
||
public $ocorrencias; | ||
|
||
/** | ||
* Ocoren constructor. | ||
* @param string $file_contents | ||
*/ | ||
public function __construct($file_contents) { | ||
$this->ocorrencias = array(); | ||
$lines = explode(PHP_EOL, $file_contents); | ||
foreach ($lines as $line) { | ||
$this->analyseLine($line); | ||
} | ||
} | ||
|
||
/** | ||
* @param string $line | ||
*/ | ||
private function analyseLine($line) { | ||
$identificador_de_registro = substr($line, 0, 3); | ||
switch ($identificador_de_registro) { | ||
case '000': | ||
$registro = new Intercambio($line); | ||
$this->intercambio = $registro; | ||
break; | ||
case '340': | ||
$registro = new Documento($line); | ||
$this->documento = $registro; | ||
break; | ||
case '341': | ||
$registro = new Transportadora($line); | ||
$this->transportadora = $registro; | ||
break; | ||
case '342': | ||
$registro = new Ocorrencia($line); | ||
$this->ocorrencias[] = $registro; | ||
break; | ||
} | ||
|
||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
|
||
namespace EdiProceda\Registros; | ||
|
||
/** | ||
* @property-read string $identificacao_do_documento | ||
*/ | ||
class Documento extends Registro | ||
{ | ||
const POSICOES = array( | ||
// 'identificador_de_registro' => [0 , 3], // Identificador de registro | ||
'identificacao_do_documento' => [3, 14], // Identificação do documento | ||
); | ||
|
||
public $identificacao_do_documento; | ||
|
||
/** | ||
* Documento constructor. | ||
* @param string $line | ||
*/ | ||
public function __construct($line) | ||
{ | ||
parent::__construct($line, self::POSICOES); | ||
} | ||
} |
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,45 @@ | ||
<?php | ||
|
||
namespace EdiProceda\Registros; | ||
|
||
use DateTime; | ||
|
||
/** | ||
* @property-read string $identificacao_do_remetente | ||
* @property-read string $identificacao_do_destinatario | ||
* @property-read string $identificacao_do_intercambio | ||
* @property-read DateTime $data | ||
*/ | ||
class Intercambio extends Registro | ||
{ | ||
|
||
const POSICOES = array( | ||
// 'identificador_de_registro' => [0 , 3], // Identificador de registro | ||
'identificacao_do_remetente' => [3, 35], // Identificação do remetente | ||
'identificacao_do_destinatario' => [38, 35], // Identificação do destinatário | ||
// 'data' => [73, 6], // Data | ||
// 'hora' => [79, 4], // Hora | ||
'identificacao_do_intercambio' => [83, 12] // Identificação do Intercâmbio | ||
); | ||
|
||
public $identificacao_do_remetente; | ||
|
||
public $identificacao_do_destinatario; | ||
|
||
public $identificacao_do_intercambio; | ||
|
||
public $data; | ||
|
||
/** | ||
* Intercambio constructor. | ||
* @param string $line | ||
*/ | ||
public function __construct($line) | ||
{ | ||
|
||
$this->data = DateTime::createFromFormat('dmyHi', substr($line, 73, 10)); | ||
|
||
parent::__construct($line, self::POSICOES); | ||
|
||
} | ||
} |
Oops, something went wrong.