Skip to content

Firefly III: a personal finances manager

Fix #12978

Sander Dorigoc983b00ea1d6
diff --git a/app/Helpers/Functions/helpers.php b/app/Helpers/Functions/helpers.php
index 873d1f02d0..f1684c9e0e 100644
--- a/app/Helpers/Functions/helpers.php
+++ b/app/Helpers/Functions/helpers.php
@@ -118,6 +118,18 @@ if (!function_exists('env_default_when_empty')) {
}
}
+if(!function_exists('steam_negative')) {
+ function steam_negative(string $amount): string {
+ return Steam::negative($amount);
+ }
+}
+
+if(!function_exists('steam_positive')) {
+ function steam_positive(string $amount): string {
+ return Steam::positive($amount);
+ }
+}
+
if (!function_exists('sign_amount')) {
function sign_amount(string $amount, string $transactionType, string $sourceType): string
{
diff --git a/app/View/Components/Generic/Amount.php b/app/View/Components/Generic/Amount.php
index 80dd3d3384..5b1ad3f995 100644
--- a/app/View/Components/Generic/Amount.php
+++ b/app/View/Components/Generic/Amount.php
@@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\View\Components\Generic;
use Closure;
+use FireflyIII\Models\Account;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
@@ -34,6 +35,7 @@ class Amount extends Component
* Create a new component instance.
*/
public function __construct(
+ public Account $account,
public array $transaction
) {}
diff --git a/app/View/Components/Lists/GroupsTiny.php b/app/View/Components/Lists/GroupsTiny.php
index 00ffb64230..dfb830d54b 100644
--- a/app/View/Components/Lists/GroupsTiny.php
+++ b/app/View/Components/Lists/GroupsTiny.php
@@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\View\Components\Lists;
use Closure;
+use FireflyIII\Models\Account;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
@@ -34,6 +35,7 @@ class GroupsTiny extends Component
* Create a new component instance.
*/
public function __construct(
+ public Account $account,
public array $transactions
) {}
diff --git a/resources/views/components/generic/amount.blade.php b/resources/views/components/generic/amount.blade.php
index d22397b7b7..548c551b41 100644
--- a/resources/views/components/generic/amount.blade.php
+++ b/resources/views/components/generic/amount.blade.php
@@ -26,23 +26,23 @@
<span class="text-info money-transfer">
{{-- transfer away --}}
@if(isset($account) && $transaction['source_account_id'] === $account->id)
- {!! format_amount_by_symbol(bcmul($transaction['amount'],'-1'), $transaction['currency_symbol'], $transaction['currency_decimal_places'], false) !!}
+ {!! format_amount_by_symbol(steam_negative($transaction['amount']), $transaction['currency_symbol'], $transaction['currency_decimal_places'], false) !!}
@if(null !== $transaction['foreign_amount'])
- ({!! format_amount_by_symbol(bcmul($transaction['foreign_amount'],'-1'), $transaction['foreign_currency_symbol'], $transaction['foreign_currency_decimal_places'], false) !!})
+ ({!! format_amount_by_symbol(steam_negative($transaction['foreign_amount']), $transaction['foreign_currency_symbol'], $transaction['foreign_currency_decimal_places'], false) !!})
@endif
@if($convertToPrimary && null !== $transaction['pc_amount'])
- (~{!! format_amount_by_symbol(bcmul($transaction['pc_amount'], '-1'), $primaryCurrency->symbol, $primaryCurrency->decimal_places, false) !!})
+ (~{!! format_amount_by_symbol(steam_negative($transaction['pc_amount']), $primaryCurrency->symbol, $primaryCurrency->decimal_places, false) !!})
@endif
@endif
{{-- transfer in (default) --}}
@if(!isset($account) || $transaction['source_account_id'] !== $account->id)
- {!! format_amount_by_symbol($transaction['amount'], $transaction['currency_symbol'], $transaction['currency_decimal_places'], false) !!}
+ {!! format_amount_by_symbol(steam_positive($transaction['amount']), $transaction['currency_symbol'], $transaction['currency_decimal_places'], false) !!}
@if(null !== $transaction['foreign_amount'])
- ({!! format_amount_by_symbol($transaction['foreign_amount'], $transaction['foreign_currency_symbol'], $transaction['foreign_currency_decimal_places'], false) !!})
+ ({!! format_amount_by_symbol(steam_positive($transaction['foreign_amount']), $transaction['foreign_currency_symbol'], $transaction['foreign_currency_decimal_places'], false) !!})
@endif
@if($convertToPrimary && null !== $transaction['pc_amount'])
- (~{!! format_amount_by_symbol($transaction['pc_amount'], $primaryCurrency->symbol, $primaryCurrency->decimal_places, false) !!})
+ (~{!! format_amount_by_symbol(steam_positive($transaction['pc_amount']), $primaryCurrency->symbol, $primaryCurrency->decimal_places, false) !!})
@endif
@endif
</span>
diff --git a/resources/views/components/lists/groups-tiny.blade.php b/resources/views/components/lists/groups-tiny.blade.php
index 8d921fac2b..a68316118b 100644
--- a/resources/views/components/lists/groups-tiny.blade.php
+++ b/resources/views/components/lists/groups-tiny.blade.php
@@ -14,7 +14,7 @@
</td>
<td class="text-end w-30">
<span class="small">
- <x-generic.amount :transaction="$transaction" />
+ <x-generic.amount :account="$account" :transaction="$transaction" />
</span>
</td>
</tr>
diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php
index 5b52e2a19e..7bdc1ef312 100644
--- a/resources/views/index.blade.php
+++ b/resources/views/index.blade.php
@@ -73,12 +73,12 @@
<div class="card card-outline mb-2">
<div class="card-header">
<div class="card-title"><a
- href="{{ route('accounts.show', [$data['account']['id']]) }}">{{ $data['account']['name'] }}</a>
+ href="{{ route('accounts.show', [$data['account']->id]) }}">{{ $data['account']->name }}</a>
</div>
</div>
@if(count($data['transactions']) > 0)
<div class="card-body p-0">
- <x-lists.groups-tiny :transactions="$data['transactions']"/>
+ <x-lists.groups-tiny :account="$data['account']" :transactions="$data['transactions']"/>
</div>
@endif
@if(0 === count($data['transactions']))