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,63 +29,63 @@ use Symfony\Component\ExpressionLanguage\SyntaxError;
|
||||
|
||||
class ActionExpression
|
||||
{
|
||||
private static array $NAMES = [
|
||||
// 'transaction_group_id',
|
||||
// 'user_id',
|
||||
// 'user_group_id',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'transaction_group_title',
|
||||
'group_created_at',
|
||||
'group_updated_at',
|
||||
// 'transaction_journal_id',
|
||||
// 'transaction_type_id',
|
||||
'description',
|
||||
'date',
|
||||
// 'order',
|
||||
'transaction_type_type',
|
||||
// 'source_transaction_id',
|
||||
'source_account_id',
|
||||
// 'reconciled',
|
||||
'amount',
|
||||
// 'currency_id',
|
||||
'currency_code',
|
||||
'currency_name',
|
||||
'currency_symbol',
|
||||
'currency_decimal_places',
|
||||
'foreign_amount',
|
||||
// 'foreign_currency_id',
|
||||
'foreign_currency_code',
|
||||
'foreign_currency_name',
|
||||
'foreign_currency_symbol',
|
||||
'foreign_currency_decimal_places',
|
||||
'destination_account_id',
|
||||
'source_account_name',
|
||||
'source_account_iban',
|
||||
'source_account_type',
|
||||
'destination_account_name',
|
||||
'destination_account_iban',
|
||||
'destination_account_type',
|
||||
'category_id',
|
||||
'category_name',
|
||||
'budget_id',
|
||||
'budget_name',
|
||||
'tags',
|
||||
// 'attachments',
|
||||
'interest_date',
|
||||
'payment_date',
|
||||
'invoice_date',
|
||||
'book_date',
|
||||
'due_date',
|
||||
'process_date',
|
||||
// 'destination_transaction_id',
|
||||
'notes',
|
||||
];
|
||||
|
||||
private static array $NAMES
|
||||
= [
|
||||
// 'transaction_group_id',
|
||||
// 'user_id',
|
||||
// 'user_group_id',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'transaction_group_title',
|
||||
'group_created_at',
|
||||
'group_updated_at',
|
||||
// 'transaction_journal_id',
|
||||
// 'transaction_type_id',
|
||||
'description',
|
||||
'date',
|
||||
// 'order',
|
||||
'transaction_type_type',
|
||||
// 'source_transaction_id',
|
||||
'source_account_id',
|
||||
// 'reconciled',
|
||||
'amount',
|
||||
// 'currency_id',
|
||||
'currency_code',
|
||||
'currency_name',
|
||||
'currency_symbol',
|
||||
'currency_decimal_places',
|
||||
'foreign_amount',
|
||||
// 'foreign_currency_id',
|
||||
'foreign_currency_code',
|
||||
'foreign_currency_name',
|
||||
'foreign_currency_symbol',
|
||||
'foreign_currency_decimal_places',
|
||||
'destination_account_id',
|
||||
'source_account_name',
|
||||
'source_account_iban',
|
||||
'source_account_type',
|
||||
'destination_account_name',
|
||||
'destination_account_iban',
|
||||
'destination_account_type',
|
||||
'category_id',
|
||||
'category_name',
|
||||
'budget_id',
|
||||
'budget_name',
|
||||
'tags',
|
||||
// 'attachments',
|
||||
'interest_date',
|
||||
'payment_date',
|
||||
'invoice_date',
|
||||
'book_date',
|
||||
'due_date',
|
||||
'process_date',
|
||||
// 'destination_transaction_id',
|
||||
'notes',
|
||||
];
|
||||
private string $expr;
|
||||
private ExpressionLanguage $expressionLanguage;
|
||||
private string $expr;
|
||||
private bool $isExpression;
|
||||
private ?SyntaxError $validationError;
|
||||
private bool $isExpression;
|
||||
private ?SyntaxError $validationError;
|
||||
|
||||
public function __construct(string $expr)
|
||||
{
|
||||
@ -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,11 +135,16 @@ 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);
|
||||
|
||||
return (string) $result;
|
||||
return (string)$result;
|
||||
}
|
||||
|
||||
public function evaluate(array $journal): string
|
||||
|
@ -36,7 +36,7 @@ class ActionExpressionLanguageProvider implements ExpressionFunctionProviderInte
|
||||
{
|
||||
$function = function ($arguments, $str): string {
|
||||
if (!is_string($str)) {
|
||||
return (string) $str;
|
||||
return (string)$str;
|
||||
}
|
||||
|
||||
return strtolower($str.'!');
|
||||
|
@ -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