🤖 Auto commit for release 'develop' on 2025-09-26

This commit is contained in:
JC5
2025-09-26 19:43:39 +02:00
parent 853a99852e
commit d3c557ca22
103 changed files with 1411 additions and 1336 deletions

View File

@@ -145,13 +145,13 @@ class AmountFormat extends AbstractExtension
static function (string $amount, ?string $symbol = null, ?int $decimalPlaces = null, ?bool $coloured = null): string {
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);
$currency = Amount::getPrimaryCurrency();
}
if (null !== $symbol) {
$decimalPlaces ??= 2;
$coloured ??= true;
$decimalPlaces ??= 2;
$coloured ??= true;
$currency = new TransactionCurrency();
$currency->symbol = $symbol;
$currency->decimal_places = $decimalPlaces;

View File

@@ -37,6 +37,7 @@ use Override;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;
use function Safe\parse_url;
/**
@@ -104,7 +105,7 @@ class General extends AbstractExtension
'activeRoutePartialObjectType',
static function ($context): string {
[, $route, $objectType] = func_get_args();
$activeObjectType = $context['objectType'] ?? false;
$activeObjectType = $context['objectType'] ?? false;
if ($objectType === $activeObjectType
&& false !== stripos(
@@ -154,14 +155,14 @@ class General extends AbstractExtension
}
/** @var Carbon $date */
$date = session('end', today(config('app.timezone'))->endOfMonth());
$date = session('end', today(config('app.timezone'))->endOfMonth());
Log::debug(sprintf('twig balance: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
$info = Steam::finalAccountBalance($account, $date);
$currency = Steam::getAccountCurrency($account);
$primary = Amount::getPrimaryCurrency();
$convertToPrimary = Amount::convertToPrimary();
$usePrimary = $convertToPrimary && $primary->id !== $currency->id;
$currency ??= $primary;
$currency ??= $primary;
$strings = [];
foreach ($info as $key => $balance) {
if ('balance' === $key) {
@@ -196,7 +197,7 @@ class General extends AbstractExtension
{
return new TwigFunction(
'carbonize',
static fn(string $date): Carbon => new Carbon($date, config('app.timezone'))
static fn (string $date): Carbon => new Carbon($date, config('app.timezone'))
);
}
@@ -225,15 +226,15 @@ class General extends AbstractExtension
static function (int $size): string {
// less than one GB, more than one MB
if ($size < (1024 * 1024 * 2014) && $size >= (1024 * 1024)) {
return round($size / (1024 * 1024), 2) . ' MB';
return round($size / (1024 * 1024), 2).' MB';
}
// less than one MB
if ($size < (1024 * 1024)) {
return round($size / 1024, 2) . ' KB';
return round($size / 1024, 2).' KB';
}
return $size . ' bytes';
return $size.' bytes';
}
);
}
@@ -337,7 +338,7 @@ class General extends AbstractExtension
{
return new TwigFilter(
'mimeIcon',
static fn(string $string): string => match ($string) {
static fn (string $string): string => match ($string) {
'application/pdf' => 'fa-file-pdf-o',
'image/webp', 'image/png', 'image/jpeg', 'image/svg+xml', 'image/heic', 'image/heic-sequence', 'application/vnd.oasis.opendocument.image' => 'fa-file-image-o',
'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 'application/x-iwork-pages-sffpages', 'application/vnd.sun.xml.writer', 'application/vnd.sun.xml.writer.template', 'application/vnd.sun.xml.writer.global', 'application/vnd.stardivision.writer', 'application/vnd.stardivision.writer-global', 'application/vnd.oasis.opendocument.text', 'application/vnd.oasis.opendocument.text-template', 'application/vnd.oasis.opendocument.text-web', 'application/vnd.oasis.opendocument.text-master' => 'fa-file-word-o',
@@ -380,7 +381,7 @@ class General extends AbstractExtension
{
return new TwigFunction(
'phpdate',
static fn(string $str): string => date($str)
static fn (string $str): string => date($str)
);
}
}

View File

@@ -42,7 +42,7 @@ class Rule extends AbstractExtension
$ruleActions = array_keys(Config::get('firefly.rule-actions'));
$possibleActions = [];
foreach ($ruleActions as $key) {
$possibleActions[$key] = (string)trans('firefly.rule_action_' . $key . '_choice');
$possibleActions[$key] = (string)trans('firefly.rule_action_'.$key.'_choice');
}
unset($ruleActions);
asort($possibleActions);
@@ -56,7 +56,7 @@ class Rule extends AbstractExtension
{
return new TwigFunction(
'allJournalTriggers',
static fn() => [
static fn () => [
'store-journal' => (string)trans('firefly.rule_trigger_store_journal'),
'update-journal' => (string)trans('firefly.rule_trigger_update_journal'),
'manual-activation' => (string)trans('firefly.rule_trigger_manual'),
@@ -73,7 +73,7 @@ class Rule extends AbstractExtension
$possibleTriggers = [];
foreach ($ruleTriggers as $key) {
if ('user_action' !== $key) {
$possibleTriggers[$key] = (string)trans('firefly.rule_trigger_' . $key . '_choice');
$possibleTriggers[$key] = (string)trans('firefly.rule_trigger_'.$key.'_choice');
}
}
unset($ruleTriggers);

View File

@@ -34,6 +34,7 @@ use Illuminate\Support\Facades\DB;
use Override;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
use function Safe\json_decode;
/**
@@ -82,10 +83,11 @@ class TransactionGroupTwig extends AbstractExtension
static function (int $journalId, string $metaField) {
/** @var null|TransactionJournalMeta $entry */
$entry = DB::table('journal_meta')
->where('name', $metaField)
->where('transaction_journal_id', $journalId)
->whereNull('deleted_at')
->first();
->where('name', $metaField)
->where('transaction_journal_id', $journalId)
->whereNull('deleted_at')
->first()
;
if (null === $entry) {
return today(config('app.timezone'));
}
@@ -102,10 +104,11 @@ class TransactionGroupTwig extends AbstractExtension
static function (int $journalId, string $metaField) {
/** @var null|TransactionJournalMeta $entry */
$entry = DB::table('journal_meta')
->where('name', $metaField)
->where('transaction_journal_id', $journalId)
->whereNull('deleted_at')
->first();
->where('name', $metaField)
->where('transaction_journal_id', $journalId)
->whereNull('deleted_at')
->first()
;
if (null === $entry) {
return '';
}
@@ -121,10 +124,11 @@ class TransactionGroupTwig extends AbstractExtension
'journalHasMeta',
static function (int $journalId, string $metaField) {
$count = DB::table('journal_meta')
->where('name', $metaField)
->where('transaction_journal_id', $journalId)
->whereNull('deleted_at')
->count();
->where('name', $metaField)
->where('transaction_journal_id', $journalId)
->whereNull('deleted_at')
->count()
;
return 1 === $count;
}
@@ -157,9 +161,9 @@ class TransactionGroupTwig extends AbstractExtension
*/
private function foreignJournalArrayAmount(array $array): string
{
$type = $array['transaction_type_type'] ?? TransactionTypeEnum::WITHDRAWAL->value;
$amount = $array['foreign_amount'] ?? '0';
$colored = true;
$type = $array['transaction_type_type'] ?? TransactionTypeEnum::WITHDRAWAL->value;
$amount = $array['foreign_amount'] ?? '0';
$colored = true;
$sourceType = $array['source_account_type'] ?? 'invalid';
$amount = $this->signAmount($amount, $type, $sourceType);
@@ -167,7 +171,7 @@ class TransactionGroupTwig extends AbstractExtension
if (TransactionTypeEnum::TRANSFER->value === $type) {
$colored = false;
}
$result = app('amount')->formatFlat($array['foreign_currency_symbol'], (int)$array['foreign_currency_decimal_places'], $amount, $colored);
$result = app('amount')->formatFlat($array['foreign_currency_symbol'], (int)$array['foreign_currency_decimal_places'], $amount, $colored);
if (TransactionTypeEnum::TRANSFER->value === $type) {
return sprintf('<span class="text-info money-transfer">%s</span>', $result);
}
@@ -180,7 +184,7 @@ class TransactionGroupTwig extends AbstractExtension
*/
private function foreignJournalObjectAmount(TransactionJournal $journal): string
{
$type = $journal->transactionType->type;
$type = $journal->transactionType->type;
/** @var Transaction $first */
$first = $journal->transactions()->where('amount', '<', 0)->first();
@@ -189,12 +193,12 @@ class TransactionGroupTwig extends AbstractExtension
$colored = true;
$sourceType = $first->account->accountType()->first()->type;
$amount = $this->signAmount($amount, $type, $sourceType);
$amount = $this->signAmount($amount, $type, $sourceType);
if (TransactionTypeEnum::TRANSFER->value === $type) {
$colored = false;
}
$result = app('amount')->formatFlat($currency->symbol, $currency->decimal_places, $amount, $colored);
$result = app('amount')->formatFlat($currency->symbol, $currency->decimal_places, $amount, $colored);
if (TransactionTypeEnum::TRANSFER->value === $type) {
return sprintf('<span class="text-info money-transfer">%s</span>', $result);
}
@@ -225,7 +229,7 @@ class TransactionGroupTwig extends AbstractExtension
$colored = false;
}
$result = app('amount')->formatFlat($array['currency_symbol'], (int)$array['currency_decimal_places'], $amount, $colored);
$result = app('amount')->formatFlat($array['currency_symbol'], (int)$array['currency_decimal_places'], $amount, $colored);
if (TransactionTypeEnum::TRANSFER->value === $type) {
return sprintf('<span class="text-info money-transfer">%s</span>', $result);
}
@@ -238,7 +242,7 @@ class TransactionGroupTwig extends AbstractExtension
*/
private function normalJournalObjectAmount(TransactionJournal $journal): string
{
$type = $journal->transactionType->type;
$type = $journal->transactionType->type;
/** @var Transaction $first */
$first = $journal->transactions()->where('amount', '<', 0)->first();
@@ -247,12 +251,12 @@ class TransactionGroupTwig extends AbstractExtension
$colored = true;
$sourceType = $first->account->accountType()->first()->type;
$amount = $this->signAmount($amount, $type, $sourceType);
$amount = $this->signAmount($amount, $type, $sourceType);
if (TransactionTypeEnum::TRANSFER->value === $type) {
$colored = false;
}
$result = app('amount')->formatFlat($currency->symbol, $currency->decimal_places, $amount, $colored);
$result = app('amount')->formatFlat($currency->symbol, $currency->decimal_places, $amount, $colored);
if (TransactionTypeEnum::TRANSFER->value === $type) {
return sprintf('<span class="text-info money-transfer">%s</span>', $result);
}

View File

@@ -39,7 +39,7 @@ class Translation extends AbstractExtension
return [
new TwigFilter(
'_',
static fn($name) => (string)trans(sprintf('firefly.%s', $name)),
static fn ($name) => (string)trans(sprintf('firefly.%s', $name)),
['is_safe' => ['html']]
),
];