Skip to content

Commit

Permalink
Merge pull request #1058 from zucchetti-pos/feat-nt-2024.001
Browse files Browse the repository at this point in the history
Ajustar Make para NT 2024.001 - prazo 02/09/2024
  • Loading branch information
robmachado committed Jun 7, 2024
2 parents 4597985 + 44920a5 commit 03bb7f2
Show file tree
Hide file tree
Showing 21 changed files with 292 additions and 32 deletions.
Empty file modified schemes/PL_009_V4/consReciNFe_v4.00.xsd
100755 → 100644
Empty file.
Empty file modified schemes/PL_009_V4/consSitNFe_v4.00.xsd
100755 → 100644
Empty file.
Empty file modified schemes/PL_009_V4/consStatServ_v4.00.xsd
100755 → 100644
Empty file.
Empty file modified schemes/PL_009_V4/enviNFe_v4.00.xsd
100755 → 100644
Empty file.
Empty file modified schemes/PL_009_V4/inutNFe_v4.00.xsd
100755 → 100644
Empty file.
Empty file modified schemes/PL_009_V4/leiauteConsSitNFe_v4.00.xsd
100755 → 100644
Empty file.
Empty file modified schemes/PL_009_V4/leiauteConsStatServ_v4.00.xsd
100755 → 100644
Empty file.
Empty file modified schemes/PL_009_V4/leiauteInutNFe_v4.00.xsd
100755 → 100644
Empty file.
27 changes: 14 additions & 13 deletions schemes/PL_009_V4/leiauteNFe_v4.00.xsd
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2008 (http://www.altova.com) by sas-softwares@procergs.rs.gov.br (PROCERGS) -->
<!-- edited with XMLSpy v2008 (http://www.altova.com) by sas-software@procergs.rs.gov.br (PROCERGS) -->
<!-- PL_009 alterações de esquema decorrentes da - NT2016.002 v1.20 - 31/05/2017 13:14hs-->
<!-- PL_008g alterações de esquema decorrentes da - NT2015.002 - 15/07/2015 -->
<!-- PL_008h alterações de esquema decorrentes da - NT2015.003 - 17/09/2015 -->
Expand Down Expand Up @@ -556,14 +556,16 @@ Preencher com &quot;2B&quot;, quando se tratar de Cupom Fiscal emitido por máqu
Este campo será obrigatoriamente preenchido com:
1 – Simples Nacional;
2 – Simples Nacional – excesso de sublimite de receita bruta;
3 – Regime Normal.</xs:documentation>
3 – Regime Normal.
4 - Simples Nacional - Microempreendedor individual - MEI</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:enumeration value="1"/>
<xs:enumeration value="2"/>
<xs:enumeration value="3"/>
<xs:enumeration value="4"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Expand Down Expand Up @@ -2756,14 +2758,13 @@ Informar o motivo da desoneração:
<xs:element name="orig" type="Torig">
<xs:annotation>
<xs:documentation>origem da mercadoria: 0 - Nacional
1 - Estrangeira - Importação direta
2 - Estrangeira - Adquirida no mercado interno</xs:documentation>
1 - Estrangeira - Importação direta
2 - Estrangeira - Adquirida no mercado interno</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CST">
<xs:annotation>
<xs:documentation>Tributção pelo ICMS
20 - Com redução de base de cálculo</xs:documentation>
<xs:documentation>Tributação pelo ICMS 51 - Tributação com Diferimento</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
Expand All @@ -2775,10 +2776,10 @@ Informar o motivo da desoneração:
<xs:element name="modBC" minOccurs="0">
<xs:annotation>
<xs:documentation>Modalidade de determinação da BC do ICMS:
0 - Margem Valor Agregado (%);
1 - Pauta (valor);
2 - Preço Tabelado Máximo (valor);
3 - Valor da Operação.</xs:documentation>
0 - Margem Valor Agregado (%);
1 - Pauta (valor);
2 - Preço Tabelado Máximo (valor);
3 - Valor da Operação.</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
Expand Down Expand Up @@ -3779,7 +3780,7 @@ Operação interestadual para consumidor final com partilha do ICMS devido na o
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="orig" type="Torig">
<xs:element name="orig" type="Torig" minOccurs="0">
<xs:annotation>
<xs:documentation>origem da mercadoria: 0 - Nacional
1 - Estrangeira - Importação direta
Expand Down Expand Up @@ -4098,11 +4099,11 @@ Operação interestadual para consumidor final com partilha do ICMS devido na o
</xs:element>
<xs:element name="ICMSSN900">
<xs:annotation>
<xs:documentation>Tributação do ICMS pelo SIMPLES NACIONAL, CRT=1 – Simples Nacional e CSOSN=900 (v2.0)</xs:documentation>
<xs:documentation>Tributação do ICMS pelo SIMPLES NACIONAL, CRT=1 – Simples Nacional, CRT=4 - MEI e CSOSN=900 (v2.0)</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="orig" type="Torig">
<xs:element name="orig" type="Torig" minOccurs="0">
<xs:annotation>
<xs:documentation>origem da mercadoria: 0 - Nacional
1 - Estrangeira - Importação direta
Expand Down
Empty file modified schemes/PL_009_V4/nfe_v4.00.xsd
100755 → 100644
Empty file.
Empty file modified schemes/PL_009_V4/procInutNFe_v4.00.xsd
100755 → 100644
Empty file.
Empty file modified schemes/PL_009_V4/procNFe_v4.00.xsd
100755 → 100644
Empty file.
Empty file modified schemes/PL_009_V4/retConsReciNFe_v4.00.xsd
100755 → 100644
Empty file.
Empty file modified schemes/PL_009_V4/retConsSitNFe_v4.00.xsd
100755 → 100644
Empty file.
Empty file modified schemes/PL_009_V4/retConsStatServ_v4.00.xsd
100755 → 100644
Empty file.
Empty file modified schemes/PL_009_V4/retEnviNFe_v4.00.xsd
100755 → 100644
Empty file.
Empty file modified schemes/PL_009_V4/retInutNFe_v4.00.xsd
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion schemes/PL_009_V4/tiposBasico_v4.00.xsd
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="[!-ÿ]{1}[ -ÿ]*[!-ÿ]{1}|[!-ÿ]{1}"/>
<xs:pattern value="[!-ÿ]{1}[ -ÿ]{0,}[!-ÿ]{1}|[!-ÿ]{1}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TData">
Expand Down
Empty file modified schemes/PL_009_V4/xmldsig-core-schema_v1.01.xsd
100755 → 100644
Empty file.
49 changes: 31 additions & 18 deletions src/Make.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,6 @@ public function montaNFe(): string
*/
public function monta(): string
{
if (!empty($this->errors)) {
$this->errors = array_merge($this->errors, $this->dom->errors);
} else {
$this->errors = $this->dom->errors;
}
//cria a tag raiz da Nfe
$this->buildNFe();
//processa nfeRef e coloca as tags na tag ide
Expand Down Expand Up @@ -516,9 +511,11 @@ public function monta(): string
// testa da chave
$this->checkNFeKey($this->dom);
$this->xml = $this->dom->saveXML();
if (count($this->errors) > 0) {

if (count($this->getErrors()) > 0) {
throw new RuntimeException('Existem erros nas tags. Obtenha os erros com getErrors().');
}

return $this->xml;
}

Expand Down Expand Up @@ -1761,7 +1758,7 @@ public function tagCreditoPresumidoProd(stdClass $std)
$std->cCredPresumido,
true,
$identificador . "[item $std->item] cCredPresumido Código de Benefício Fiscal de Crédito "
. "Presumido na UF aplicado ao item",
. "Presumido na UF aplicado ao item",
true
);
$this->dom->addChild(
Expand Down Expand Up @@ -1845,6 +1842,14 @@ public function tagprod(stdClass $std): DOMElement
$this->errors[] = "cEANTrib {$ceantrib} " . $e->getMessage();
}

$CRT = $this->emit->getElementsByTagName("CRT")->item(0)->nodeValue ?? null;
$idDest = $this->ide->getElementsByTagName("idDest")->item(0)->nodeValue ?? null;
$allowEmptyNcm = $CRT == 4 && $idDest == 1;

if ($allowEmptyNcm && empty($std->NCM)) {
$std->NCM = '00000000';
}

$identificador = 'I01 <prod> - ';
$prod = $this->dom->createElement("prod");
$this->dom->addChild(
Expand Down Expand Up @@ -2886,7 +2891,7 @@ public function tagcomb(stdClass $std): DOMElement
$this->conditionalNumberFormatting($std->pBio, 4),
false,
"$identificador [item $std->item] Percentual do índice de mistura do Biodiesel (B100) no Óleo Diesel B "
. "instituído pelo órgão regulamentador"
. "instituído pelo órgão regulamentador"
);
$this->aComb[$std->item] = $comb;
return $comb;
Expand Down Expand Up @@ -3631,7 +3636,7 @@ public function tagICMS(stdClass $std): DOMElement
$std->indDeduzDeson,
false,
"$identificador [item $std->item] Indica se o valor do ICMS desonerado (vICMSDeson) "
. "deduz do valor do item (vProd)."
. "deduz do valor do item (vProd)."
);
break;
case '40':
Expand Down Expand Up @@ -4181,7 +4186,7 @@ public function tagICMS(stdClass $std): DOMElement
$std->indDeduzDeson,
false,
"$identificador [item $std->item] Indica se o valor do ICMS desonerado (vICMSDeson) "
. "deduz do valor do item (vProd)."
. "deduz do valor do item (vProd)."
);
$this->dom->addChild(
$icms,
Expand Down Expand Up @@ -4364,7 +4369,7 @@ public function tagICMS(stdClass $std): DOMElement
$std->indDeduzDeson,
false,
"$identificador [item $std->item] Indica se o valor do ICMS desonerado (vICMSDeson) "
. "deduz do valor do item (vProd)."
. "deduz do valor do item (vProd)."
);
$this->dom->addChild(
$icms,
Expand Down Expand Up @@ -4528,7 +4533,7 @@ public function tagICMSPart(stdClass $std): DOMElement
$this->conditionalNumberFormatting($std->pFCPST, 4),
false,
"[item $std->item] Percentual do Fundo de "
. "Combate à Pobreza (FCP) ST"
. "Combate à Pobreza (FCP) ST"
);
$this->dom->addChild(
$icmsPart,
Expand Down Expand Up @@ -4749,6 +4754,12 @@ public function tagICMSSN(stdClass $std): DOMElement
//totalizador generico
$this->stdTot->vFCPST += (float) !empty($std->vFCPST) ? $std->vFCPST : 0;
$this->stdTot->vFCPSTRet += (float) !empty($std->vFCPSTRet) ? $std->vFCPSTRet : 0;

$CRT = $this->emit->getElementsByTagName("CRT")->item(0)->nodeValue ?? null;
$allowEmptyOrig = $CRT == 4 && in_array($std->CSOSN, [
'102', '103', '300', '400', '900',
]);

switch ($std->CSOSN) {
case '101':
$icmsSN = $this->dom->createElement("ICMSSN101");
Expand Down Expand Up @@ -4791,8 +4802,9 @@ public function tagICMSSN(stdClass $std): DOMElement
$icmsSN,
'orig',
$std->orig,
true,
"[item $std->item] Origem da mercadoria"
!$allowEmptyOrig,
"[item $std->item] Origem da mercadoria",
$allowEmptyOrig,
);
$this->dom->addChild(
$icmsSN,
Expand Down Expand Up @@ -5096,8 +5108,9 @@ public function tagICMSSN(stdClass $std): DOMElement
$icmsSN,
'orig',
$std->orig,
true,
"[item $std->item] Origem da mercadoria"
!$allowEmptyOrig,
"[item $std->item] Origem da mercadoria",
$allowEmptyOrig,
);
$this->dom->addChild(
$icmsSN,
Expand Down Expand Up @@ -8018,7 +8031,7 @@ protected function buildDet()
//incluso NT 2023.001-1.10 /1.20
if (!empty($this->aOrigComb[$nItem])) {
foreach ($this->aOrigComb[$nItem] as $origcomb) {
$this->dom->appChild($child, $origcomb, "inclusão do node origComb na tag comb");
$this->dom->appChild($child, $origcomb, "inclusão do node origComb na tag comb");
}
}
$this->dom->appChild($prod, $child, "Inclusão do node combustivel");
Expand Down Expand Up @@ -8257,7 +8270,7 @@ protected function checkNFeKey(Dom $dom): void
*/
public function getErrors(): array
{
return $this->errors;
return array_merge($this->errors, $this->dom->errors);
}

/**
Expand Down
Loading

0 comments on commit 03bb7f2

Please sign in to comment.