Skip to content

Commit

Permalink
Merge pull request #540 from robmachado/versionamento
Browse files Browse the repository at this point in the history
Versionamento
  • Loading branch information
robmachado authored Oct 7, 2023
2 parents 3c110d6 + f787689 commit a06735b
Show file tree
Hide file tree
Showing 1,165 changed files with 25,725 additions and 3,035 deletions.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# sped-efd
https://stackoverflow.com/questions/8549496/how-can-i-create-a-function-dynamically

- Contrib/M215
- Contrib/M615
- Contrib/Z1601

## EM DESENVOLVIMENTO

Expand All @@ -15,7 +20,21 @@ Classes para a geração do SPED EFD (fiscal ICMS IPI) e para o SPED EFD contrib
## Controle de Versões de Layouts do EFD

A ser estabelecido !
O controle de versões é feito com jsons na pasta storage.

#### storage/layouts/ICMSIPI/vigencias.json

Este json contêm o codigo de leyout, versão, data inicial e a data final de vigência, obtido nas tabelas do Sped (vide portal Sped)

Deve ser passado uma string com o codigo do layaut no construtor de cada bloco, este por sua vez irão passar esse codigo e os demais dados de vigencia para cada elemento que pertença a esse bloco.

As estruturas construtivas de cada elemento e versão, deverão ser salvos como json na pasta denominada pelo codigo da versão. por exemplo:

- storage/layouts/ICMSIPI/v017

Ao ser criado ou editado o elemento internamente ele deve conter a estrutura referente a ultima versão existente.

Caso se necessite de versões anteriores a 017, estas deverão ser criadas como json elemente por elemento na pasta adequada.


## DETALHES
Expand Down
19 changes: 19 additions & 0 deletions examples/ICMS_IPI/BlocoB.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
require_once '../../bootstrap.php';

use NFePHP\EFD\Blocks\ICMSIPI\BlockB;

//grava json das propriedades dos elementos dos blocos para a versão 017
$bC = new BlockB('017');
$std = new stdClass();

foreach ($bC->elements as $key => $element) {
try {
$bC->$key($std);
} catch (\Exception $e) {
}
}


18 changes: 18 additions & 0 deletions examples/ICMS_IPI/BlocoC.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
require_once '../../bootstrap.php';

use NFePHP\EFD\Blocks\ICMSIPI\BlockC;

$bC = new BlockC('017');
$std = new stdClass();

foreach ($bC->elements as $key => $element) {
try {
$bC->$key($std);
} catch (\Exception $e) {
}
}


11 changes: 11 additions & 0 deletions examples/ICMS_IPI/BlocoD.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@
use \stdClass;
use NFePHP\EFD\Blocks\ICMSIPI\BlockD;

$bD = new BlockD('017');
$std = new stdClass();

foreach ($bD->elements as $key => $element) {
try {
$bD->$key($std);
} catch (\Exception $e) {
}
}


