I\'m just playing around learning classes functions etc, So I decided to create a simple function what should give me tax amount.
this is my code so far.
Your issue is, as the error says, that you're trying to multiply a Decimal
by a float
The simplest solution is to rewrite any reference to amount
declaring it as a Decimal object:
self.amount = decimal.Decimal(float(amount))
and in initialize
:
self.amount = decimal.Decimal('0.0')
Another option would be to declare Decimals in your final line:
return (decimal.Decimal(float(self.amount)) * self.VAT).quantize(decimal.Decimal(float(self.amount)), rounding=decimal.ROUND_UP)
...but that seems messier.