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 |         elem.text = text | ||||||
|  |  | ||||||
|     def xpath(self, elem, xpath): |     def xpath(self, elem, xpath): | ||||||
|         print('xpath:' + xpath) |  | ||||||
|         print('elem:'+ self.tostring(elem)) |  | ||||||
|         elems = elem.xpath(xpath, namespaces=self.nsmap) |         elems = elem.xpath(xpath, namespaces=self.nsmap) | ||||||
|         print('xpath elemnts:' + str(elems)) |  | ||||||
|         if elems: |         if elems: | ||||||
|             return elems[0] |             return elems[0] | ||||||
|  |  | ||||||
|   | |||||||
| @@ -231,11 +231,13 @@ class DIANInvoiceXML(fe.FeXML): | |||||||
|         fexml.set_element('/fe:Invoice/fe:LegalMonetaryTotal/cbc:PayableAmount', |         fexml.set_element('/fe:Invoice/fe:LegalMonetaryTotal/cbc:PayableAmount', | ||||||
|                           invoice.invoice_legal_monetary_total.payable_amount, |                           invoice.invoice_legal_monetary_total.payable_amount, | ||||||
|                           currencyID='COP') |                           currencyID='COP') | ||||||
|                            |  | ||||||
|         for index, invoice_line in enumerate(invoice.invoice_lines): |  | ||||||
|             line = fexml.fragment('/fe:Invoice/fe:InvoiceLine', append=True) |  | ||||||
|  |  | ||||||
|             line.set_element('/fe:InvoiceLine/cbc:ID', index) |         next_append = False | ||||||
|  |         for index, invoice_line in enumerate(invoice.invoice_lines): | ||||||
|  |             line = fexml.fragment('/fe:Invoice/fe:InvoiceLine', append=next_append) | ||||||
|  |             next_append = True | ||||||
|  |  | ||||||
|  |             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:InvoicedQuantity', invoice_line.quantity, unitCode = 'NAR') | ||||||
|             line.set_element('/fe:InvoiceLine/cbc:LineExtensionAmount', invoice_line.total_amount, currencyID="COP") |             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")  |             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') |         xml_data = dianzip.open(name_invoice).read().decode('utf-8') | ||||||
|         assert xml_data == str(xml_invoice) |         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