Skip to content

Commit

Permalink
Merge pull request #1078 from robmachado/master
Browse files Browse the repository at this point in the history
inclusão da tag agropecuario em Make:class e novos XSD
  • Loading branch information
robmachado authored Oct 16, 2024
2 parents 1624494 + 5eabcea commit 2b75658
Show file tree
Hide file tree
Showing 35 changed files with 1,298 additions and 1,020 deletions.
1,928 changes: 964 additions & 964 deletions examples/nfe_v4.00.xsd.xml

Large diffs are not rendered by default.

Empty file modified schemes/PL_009_V4/EventoCancEConf_v1.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/EventoEConf_v1.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/consReciNFe_v4.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/consSitNFe_v4.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/consStatServ_v4.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/e110750_v1.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/e110751_v1.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/envEventoCancEConf_v1.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/envEventoEConf_v1.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/enviNFe_v4.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/inutNFe_v4.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/leiauteConsSitNFe_v4.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/leiauteConsStatServ_v4.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/leiauteEventoCancEConf_v1.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/leiauteEventoEConf_v1.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/leiauteInutNFe_v4.00.xsd
100644 → 100755
Empty file.
191 changes: 137 additions & 54 deletions schemes/PL_009_V4/leiauteNFe_v4.00.xsd
100644 → 100755

Large diffs are not rendered by default.

Empty file modified schemes/PL_009_V4/nfe_v4.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/procEventoCancEConf_v1.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/procEventoEConf_v1.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/procInutNFe_v4.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/procNFe_v4.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/retConsReciNFe_v4.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/retConsSitNFe_v4.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/retConsStatServ_v4.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/retEnviNFe_v4.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/retEventoCancEConf_v1.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/retEventoEConf_v1.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/retInutNFe_v4.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/tiposBasico_v4.00.xsd
100644 → 100755
Empty file.
Empty file modified schemes/PL_009_V4/xmldsig-core-schema_v1.01.xsd
100644 → 100755
Empty file.
82 changes: 80 additions & 2 deletions src/Make.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ class Make
* @var DOMElement
*/
protected $infRespTec;
/**
* @var DOMElement
*/
protected $agropecuario;
/**
* @var string
*/
Expand Down Expand Up @@ -518,6 +522,8 @@ public function monta(): string
$this->dom->appChild($this->infNFe, $this->cana, 'Falta tag "infNFe"');
//Responsável Técnico
$this->dom->appChild($this->infNFe, $this->infRespTec, 'Falta tag "infNFe"');
//agropacuario
$this->dom->appChild($this->infNFe, $this->agropecuario, 'Falta tag "infNFe"');
//[1] tag infNFe (1 A01)
$this->dom->appChild($this->NFe, $this->infNFe, 'Falta tag "NFe"');
//[0] tag NFe
Expand Down Expand Up @@ -2310,8 +2316,8 @@ public function tagadi(stdClass $std): DOMElement
$this->dom->addChild(
$adi,
"nAdicao",
$std->nAdicao,
true,
$std->nAdicao ?? null,
false,
$identificador . "[item $std->item] Número da Adição"
);
$this->dom->addChild(
Expand Down Expand Up @@ -7728,6 +7734,78 @@ public function taginfRespTec(stdClass $std): DOMElement
return $infRespTec;
}

/**
* Informações de produtos da agricultura, pecuária e produção Florestal ZF01 pai A01
* tag NFe/infNFe/agropecuario (opcional)
* @param stdClass $std
* @return DOMElement
* @throws \DOMException
*/
public function tagagropecuario(stdClass $std): DOMElement
{
$possible = [
'nReceituario',
'CPFRespTec',
'tpGuia',
'UFGuia',
'serieGuia',
'nGuia'
];
$std = $this->equilizeParameters($std, $possible);
$agro = $this->dom->createElement("agropecuario");
if (!empty($std->nReceituario)) {
$def = $this->dom->createElement("defensivo");
$this->dom->addChild(
$def,
"nReceituario",
$std->nReceituario,
true,
"Número da receita ou receituário do agrotóxico/defensivo agrícola"
);
$this->dom->addChild(
$def,
"CPFRespTec",
$std->CPFRespTec,
true,
"CPF do Responsável Técnico, emitente do receituário"
);
$agro->appendChild($def);
} elseif (!empty($std->tpGuia)) {
$guia = $this->dom->createElement("guiaTransito");
$this->dom->addChild(
$guia,
"tpGuia",
$std->tpGuia,
true,
"Tipo da Guia"
);
$this->dom->addChild(
$guia,
"UFGuia",
!empty($std->UFGuia) ? $std->UFGuia : null,
false,
"UF de emissão"
);
$this->dom->addChild(
$guia,
"serieGuia",
$std->serieGuia ?? null,
false,
"Série da Guia"
);
$this->dom->addChild(
$guia,
"nGuia",
$std->nGuia,
true,
"Número da Guia"
);
$agro->appendChild($guia);
}
$this->agropecuario = $agro;
return $agro;
}

