From 5fef99ac1be78f68b1c9aaba185cdcd609f28e1f Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Thu, 1 Jun 2023 12:57:07 +0300 Subject: [PATCH] Currency conversion on dashboard completed payments is incorrect. #562 --- lib/redux/dashboard/dashboard_selectors.dart | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/redux/dashboard/dashboard_selectors.dart b/lib/redux/dashboard/dashboard_selectors.dart index 68e5958cf..bc22c189d 100644 --- a/lib/redux/dashboard/dashboard_selectors.dart +++ b/lib/redux/dashboard/dashboard_selectors.dart @@ -458,14 +458,22 @@ List chartPayments( double completedAmount = payment.completedAmount; double refunded = payment.refunded; + var invoice = InvoiceEntity(); + if (payment.invoicePaymentables.isNotEmpty) { + final paymentable = payment.invoicePaymentables.first; + invoice = invoiceMap[paymentable.invoiceId] ?? InvoiceEntity(); + } + // Handle "All" if (settings.currencyId == kCurrencyAll && client.currencyId != company.currencyId) { final exchangeRate = payment.hasExchangeRate ? payment.exchangeRate - : getExchangeRate(currencyMap, - fromCurrencyId: client.currencyId, - toCurrencyId: company.currencyId); + : invoice.hasExchangeRate + ? invoice.exchangeRate + : getExchangeRate(currencyMap, + fromCurrencyId: client.currencyId, + toCurrencyId: company.currencyId); completedAmount *= exchangeRate; refunded *= exchangeRate; }