facho/fe/form.py: correcion identificador InvoiceLine/cbc:ID
FossilOrigin-Name: d3f7682487635e42acb9c15fcb1668beab6ea085e74e3ca55c147121f2ca59bb
This commit is contained in:
		| @@ -86,10 +86,7 @@ class LXMLBuilder: | ||||
|         elem.text = text | ||||
|  | ||||
|     def xpath(self, elem, xpath): | ||||
|         print('xpath:' + xpath) | ||||
|         print('elem:'+ self.tostring(elem)) | ||||
|         elems = elem.xpath(xpath, namespaces=self.nsmap) | ||||
|         print('xpath elemnts:' + str(elems)) | ||||
|         if elems: | ||||
|             return elems[0] | ||||
|  | ||||
|   | ||||
| @@ -232,10 +232,12 @@ class DIANInvoiceXML(fe.FeXML): | ||||
|                           invoice.invoice_legal_monetary_total.payable_amount, | ||||
|                           currencyID='COP') | ||||
|  | ||||
|         next_append = False | ||||
|         for index, invoice_line in enumerate(invoice.invoice_lines): | ||||
|             line = fexml.fragment('/fe:Invoice/fe:InvoiceLine', append=True) | ||||
|             line = fexml.fragment('/fe:Invoice/fe:InvoiceLine', append=next_append) | ||||
|             next_append = True | ||||
|  | ||||
|             line.set_element('/fe:InvoiceLine/cbc:ID', index) | ||||
|             line.set_element('/fe:InvoiceLine/cbc:ID', index + 1) | ||||
|             line.set_element('/fe:InvoiceLine/cbc:InvoicedQuantity', invoice_line.quantity, unitCode = 'NAR') | ||||
|             line.set_element('/fe:InvoiceLine/cbc:LineExtensionAmount', invoice_line.total_amount, currencyID="COP") | ||||
|             line.set_element('/fe:InvoiceLine/fe:Price/cbc:PriceAmount', invoice_line.price_amount, currencyID="COP")  | ||||
|   | ||||
| @@ -107,3 +107,10 @@ def test_invoicesimple_zip(simple_invoice): | ||||
|         xml_data = dianzip.open(name_invoice).read().decode('utf-8') | ||||
|         assert xml_data == str(xml_invoice) | ||||
|  | ||||
|  | ||||
| def test_bug_cbcid_empty_on_invoice_line(simple_invoice): | ||||
|     xml_invoice = form.DIANInvoiceXML(simple_invoice) | ||||
|     print(str(xml_invoice)) | ||||
|  | ||||
|     cbc_id = xml_invoice.get_element_text('/fe:Invoice/fe:InvoiceLine[1]/cbc:ID', format_=int) | ||||
|     assert cbc_id == 1 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user