mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Code clean up.
This commit is contained in:
@@ -141,7 +141,6 @@ class Amount
|
||||
}
|
||||
|
||||
if ($coloured === true) {
|
||||
|
||||
if ($amount > 0) {
|
||||
return sprintf('<span class="text-success">%s</span>', $result);
|
||||
}
|
||||
@@ -150,8 +149,6 @@ class Amount
|
||||
}
|
||||
|
||||
return sprintf('<span style="color:#999">%s</span>', $result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
return $result;
|
||||
@@ -170,7 +167,6 @@ class Amount
|
||||
*/
|
||||
public function getCurrencyCode(): string
|
||||
{
|
||||
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty('getCurrencyCode');
|
||||
if ($cache->has()) {
|
||||
@@ -180,7 +176,6 @@ class Amount
|
||||
|
||||
$currency = TransactionCurrency::where('code', $currencyPreference->data)->first();
|
||||
if ($currency) {
|
||||
|
||||
$cache->store($currency->code);
|
||||
|
||||
return $currency->code;
|
||||
@@ -263,5 +258,4 @@ class Amount
|
||||
'zero' => $positive,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Binder;
|
||||
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use Illuminate\Support\Collection;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
@@ -44,9 +43,7 @@ class AccountList implements BinderInterface
|
||||
*/
|
||||
public static function routeBinder($value, $route): Collection
|
||||
{
|
||||
|
||||
if (auth()->check()) {
|
||||
|
||||
$ids = explode(',', $value);
|
||||
// filter ids:
|
||||
$ids = self::filterIds($ids);
|
||||
|
||||
@@ -37,5 +37,4 @@ interface BinderInterface
|
||||
* @return mixed
|
||||
*/
|
||||
public static function routeBinder($value, $route);
|
||||
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ use FireflyIII\Models\Budget;
|
||||
use Illuminate\Support\Collection;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
|
||||
/**
|
||||
* Class BudgetList
|
||||
*
|
||||
|
||||
@@ -54,6 +54,5 @@ class UnfinishedJournal implements BinderInterface
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support;
|
||||
|
||||
|
||||
use Cache;
|
||||
use Illuminate\Support\Collection;
|
||||
use Preferences as Prefs;
|
||||
|
||||
@@ -36,7 +36,6 @@ class Domain
|
||||
public static function getBindables(): array
|
||||
{
|
||||
return config('firefly.bindables');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Events;
|
||||
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
|
||||
@@ -48,5 +47,4 @@ class BillScanner
|
||||
$repository->scan($bill, $journal);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -133,7 +133,6 @@ class ExpandedForm
|
||||
$html = view('form.file', compact('classes', 'name', 'label', 'options'))->render();
|
||||
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,7 +152,6 @@ class ExpandedForm
|
||||
$html = view('form.integer', compact('classes', 'name', 'label', 'value', 'options'))->render();
|
||||
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,7 +170,6 @@ class ExpandedForm
|
||||
$html = view('form.location', compact('classes', 'name', 'label', 'value', 'options'))->render();
|
||||
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -387,7 +384,6 @@ class ExpandedForm
|
||||
$html = view('form.password', compact('classes', 'name', 'label', 'value', 'options'))->render();
|
||||
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -426,7 +422,6 @@ class ExpandedForm
|
||||
$html = view('form.static', compact('classes', 'name', 'label', 'value', 'options'))->render();
|
||||
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -464,7 +459,6 @@ class ExpandedForm
|
||||
$html = view('form.text', compact('classes', 'name', 'label', 'value', 'options'))->render();
|
||||
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -484,7 +478,6 @@ class ExpandedForm
|
||||
$html = view('form.textarea', compact('classes', 'name', 'label', 'value', 'options'))->render();
|
||||
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -567,7 +560,6 @@ class ExpandedForm
|
||||
$name = str_replace('[]', '', $name);
|
||||
|
||||
return strval(trans('form.' . $name));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,5 +41,4 @@ class Amount extends Facade
|
||||
{
|
||||
return 'amount';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,5 +41,4 @@ class ExpandedForm extends Facade
|
||||
{
|
||||
return 'expandedform';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,5 +41,4 @@ class FireflyConfig extends Facade
|
||||
{
|
||||
return 'fireflyconfig';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,5 +41,4 @@ class Navigation extends Facade
|
||||
{
|
||||
return 'navigation';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,5 +41,4 @@ class Preferences extends Facade
|
||||
{
|
||||
return 'preferences';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,5 +41,4 @@ class Steam extends Facade
|
||||
{
|
||||
return 'steam';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -117,7 +117,5 @@ class FireflyConfig
|
||||
Cache::forget('ff-config-' . $name);
|
||||
|
||||
return $config;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -61,5 +61,4 @@ interface ConfigurationInterface
|
||||
* @return bool
|
||||
*/
|
||||
public function storeConfiguration(array $data): bool;
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Import\Configuration\Csv;
|
||||
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Import\Mapper\MapperInterface;
|
||||
use FireflyIII\Import\MapperPreProcess\PreProcessorInterface;
|
||||
@@ -69,7 +68,6 @@ class Map implements ConfigurationInterface
|
||||
$indexes = array_keys($this->data);
|
||||
$rowIndex = 0;
|
||||
foreach ($results as $rowIndex => $row) {
|
||||
|
||||
$row = $this->runSpecifics($row);
|
||||
|
||||
//do something here
|
||||
@@ -117,7 +115,6 @@ class Map implements ConfigurationInterface
|
||||
$this->job->save();
|
||||
|
||||
return $this->data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,7 +213,6 @@ class Map implements ConfigurationInterface
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Import\Configuration\Csv;
|
||||
|
||||
|
||||
use FireflyIII\Import\Specifics\SpecificInterface;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Support\Import\Configuration\ConfigurationInterface;
|
||||
@@ -150,7 +149,6 @@ class Roles implements ConfigurationInterface
|
||||
}
|
||||
|
||||
return $roles;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,7 +173,6 @@ class Roles implements ConfigurationInterface
|
||||
$this->job->save();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -83,7 +83,6 @@ class BunqInformation implements InformationInterface
|
||||
$return = [];
|
||||
/** @var MonetaryAccountBank $account */
|
||||
foreach ($accounts as $account) {
|
||||
|
||||
$current = [
|
||||
'id' => $account->getId(),
|
||||
'name' => $account->getDescription(),
|
||||
@@ -156,7 +155,6 @@ class BunqInformation implements InformationInterface
|
||||
$request->call();
|
||||
|
||||
return $request->getMonetaryAccounts();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -149,7 +149,6 @@ class BunqPrerequisites implements PrerequisitesInterface
|
||||
Log::debug('Created key pair');
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -334,5 +333,4 @@ class BunqPrerequisites implements PrerequisitesInterface
|
||||
|
||||
return $deviceServerId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Import\Prerequisites;
|
||||
|
||||
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Models;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Transaction;
|
||||
@@ -161,8 +160,6 @@ trait TransactionJournalTrait
|
||||
}
|
||||
|
||||
return '';
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -176,7 +176,6 @@ class Navigation
|
||||
if (isset($functionMap[$repeatFreq])) {
|
||||
$function = $functionMap[$repeatFreq];
|
||||
$currentEnd->$function();
|
||||
|
||||
}
|
||||
|
||||
if (!is_null($maxDate) && $currentEnd > $maxDate) {
|
||||
@@ -221,7 +220,6 @@ class Navigation
|
||||
}
|
||||
|
||||
return $entries;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -310,7 +308,6 @@ class Navigation
|
||||
}
|
||||
|
||||
return $format;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -357,7 +354,6 @@ class Navigation
|
||||
}
|
||||
|
||||
return $format;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -381,7 +377,6 @@ class Navigation
|
||||
}
|
||||
|
||||
return $format;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -565,11 +560,7 @@ class Navigation
|
||||
$start->startOfYear();
|
||||
|
||||
return $start;
|
||||
|
||||
|
||||
}
|
||||
throw new FireflyException(sprintf('updateStartDate cannot handle range "%s"', $range));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -115,7 +115,6 @@ class Preferences
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,7 +145,6 @@ class Preferences
|
||||
}
|
||||
|
||||
return $this->setForUser($user, $name, $default);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,6 +225,5 @@ class Preferences
|
||||
Cache::forever($fullName, $pref);
|
||||
|
||||
return $pref;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Search;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
@@ -154,7 +153,6 @@ class Modifier
|
||||
Log::debug(sprintf('"%s" is in "%s"? %s', $needle, $haystack, var_export($res, true)));
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Search;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
@@ -134,7 +133,6 @@ class Search implements SearchInterface
|
||||
// Filter transactions that match the given triggers.
|
||||
$filtered = $set->filter(
|
||||
function (Transaction $transaction) {
|
||||
|
||||
if ($this->matchModifiers($transaction)) {
|
||||
return $transaction;
|
||||
}
|
||||
@@ -167,7 +165,6 @@ class Search implements SearchInterface
|
||||
// break at some point so the script does not crash:
|
||||
$currentTime = microtime(true) - $startTime;
|
||||
Log::debug(sprintf('Have been running for %f seconds.', $currentTime));
|
||||
|
||||
} while (!$reachedEndOfList && !$foundEnough && $currentTime <= 30);
|
||||
|
||||
$result = $result->slice(0, $this->limit);
|
||||
@@ -287,7 +284,6 @@ class Search implements SearchInterface
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support;
|
||||
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
|
||||
@@ -208,8 +208,6 @@ class Steam
|
||||
$cache->store($balances);
|
||||
|
||||
return $balances;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -337,8 +335,6 @@ class Steam
|
||||
}
|
||||
|
||||
return intval($string);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -370,5 +366,4 @@ class Steam
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Twig;
|
||||
|
||||
|
||||
use FireflyIII\Models\Account as AccountModel;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use Twig_Extension;
|
||||
@@ -46,7 +45,6 @@ class AmountFormat extends Twig_Extension
|
||||
$this->formatAmount(),
|
||||
$this->formatAmountPlain(),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +61,6 @@ class AmountFormat extends Twig_Extension
|
||||
$this->formatSourceBefore(),
|
||||
$this->formatAmountByCurrency(),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,12 +80,13 @@ class AmountFormat extends Twig_Extension
|
||||
protected function formatAmount(): Twig_SimpleFilter
|
||||
{
|
||||
return new Twig_SimpleFilter(
|
||||
'formatAmount', function (string $string): string {
|
||||
'formatAmount',
|
||||
function (string $string): string {
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
|
||||
return app('amount')->formatAnything($currency, $string, true);
|
||||
}, ['is_safe' => ['html']]
|
||||
return app('amount')->formatAnything($currency, $string, true);
|
||||
},
|
||||
['is_safe' => ['html']]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -100,20 +98,20 @@ class AmountFormat extends Twig_Extension
|
||||
protected function formatAmountByAccount(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'formatAmountByAccount', function (AccountModel $account, string $amount, bool $coloured = true): string {
|
||||
$currencyId = intval($account->getMeta('currency_id'));
|
||||
'formatAmountByAccount',
|
||||
function (AccountModel $account, string $amount, bool $coloured = true): string {
|
||||
$currencyId = intval($account->getMeta('currency_id'));
|
||||
|
||||
if ($currencyId !== 0) {
|
||||
$currency = TransactionCurrency::find($currencyId);
|
||||
if ($currencyId !== 0) {
|
||||
$currency = TransactionCurrency::find($currencyId);
|
||||
|
||||
return app('amount')->formatAnything($currency, $amount, $coloured);
|
||||
}
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
|
||||
return app('amount')->formatAnything($currency, $amount, $coloured);
|
||||
}
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
|
||||
return app('amount')->formatAnything($currency, $amount, $coloured);
|
||||
|
||||
|
||||
}, ['is_safe' => ['html']]
|
||||
},
|
||||
['is_safe' => ['html']]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -125,12 +123,11 @@ class AmountFormat extends Twig_Extension
|
||||
protected function formatAmountByCurrency(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'formatAmountByCurrency', function (TransactionCurrency $currency, string $amount, bool $coloured = true): string {
|
||||
|
||||
return app('amount')->formatAnything($currency, $amount, $coloured);
|
||||
|
||||
|
||||
}, ['is_safe' => ['html']]
|
||||
'formatAmountByCurrency',
|
||||
function (TransactionCurrency $currency, string $amount, bool $coloured = true): string {
|
||||
return app('amount')->formatAnything($currency, $amount, $coloured);
|
||||
},
|
||||
['is_safe' => ['html']]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -142,16 +139,15 @@ class AmountFormat extends Twig_Extension
|
||||
protected function formatAmountBySymbol(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'formatAmountBySymbol', function (string $amount, string $symbol, int $decimalPlaces = 2, bool $coloured = true): string {
|
||||
'formatAmountBySymbol',
|
||||
function (string $amount, string $symbol, int $decimalPlaces = 2, bool $coloured = true): string {
|
||||
$currency = new TransactionCurrency;
|
||||
$currency->symbol = $symbol;
|
||||
$currency->decimal_places = $decimalPlaces;
|
||||
|
||||
$currency = new TransactionCurrency;
|
||||
$currency->symbol = $symbol;
|
||||
$currency->decimal_places = $decimalPlaces;
|
||||
|
||||
return app('amount')->formatAnything($currency, $amount, $coloured);
|
||||
|
||||
|
||||
}, ['is_safe' => ['html']]
|
||||
return app('amount')->formatAnything($currency, $amount, $coloured);
|
||||
},
|
||||
['is_safe' => ['html']]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -161,12 +157,13 @@ class AmountFormat extends Twig_Extension
|
||||
protected function formatAmountPlain(): Twig_SimpleFilter
|
||||
{
|
||||
return new Twig_SimpleFilter(
|
||||
'formatAmountPlain', function (string $string): string {
|
||||
'formatAmountPlain',
|
||||
function (string $string): string {
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
|
||||
return app('amount')->formatAnything($currency, $string, false);
|
||||
}, ['is_safe' => ['html']]
|
||||
return app('amount')->formatAnything($currency, $string, false);
|
||||
},
|
||||
['is_safe' => ['html']]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -176,27 +173,28 @@ class AmountFormat extends Twig_Extension
|
||||
protected function formatDestinationAfter(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'formatDestinationAfter', function (array $transaction): string {
|
||||
'formatDestinationAfter',
|
||||
function (array $transaction): string {
|
||||
|
||||
// build fake currency for main amount.
|
||||
$format = new TransactionCurrency;
|
||||
$format->decimal_places = $transaction['transaction_currency_dp'];
|
||||
$format->symbol = $transaction['transaction_currency_symbol'];
|
||||
$string = app('amount')->formatAnything($format, $transaction['destination_account_after'], true);
|
||||
|
||||
// also append foreign amount for clarity:
|
||||
if (!is_null($transaction['foreign_destination_amount'])) {
|
||||
// build fake currency for foreign amount
|
||||
$format = new TransactionCurrency;
|
||||
$format->decimal_places = $transaction['foreign_currency_dp'];
|
||||
$format->symbol = $transaction['foreign_currency_symbol'];
|
||||
$string .= ' (' . app('amount')->formatAnything($format, $transaction['foreign_destination_amount'], true) . ')';
|
||||
}
|
||||
$format->decimal_places = $transaction['transaction_currency_dp'];
|
||||
$format->symbol = $transaction['transaction_currency_symbol'];
|
||||
$string = app('amount')->formatAnything($format, $transaction['destination_account_after'], true);
|
||||
|
||||
// also append foreign amount for clarity:
|
||||
if (!is_null($transaction['foreign_destination_amount'])) {
|
||||
// build fake currency for foreign amount
|
||||
$format = new TransactionCurrency;
|
||||
$format->decimal_places = $transaction['foreign_currency_dp'];
|
||||
$format->symbol = $transaction['foreign_currency_symbol'];
|
||||
$string .= ' (' . app('amount')->formatAnything($format, $transaction['foreign_destination_amount'], true) . ')';
|
||||
}
|
||||
|
||||
|
||||
return $string;
|
||||
|
||||
}, ['is_safe' => ['html']]
|
||||
return $string;
|
||||
},
|
||||
['is_safe' => ['html']]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -206,16 +204,17 @@ class AmountFormat extends Twig_Extension
|
||||
protected function formatDestinationBefore(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'formatDestinationBefore', function (array $transaction): string {
|
||||
'formatDestinationBefore',
|
||||
function (array $transaction): string {
|
||||
|
||||
// build fake currency for main amount.
|
||||
$format = new TransactionCurrency;
|
||||
$format->decimal_places = $transaction['transaction_currency_dp'];
|
||||
$format->symbol = $transaction['transaction_currency_symbol'];
|
||||
$format = new TransactionCurrency;
|
||||
$format->decimal_places = $transaction['transaction_currency_dp'];
|
||||
$format->symbol = $transaction['transaction_currency_symbol'];
|
||||
|
||||
return app('amount')->formatAnything($format, $transaction['destination_account_before'], true);
|
||||
|
||||
}, ['is_safe' => ['html']]
|
||||
return app('amount')->formatAnything($format, $transaction['destination_account_before'], true);
|
||||
},
|
||||
['is_safe' => ['html']]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -225,28 +224,28 @@ class AmountFormat extends Twig_Extension
|
||||
protected function formatSourceAfter(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'formatSourceAfter', function (array $transaction): string {
|
||||
'formatSourceAfter',
|
||||
function (array $transaction): string {
|
||||
|
||||
// build fake currency for main amount.
|
||||
$format = new TransactionCurrency;
|
||||
$format->decimal_places = $transaction['transaction_currency_dp'];
|
||||
$format->symbol = $transaction['transaction_currency_symbol'];
|
||||
$string = app('amount')->formatAnything($format, $transaction['source_account_after'], true);
|
||||
|
||||
// also append foreign amount for clarity:
|
||||
if (!is_null($transaction['foreign_source_amount'])) {
|
||||
// build fake currency for foreign amount
|
||||
$format = new TransactionCurrency;
|
||||
$format->decimal_places = $transaction['foreign_currency_dp'];
|
||||
$format->symbol = $transaction['foreign_currency_symbol'];
|
||||
$string .= ' (' . app('amount')->formatAnything($format, $transaction['foreign_source_amount'], true) . ')';
|
||||
}
|
||||
$format->decimal_places = $transaction['transaction_currency_dp'];
|
||||
$format->symbol = $transaction['transaction_currency_symbol'];
|
||||
$string = app('amount')->formatAnything($format, $transaction['source_account_after'], true);
|
||||
|
||||
// also append foreign amount for clarity:
|
||||
if (!is_null($transaction['foreign_source_amount'])) {
|
||||
// build fake currency for foreign amount
|
||||
$format = new TransactionCurrency;
|
||||
$format->decimal_places = $transaction['foreign_currency_dp'];
|
||||
$format->symbol = $transaction['foreign_currency_symbol'];
|
||||
$string .= ' (' . app('amount')->formatAnything($format, $transaction['foreign_source_amount'], true) . ')';
|
||||
}
|
||||
|
||||
|
||||
return $string;
|
||||
|
||||
|
||||
}, ['is_safe' => ['html']]
|
||||
return $string;
|
||||
},
|
||||
['is_safe' => ['html']]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -256,17 +255,17 @@ class AmountFormat extends Twig_Extension
|
||||
protected function formatSourceBefore(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'formatSourceBefore', function (array $transaction): string {
|
||||
'formatSourceBefore',
|
||||
function (array $transaction): string {
|
||||
|
||||
// build fake currency for main amount.
|
||||
$format = new TransactionCurrency;
|
||||
$format->decimal_places = $transaction['transaction_currency_dp'];
|
||||
$format->symbol = $transaction['transaction_currency_symbol'];
|
||||
$format = new TransactionCurrency;
|
||||
$format->decimal_places = $transaction['transaction_currency_dp'];
|
||||
$format->symbol = $transaction['transaction_currency_symbol'];
|
||||
|
||||
return app('amount')->formatAnything($format, $transaction['source_account_before'], true);
|
||||
|
||||
}, ['is_safe' => ['html']]
|
||||
return app('amount')->formatAnything($format, $transaction['source_account_before'], true);
|
||||
},
|
||||
['is_safe' => ['html']]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -194,7 +194,6 @@ class Transaction extends Twig_Extension
|
||||
$cache->store($txt);
|
||||
|
||||
return $txt;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -310,7 +309,8 @@ class Transaction extends Twig_Extension
|
||||
/** @var TransactionModel $other */
|
||||
$other = TransactionModel::where('transaction_journal_id', $journalId)->where('transactions.id', '!=', $transaction->id)
|
||||
->where('amount', '=', bcmul($transaction->transaction_amount, '-1'))->where(
|
||||
'identifier', $transaction->identifier
|
||||
'identifier',
|
||||
$transaction->identifier
|
||||
)
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
|
||||
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||
@@ -488,7 +488,8 @@ class Transaction extends Twig_Extension
|
||||
/** @var TransactionModel $other */
|
||||
$other = TransactionModel::where('transaction_journal_id', $journalId)->where('transactions.id', '!=', $transaction->id)
|
||||
->where('amount', '=', bcmul($transaction->transaction_amount, '-1'))->where(
|
||||
'identifier', $transaction->identifier
|
||||
'identifier',
|
||||
$transaction->identifier
|
||||
)
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
|
||||
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||
|
||||
@@ -37,7 +37,7 @@ class TransactionJournal extends Twig_Extension
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function totalAmount(JournalModel $journal): string
|
||||
public function totalAmount(JournalModel $journal): string
|
||||
{
|
||||
$cache = new SingleCacheProperties;
|
||||
$cache->addProperty('total-amount');
|
||||
@@ -86,7 +86,5 @@ class TransactionJournal extends Twig_Extension
|
||||
$cache->store($txt);
|
||||
|
||||
return $txt;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ class General extends Twig_Extension
|
||||
$this->mimeIcon(),
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +72,6 @@ class General extends Twig_Extension
|
||||
$this->activeRoutePartialWhat(),
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,16 +91,17 @@ class General extends Twig_Extension
|
||||
protected function activeRoutePartial(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'activeRoutePartial', function (): string {
|
||||
$args = func_get_args();
|
||||
$route = $args[0]; // name of the route.
|
||||
$name = Route::getCurrentRoute()->getName() ?? '';
|
||||
if (!(strpos($name, $route) === false)) {
|
||||
return 'active';
|
||||
}
|
||||
'activeRoutePartial',
|
||||
function (): string {
|
||||
$args = func_get_args();
|
||||
$route = $args[0]; // name of the route.
|
||||
$name = Route::getCurrentRoute()->getName() ?? '';
|
||||
if (!(strpos($name, $route) === false)) {
|
||||
return 'active';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -115,18 +114,20 @@ class General extends Twig_Extension
|
||||
protected function activeRoutePartialWhat(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'activeRoutePartialWhat', function ($context): string {
|
||||
$args = func_get_args();
|
||||
$route = $args[1]; // name of the route.
|
||||
'activeRoutePartialWhat',
|
||||
function ($context): string {
|
||||
$args = func_get_args();
|
||||
$route = $args[1]; // name of the route.
|
||||
$what = $args[2]; // name of the route.
|
||||
$activeWhat = $context['what'] ?? false;
|
||||
|
||||
if ($what === $activeWhat && !(strpos(Route::getCurrentRoute()->getName(), $route) === false)) {
|
||||
return 'active';
|
||||
}
|
||||
if ($what === $activeWhat && !(strpos(Route::getCurrentRoute()->getName(), $route) === false)) {
|
||||
return 'active';
|
||||
}
|
||||
|
||||
return '';
|
||||
}, ['needs_context' => true]
|
||||
return '';
|
||||
},
|
||||
['needs_context' => true]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -139,16 +140,17 @@ class General extends Twig_Extension
|
||||
protected function activeRouteStrict(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'activeRouteStrict', function (): string {
|
||||
$args = func_get_args();
|
||||
$route = $args[0]; // name of the route.
|
||||
'activeRouteStrict',
|
||||
function (): string {
|
||||
$args = func_get_args();
|
||||
$route = $args[0]; // name of the route.
|
||||
|
||||
if (Route::getCurrentRoute()->getName() === $route) {
|
||||
return 'active';
|
||||
if (Route::getCurrentRoute()->getName() === $route) {
|
||||
return 'active';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -158,14 +160,15 @@ class General extends Twig_Extension
|
||||
protected function balance(): Twig_SimpleFilter
|
||||
{
|
||||
return new Twig_SimpleFilter(
|
||||
'balance', function (?Account $account): string {
|
||||
if (is_null($account)) {
|
||||
return 'NULL';
|
||||
}
|
||||
$date = session('end', Carbon::now()->endOfMonth());
|
||||
'balance',
|
||||
function (?Account $account): string {
|
||||
if (is_null($account)) {
|
||||
return 'NULL';
|
||||
}
|
||||
$date = session('end', Carbon::now()->endOfMonth());
|
||||
|
||||
return app('steam')->balance($account, $date);
|
||||
}
|
||||
return app('steam')->balance($account, $date);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -175,9 +178,10 @@ class General extends Twig_Extension
|
||||
protected function env(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'env', function (string $name, string $default): string {
|
||||
return env($name, $default);
|
||||
}
|
||||
'env',
|
||||
function (string $name, string $default): string {
|
||||
return env($name, $default);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -187,20 +191,21 @@ class General extends Twig_Extension
|
||||
protected function formatFilesize(): Twig_SimpleFilter
|
||||
{
|
||||
return new Twig_SimpleFilter(
|
||||
'filesize', function (int $size): string {
|
||||
'filesize',
|
||||
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';
|
||||
}
|
||||
if ($size < (1024 * 1024 * 2014) && $size >= (1024 * 1024)) {
|
||||
return round($size / (1024 * 1024), 2) . ' MB';
|
||||
}
|
||||
|
||||
// less than one MB
|
||||
if ($size < (1024 * 1024)) {
|
||||
return round($size / 1024, 2) . ' KB';
|
||||
}
|
||||
// less than one MB
|
||||
if ($size < (1024 * 1024)) {
|
||||
return round($size / 1024, 2) . ' KB';
|
||||
}
|
||||
|
||||
return $size . ' bytes';
|
||||
}
|
||||
return $size . ' bytes';
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -211,9 +216,10 @@ class General extends Twig_Extension
|
||||
protected function getCurrencyCode(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'getCurrencyCode', function (): string {
|
||||
return app('amount')->getCurrencyCode();
|
||||
}
|
||||
'getCurrencyCode',
|
||||
function (): string {
|
||||
return app('amount')->getCurrencyCode();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -223,9 +229,10 @@ class General extends Twig_Extension
|
||||
protected function getCurrencySymbol(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'getCurrencySymbol', function (): string {
|
||||
return app('amount')->getCurrencySymbol();
|
||||
}
|
||||
'getCurrencySymbol',
|
||||
function (): string {
|
||||
return app('amount')->getCurrencySymbol();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -235,8 +242,9 @@ class General extends Twig_Extension
|
||||
protected function mimeIcon(): Twig_SimpleFilter
|
||||
{
|
||||
return new Twig_SimpleFilter(
|
||||
'mimeIcon', function (string $string): string {
|
||||
switch ($string) {
|
||||
'mimeIcon',
|
||||
function (string $string): string {
|
||||
switch ($string) {
|
||||
default:
|
||||
return 'fa-file-o';
|
||||
case 'application/pdf':
|
||||
@@ -245,7 +253,8 @@ class General extends Twig_Extension
|
||||
case 'image/jpeg':
|
||||
return 'fa-file-image-o';
|
||||
}
|
||||
}, ['is_safe' => ['html']]
|
||||
},
|
||||
['is_safe' => ['html']]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -255,9 +264,10 @@ class General extends Twig_Extension
|
||||
protected function phpdate()
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'phpdate', function (string $str): string {
|
||||
return date($str);
|
||||
}
|
||||
'phpdate',
|
||||
function (string $str): string {
|
||||
return date($str);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -267,9 +277,10 @@ class General extends Twig_Extension
|
||||
protected function steamPositive()
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'steam_positive', function (string $str): string {
|
||||
return Steam::positive($str);
|
||||
}
|
||||
'steam_positive',
|
||||
function (string $str): string {
|
||||
return Steam::positive($str);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -279,10 +290,10 @@ class General extends Twig_Extension
|
||||
private function getAmountFromJournal()
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'getAmount', function (TransactionJournal $journal): string {
|
||||
return $journal->amount();
|
||||
}
|
||||
'getAmount',
|
||||
function (TransactionJournal $journal): string {
|
||||
return $journal->amount();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Twig;
|
||||
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Category;
|
||||
@@ -49,31 +48,32 @@ class Journal extends Twig_Extension
|
||||
public function getDestinationAccount(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'destinationAccount', function (TransactionJournal $journal) {
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($journal->id);
|
||||
$cache->addProperty('transaction-journal');
|
||||
$cache->addProperty('destination-account-string');
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$list = $journal->destinationAccountList();
|
||||
$array = [];
|
||||
/** @var Account $entry */
|
||||
foreach ($list as $entry) {
|
||||
if ($entry->accountType->type === AccountType::CASH) {
|
||||
$array[] = '<span class="text-success">(cash)</span>';
|
||||
continue;
|
||||
'destinationAccount',
|
||||
function (TransactionJournal $journal) {
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($journal->id);
|
||||
$cache->addProperty('transaction-journal');
|
||||
$cache->addProperty('destination-account-string');
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
$array[] = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($entry->name), route('accounts.show', $entry->id));
|
||||
}
|
||||
$array = array_unique($array);
|
||||
$result = join(', ', $array);
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
$list = $journal->destinationAccountList();
|
||||
$array = [];
|
||||
/** @var Account $entry */
|
||||
foreach ($list as $entry) {
|
||||
if ($entry->accountType->type === AccountType::CASH) {
|
||||
$array[] = '<span class="text-success">(cash)</span>';
|
||||
continue;
|
||||
}
|
||||
$array[] = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($entry->name), route('accounts.show', $entry->id));
|
||||
}
|
||||
$array = array_unique($array);
|
||||
$result = join(', ', $array);
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -120,34 +120,32 @@ class Journal extends Twig_Extension
|
||||
public function getSourceAccount(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'sourceAccount', function (TransactionJournal $journal): string {
|
||||
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($journal->id);
|
||||
$cache->addProperty('transaction-journal');
|
||||
$cache->addProperty('source-account-string');
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$list = $journal->sourceAccountList();
|
||||
$array = [];
|
||||
/** @var Account $entry */
|
||||
foreach ($list as $entry) {
|
||||
if ($entry->accountType->type === AccountType::CASH) {
|
||||
$array[] = '<span class="text-success">(cash)</span>';
|
||||
continue;
|
||||
'sourceAccount',
|
||||
function (TransactionJournal $journal): string {
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($journal->id);
|
||||
$cache->addProperty('transaction-journal');
|
||||
$cache->addProperty('source-account-string');
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
$array[] = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($entry->name), route('accounts.show', $entry->id));
|
||||
|
||||
$list = $journal->sourceAccountList();
|
||||
$array = [];
|
||||
/** @var Account $entry */
|
||||
foreach ($list as $entry) {
|
||||
if ($entry->accountType->type === AccountType::CASH) {
|
||||
$array[] = '<span class="text-success">(cash)</span>';
|
||||
continue;
|
||||
}
|
||||
$array[] = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($entry->name), route('accounts.show', $entry->id));
|
||||
}
|
||||
$array = array_unique($array);
|
||||
$result = join(', ', $array);
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
$array = array_unique($array);
|
||||
$result = join(', ', $array);
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -157,34 +155,33 @@ class Journal extends Twig_Extension
|
||||
public function journalBudgets(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'journalBudgets', function (TransactionJournal $journal): string {
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($journal->id);
|
||||
$cache->addProperty('transaction-journal');
|
||||
$cache->addProperty('budget-string');
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
'journalBudgets',
|
||||
function (TransactionJournal $journal): string {
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($journal->id);
|
||||
$cache->addProperty('transaction-journal');
|
||||
$cache->addProperty('budget-string');
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
|
||||
$budgets = [];
|
||||
// get all budgets:
|
||||
foreach ($journal->budgets as $budget) {
|
||||
$budgets[] = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($budget->name), route('budgets.show', $budget->id));
|
||||
}
|
||||
// and more!
|
||||
foreach ($journal->transactions as $transaction) {
|
||||
foreach ($transaction->budgets as $budget) {
|
||||
$budgets = [];
|
||||
// get all budgets:
|
||||
foreach ($journal->budgets as $budget) {
|
||||
$budgets[] = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($budget->name), route('budgets.show', $budget->id));
|
||||
}
|
||||
// and more!
|
||||
foreach ($journal->transactions as $transaction) {
|
||||
foreach ($transaction->budgets as $budget) {
|
||||
$budgets[] = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($budget->name), route('budgets.show', $budget->id));
|
||||
}
|
||||
}
|
||||
$string = join(', ', array_unique($budgets));
|
||||
$cache->store($string);
|
||||
|
||||
return $string;
|
||||
}
|
||||
$string = join(', ', array_unique($budgets));
|
||||
$cache->store($string);
|
||||
|
||||
return $string;
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -194,37 +191,38 @@ class Journal extends Twig_Extension
|
||||
public function journalCategories(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'journalCategories', function (TransactionJournal $journal): string {
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($journal->id);
|
||||
$cache->addProperty('transaction-journal');
|
||||
$cache->addProperty('category-string');
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
$categories = [];
|
||||
// get all categories for the journal itself (easy):
|
||||
foreach ($journal->categories as $category) {
|
||||
$categories[] = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($category->name), route('categories.show', $category->id));
|
||||
}
|
||||
if (count($categories) === 0) {
|
||||
$set = Category::distinct()->leftJoin('category_transaction', 'categories.id', '=', 'category_transaction.category_id')
|
||||
'journalCategories',
|
||||
function (TransactionJournal $journal): string {
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($journal->id);
|
||||
$cache->addProperty('transaction-journal');
|
||||
$cache->addProperty('category-string');
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
$categories = [];
|
||||
// get all categories for the journal itself (easy):
|
||||
foreach ($journal->categories as $category) {
|
||||
$categories[] = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($category->name), route('categories.show', $category->id));
|
||||
}
|
||||
if (count($categories) === 0) {
|
||||
$set = Category::distinct()->leftJoin('category_transaction', 'categories.id', '=', 'category_transaction.category_id')
|
||||
->leftJoin('transactions', 'category_transaction.transaction_id', '=', 'transactions.id')
|
||||
->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->where('categories.user_id', $journal->user_id)
|
||||
->where('transaction_journals.id', $journal->id)
|
||||
->get(['categories.*']);
|
||||
/** @var Category $category */
|
||||
foreach ($set as $category) {
|
||||
$categories[] = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($category->name), route('categories.show', $category->id));
|
||||
/** @var Category $category */
|
||||
foreach ($set as $category) {
|
||||
$categories[] = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($category->name), route('categories.show', $category->id));
|
||||
}
|
||||
}
|
||||
|
||||
$string = join(', ', array_unique($categories));
|
||||
$cache->store($string);
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
$string = join(', ', array_unique($categories));
|
||||
$cache->store($string);
|
||||
|
||||
return $string;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Twig\Loader;
|
||||
|
||||
|
||||
use FireflyIII\Support\Twig\Extension\TransactionJournal;
|
||||
use Twig_RuntimeLoaderInterface;
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Twig\Loader;
|
||||
|
||||
|
||||
use FireflyIII\Support\Twig\Extension\Transaction;
|
||||
use Twig_RuntimeLoaderInterface;
|
||||
|
||||
|
||||
@@ -44,15 +44,17 @@ class PiggyBank extends Twig_Extension
|
||||
$functions = [];
|
||||
|
||||
$functions[] = new Twig_SimpleFunction(
|
||||
'currentRelevantRepAmount', function (PB $piggyBank) {
|
||||
return $piggyBank->currentRelevantRep()->currentamount;
|
||||
}
|
||||
'currentRelevantRepAmount',
|
||||
function (PB $piggyBank) {
|
||||
return $piggyBank->currentRelevantRep()->currentamount;
|
||||
}
|
||||
);
|
||||
|
||||
$functions[] = new Twig_SimpleFunction(
|
||||
'suggestedMonthlyAmount', function (PB $piggyBank) {
|
||||
return $piggyBank->getSuggestedMonthlyAmount();
|
||||
}
|
||||
'suggestedMonthlyAmount',
|
||||
function (PB $piggyBank) {
|
||||
return $piggyBank->getSuggestedMonthlyAmount();
|
||||
}
|
||||
);
|
||||
|
||||
return $functions;
|
||||
|
||||
@@ -41,18 +41,19 @@ class Rule extends Twig_Extension
|
||||
public function allActionTriggers(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'allRuleActions', function () {
|
||||
// array of valid values for actions
|
||||
$ruleActions = array_keys(Config::get('firefly.rule-actions'));
|
||||
$possibleActions = [];
|
||||
foreach ($ruleActions as $key) {
|
||||
$possibleActions[$key] = trans('firefly.rule_action_' . $key . '_choice');
|
||||
}
|
||||
unset($key, $ruleActions);
|
||||
asort($possibleActions);
|
||||
'allRuleActions',
|
||||
function () {
|
||||
// array of valid values for actions
|
||||
$ruleActions = array_keys(Config::get('firefly.rule-actions'));
|
||||
$possibleActions = [];
|
||||
foreach ($ruleActions as $key) {
|
||||
$possibleActions[$key] = trans('firefly.rule_action_' . $key . '_choice');
|
||||
}
|
||||
unset($key, $ruleActions);
|
||||
asort($possibleActions);
|
||||
|
||||
return $possibleActions;
|
||||
}
|
||||
return $possibleActions;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -62,12 +63,13 @@ class Rule extends Twig_Extension
|
||||
public function allJournalTriggers(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'allJournalTriggers', function () {
|
||||
return [
|
||||
'allJournalTriggers',
|
||||
function () {
|
||||
return [
|
||||
'store-journal' => trans('firefly.rule_trigger_store_journal'),
|
||||
'update-journal' => trans('firefly.rule_trigger_update_journal'),
|
||||
];
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -77,22 +79,22 @@ class Rule extends Twig_Extension
|
||||
public function allRuleTriggers(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'allRuleTriggers', function () {
|
||||
$ruleTriggers = array_keys(Config::get('firefly.rule-triggers'));
|
||||
$possibleTriggers = [];
|
||||
foreach ($ruleTriggers as $key) {
|
||||
if ($key !== 'user_action') {
|
||||
$possibleTriggers[$key] = trans('firefly.rule_trigger_' . $key . '_choice');
|
||||
'allRuleTriggers',
|
||||
function () {
|
||||
$ruleTriggers = array_keys(Config::get('firefly.rule-triggers'));
|
||||
$possibleTriggers = [];
|
||||
foreach ($ruleTriggers as $key) {
|
||||
if ($key !== 'user_action') {
|
||||
$possibleTriggers[$key] = trans('firefly.rule_trigger_' . $key . '_choice');
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($key, $ruleTriggers);
|
||||
asort($possibleTriggers);
|
||||
unset($key, $ruleTriggers);
|
||||
asort($possibleTriggers);
|
||||
|
||||
return $possibleTriggers;
|
||||
}
|
||||
return $possibleTriggers;
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,7 +107,6 @@ class Rule extends Twig_Extension
|
||||
$this->allRuleTriggers(),
|
||||
$this->allActionTriggers(),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,11 +44,11 @@ class Translation extends Twig_Extension
|
||||
$filters = [];
|
||||
|
||||
$filters[] = new Twig_SimpleFilter(
|
||||
'_', function ($name) {
|
||||
|
||||
return strval(trans(sprintf('firefly.%s', $name)));
|
||||
|
||||
}, ['is_safe' => ['html']]
|
||||
'_',
|
||||
function ($name) {
|
||||
return strval(trans(sprintf('firefly.%s', $name)));
|
||||
},
|
||||
['is_safe' => ['html']]
|
||||
);
|
||||
|
||||
return $filters;
|
||||
@@ -64,7 +64,6 @@ class Translation extends Twig_Extension
|
||||
$this->journalLinkTranslation(),
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,17 +80,17 @@ class Translation extends Twig_Extension
|
||||
public function journalLinkTranslation(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'journalLinkTranslation', function (string $direction, string $original) {
|
||||
$key = sprintf('firefly.%s_%s', $original, $direction);
|
||||
$translation = trans($key);
|
||||
if ($key === $translation) {
|
||||
return $original;
|
||||
}
|
||||
'journalLinkTranslation',
|
||||
function (string $direction, string $original) {
|
||||
$key = sprintf('firefly.%s_%s', $original, $direction);
|
||||
$translation = trans($key);
|
||||
if ($key === $translation) {
|
||||
return $original;
|
||||
}
|
||||
|
||||
return $translation;
|
||||
|
||||
|
||||
}, ['is_safe' => ['html']]
|
||||
return $translation;
|
||||
},
|
||||
['is_safe' => ['html']]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user