Fix: Se implementa estrategía para CreditNote
This commit is contained in:
		| @@ -184,6 +184,9 @@ class FachoXML: | |||||||
|     def root_namespace(self): |     def root_namespace(self): | ||||||
|         return etree.QName(self.root).namespace |         return etree.QName(self.root).namespace | ||||||
|  |  | ||||||
|  |     def root_localname(self): | ||||||
|  |         return etree.QName(self.root).localname | ||||||
|  |  | ||||||
|     def append_element(self, elem, new_elem): |     def append_element(self, elem, new_elem): | ||||||
|         # elem = self.find_or_create_element(xpath, append=append) |         # elem = self.find_or_create_element(xpath, append=append) | ||||||
|         # self.builder.append(elem, new_elem) |         # self.builder.append(elem, new_elem) | ||||||
|   | |||||||
| @@ -105,11 +105,16 @@ class FeXML(FachoXML): | |||||||
|     def tostring(self, **kw): |     def tostring(self, **kw): | ||||||
|         # MACHETE(bit4bit) la DIAN espera que la etiqueta raiz no este en un namespace |         # MACHETE(bit4bit) la DIAN espera que la etiqueta raiz no este en un namespace | ||||||
|         root_namespace = self.root_namespace() |         root_namespace = self.root_namespace() | ||||||
|  |         root_localname = self.root_localname() | ||||||
|         xmlns_name = {v: k for k, v in NAMESPACES.items()}[root_namespace] |         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)\ |         return super().tostring(**kw)\ | ||||||
|                         .replace(xmlns_name + ':', '')\ |                         .replace(xmlns_name + ':', '')\ | ||||||
|                         .replace('xmlns:'+xmlns_name, 'xmlns')\ |                         .replace('xmlns:'+xmlns_name, 'xmlns')\ | ||||||
|                         .replace('http://www.dian.gov.co/contratos/facturaelectronica/v1', 'urn:oasis:names:specification:ubl:schema:xsd:Invoice-2') |                         .replace(root_namespace, urn_oasis) | ||||||
|  |  | ||||||
|  |  | ||||||
| class DianXMLExtensionCUDFE(FachoXMLExtension): | class DianXMLExtensionCUDFE(FachoXMLExtension): | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user