diff --git a/financepy/utils/amount.py b/financepy/utils/amount.py index d3afc0ee..42af7e81 100644 --- a/financepy/utils/amount.py +++ b/financepy/utils/amount.py @@ -64,7 +64,7 @@ def __sub__(self, other): return Amount( self.amount - other.amount, - self.currency_type, + self.ccy_name, ) def __mul__(self, scalar): @@ -97,7 +97,7 @@ def __eq__(self, other): return False return ( - self.currency_type == other.currency_type + self.ccy_name == other.ccy_name and self.amount == other.amount ) diff --git a/tests/unit/test_FinAmount.py b/tests/unit/test_FinAmount.py index b6ec0f92..102a8e37 100644 --- a/tests/unit/test_FinAmount.py +++ b/tests/unit/test_FinAmount.py @@ -9,3 +9,12 @@ def test_amount(): amt = Amount(101000.232, "CAD") assert repr(amt) == "CAD 101,000.23" + + +def test_amount_sub_and_eq(): + + diff = Amount(100.0, "CAD") - Amount(40.0, "CAD") + assert diff.amount == 60.0 + assert diff.ccy_name == "CAD" + assert Amount(1.0, "CAD") == Amount(1.0, "CAD") + assert Amount(1.0, "CAD") != Amount(1.0, "USD")