facho/fe/form: InvoiceLine fix taxable amount
FossilOrigin-Name: 26cc98a74588647ec409716c1954d37baa1951b41605a4f9ffc624a1bf090269
This commit is contained in:
		| @@ -110,7 +110,7 @@ class Amount: | ||||
|         return formatter % self.float() | ||||
|  | ||||
|     def float(self): | ||||
|         return round(self.amount, DECIMAL_PRECISION) | ||||
|         return float(round(self.amount, DECIMAL_PRECISION)) | ||||
|      | ||||
|  | ||||
| class Quantity: | ||||
| @@ -279,11 +279,9 @@ class TaxSubTotal: | ||||
|     tax_scheme_name: str = 'IVA' | ||||
|  | ||||
|     tax_amount: Amount = Amount(0.0) | ||||
|     taxable_amount: Amount = Amount(0.0) | ||||
|  | ||||
|     def calculate(self, invline): | ||||
|         self.tax_amount = invline.total_amount * Amount(self.percent / 100) | ||||
|         self.taxable_amount = invline.total_amount | ||||
|  | ||||
|  | ||||
| @dataclass | ||||
| @@ -293,10 +291,11 @@ class TaxTotal: | ||||
|     taxable_amount: Amount = Amount(0.0) | ||||
|  | ||||
|     def calculate(self, invline): | ||||
|         self.taxable_amount = invline.total_amount | ||||
|  | ||||
|         for subtax in self.subtotals: | ||||
|             subtax.calculate(invline) | ||||
|             self.tax_amount += subtax.tax_amount | ||||
|             self.taxable_amount += subtax.taxable_amount | ||||
|  | ||||
|  | ||||
| @dataclass | ||||
| @@ -409,6 +408,14 @@ class LegalMonetaryTotal: | ||||
|     payable_amount: Amount = Amount(0.0) | ||||
|     prepaid_amount: Amount = Amount(0.0) | ||||
|  | ||||
|     def calculate(self): | ||||
|         #DIAN 1.7.-2020: FAU14 | ||||
|         self.payable_amount = \ | ||||
|             self.tax_inclusive_amount \ | ||||
|             + self.allowance_total_amount \ | ||||
|             + self.charge_total_amount \ | ||||
|             - self.prepaid_amount | ||||
|  | ||||
|  | ||||
| @dataclass | ||||
| class AllowanceChargeReason: | ||||
| @@ -556,12 +563,7 @@ class Invoice: | ||||
|             .sum() | ||||
|  | ||||
|         #DIAN 1.7.-2020: FAU14 | ||||
|         self.invoice_legal_monetary_total.payable_amount = \ | ||||
|             self.invoice_legal_monetary_total.tax_inclusive_amount \ | ||||
|             + self.invoice_legal_monetary_total.allowance_total_amount \ | ||||
|             + self.invoice_legal_monetary_total.charge_total_amount \ | ||||
|             - self.invoice_legal_monetary_total.prepaid_amount | ||||
|  | ||||
|         self.invoice_legal_monetary_total.calculate() | ||||
|  | ||||
|     def calculate(self): | ||||
|         for invline in self.invoice_lines: | ||||
|   | ||||
| @@ -435,9 +435,10 @@ class DIANInvoiceXML(fe.FeXML): | ||||
|         total_tax_amount = Amount(0.0) | ||||
|  | ||||
|         for invoice_line in invoice.invoice_lines: | ||||
|  | ||||
|             for subtotal in invoice_line.tax.subtotals: | ||||
|                 tax_amount_for[subtotal.tax_scheme_ident]['tax_amount'] += subtotal.tax_amount | ||||
|                 tax_amount_for[subtotal.tax_scheme_ident]['taxable_amount'] += subtotal.taxable_amount | ||||
|                 tax_amount_for[subtotal.tax_scheme_ident]['taxable_amount'] = invoice_line.taxable_amount | ||||
|                 total_tax_amount += subtotal.tax_amount | ||||
|                 # MACHETE ojo InvoiceLine.tax pasar a Invoice | ||||
|                 percent_for[subtotal.tax_scheme_ident] = subtotal.percent | ||||
| @@ -505,10 +506,12 @@ class DIANInvoiceXML(fe.FeXML): | ||||
|                                          './cac:TaxTotal/cbc:TaxAmount', | ||||
|                                          invoice_line.tax_amount) | ||||
|  | ||||
|             #DIAN 1.7.-2020: FAX05 | ||||
|             fexml.set_element_amount_for(line, | ||||
|                                          './cac:TaxTotal/cac:TaxSubtotal/cbc:TaxableAmount', | ||||
|                                          invoice_line.taxable_amount) | ||||
|             for subtotal in invoice_line.tax.subtotals: | ||||
|                 fexml.set_element_amount_for(line, | ||||
|                                              './cac:TaxTotal/cac:TaxSubtotal/cbc:TaxableAmount', | ||||
|                                              subtotal.taxable_amount) | ||||
|  | ||||
|                 line.set_element('./cac:TaxTotal/cac:TaxSubtotal/cbc:TaxAmount', subtotal.tax_amount, currencyID='COP') | ||||
|                 line.set_element('./cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/cbc:Percent', subtotal.percent) | ||||
|                 line.set_element('./cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/cac:TaxScheme/cbc:ID', subtotal.tax_scheme_ident) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user