try {
$bD = new BlockD();

Expand Down
18 changes: 18 additions & 0 deletions examples/ICMS_IPI/BlocoE.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
require_once '../../bootstrap.php';

use NFePHP\EFD\Blocks\ICMSIPI\BlockE;

$b = new BlockE('017');
$std = new stdClass();

foreach ($b->elements as $key => $element) {
try {
$b->$key($std);
} catch (\Exception $e) {
}
}


18 changes: 18 additions & 0 deletions examples/ICMS_IPI/BlocoG.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
require_once '../../bootstrap.php';

use NFePHP\EFD\Blocks\ICMSIPI\BlockG;

$b = new BlockG('017');
$std = new stdClass();

foreach ($b->elements as $key => $element) {
try {
$b->$key($std);
} catch (\Exception $e) {
}
}


45 changes: 30 additions & 15 deletions examples/ICMS_IPI/BlocoH.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,32 @@
ini_set('display_errors', 'On');
require_once '../../bootstrap.php';

use \stdClass;
use NFePHP\EFD\Blocks\ICMSIPI\BlockH;

$b = new BlockH('017');
$std = new stdClass();

foreach ($b->elements as $key => $element) {
try {
$b->$key($std);
} catch (\Exception $e) {
}
}

try {
$bH = new BlockH();
$std = new stdClass();
$std->IND_MOV = 0;
$bH = new BlockH('017');

$std = new \stdClass();
$std->IND_MOV = 0;
$bH->h001($std);
$std = new stdClass();
$std->DT_INV = '31102017';

$std = new \stdClass();
$std->DT_INV = '31102017';
$std->VL_INV = 3457892.939392882;
$std->MOT_INV = '01';
$bH->h005($std);
$std = new stdClass();

$std = new \stdClass();
$std->COD_ITEM = 'ABC230';
$std->UNID = 'KG';
$std->QTD = 1234.50;
Expand All @@ -31,14 +40,14 @@
//$std->COD_CTA = 'código da conta seilá';
//$std->VL_ITEM_IR = 12345.987;
$bH->h010($std);
$std = new stdClass();

$std = new \stdClass();
$std->CST_ICMS = '123';
$std->BC_ICMS = 36207.885;
$std->VL_ICMS = 6517.4193;
$bH->h020($std);
$std = new stdClass();

$std = new \stdClass();
$std->COD_ITEM = '230KCC';
$std->UNID = 'KG';
$std->QTD = 2.50;
Expand All @@ -50,9 +59,15 @@
$std->COD_CTA = 'código da conta seilá';
$std->VL_ITEM_IR = 12345.987;
$bH->h010($std);

$txt = str_replace("\n", "<br>", $bH->get());
echo $txt.'<br>';

echo "<h2>Errors</h2>";
echo "<pre>";
print_r($bH->errors);
echo "</pre>";

} catch (\Exception $e) {
echo $e->getMessage();
}
25 changes: 18 additions & 7 deletions examples/ICMS_IPI/BlocoK.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,38 @@
use \stdClass;
use NFePHP\EFD\Blocks\ICMSIPI\BlockK;

$b = new BlockK('017');
$std = new stdClass();

foreach ($b->elements as $key => $element) {
try {
$b->$key($std);
} catch (\Exception $e) {
}
}


try {
$bK = new BlockK();

$std = new stdClass();
$std->IND_MOV = 0;
$std->IND_MOV = 0;
$bK->k001($std);

$std = new stdClass();
$std->DT_INI = '30062017';
$std->DT_INI = '30062017';
$std->DT_FIN = '30112017';
$bK->k100($std);

$std = new stdClass();
$std->DT_EST = '01112016';
$std->COD_ITEM = '123456';
$std->QTD = 123.56;
$std->IND_EST = 0;
$std->COD_PART = null;
$bK->k200($std);


$txt = str_replace("\n", "<br>", $bK->get());
echo $txt.'<br>';
} catch (\Exception $e) {
Expand Down
18 changes: 18 additions & 0 deletions examples/ICMS_IPI/BlocoUm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
require_once '../../bootstrap.php';

use NFePHP\EFD\Blocks\ICMSIPI\Block1;

$b = new Block1('017');
$std = new stdClass();

foreach ($b->elements as $key => $element) {
try {
$b->$key($std);
} catch (\Exception $e) {
}
}


39 changes: 25 additions & 14 deletions examples/ICMS_IPI/BlocoZero.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,27 @@
ini_set('display_errors', 'On');
require_once '../../bootstrap.php';

use \stdClass;
use stdClass;
use NFePHP\EFD\Blocks\ICMSIPI\Block0;

//grava json das propriedades dos elementos dos blocos para a versão 017
$b = new Block0('017');
$std = new stdClass();
foreach ($b->elements as $key => $element) {
try {
$b->$key($std);
} catch (\Exception $e) {
}
}


try {
$b0 = new Block0();

//0000 Obrigatório [1:1]
//Abertura do Arquivo Digital e Identificação da entidade
$std = new stdClass();
$std->cod_ver = '001';
$std->cod_ver = '001';
$std->cod_fin = 0;
$std->dt_ini = '01062008';
$std->dt_fin = '30062008';
Expand All @@ -27,13 +38,13 @@
$std->ind_perfil = 'B';
$std->ind_ativ = 0;
$b0->z0000($std);

//0001 Obrigatório
//Abertura do Bloco 0
$std = new stdClass();
$std->ind_mov = 1;
$std->ind_mov = 1;
$b0->z0001($std);

//0005 Obrigatório
//Dados Complementares da entidade
$std = new stdClass();
Expand All @@ -47,14 +58,14 @@
$std->FAX = '1155552222';
$std->EMAIL = '[email protected]';
$b0->z0005($std);

//0015 Opcional deve ser incluso apenas se existir
//Dados do Contribuinte Substituto ou Responsável pelo ICMS Destino
$std = new stdClass();
$std->uf_st = 'PR';
$std->ie_st = '12345678901234';
$b0->z0015($std);

//0100 Obrigatório
//Dados do Contabilista
$std = new stdClass();
Expand All @@ -72,7 +83,7 @@
$std->EMAIL = '[email protected]';
$std->COD_MUN = '0123456';
$b0->z0100($std);

//0150 Opcional
//Tabela de Cadastro do Participante
$std = new stdClass();
Expand All @@ -89,13 +100,13 @@
$std->COMPL = 'Sala 1';
$std->BAIRRO = 'Um de Dois';
$b0->z0150($std);

$std = new stdClass();
$std->DT_ALT = '12082018';
$std->NR_CAMPO = '08';
$std->CONT_ANT = '3514536'; //campo 8 COD_MUN do registro 0150
$b0->z0175($std);

$std = new stdClass();
$std->UNID = 'mts';
$std->DESCR = 'metros';
Expand All @@ -108,7 +119,7 @@
$std->UNID = 'un';
$std->DESCR = 'unidade';
$b0->z0190($std);

$std = new stdClass();
$std->COD_ITEM = '123456';
$std->DESCR_ITEM = 'Produto descrito na nota fiscal';
Expand All @@ -123,14 +134,14 @@
$std->ALIQ_ICMS = 18;
$std->CEST = '1234567';
$b0->z0200($std);

$std = new stdClass();
$std->DESCR_ANT_ITEM = 'Produto anterior descrito na nota fiscal';
$std->DT_INI = '01012005';
$std->DT_FIM = '01052008';
$std->COD_ANT_ITEM = '654321';
$b0->z0205($std);

$txt = str_replace("\n", "<br>", $b0->get());
echo $txt.'<br>';
} catch (\Exception $e) {
Expand Down
2 changes: 1 addition & 1 deletion examples/ICMS_IPI/EFDICMS.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//Construção do Bloco 0 - Bloco Inicial
//IMPORTANTE: a ORDEM afeta o resultado portanto é muito importante
//carregar os elementos na ordem correta
$b0 = new Block0();
$b0 = new Block0('017');

//0000 Obrigatório [1:1]
//Abertura do Arquivo Digital e Identificação da entidade
Expand Down
Loading

0 comments on commit a06735b

Please sign in to comment.