From 2f66315416bead1c211ee0b024576bba7eceafa8 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 23 Oct 2022 14:53:13 +0200 Subject: [PATCH] Fix #6556 --- app/Http/Controllers/Chart/BillController.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Chart/BillController.php b/app/Http/Controllers/Chart/BillController.php index 6ba30c5dec..ff1782f1b5 100644 --- a/app/Http/Controllers/Chart/BillController.php +++ b/app/Http/Controllers/Chart/BillController.php @@ -31,7 +31,6 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Support\CacheProperties; use Illuminate\Http\JsonResponse; -use JsonException; /** * Class BillController. @@ -134,7 +133,7 @@ class BillController extends Controller } ); - $chartData = [ + $chartData = [ ['type' => 'line', 'label' => (string) trans('firefly.min-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, 'currency_code' => $bill->transactionCurrency->code, 'entries' => []], ['type' => 'line', 'label' => (string) trans('firefly.max-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, @@ -142,7 +141,7 @@ class BillController extends Controller ['type' => 'bar', 'label' => (string) trans('firefly.journal-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, 'currency_code' => $bill->transactionCurrency->code, 'entries' => []], ]; - + $currencyId = (int) $bill->transaction_currency_id; foreach ($journals as $journal) { $date = $journal['date']->isoFormat((string) trans('config.month_and_day_js', [], $locale)); $chartData[0]['entries'][$date] = $bill->amount_min; // minimum amount of bill @@ -152,7 +151,12 @@ class BillController extends Controller if (!array_key_exists($date, $chartData[2]['entries'])) { $chartData[2]['entries'][$date] = '0'; } - $amount = bcmul($journal['amount'], '-1'); + $amount = bcmul($journal['amount'], '-1'); + if ($currencyId === $journal['foreign_currency_id']) { + $amount = bcmul($journal['foreign_amount'], '-1'); + } + + $chartData[2]['entries'][$date] = bcadd($chartData[2]['entries'][$date], $amount); // amount of journal }