diff --git a/facho/fe/form.py b/facho/fe/form.py index fba0c4d..79f7188 100644 --- a/facho/fe/form.py +++ b/facho/fe/form.py @@ -55,6 +55,10 @@ class AmountCollection(Collection): class Amount: def __init__(self, amount: int or float or Amount, currency: Currency = Currency('COP')): + #DIAN 1.7.-2020: 1.2.3.1 + if amount < 0: + raise ValueError('amount must be positive >= 0') + if isinstance(amount, Amount): self.amount = amount.amount self.currency = amount.currency diff --git a/tests/test_amount.py b/tests/test_amount.py index 04bf846..76a0d8c 100644 --- a/tests/test_amount.py +++ b/tests/test_amount.py @@ -10,6 +10,10 @@ import pytest import facho.fe.form as form +def test_amount_positive(): + with pytest.raises(ValueError): + form.Amount(-1.0) + def test_amount_equals(): price1 = form.Amount(110.0) price2 = form.Amount(100 + 10.0)