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...
A set of methods for VAT calculations.
def __init__(self, amount=None):
self.amount = amount
self.VAT = decimal.Decimal('0.095')
self.amount = 0
Returns amount with VAT added.
if not self.amount:
msg = u"Cannot add VAT if no amount is passed!'"
return (self.amount * self.VAT).quantize(self.amount, rounding=decimal.ROUND_UP)
It seems like
self.VAT is of
decimal.Decimal type and
self.amount is a
float, thing that you can't do.
decimal.Decimal(self.amount) * self.VAT instead.