mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Various code cleanup and fixed alignments.
This commit is contained in:
@@ -54,7 +54,7 @@ class ConvertToWithdrawal implements ActionInterface
|
||||
{
|
||||
// make object from array (so the data is fresh).
|
||||
/** @var null|TransactionJournal $object */
|
||||
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
if (null === $object) {
|
||||
app('log')->error(sprintf('Cannot find journal #%d, cannot convert to withdrawal.', $journal['transaction_journal_id']));
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_not_found')));
|
||||
@@ -69,7 +69,7 @@ class ConvertToWithdrawal implements ActionInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
$type = $object->transactionType->type;
|
||||
$type = $object->transactionType->type;
|
||||
if (TransactionType::WITHDRAWAL === $type) {
|
||||
app('log')->error(sprintf('Journal #%d is already a withdrawal (rule #%d).', $journal['transaction_journal_id'], $this->action->rule_id));
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.is_already_withdrawal')));
|
||||
@@ -119,21 +119,21 @@ class ConvertToWithdrawal implements ActionInterface
|
||||
*/
|
||||
private function convertDepositArray(TransactionJournal $journal): bool
|
||||
{
|
||||
$user = $journal->user;
|
||||
$user = $journal->user;
|
||||
|
||||
/** @var AccountFactory $factory */
|
||||
$factory = app(AccountFactory::class);
|
||||
$factory = app(AccountFactory::class);
|
||||
$factory->setUser($user);
|
||||
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$repository->setUser($user);
|
||||
|
||||
$sourceAccount = $this->getSourceAccount($journal);
|
||||
$destAccount = $this->getDestinationAccount($journal);
|
||||
$sourceAccount = $this->getSourceAccount($journal);
|
||||
$destAccount = $this->getDestinationAccount($journal);
|
||||
|
||||
// get the action value, or use the original source name in case the action value is empty:
|
||||
// this becomes a new or existing (expense) account, which is the destination of the new withdrawal.
|
||||
$opposingName = '' === $this->action->action_value ? $sourceAccount->name : $this->action->action_value;
|
||||
$opposingName = '' === $this->action->action_value ? $sourceAccount->name : $this->action->action_value;
|
||||
// we check all possible source account types if one exists:
|
||||
$validTypes = config('firefly.expected_source_types.destination.Withdrawal');
|
||||
$opposingAccount = $repository->findByName($opposingName, $validTypes);
|
||||
@@ -158,7 +158,7 @@ class ConvertToWithdrawal implements ActionInterface
|
||||
;
|
||||
|
||||
// change transaction type of journal:
|
||||
$newType = TransactionType::whereType(TransactionType::WITHDRAWAL)->first();
|
||||
$newType = TransactionType::whereType(TransactionType::WITHDRAWAL)->first();
|
||||
\DB::table('transaction_journals')
|
||||
->where('id', '=', $journal->id)
|
||||
->update(['transaction_type_id' => $newType->id])
|
||||
@@ -206,20 +206,20 @@ class ConvertToWithdrawal implements ActionInterface
|
||||
private function convertTransferArray(TransactionJournal $journal): bool
|
||||
{
|
||||
// find or create expense account.
|
||||
$user = $journal->user;
|
||||
$user = $journal->user;
|
||||
|
||||
/** @var AccountFactory $factory */
|
||||
$factory = app(AccountFactory::class);
|
||||
$factory = app(AccountFactory::class);
|
||||
$factory->setUser($user);
|
||||
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$repository->setUser($user);
|
||||
|
||||
$destAccount = $this->getDestinationAccount($journal);
|
||||
$destAccount = $this->getDestinationAccount($journal);
|
||||
|
||||
// get the action value, or use the original source name in case the action value is empty:
|
||||
// this becomes a new or existing (expense) account, which is the destination of the new withdrawal.
|
||||
$opposingName = '' === $this->action->action_value ? $destAccount->name : $this->action->action_value;
|
||||
$opposingName = '' === $this->action->action_value ? $destAccount->name : $this->action->action_value;
|
||||
// we check all possible source account types if one exists:
|
||||
$validTypes = config('firefly.expected_source_types.destination.Withdrawal');
|
||||
$opposingAccount = $repository->findByName($opposingName, $validTypes);
|
||||
@@ -237,7 +237,7 @@ class ConvertToWithdrawal implements ActionInterface
|
||||
;
|
||||
|
||||
// change transaction type of journal:
|
||||
$newType = TransactionType::whereType(TransactionType::WITHDRAWAL)->first();
|
||||
$newType = TransactionType::whereType(TransactionType::WITHDRAWAL)->first();
|
||||
\DB::table('transaction_journals')
|
||||
->where('id', '=', $journal->id)
|
||||
->update(['transaction_type_id' => $newType->id])
|
||||
|
Reference in New Issue
Block a user