se adiciona firmador de NominaIndividual
FossilOrigin-Name: 61f093ca18fd0d4edf76d84693fc5cb3b6c4b008ba238f7e7defef23e400f328
This commit is contained in:
parent
a34963ca49
commit
fb88d56652
@ -172,6 +172,16 @@ class InformacionGeneral:
|
||||
CUNE = cune_hash
|
||||
)
|
||||
|
||||
class DianXMLExtensionSigner(fe.DianXMLExtensionSigner):
|
||||
|
||||
def __init__(self, pkcs12_path, passphrase=None, mockpolicy=False):
|
||||
super().__init__(pkcs12_path, passphrase=passphrase, mockpolicy=mockpolicy)
|
||||
|
||||
def build(self, fachoxml):
|
||||
signature = self.sign_xml_element(fachoxml.root)
|
||||
xpath = fachoxml.xpath_from_root('/ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent')
|
||||
extcontent = fachoxml.get_element(xpath)
|
||||
fachoxml.append_element(extcontent, signature)
|
||||
|
||||
class DIANNominaXML:
|
||||
def __init__(self, tag_document):
|
||||
@ -180,7 +190,7 @@ class DIANNominaXML:
|
||||
|
||||
# layout, la dian requiere que los elementos
|
||||
# esten ordenados segun el anexo tecnico
|
||||
self.fexml.placeholder_for('./UBLExtensions')
|
||||
self.fexml.placeholder_for('./ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent')
|
||||
self.fexml.placeholder_for('./Novedad', optional=True)
|
||||
self.fexml.placeholder_for('./Periodo')
|
||||
self.fexml.placeholder_for('./NumeroSecuenciaXML')
|
||||
|
@ -9,6 +9,15 @@ import pytest
|
||||
|
||||
from facho import fe
|
||||
|
||||
import helpers
|
||||
|
||||
def assert_error(errors, msg):
|
||||
for error in errors:
|
||||
if str(error) == msg:
|
||||
return True
|
||||
|
||||
raise "wants error: %s" % (msg)
|
||||
|
||||
def test_adicionar_devengado_Basico():
|
||||
nomina = fe.nomina.DIANNominaIndividual()
|
||||
|
||||
@ -210,13 +219,6 @@ def test_nomina_xml():
|
||||
assert xml.get_element_text_or_attribute('/fe:NominaIndividual/ProveedorXML/@SoftwareSC') == 'yy'
|
||||
assert xml.get_element_text_or_attribute('/fe:NominaIndividual/ProveedorXML/@CodigoQR') != None
|
||||
|
||||
def assert_error(errors, msg):
|
||||
for error in errors:
|
||||
if str(error) == msg:
|
||||
return True
|
||||
|
||||
raise "wants error: %s" % (msg)
|
||||
|
||||
|
||||
def test_asignar_pago():
|
||||
nomina = fe.nomina.DIANNominaIndividual()
|
||||
@ -224,3 +226,16 @@ def test_asignar_pago():
|
||||
forma = fe.nomina.FormaPago(code='1'),
|
||||
metodo = fe.nomina.MetodoPago(code='1')
|
||||
))
|
||||
|
||||
def test_nomina_xmlsign(monkeypatch):
|
||||
nomina = fe.nomina.DIANNominaIndividual()
|
||||
xml = nomina.toFachoXML()
|
||||
|
||||
signer = fe.nomina.DianXMLExtensionSigner('./tests/example.p12')
|
||||
with monkeypatch.context() as m:
|
||||
helpers.mock_urlopen(m)
|
||||
xml.add_extension(signer)
|
||||
|
||||
print(xml.tostring())
|
||||
elem = xml.get_element('/fe:NominaIndividual/ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent/ds:Signature')
|
||||
assert elem is not None
|
||||
|
Loading…
Reference in New Issue
Block a user