mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Clean up code.
This commit is contained in:
@@ -140,6 +140,29 @@ class UpdatePiggyBank implements ActionInterface
|
||||
return $repository->findByName($name);
|
||||
}
|
||||
|
||||
private function getAccounts(TransactionJournal $journal): array
|
||||
{
|
||||
return [
|
||||
'source' => $journal->transactions()->where('amount', '<', '0')->first()?->account,
|
||||
'destination' => $journal->transactions()->where('amount', '>', '0')->first()?->account,
|
||||
];
|
||||
}
|
||||
|
||||
private function isConnected(PiggyBank $piggyBank, ?Account $link): bool
|
||||
{
|
||||
if (null === $link) {
|
||||
return false;
|
||||
}
|
||||
foreach ($piggyBank->accounts as $account) {
|
||||
if ($account->id === $link->id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Log::debug(sprintf('Piggy bank is not connected to account #%d "%s"', $link->id, $link->name));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function removeAmount(PiggyBank $piggyBank, array $array, TransactionJournal $journal, Account $account, string $amount): void
|
||||
{
|
||||
$repository = app(PiggyBankRepositoryInterface::class);
|
||||
@@ -208,27 +231,4 @@ class UpdatePiggyBank implements ActionInterface
|
||||
|
||||
$repository->addAmount($piggyBank, $account, $amount, $journal);
|
||||
}
|
||||
|
||||
private function getAccounts(TransactionJournal $journal): array
|
||||
{
|
||||
return [
|
||||
'source' => $journal->transactions()->where('amount', '<', '0')->first()?->account,
|
||||
'destination' => $journal->transactions()->where('amount', '>', '0')->first()?->account,
|
||||
];
|
||||
}
|
||||
|
||||
private function isConnected(PiggyBank $piggyBank, ?Account $link): bool
|
||||
{
|
||||
if (null === $link) {
|
||||
return false;
|
||||
}
|
||||
foreach ($piggyBank->accounts as $account) {
|
||||
if ($account->id === $link->id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Log::debug(sprintf('Piggy bank is not connected to account #%d "%s"', $link->id, $link->name));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user