facho/fe/form.py(Amount): solo permite positivos.
FossilOrigin-Name: 220d676ea89de7c4562375be0d71d0b8b410d146a828969d56fc30d1e4532835
This commit is contained in:
parent
22ced94163
commit
d97ff79137
@ -55,6 +55,10 @@ class AmountCollection(Collection):
|
|||||||
class Amount:
|
class Amount:
|
||||||
def __init__(self, amount: int or float or Amount, currency: Currency = Currency('COP')):
|
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):
|
if isinstance(amount, Amount):
|
||||||
self.amount = amount.amount
|
self.amount = amount.amount
|
||||||
self.currency = amount.currency
|
self.currency = amount.currency
|
||||||
|
@ -10,6 +10,10 @@ import pytest
|
|||||||
import facho.fe.form as form
|
import facho.fe.form as form
|
||||||
|
|
||||||
|
|
||||||
|
def test_amount_positive():
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
form.Amount(-1.0)
|
||||||
|
|
||||||
def test_amount_equals():
|
def test_amount_equals():
|
||||||
price1 = form.Amount(110.0)
|
price1 = form.Amount(110.0)
|
||||||
price2 = form.Amount(100 + 10.0)
|
price2 = form.Amount(100 + 10.0)
|
||||||
|
Loading…
Reference in New Issue
Block a user