facho/facho.py (FachoXML): se simplifica adicion de extension
FossilOrigin-Name: d939f6486757338766762589965955cd9a9a0a84aaad4c37a848f544d8119ab2
This commit is contained in:
		@@ -131,16 +131,8 @@ class FachoXML:
 | 
				
			|||||||
        self.builder.append(elem, new_elem)
 | 
					        self.builder.append(elem, new_elem)
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
    def add_extension(self, extension):
 | 
					    def add_extension(self, extension):
 | 
				
			||||||
        root_tag = self.builder.get_tag(self.root)
 | 
					        extension.build(self)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # construir las extensiones o adicionar en caso de indicar
 | 
					 | 
				
			||||||
        xpath, elements = extension.build(self)
 | 
					 | 
				
			||||||
        if isinstance(elements, str):
 | 
					 | 
				
			||||||
            elem = self.set_element('/'+ root_tag + xpath, elements)
 | 
					 | 
				
			||||||
        else:
 | 
					 | 
				
			||||||
            for new_element in elements:
 | 
					 | 
				
			||||||
                elem = self.find_or_create_element('/' + root_tag + xpath)
 | 
					 | 
				
			||||||
                self.builder.append(elem, new_element)
 | 
					 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def fragment(self, xpath, append=False, append_not_exists=False):
 | 
					    def fragment(self, xpath, append=False, append_not_exists=False):
 | 
				
			||||||
        nodes = xpath.split('/')
 | 
					        nodes = xpath.split('/')
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -63,7 +63,6 @@ class DianXMLExtensionCUFE(FachoXMLExtension):
 | 
				
			|||||||
        fachoxml.set_element('/fe:Invoice/cbc:UUID', cufe, schemeName='CUFE-SHA384')
 | 
					        fachoxml.set_element('/fe:Invoice/cbc:UUID', cufe, schemeName='CUFE-SHA384')
 | 
				
			||||||
        fachoxml.set_element('/fe:Invoice/cbc:ProfileID', 'DIAN 2.1')
 | 
					        fachoxml.set_element('/fe:Invoice/cbc:ProfileID', 'DIAN 2.1')
 | 
				
			||||||
        fachoxml.set_element('/fe:Invoice/cbc:ProfileExecutionID', self._tipo_ambiente())
 | 
					        fachoxml.set_element('/fe:Invoice/cbc:ProfileExecutionID', self._tipo_ambiente())
 | 
				
			||||||
        return '', []
 | 
					 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
    def issue_time(self, datetime_):
 | 
					    def issue_time(self, datetime_):
 | 
				
			||||||
        return datetime_.strftime('%H:%M:%S%z')
 | 
					        return datetime_.strftime('%H:%M:%S%z')
 | 
				
			||||||
@@ -133,7 +132,7 @@ class DianXMLExtensionSoftwareProvider(FachoXMLExtension):
 | 
				
			|||||||
                                      **SCHEME_AGENCY_ATTRS)
 | 
					                                      **SCHEME_AGENCY_ATTRS)
 | 
				
			||||||
        software_provider.set_element('/sts:SoftwareProvider/sts:SoftwareID', self.id_software,
 | 
					        software_provider.set_element('/sts:SoftwareProvider/sts:SoftwareID', self.id_software,
 | 
				
			||||||
                                      **SCHEME_AGENCY_ATTRS)
 | 
					                                      **SCHEME_AGENCY_ATTRS)
 | 
				
			||||||
        return '', []
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
class DianXMLExtensionSoftwareSecurityCode(FachoXMLExtension):
 | 
					class DianXMLExtensionSoftwareSecurityCode(FachoXMLExtension):
 | 
				
			||||||
@@ -240,7 +239,6 @@ class DianXMLExtensionSigner(FachoXMLExtension):
 | 
				
			|||||||
        extcontent = ublextension.find_or_create_element('/ext:UBLExtension:/ext:ExtensionContent')
 | 
					        extcontent = ublextension.find_or_create_element('/ext:UBLExtension:/ext:ExtensionContent')
 | 
				
			||||||
        fachoxml.append_element(extcontent, signature)
 | 
					        fachoxml.append_element(extcontent, signature)
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        return '', []
 | 
					 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class DianXMLExtensionAuthorizationProvider(FachoXMLExtension):
 | 
					class DianXMLExtensionAuthorizationProvider(FachoXMLExtension):
 | 
				
			||||||
@@ -253,7 +251,7 @@ class DianXMLExtensionAuthorizationProvider(FachoXMLExtension):
 | 
				
			|||||||
        attrs = {'schemeID': '4', 'schemeName': '31'}
 | 
					        attrs = {'schemeID': '4', 'schemeName': '31'}
 | 
				
			||||||
        attrs.update(SCHEME_AGENCY_ATTRS)
 | 
					        attrs.update(SCHEME_AGENCY_ATTRS)
 | 
				
			||||||
        fexml.set_attributes(dian_path, **attrs)
 | 
					        fexml.set_attributes(dian_path, **attrs)
 | 
				
			||||||
        return '', []
 | 
					
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class DianXMLExtensionInvoiceAuthorization(FachoXMLExtension):
 | 
					class DianXMLExtensionInvoiceAuthorization(FachoXMLExtension):
 | 
				
			||||||
@@ -284,7 +282,7 @@ class DianXMLExtensionInvoiceAuthorization(FachoXMLExtension):
 | 
				
			|||||||
                                    self.from_)
 | 
					                                    self.from_)
 | 
				
			||||||
        invoice_control.set_element('/sts:InvoiceControl/sts:AuthorizedInvoices/sts:To',
 | 
					        invoice_control.set_element('/sts:InvoiceControl/sts:AuthorizedInvoices/sts:To',
 | 
				
			||||||
                                    self.to)
 | 
					                                    self.to)
 | 
				
			||||||
        return '', []
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
class DianZIP:
 | 
					class DianZIP:
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user