From 4875c36a055ea89118e665bdd8b3d0148b112307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Oliva?= Date: Sun, 7 May 2023 00:17:03 -0600 Subject: We can now compare currencies. At least with just the `<` and if we only have one type of currency. The value is the only thing that will be compared. --- utils/register.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'utils') diff --git a/utils/register.py b/utils/register.py index 8ebb5b6..0a103fb 100644 --- a/utils/register.py +++ b/utils/register.py @@ -101,6 +101,18 @@ class currencies: return negated + def __lt__(self, other): + if len(self.money.values()) != 1 or len(other.money.values()) != 1: + raise Exception('Cannot compare multiple currencies at once!') + + for amount_left in self.money.values(): + break + for amount_right in other.money.values(): + break + + return amount_left < amount_right + + def complete_prices(my_entry: entry): """ Transform all string of prices to the class `currencies`. If there is an -- cgit v1.2.3