Beispiel #1
0
 def __sub__(self, y):
     if not isinstance(y, Expression):
         raise OperatorError("supported operand only Expression instance"
                             " for __sub__ Operator of Money")
     elif isinstance(y, BaseMoney) and y.currency == self.currency:
         return self.__class__(self.amount - y.amount, self.currency)
     else:
         return super(Money, self).__sub__(y)
Beispiel #2
0
 def __init__(self, x, y):
     """
      @param Expression x
      @param Expression y
     """
     if not isinstance(x, Expression) or not isinstance(y, Expression):
         raise OperatorError("supported operand only instance of Expression"
                             " for Minus Operator of Money")
     self.x, self.y = x, y
Beispiel #3
0
 def __init__(self, augend, addend):
     """
      @param Expression x
      @param Expression y
     """
     if not isinstance(addend, Expression) or not isinstance(
             augend, Expression):
         raise OperatorError("supported operand only instance of Expression"
                             " for Sum Operator of Money")
     self.x, self.y = augend, addend
Beispiel #4
0
 def __init__(self, x, y):
     """
      @param Expression x
      @param int,float y
     """
     if type(y) not in (int, float, Decimal):
         raise OperatorError("supported operand only in types int,float"
                             " for Div Operator of Money")
     y = Decimal(y)
     self.x, self.y = x, y
Beispiel #5
0
 def __truediv__(self, y):
     if type(y) not in (int, float, Decimal):
         raise OperatorError("supported operand only in types int,float"
                             " for Div Operator of Money")
     y = Decimal(str(y))
     return self.__class__(self.left / y, self.right / y)
Beispiel #6
0
 def __mul__(self, y):
     if type(y) not in (int, float, Decimal):
         raise OperatorError("supported operand only in types int,float"
                             " for Mul Operator of Money")
     y = Decimal(str(y))
     return DistributionAdd(self.left * y, self.right * y)
Beispiel #7
0
 def __rtruediv__(self, x):
     raise OperatorError("supported operand only in types int,float"
                         " for __rturediv__ Operator of Money")
Beispiel #8
0
 def __truediv__(self, y):
     if type(y) not in (int, float, Decimal):
         raise OperatorError("supported operand only in types int,float"
                             " for __turediv__ Operator of Money")
     y = Decimal(y)
     return self.__class__(self.amount / y, self.currency)