Fix: Se descomenta test AttachedDocument
This commit is contained in:
parent
8cc6146be2
commit
e237d1b45f
@ -57,6 +57,7 @@ Bogota = tz.gettz('America/Bogota')
|
||||
|
||||
|
||||
NAMESPACES = {
|
||||
'atd': 'urn:oasis:names:specification:ubl:schema:xsd:AttachedDocument-2',
|
||||
'fe': 'http://www.dian.gov.co/contratos/facturaelectronica/v1',
|
||||
'cac': 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2',
|
||||
'cbc': 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2',
|
||||
@ -106,17 +107,20 @@ class FeXML(FachoXML):
|
||||
|
||||
def tostring(self, **kw):
|
||||
# MACHETE(bit4bit) la DIAN espera que la etiqueta raiz no este en un namespace
|
||||
urn_oasis = {
|
||||
'AttachedDocument': 'urn:oasis:names:specification:ubl:schema:xsd:AttachedDocument-2',
|
||||
'Invoice': 'urn:oasis:names:specification:ubl:schema:xsd:Invoice-2',
|
||||
'CreditNote': 'urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2',
|
||||
}
|
||||
|
||||
root_namespace = self.root_namespace()
|
||||
root_localname = self.root_localname()
|
||||
xmlns_name = {v: k for k, v in NAMESPACES.items()}[root_namespace]
|
||||
if root_localname == 'Invoice':
|
||||
urn_oasis = 'urn:oasis:names:specification:ubl:schema:xsd:Invoice-2'
|
||||
if root_localname == 'CreditNote':
|
||||
urn_oasis = 'urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2'
|
||||
|
||||
return super().tostring(**kw)\
|
||||
.replace(xmlns_name + ':', '')\
|
||||
.replace('xmlns:'+xmlns_name, 'xmlns')\
|
||||
.replace(root_namespace, urn_oasis)
|
||||
.replace(root_namespace, urn_oasis[root_localname])
|
||||
|
||||
|
||||
class DianXMLExtensionCUDFE(FachoXMLExtension):
|
||||
|
@ -4,13 +4,13 @@
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
# from datetime import datetime
|
||||
|
||||
# import pytest
|
||||
# from facho.fe import form_xml
|
||||
import pytest
|
||||
from facho.fe import form_xml
|
||||
|
||||
# import helpers
|
||||
import helpers
|
||||
|
||||
|
||||
# def test_xml_with_required_elements():
|
||||
# doc = form_xml.AttachedDocument(id='123')
|
||||
# xml = doc.toFachoXML()
|
||||
# assert xml.get_element_text('/atd:AttachedDocument/cbc:ID') == '123'
|
||||
def test_xml_with_required_elements():
|
||||
doc = form_xml.AttachedDocument(id='123')
|
||||
xml = doc.toFachoXML()
|
||||
assert xml.get_element_text('/atd:AttachedDocument/cbc:ID') == '123'
|
||||
|
Loading…
Reference in New Issue
Block a user