se adiciona xml para linea de AllowanceCharge
FossilOrigin-Name: 20a354ef9c6c5aa3fb0436716b43d68cac7bfa1b56be550abc18af79444f1662
This commit is contained in:
@@ -40,3 +40,6 @@ def test_amount_truncate():
|
||||
assert form.Amount(10084.03).truncate_as_string(2) == '10084.03'
|
||||
assert form.Amount(10000.02245).truncate_as_string(2) == '10000.02'
|
||||
assert form.Amount(10000.02357).truncate_as_string(2) == '10000.02'
|
||||
|
||||
def test_amount_format():
|
||||
assert str(round(form.Amount(1.1569),2)) == '1.16'
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
import pytest
|
||||
from datetime import datetime
|
||||
import copy
|
||||
|
||||
from facho.fe import form
|
||||
from facho.fe import form_xml
|
||||
@@ -32,8 +33,8 @@ def test_import_DIANCreditNoteXML():
|
||||
except AttributeError:
|
||||
pytest.fail("unexpected not found")
|
||||
|
||||
def test_FAU10(simple_invoice_without_lines):
|
||||
inv = simple_invoice_without_lines
|
||||
def test_allowance_charge_in_invoice(simple_invoice_without_lines):
|
||||
inv = copy.copy(simple_invoice_without_lines)
|
||||
inv.add_invoice_line(form.InvoiceLine(
|
||||
quantity = form.Quantity(1, '94'),
|
||||
description = 'producto facho',
|
||||
@@ -52,8 +53,44 @@ def test_FAU10(simple_invoice_without_lines):
|
||||
)
|
||||
))
|
||||
inv.add_allowance_charge(form.AllowanceCharge(amount=form.Amount(19.0)))
|
||||
inv.calculate()
|
||||
|
||||
xml = form_xml.DIANInvoiceXML(inv)
|
||||
assert xml.get_element_text('./cac:AllowanceCharge/cbc:ID') == '1'
|
||||
assert xml.get_element_text('./cac:AllowanceCharge/cbc:ChargeIndicator') == 'true'
|
||||
assert xml.get_element_text('./cac:AllowanceCharge/cbc:Amount') == '19.0'
|
||||
assert xml.get_element_text('./cac:AllowanceCharge/cbc:BaseAmount') == '100.0'
|
||||
|
||||
def test_allowance_charge_in_invoice_line(simple_invoice_without_lines):
|
||||
inv = copy.copy(simple_invoice_without_lines)
|
||||
inv.add_invoice_line(form.InvoiceLine(
|
||||
quantity = form.Quantity(1, '94'),
|
||||
description = 'producto facho',
|
||||
item = form.StandardItem(9999),
|
||||
price = form.Price(
|
||||
amount = form.Amount(100.0),
|
||||
type_code = '01',
|
||||
type = 'x'
|
||||
),
|
||||
tax = form.TaxTotal(
|
||||
subtotals = [
|
||||
form.TaxSubTotal(
|
||||
percent = 19.0,
|
||||
)
|
||||
]
|
||||
),
|
||||
allowance_charge = [
|
||||
form.AllowanceChargeAsDiscount(amount=form.Amount(10.0))
|
||||
]
|
||||
))
|
||||
inv.calculate()
|
||||
|
||||
# se aplico descuento
|
||||
assert inv.invoice_legal_monetary_total.line_extension_amount == form.Amount(90.0)
|
||||
|
||||
xml = form_xml.DIANInvoiceXML(inv)
|
||||
|
||||
with pytest.raises(AttributeError):
|
||||
assert xml.get_element_text('/fe:Invoice/cac:AllowanceCharge/cbc:ID') == '1'
|
||||
xml.get_element_text('/fe:Invoice/cac:InvoiceLine/cac:AllowanceCharge/cbc:ID') == '1'
|
||||
xml.get_element_text('/fe:Invoice/cac:InvoiceLine/cac:AllowanceCharge/cbc:BaseAmount') == '100.0'
|
||||
|
||||
Reference in New Issue
Block a user