se corrige NIE021

FossilOrigin-Name: ae3eae5bc793a328a0fd65a7172f65a243ed87f1a616f390fba4d721a0864875
This commit is contained in:
bit4bit 2021-11-27 00:15:57 +00:00
parent e13896db28
commit ab1646f156
2 changed files with 22 additions and 5 deletions

View File

@ -118,10 +118,15 @@ class Proveedor:
def post_apply(self, fexml, fragment):
cune_xpath = fexml.xpath_from_root('/InformacionGeneral')
cune = fexml.get_element_attribute(cune_xpath, 'CUNE')
# TODO(bit4bit) https://catalogovpfehab.dian.gov.co/document/searchqr?documentkey=CUNE para habilitacion
# https://catalogovpfe.dian.gov.co/document/searchqr?documentkey=CUNE
codigo_qr = f"https://catalogovpfe-hab.dian.gov.co/document/searchqr?documentkey={cune}"
ambiente = fexml.get_element_attribute(fexml.xpath_from_root('/InformacionGeneral'), 'Ambiente')
codigo_qr = f"https://catalogo-vpfe.dian.gov.co/document/searchqr?documentkey={cune}"
if InformacionGeneral.AMBIENTE_PRUEBAS.same(ambiente):
codigo_qr = f"https://catalogo-vpfe-hab.dian.gov.co/document/searchqr?documentkey={cune}"
elif ambiente is None:
raise RuntimeError('fail to get InformacionGeneral/@Ambiente')
fexml.set_element('./CodigoQR', codigo_qr)
# NIE020
@ -181,17 +186,29 @@ class TipoMoneda:
@dataclass
class InformacionGeneral:
@dataclass
class TIPO_AMBIENTE:
pass
valor: str
@classmethod
def same(cls, value):
return cls.valor == str(value)
# TABLA 5.1.1
@dataclass
class AMBIENTE_PRODUCCION(TIPO_AMBIENTE):
valor: str = '1'
def __str__(self):
self.valor
@dataclass
class AMBIENTE_PRUEBAS(TIPO_AMBIENTE):
valor: str = '2'
def __str__(self):
self.valor
fecha_generacion: typing.Union[str, Fecha]
hora_generacion: str
periodo_nomina: PeriodoNomina

View File

@ -221,7 +221,7 @@ def test_nomina_xml():
assert xml.get_element_text_or_attribute('/fe:NominaIndividual/ProveedorXML/@SoftwareID') == 'xx'
assert xml.get_element_text_or_attribute('/fe:NominaIndividual/ProveedorXML/@fachoSoftwareSC') == 'xx12N00001'
assert xml.get_element_text_or_attribute('/fe:NominaIndividual/ProveedorXML/@SoftwareSC') is not None
assert xml.get_element_text_or_attribute('/fe:NominaIndividual/CodigoQR') == f"https://catalogovpfe-hab.dian.gov.co/document/searchqr?documentkey={expected_cune}"
assert xml.get_element_text_or_attribute('/fe:NominaIndividual/CodigoQR') == f"https://catalogo-vpfe.dian.gov.co/document/searchqr?documentkey={expected_cune}"
assert xml.get_element_text_or_attribute('/fe:NominaIndividual/Empleador/@NIT') == '700085371'
assert xml.get_element_text_or_attribute('/fe:NominaIndividual/Trabajador/@NumeroDocumento') == '800199436'