mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-04-19 23:31:27 +02:00
feat: convert returns None if Currency convertion has same currency for both or if amount if 0
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if currency.exchanged %}
|
||||
{% if currency.exchanged and currency.exchanged.amount %}
|
||||
<div>
|
||||
<c-amount.display
|
||||
:amount="currency.exchanged.amount"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
:suffix="entry.suffix"
|
||||
:decimal_places="entry.decimal_places"></c-amount.display>
|
||||
</div>
|
||||
{% if entry.exchanged %}
|
||||
{% if entry.exchanged and entry.exchanged.amount %}
|
||||
<div>
|
||||
<c-amount.display
|
||||
:amount="entry.exchanged.amount"
|
||||
@@ -44,7 +44,7 @@
|
||||
:suffix="entry.suffix"
|
||||
:decimal_places="entry.decimal_places"></c-amount.display>
|
||||
</div>
|
||||
{% if entry.exchanged %}
|
||||
{% if entry.exchanged and entry.exchanged.amount %}
|
||||
<div>
|
||||
<c-amount.display
|
||||
:amount="entry.exchanged.amount"
|
||||
@@ -74,7 +74,7 @@
|
||||
:decimal_places="entry.decimal_places"
|
||||
color="{% if entry.amount > 0 %}green{% elif entry.amount < 0 %}red{% endif %}"></c-amount.display>
|
||||
</div>
|
||||
{% if entry.exchanged %}
|
||||
{% if entry.exchanged and entry.exchanged.amount %}
|
||||
<div>
|
||||
<c-amount.display
|
||||
:amount="entry.exchanged.amount"
|
||||
@@ -104,7 +104,7 @@
|
||||
:suffix="entry.suffix"
|
||||
:decimal_places="entry.decimal_places"></c-amount.display>
|
||||
</div>
|
||||
{% if entry.exchanged %}
|
||||
{% if entry.exchanged and entry.exchanged.amount %}
|
||||
<div>
|
||||
<c-amount.display
|
||||
:amount="entry.exchanged.amount"
|
||||
@@ -133,7 +133,7 @@
|
||||
:suffix="entry.suffix"
|
||||
:decimal_places="entry.decimal_places"></c-amount.display>
|
||||
</div>
|
||||
{% if entry.exchanged %}
|
||||
{% if entry.exchanged and entry.exchanged.amount %}
|
||||
<div>
|
||||
<c-amount.display
|
||||
:amount="entry.exchanged.amount"
|
||||
@@ -163,7 +163,7 @@
|
||||
:decimal_places="entry.decimal_places"
|
||||
color="{% if entry.amount > 0 %}green{% elif entry.amount < 0 %}red{% endif %}"></c-amount.display>
|
||||
</div>
|
||||
{% if entry.exchanged %}
|
||||
{% if entry.exchanged and entry.exchanged.amount %}
|
||||
<div>
|
||||
<c-amount.display
|
||||
:amount="entry.exchanged.amount"
|
||||
@@ -194,7 +194,7 @@
|
||||
:decimal_places="entry.decimal_places"
|
||||
color="{% if entry.amount > 0 %}green{% elif entry.amount < 0 %}red{% endif %}"></c-amount.display>
|
||||
</div>
|
||||
{% if entry.exchanged %}
|
||||
{% if entry.exchanged and entry.exchanged.amount %}
|
||||
<div>
|
||||
<c-amount.display
|
||||
:amount="entry.exchanged.amount"
|
||||
|
||||
Reference in New Issue
Block a user