From 80edf557cb996009c82547e620468c04926cc503 Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Mon, 3 Feb 2025 00:30:26 -0300 Subject: [PATCH] fix(transactions): transaction convert value doesn't take into account currency's exchange currency account takes precedence --- app/apps/transactions/models.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/apps/transactions/models.py b/app/apps/transactions/models.py index f6c54a5..4bdc808 100644 --- a/app/apps/transactions/models.py +++ b/app/apps/transactions/models.py @@ -255,6 +255,20 @@ class Transaction(models.Model): "suffix": suffix, "decimal_places": decimal_places, } + elif self.account.currency.exchange_currency: + converted_amount, prefix, suffix, decimal_places = convert( + self.amount, + to_currency=self.account.currency.exchange_currency, + from_currency=self.account.currency, + date=self.date, + ) + if converted_amount: + return { + "amount": converted_amount, + "prefix": prefix, + "suffix": suffix, + "decimal_places": decimal_places, + } return None