mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Auto commit for release 'branch-v6.2' on 2024-12-22
This commit is contained in:
@@ -32,7 +32,6 @@ use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Trait ModelInformation
|
||||
@@ -56,7 +55,7 @@ trait ModelInformation
|
||||
'count' => 1,
|
||||
]
|
||||
)->render();
|
||||
} catch (Throwable $e) {
|
||||
} catch (\Throwable $e) {
|
||||
app('log')->error(sprintf('Throwable was thrown in getActionsForBill(): %s', $e->getMessage()));
|
||||
app('log')->error($e->getTraceAsString());
|
||||
$result = 'Could not render view. See log files.';
|
||||
@@ -75,14 +74,14 @@ trait ModelInformation
|
||||
protected function getLiabilityTypes(): array
|
||||
{
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
|
||||
// types of liability:
|
||||
/** @var AccountType $debt */
|
||||
$debt = $repository->getAccountTypeByType(AccountType::DEBT);
|
||||
$debt = $repository->getAccountTypeByType(AccountType::DEBT);
|
||||
|
||||
/** @var AccountType $loan */
|
||||
$loan = $repository->getAccountTypeByType(AccountType::LOAN);
|
||||
$loan = $repository->getAccountTypeByType(AccountType::LOAN);
|
||||
|
||||
/** @var AccountType $mortgage */
|
||||
$mortgage = $repository->getAccountTypeByType(AccountType::MORTGAGE);
|
||||
@@ -114,8 +113,8 @@ trait ModelInformation
|
||||
protected function getTriggersForBill(Bill $bill): array // get info and argument
|
||||
{
|
||||
// TODO duplicate code
|
||||
$operators = config('search.operators');
|
||||
$triggers = [];
|
||||
$operators = config('search.operators');
|
||||
$triggers = [];
|
||||
foreach ($operators as $key => $operator) {
|
||||
if ('user_action' !== $key && false === $operator['alias']) {
|
||||
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
|
||||
@@ -143,7 +142,7 @@ trait ModelInformation
|
||||
'triggers' => $triggers,
|
||||
]
|
||||
)->render();
|
||||
} catch (Throwable $e) {
|
||||
} catch (\Throwable $e) {
|
||||
app('log')->debug(sprintf('Throwable was thrown in getTriggersForBill(): %s', $e->getMessage()));
|
||||
app('log')->debug($e->getTraceAsString());
|
||||
|
||||
@@ -165,8 +164,8 @@ trait ModelInformation
|
||||
private function getTriggersForJournal(TransactionJournal $journal): array
|
||||
{
|
||||
// TODO duplicated code.
|
||||
$operators = config('search.operators');
|
||||
$triggers = [];
|
||||
$operators = config('search.operators');
|
||||
$triggers = [];
|
||||
foreach ($operators as $key => $operator) {
|
||||
if ('user_action' !== $key && false === $operator['alias']) {
|
||||
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
|
||||
@@ -174,18 +173,18 @@ trait ModelInformation
|
||||
}
|
||||
asort($triggers);
|
||||
|
||||
$result = [];
|
||||
$journalTriggers = [];
|
||||
$values = [];
|
||||
$index = 0;
|
||||
$result = [];
|
||||
$journalTriggers = [];
|
||||
$values = [];
|
||||
$index = 0;
|
||||
|
||||
// amount, description, category, budget, tags, source, destination, notes, currency type
|
||||
// ,type
|
||||
/** @var null|Transaction $source */
|
||||
$source = $journal->transactions()->where('amount', '<', 0)->first();
|
||||
$source = $journal->transactions()->where('amount', '<', 0)->first();
|
||||
|
||||
/** @var null|Transaction $destination */
|
||||
$destination = $journal->transactions()->where('amount', '>', 0)->first();
|
||||
$destination = $journal->transactions()->where('amount', '>', 0)->first();
|
||||
if (null === $destination || null === $source) {
|
||||
return $result;
|
||||
}
|
||||
@@ -220,21 +219,21 @@ trait ModelInformation
|
||||
++$index;
|
||||
|
||||
// category (if)
|
||||
$category = $journal->categories()->first();
|
||||
$category = $journal->categories()->first();
|
||||
if (null !== $category) {
|
||||
$journalTriggers[$index] = 'category_is';
|
||||
$values[$index] = $category->name;
|
||||
++$index;
|
||||
}
|
||||
// budget (if)
|
||||
$budget = $journal->budgets()->first();
|
||||
$budget = $journal->budgets()->first();
|
||||
if (null !== $budget) {
|
||||
$journalTriggers[$index] = 'budget_is';
|
||||
$values[$index] = $budget->name;
|
||||
++$index;
|
||||
}
|
||||
// tags (if)
|
||||
$tags = $journal->tags()->get();
|
||||
$tags = $journal->tags()->get();
|
||||
|
||||
/** @var Tag $tag */
|
||||
foreach ($tags as $tag) {
|
||||
@@ -243,7 +242,7 @@ trait ModelInformation
|
||||
++$index;
|
||||
}
|
||||
// notes (if)
|
||||
$notes = $journal->notes()->first();
|
||||
$notes = $journal->notes()->first();
|
||||
if (null !== $notes) {
|
||||
$journalTriggers[$index] = 'notes_are';
|
||||
$values[$index] = $notes->text;
|
||||
@@ -259,7 +258,7 @@ trait ModelInformation
|
||||
'triggers' => $triggers,
|
||||
];
|
||||
$string = view('rules.partials.trigger', $renderInfo)->render();
|
||||
} catch (Throwable $e) {
|
||||
} catch (\Throwable $e) {
|
||||
app('log')->debug(sprintf('Throwable was thrown in getTriggersForJournal(): %s', $e->getMessage()));
|
||||
app('log')->debug($e->getTraceAsString());
|
||||
|
||||
|
Reference in New Issue
Block a user