/**
* Tag raiz da NFe
* tag NFe DOMNode
Expand Down
89 changes: 89 additions & 0 deletions src/Traits/TraitTagAgropecuario.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php

namespace NFePHP\NFe\Traits;

use stdClass;
use DOMElement;
use NFePHP\Common\DOMImproved;

/**
* @method equilizeParameters($std, $possible)
* @property DOMImproved $dom
* @property int $mod
* @property int $tpAmb
* @property DOMElement $dest
*/
trait TraitTagAgropecuario
{
/**
* Informações de produtos da agricultura, pecuária e produção Florestal ZF01 pai A01
* tag NFe/infNFe/agropecuario (opcional)
* @param stdClass $std
* @return DOMElement
* @throws \DOMException
*/
public function tagagropecuario(stdClass $std): DOMElement
{
$possible = [
'nReceituario',
'CPFRespTec',
'tpGuia',
'UFGuia',
'serieGuia',
'nGuia'
];
$std = $this->equilizeParameters($std, $possible);
$agro = $this->dom->createElement("agropecuario");
if (!empty($std->nReceituario)) {
$def = $this->dom->createElement("defencivo");
$this->dom->addChild(
$def,
"nReceituario",
$std->nReceituario,
true,
"Número da receita ou receituário do agrotóxico/defensivo agrícola"
);
$this->dom->addChild(
$def,
"CPFRespTec",
$std->CPFRespTec,
true,
"CPF do Responsável Técnico, emitente do receituário"
);
$agro->appendChild($def);
} elseif (!empty($std->tpGuia)) {
$guia = $this->dom->createElement("guiaTransito");
$this->dom->addChild(
$guia,
"tpGuia",
$std->tpGuia,
true,
"Tipo da Guia"
);
$this->dom->addChild(
$guia,
"UFGuia",
!empty($std->UFGuia) ? $std->UFGuia : null,
false,
"UF de emissão"
);
$this->dom->addChild(
$guia,
"serieGuia",
$std->serieGuia ?? null,
false,
"Série da Guia"
);
$this->dom->addChild(
$guia,
"nGuia",
$std->nGuia,
true,
"Número da Guia"
);
$agro->appendChild($guia);
}
$this->agropecuario = $agro;
return $agro;
}
}
28 changes: 28 additions & 0 deletions tests/MakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,34 @@ public function test_taginfRespTec(): void
$this->validarCriacaoTag2($std, $element, 'infRespTec', ['CSRT']);
}

public function test_tagagropecuario_defencivo(): void
{
$std = new \stdClass();
$std->nReceituario = '1234567890ABCDEFGHIJ'; //Obrigatório se houver defencivo 1-20 caracteres, opcional caso contrario
$std->CPFRespTec = '12345678901'; //Obrigatório se houver defencivo 11 digitos, opcional caso contrario
//$std->tpGuia = '1'; //Obrigatório se houver guia 1-GTA, 2-TTA, 3-DTA, 4-ATV, 5-PTV, 6-GVT, 7-GF, opcional caso contrario
//$std->UFGuia = 'MG'; //opcional
//$std->serieGuia = 'A12345678'; //opcional 9 caracteres
//$std->nGuia = '123456789'; //Obrigatório se houver guia 9 digitos, opcional caso contrario

$element = $this->make->tagagropecuario($std);
$this->validarCriacaoTag2($std, $element, 'agropecuario', ['nReceituario', 'CPFRespTec']);
}

public function test_tagagropecuario_guia(): void
{
$std = new \stdClass();
//$std->nReceituario = '1234567890ABCDEFGHIJ'; //Obrigatório se houver defencivo 1-20 caracteres, opcional caso contrario
//$std->CPFRespTec = '12345678901'; //Obrigatório se houver defencivo 11 digitos, opcional caso contrario
$std->tpGuia = '1'; //Obrigatório se houver guia 1-GTA, 2-TTA, 3-DTA, 4-ATV, 5-PTV, 6-GVT, 7-GF, opcional caso contrario
$std->UFGuia = 'MG'; //opcional
$std->serieGuia = 'A12345678'; //opcional 9 caracteres
$std->nGuia = '123456789'; //Obrigatório se houver guia 9 digitos, opcional caso contrario

$element = $this->make->tagagropecuario($std);
$this->validarCriacaoTag2($std, $element, 'agropecuario', ['tpGuia']);
}

private function validarCriacaoTag2(
\stdClass $std,
\DOMElement $element,
Expand Down

0 comments on commit 2b75658

Please sign in to comment.