fache/fe/form: Quantity require UnidadesMedida.
FossilOrigin-Name: 675900c1251c0b7319dc8b395ce5d385297209197ce13b0ee5358b4ce619d9a8
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user