mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-19 16:10:00 +00:00
Various code cleanup and fixed alignments.
This commit is contained in:
@@ -72,14 +72,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);
|
||||
@@ -111,8 +111,8 @@ trait ModelInformation
|
||||
protected function getTriggersForBill(Bill $bill): array // get info and augument
|
||||
{
|
||||
// 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));
|
||||
@@ -162,8 +162,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));
|
||||
@@ -171,18 +171,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;
|
||||
}
|
||||
@@ -217,21 +217,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) {
|
||||
@@ -240,7 +240,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;
|
||||
|
||||
Reference in New Issue
Block a user