Browse Source

[IMP] Layouts de validação da NFe

pull/155/head
Danimar Ribeiro 7 years ago
parent
commit
0ede46a705
  1. 2
      pytrustnfe/xml/schemas/enviNFe_v4.00.xsd
  2. 1104
      pytrustnfe/xml/schemas/leiauteNFe_v4.00.xsd
  3. 2
      pytrustnfe/xml/schemas/nfe_v4.00.xsd
  4. 20
      pytrustnfe/xml/schemas/tiposBasico_v4.00.xsd
  5. 0
      pytrustnfe/xml/schemas/xmldsig-core-schema_v1.01.xsd
  6. 4
      pytrustnfe/xml/validate.py

2
pytrustnfe/xml/schemas/enviNFe_v3.10.xsd → pytrustnfe/xml/schemas/enviNFe_v4.00.xsd

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/nfe" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="leiauteNFe_v3.10.xsd"/>
<xs:include schemaLocation="leiauteNFe_v4.00.xsd"/>
<xs:element name="enviNFe" type="TEnviNFe">
<xs:annotation>
<xs:documentation>Schema XML de validação do Pedido de Concessão de Autorização da Nota Fiscal Eletrônica</xs:documentation>

1104
pytrustnfe/xml/schemas/leiauteNFe_v4.00.xsd
File diff suppressed because it is too large
View File

2
pytrustnfe/xml/schemas/nfe_v3.10.xsd → pytrustnfe/xml/schemas/nfe_v4.00.xsd

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/nfe" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="leiauteNFe_v3.10.xsd"/>
<xs:include schemaLocation="leiauteNFe_v4.00.xsd"/>
<xs:element name="NFe" type="TNFe">
<xs:annotation>
<xs:documentation>Nota Fiscal Eletrônica</xs:documentation>

20
pytrustnfe/xml/schemas/tiposBasico_v3.10.xsd → pytrustnfe/xml/schemas/tiposBasico_v4.00.xsd

@ -135,6 +135,15 @@
<xs:pattern value="[0-9]{3,11}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_0104v">
<xs:annotation>
<xs:documentation>Tipo Decimal com até 1 dígitos inteiros, podendo ter de 1 até 4 decimais</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0|0\.[0-9]{1,4}|[1-9]{1}(\.[0-9]{1,4})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_0204v">
<xs:annotation>
<xs:documentation>Tipo Decimal com até 2 dígitos inteiros, podendo ter de 1 até 4 decimais</xs:documentation>
@ -171,13 +180,22 @@
<xs:pattern value="0(\.[0-9]{2})?|100(\.00)?|[1-9]{1}[0-9]{0,1}(\.[0-9]{2})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_0304Max100">
<xs:annotation>
<xs:documentation>Tipo Decimal com 3 inteiros (no máximo 100), com 4 decimais</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0(\.[0-9]{4})?|100(\.00)?|[1-9]{1}[0-9]{0,1}(\.[0-9]{4})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_0302a04Max100">
<xs:annotation>
<xs:documentation>Tipo Decimal com 3 inteiros (no máximo 100), com até 4 decimais</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="[1-9]{1}(\.[0-9]{2,4})?|[1-9]{1}[0-9]{1}(\.[0-9]{2,4})?|100(\.0{2,4})?"/>
<xs:pattern value="0(\.[0-9]{2,4})?|[1-9]{1}[0-9]{0,1}(\.[0-9]{2,4})?|100(\.0{2,4})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_0803v">

0
pytrustnfe/xml/schemas/xmldsig-core-schema_v1.01.xsd

4
pytrustnfe/xml/validate.py

@ -8,7 +8,7 @@ import re
from lxml import etree
PATH = os.path.dirname(os.path.abspath(__file__))
SCHEMA = os.path.join(PATH, 'schemas/nfe_v3.10.xsd')
SCHEMA = os.path.join(PATH, 'schemas/nfe_v4.00.xsd')
def pop_encoding(xml):
@ -30,7 +30,7 @@ def valida_nfe(nfe):
mensagens = []
for erro in erros:
campo = re.findall(r"'([^']*)'", erro)[0]
nome = campo[campo.find('}') + 1: ]
nome = campo[campo.find('}') + 1:]
valor = nfe.find('.//' + campo).text
if 'Expected is' in erro:
expected_name = re.findall('\(.*?\)', erro)

Loading…
Cancel
Save