Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions financepy/utils/amount.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __sub__(self, other):

return Amount(
self.amount - other.amount,
self.currency_type,
self.ccy_name,
)

def __mul__(self, scalar):
Expand Down Expand Up @@ -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
)

Expand Down
9 changes: 9 additions & 0 deletions tests/unit/test_FinAmount.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Loading