fache/fe/form: Quantity require UnidadesMedida.

FossilOrigin-Name: 675900c1251c0b7319dc8b395ce5d385297209197ce13b0ee5358b4ce619d9a8
This commit is contained in:
2020-11-04 00:40:46 +00:00
parent ee58dba82f
commit 44827fe811
6 changed files with 37 additions and 11 deletions

View File

@@ -113,8 +113,30 @@ class Amount:
return round(self.amount, DECIMAL_PRECISION)
class Quantity(Amount):
pass
class Quantity:
def __init__(self, val, code):
if not isinstance(val, int):
raise ValueError('val expected int')
if code not in codelist.UnidadesMedida:
raise ValueError("code [%s] not found" % (code))
self.value = val
self.code = code
def __mul__(self, other):
if isinstance(other, Amount):
return Amount(self.value) * other
return self.value * other
def __lt__(self, other):
if isinstance(other, Amount):
return Amount(self.value) < other
return self.value < other
def __str__(self):
return str(self.value)
@dataclass
class Item: