Fix #10854 and another issue (again).

This commit is contained in:
James Cole
2025-09-15 19:20:51 +02:00
parent f512e6724e
commit ecfb3e2f95
6 changed files with 72 additions and 86 deletions

View File

@@ -26,6 +26,7 @@ namespace FireflyIII\Http\Controllers;
use FireflyIII\Events\RequestedSendWebhookMessages; use FireflyIII\Events\RequestedSendWebhookMessages;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Support\Facades\Amount; use FireflyIII\Support\Facades\Amount;
use FireflyIII\Support\Facades\Preferences;
use FireflyIII\Support\Facades\Steam; use FireflyIII\Support\Facades\Steam;
use FireflyIII\Support\Http\Controllers\RequestInformation; use FireflyIII\Support\Http\Controllers\RequestInformation;
use FireflyIII\Support\Http\Controllers\UserNavigation; use FireflyIII\Support\Http\Controllers\UserNavigation;
@@ -133,7 +134,7 @@ abstract class Controller extends BaseController
$this->primaryCurrency = Amount::getPrimaryCurrency(); $this->primaryCurrency = Amount::getPrimaryCurrency();
$language = Steam::getLanguage(); $language = Steam::getLanguage();
$locale = Steam::getLocale(); $locale = Steam::getLocale();
$darkMode = app('preferences')->get('darkMode', 'browser')->data; $darkMode = Preferences::get('darkMode', 'browser')->data;
$this->convertToPrimary = Amount::convertToPrimary(); $this->convertToPrimary = Amount::convertToPrimary();
$page = $this->getPageName(); $page = $this->getPageName();
$shownDemo = $this->hasSeenDemo(); $shownDemo = $this->hasSeenDemo();

View File

@@ -146,25 +146,7 @@ class ShowController extends Controller
$attachments = $this->repository->getAttachments($transactionGroup); $attachments = $this->repository->getAttachments($transactionGroup);
$links = $this->repository->getLinks($transactionGroup); $links = $this->repository->getLinks($transactionGroup);
return view( return view('transactions.show', compact('transactionGroup', 'amounts', 'first', 'type', 'logEntries', 'groupLogEntries', 'subTitle', 'splits', 'selectedGroup', 'groupArray', 'events', 'attachments', 'links', 'accounts'));
'transactions.show',
compact(
'transactionGroup',
'amounts',
'first',
'type',
'logEntries',
'groupLogEntries',
'subTitle',
'splits',
'selectedGroup',
'groupArray',
'events',
'attachments',
'links',
'accounts',
)
);
} }
private function getAmounts(array $group): array private function getAmounts(array $group): array

View File

@@ -370,8 +370,11 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
public function getTagObjects(int $journalId): Collection public function getTagObjects(int $journalId): Collection
{ {
/** @var TransactionJournal $journal */ /** @var TransactionJournal|null $journal */
$journal = $this->user->transactionJournals()->find($journalId); $journal = $this->user->transactionJournals()->find($journalId);
if(null ===$journal) {
return new Collection();
}
return $journal->tags()->whereNull('deleted_at')->get(); return $journal->tags()->whereNull('deleted_at')->get();
} }

View File

@@ -128,7 +128,7 @@ class Amount
} }
$currency = TransactionCurrency::find($currencyId); $currency = TransactionCurrency::find($currencyId);
if (null === $currency) { if (null === $currency) {
$message = sprintf('Could not find a transaction currency with ID #%d', $currencyId); $message = sprintf('Could not find a transaction currency with ID #%d in %s', $currencyId, __METHOD__);
Log::error($message); Log::error($message);
throw new FireflyException($message); throw new FireflyException($message);
@@ -150,7 +150,7 @@ class Amount
} }
$currency = TransactionCurrency::whereCode($code)->first(); $currency = TransactionCurrency::whereCode($code)->first();
if (null === $currency) { if (null === $currency) {
$message = sprintf('Could not find a transaction currency with code "%s"', $code); $message = sprintf('Could not find a transaction currency with code "%s" in %s', $code, __METHOD__);
Log::error($message); Log::error($message);
throw new FireflyException($message); throw new FireflyException($message);
@@ -379,9 +379,9 @@ class Amount
} }
if ($csPrecedes) { if ($csPrecedes) {
return $posA.$posB.'%s'.$posC.$space.$posD.'%v'.$posE; return $posA . $posB . '%s' . $posC . $space . $posD . '%v' . $posE;
} }
return $posA.$posD.'%v'.$space.$posB.'%s'.$posC.$posE; return $posA . $posD . '%v' . $space . $posB . '%s' . $posC . $posE;
} }
} }

View File

@@ -114,20 +114,20 @@ class AmountFormat extends AbstractExtension
{ {
return new TwigFunction( return new TwigFunction(
'formatAmountBySymbol', 'formatAmountBySymbol',
static function (string $amount, ?string $symbol, ?int $decimalPlaces = null, ?bool $coloured = null): string { static function (string $amount, ?string $symbol = null, ?int $decimalPlaces = null, ?bool $coloured = null): string {
if (null === $symbol) { if (null === $symbol) {
$message = sprintf('formatAmountBySymbol("%s", %s, %d, %s) was called without a symbol. Please browse to /flush to clear your cache.', $amount, var_export($symbol, true), $decimalPlaces, var_export($coloured, true)); $message = sprintf('formatAmountBySymbol("%s", %s, %d, %s) was called without a symbol. Please browse to /flush to clear your cache.', $amount, var_export($symbol, true), $decimalPlaces, var_export($coloured, true));
Log::error($message); Log::error($message);
$currency = Amount::getPrimaryCurrency();
throw new FireflyException($message);
} }
if (null !== $symbol) {
$decimalPlaces ??= 2; $decimalPlaces ??= 2;
$coloured ??= true; $coloured ??= true;
$currency = new TransactionCurrency(); $currency = new TransactionCurrency();
$currency->symbol = $symbol; $currency->symbol = $symbol;
$currency->decimal_places = $decimalPlaces; $currency->decimal_places = $decimalPlaces;
}
return Amount::formatAnything($currency, $amount, $coloured); return Amount::formatAnything($currency, $amount, $coloured);
}, },

View File

@@ -203,7 +203,7 @@
{% set boxSize = 4 %} {% set boxSize = 4 %}
{% endif %} {% endif %}
<div class="row"> <div class="row">
{% for index,journal in selectedGroup.transactions %} {% for index, journal in selectedGroup.transactions %}
<div class="col-lg-{{ boxSize }}"> <div class="col-lg-{{ boxSize }}">
<div class="box"> <div class="box">
<div class="box-header with-border"> <div class="box-header with-border">
@@ -440,7 +440,7 @@
<td style="width:40%;">{{ 'tags'|_ }}</td> <td style="width:40%;">{{ 'tags'|_ }}</td>
<td> <td>
{% for tag in journal.tags %} {% for tag in journal.tags %}
{% if null != tag.id %} {% if null != tag.id and '' != tag.id %}
<h4 style="display: inline;"><a class="label label-success" href="{{ route('tags.show', [tag.id]) }}"><span class="fa fa-fw fa-tag"></span>{{ tag.tag }}</a></h4> <h4 style="display: inline;"><a class="label label-success" href="{{ route('tags.show', [tag.id]) }}"><span class="fa fa-fw fa-tag"></span>{{ tag.tag }}</a></h4>
{% endif %} {% endif %}
{% endfor %} {% endfor %}