commit 4875c36a055ea89118e665bdd8b3d0148b112307 parent 579fdc4a200aa0560fb063fae79c84c14ca73c30 Author: Adrián Oliva <[email protected]> Date: Sun, 7 May 2023 00:17:03 -0600 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. Diffstat:
M | utils/register.py | | | 12 | ++++++++++++ |
1 file changed, 12 insertions(+), 0 deletions(-)
diff --git 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