mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Small code cleanup.
This commit is contained in:
parent
1bd3019c16
commit
7224f1be6f
@ -72,7 +72,7 @@ interface AccountRepositoryInterface
|
||||
|
||||
public function setUser(User $user): void;
|
||||
|
||||
public function update(Account $account, array $data): Account;
|
||||
|
||||
public function setUserGroup(UserGroup $userGroup): void;
|
||||
|
||||
public function update(Account $account, array $data): Account;
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ use FireflyIII\TransactionRules\Traits\RefreshNotesTrait;
|
||||
class AppendDescription implements ActionInterface
|
||||
{
|
||||
use RefreshNotesTrait;
|
||||
|
||||
private RuleAction $action;
|
||||
|
||||
/**
|
||||
|
@ -38,6 +38,7 @@ use FireflyIII\TransactionRules\Traits\RefreshNotesTrait;
|
||||
class AppendDescriptionToNotes implements ActionInterface
|
||||
{
|
||||
use RefreshNotesTrait;
|
||||
|
||||
private RuleAction $action;
|
||||
|
||||
/**
|
||||
|
@ -36,6 +36,7 @@ use FireflyIII\TransactionRules\Traits\RefreshNotesTrait;
|
||||
class AppendNotes implements ActionInterface
|
||||
{
|
||||
use RefreshNotesTrait;
|
||||
|
||||
private RuleAction $action;
|
||||
|
||||
/**
|
||||
|
@ -40,6 +40,7 @@ class AppendNotesToDescription implements ActionInterface
|
||||
{
|
||||
use ConvertsDataTypes;
|
||||
use RefreshNotesTrait;
|
||||
|
||||
private RuleAction $action;
|
||||
|
||||
/**
|
||||
|
@ -33,6 +33,7 @@ use FireflyIII\TransactionRules\Traits\RefreshNotesTrait;
|
||||
class SetAmount implements ActionInterface
|
||||
{
|
||||
use RefreshNotesTrait;
|
||||
|
||||
private RuleAction $action;
|
||||
|
||||
/**
|
||||
@ -105,6 +106,13 @@ class SetAmount implements ActionInterface
|
||||
$this->updateAmount($transaction, $amount);
|
||||
}
|
||||
|
||||
private function updateAmount(Transaction $transaction, string $amount): void
|
||||
{
|
||||
$transaction->amount = $amount;
|
||||
$transaction->save();
|
||||
$transaction->transactionJournal->touch();
|
||||
}
|
||||
|
||||
private function updateNegative(TransactionJournal $object, string $amount): void
|
||||
{
|
||||
/** @var null|Transaction $transaction */
|
||||
@ -114,11 +122,4 @@ class SetAmount implements ActionInterface
|
||||
}
|
||||
$this->updateAmount($transaction, $amount);
|
||||
}
|
||||
|
||||
private function updateAmount(Transaction $transaction, string $amount): void
|
||||
{
|
||||
$transaction->amount = $amount;
|
||||
$transaction->save();
|
||||
$transaction->transactionJournal->touch();
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ use FireflyIII\TransactionRules\Traits\RefreshNotesTrait;
|
||||
class SetDescription implements ActionInterface
|
||||
{
|
||||
use RefreshNotesTrait;
|
||||
|
||||
private RuleAction $action;
|
||||
|
||||
/**
|
||||
|
@ -473,6 +473,18 @@ class SearchRuleEngine implements RuleEngineInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
private function addNotes(array $transaction): array
|
||||
{
|
||||
$transaction['notes'] = '';
|
||||
$dbNote = Note::where('noteable_id', (int)$transaction['transaction_journal_id'])->where('noteable_type', TransactionJournal::class)->first(['notes.*']);
|
||||
if (null !== $dbNote) {
|
||||
$transaction['notes'] = $dbNote->text;
|
||||
}
|
||||
Log::debug(sprintf('Notes of journal #%d filled in.', $transaction['transaction_journal_id']));
|
||||
|
||||
return $transaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the rule is fired (the collection is larger than zero).
|
||||
*
|
||||
@ -542,16 +554,4 @@ class SearchRuleEngine implements RuleEngineInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function addNotes(array $transaction): array
|
||||
{
|
||||
$transaction['notes'] = '';
|
||||
$dbNote = Note::where('noteable_id', (int)$transaction['transaction_journal_id'])->where('noteable_type', TransactionJournal::class)->first(['notes.*']);
|
||||
if (null !== $dbNote) {
|
||||
$transaction['notes'] = $dbNote->text;
|
||||
}
|
||||
Log::debug(sprintf('Notes of journal #%d filled in.', $transaction['transaction_journal_id']));
|
||||
|
||||
return $transaction;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,8 @@ use Symfony\Component\ExpressionLanguage\SyntaxError;
|
||||
|
||||
class ActionExpression
|
||||
{
|
||||
private static array $NAMES = [
|
||||
private static array $NAMES
|
||||
= [
|
||||
// 'transaction_group_id',
|
||||
// 'user_id',
|
||||
// 'user_group_id',
|
||||
@ -81,9 +82,8 @@ class ActionExpression
|
||||
// 'destination_transaction_id',
|
||||
'notes',
|
||||
];
|
||||
|
||||
private ExpressionLanguage $expressionLanguage;
|
||||
private string $expr;
|
||||
private ExpressionLanguage $expressionLanguage;
|
||||
private bool $isExpression;
|
||||
private ?SyntaxError $validationError;
|
||||
|
||||
@ -116,11 +116,6 @@ class ActionExpression
|
||||
}
|
||||
}
|
||||
|
||||
private function lintExpression(string $expr): void
|
||||
{
|
||||
$this->expressionLanguage->lint($expr, self::$NAMES);
|
||||
}
|
||||
|
||||
private function lint(): void
|
||||
{
|
||||
if (!$this->isExpression) {
|
||||
@ -130,9 +125,9 @@ class ActionExpression
|
||||
$this->lintExpression(substr($this->expr, 1));
|
||||
}
|
||||
|
||||
public function isValid(): bool
|
||||
private function lintExpression(string $expr): void
|
||||
{
|
||||
return null === $this->validationError;
|
||||
$this->expressionLanguage->lint($expr, self::$NAMES);
|
||||
}
|
||||
|
||||
public function getValidationError(): ?SyntaxError
|
||||
@ -140,6 +135,11 @@ class ActionExpression
|
||||
return $this->validationError;
|
||||
}
|
||||
|
||||
public function isValid(): bool
|
||||
{
|
||||
return null === $this->validationError;
|
||||
}
|
||||
|
||||
private function evaluateExpression(string $expr, array $journal): string
|
||||
{
|
||||
$result = $this->expressionLanguage->evaluate($expr, $journal);
|
||||
|
@ -41,12 +41,12 @@ use Illuminate\Support\Facades\DB;
|
||||
class AccountTransformer extends AbstractTransformer
|
||||
{
|
||||
private array $accountMeta;
|
||||
private array $lastActivity;
|
||||
private array $accountTypes;
|
||||
private array $balances;
|
||||
private array $convertedBalances;
|
||||
private array $currencies;
|
||||
private TransactionCurrency $default;
|
||||
private array $lastActivity;
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
|
Loading…
Reference in New Issue
Block a user