From 2623fb3da5ec3d01b846a90f096fea22911dab0a Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Sat, 16 Nov 2024 23:59:46 -0300 Subject: [PATCH] feat: convert returns None if Currency convertion has same currency for both or if amount if 0 --- app/apps/currencies/utils/convert.py | 10 ++++------ app/templates/net_worth/net_worth.html | 2 +- .../yearly_overview/fragments/currency_data.html | 14 +++++++------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/app/apps/currencies/utils/convert.py b/app/apps/currencies/utils/convert.py index caa2a94..cc22cd2 100644 --- a/app/apps/currencies/utils/convert.py +++ b/app/apps/currencies/utils/convert.py @@ -43,12 +43,10 @@ def get_exchange_rate( def convert(amount, from_currency: Currency, to_currency: Currency, date=None): if from_currency == to_currency: - return ( - amount, - to_currency.prefix, - to_currency.suffix, - to_currency.decimal_places, - ) + return None, None, None, None + + if amount == 0: + return None, None, None, None if date is None: date = timezone.localtime(timezone.now()) diff --git a/app/templates/net_worth/net_worth.html b/app/templates/net_worth/net_worth.html index 1b1c85e..0254261 100644 --- a/app/templates/net_worth/net_worth.html +++ b/app/templates/net_worth/net_worth.html @@ -37,7 +37,7 @@ - {% if currency.exchanged %} + {% if currency.exchanged and currency.exchanged.amount %}
- {% if entry.exchanged %} + {% if entry.exchanged and entry.exchanged.amount %}
- {% if entry.exchanged %} + {% if entry.exchanged and entry.exchanged.amount %}
- {% if entry.exchanged %} + {% if entry.exchanged and entry.exchanged.amount %}
- {% if entry.exchanged %} + {% if entry.exchanged and entry.exchanged.amount %}
- {% if entry.exchanged %} + {% if entry.exchanged and entry.exchanged.amount %}
- {% if entry.exchanged %} + {% if entry.exchanged and entry.exchanged.amount %}
- {% if entry.exchanged %} + {% if entry.exchanged and entry.exchanged.amount %}