facho/fe/fe.py (DianXMLExtensionSoftwareSecurityCode): nuevo extension para adicion de codigo de seguridad
FossilOrigin-Name: 947190c281ca816b6802654d91ca8480a4e7e3afac477997f8ccb2377d08f52a
This commit is contained in:
parent
33cc210ad4
commit
24b227710e
@ -118,6 +118,9 @@ class FachoXML:
|
|||||||
# construir las extensiones o adicionar en caso de indicar
|
# construir las extensiones o adicionar en caso de indicar
|
||||||
for extension in self.extensions:
|
for extension in self.extensions:
|
||||||
xpath, elements = extension.build(self)
|
xpath, elements = extension.build(self)
|
||||||
|
if isinstance(elements, str):
|
||||||
|
elem = self.set_element('/'+ root_tag + xpath, elements)
|
||||||
|
else:
|
||||||
for new_element in elements:
|
for new_element in elements:
|
||||||
elem = self.find_or_create_element('/'+ root_tag + xpath)
|
elem = self.find_or_create_element('/'+ root_tag + xpath)
|
||||||
self.builder.append(elem, new_element)
|
self.builder.append(elem, new_element)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from .fe import FeXML
|
from .fe import FeXML
|
||||||
from .fe import NAMESPACES
|
from .fe import NAMESPACES
|
||||||
from .fe import DianXMLExtensionSigner
|
from .fe import DianXMLExtensionSigner
|
||||||
|
from .fe import DianXMLExtensionSoftwareSecurityCode
|
||||||
from .fe import DianZIP
|
from .fe import DianZIP
|
||||||
|
@ -76,6 +76,20 @@ class ConsultaResolucionesFacturacionPeticion(SOAPService):
|
|||||||
def build_response(self, as_dict):
|
def build_response(self, as_dict):
|
||||||
return ConsultaResolucionesFacturacionRespuesta.fromdict(as_dict)
|
return ConsultaResolucionesFacturacionRespuesta.fromdict(as_dict)
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class SendBillAsync:
|
||||||
|
fileName: str
|
||||||
|
contentFile: str
|
||||||
|
|
||||||
|
def get_wsdl(self):
|
||||||
|
return 'https://colombia-dian-webservices-input-sbx.azurewebsites.net/WcfDianCustomerServices.svc?wsdl'
|
||||||
|
|
||||||
|
def get_service(self):
|
||||||
|
return 'SendBillAsync'
|
||||||
|
|
||||||
|
def build_response(self, as_dict):
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
class DianClient:
|
class DianClient:
|
||||||
|
|
||||||
|
@ -40,6 +40,22 @@ class FeXML(FachoXML):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class DianXMLExtensionSoftwareSecurityCode:
|
||||||
|
# RESOLUCION 0001: pagina 535
|
||||||
|
|
||||||
|
def __init__(self, id_software: str, pin: str, invoice_ident: str):
|
||||||
|
self.id_software = id_software
|
||||||
|
self.pin = pin
|
||||||
|
self.invoice_ident = invoice_ident
|
||||||
|
|
||||||
|
def build(self, fachoxml):
|
||||||
|
dian_path = '/ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent/sts:DianExtensions/sts:SoftwareSecurityCode'
|
||||||
|
code = str(self.id_software) + str(self.pin) + str(self.invoice_ident)
|
||||||
|
m = hashlib.sha384()
|
||||||
|
m.update(code.encode('utf-8'))
|
||||||
|
return dian_path, m.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
class DianXMLExtensionSigner:
|
class DianXMLExtensionSigner:
|
||||||
POLICY_ID = 'https://facturaelectronica.dian.gov.co/politicadefirma/v2/politicadefirmav2.pdf'
|
POLICY_ID = 'https://facturaelectronica.dian.gov.co/politicadefirma/v2/politicadefirmav2.pdf'
|
||||||
POLICY_NAME = 'Dian'
|
POLICY_NAME = 'Dian'
|
||||||
|
@ -35,3 +35,13 @@ def test_xmlsigned_with_passphrase_build():
|
|||||||
|
|
||||||
assert elem is not None
|
assert elem is not None
|
||||||
#assert elem.findall('ds:SignedInfo', fe.NAMESPACES) is not None
|
#assert elem.findall('ds:SignedInfo', fe.NAMESPACES) is not None
|
||||||
|
|
||||||
|
|
||||||
|
def test_dian_extension_software_security_code():
|
||||||
|
security_code = fe.DianXMLExtensionSoftwareSecurityCode('idsoftware', '1234', '1')
|
||||||
|
xml = fe.FeXML('Invoice',
|
||||||
|
'http://www.dian.gov.co/contratos/facturaelectronica/v1')
|
||||||
|
xml.add_extension(security_code)
|
||||||
|
xml.attach_extensions()
|
||||||
|
content = xml.get_element_text('/fe:Invoice/ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent/sts:DianExtensions/sts:SoftwareSecurityCode')
|
||||||
|
assert content is not None
|
||||||
|
Loading…
Reference in New Issue
Block a user