-from decimal import Decimal
-import re
-from typing import Optional, TypeVar, Tuple
+# © Copyright 2021-2022, Scott Gasch
):
self.strict_mode = strict_mode
if isinstance(amount, str):
):
self.strict_mode = strict_mode
if isinstance(amount, str):
def __add__(self, other):
if isinstance(other, Money):
if self.currency == other.currency:
def __add__(self, other):
if isinstance(other, Money):
if self.currency == other.currency:
- amount = self.amount + Decimal(float(other)),
- currency = self.currency
+ amount=self.amount + Decimal(float(other)),
+ currency=self.currency,
)
def __sub__(self, other):
if isinstance(other, Money):
if self.currency == other.currency:
)
def __sub__(self, other):
if isinstance(other, Money):
if self.currency == other.currency:
- amount = self.amount - Decimal(float(other)),
- currency = self.currency
+ amount=self.amount - Decimal(float(other)),
+ currency=self.currency,
- amount = self.amount * Decimal(float(other)),
- currency = self.currency
+ amount=self.amount * Decimal(float(other)),
+ currency=self.currency,
- amount = self.amount / Decimal(float(other)),
- currency = self.currency
+ amount=self.amount / Decimal(float(other)),
+ currency=self.currency,
def __rsub__(self, other):
if isinstance(other, Money):
if self.currency == other.currency:
def __rsub__(self, other):
if isinstance(other, Money):
if self.currency == other.currency:
- amount = Decimal(float(other)) - self.amount,
- currency = self.currency
+ amount=Decimal(float(other)) - self.amount,
+ currency=self.currency,