mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Fix #4710
This commit is contained in:
@@ -56,8 +56,8 @@ class SetDestinationAccount implements ActionInterface
|
|||||||
*/
|
*/
|
||||||
public function actOnArray(array $journal): bool
|
public function actOnArray(array $journal): bool
|
||||||
{
|
{
|
||||||
$user = User::find($journal['user_id']);
|
$user = User::find($journal['user_id']);
|
||||||
$type = $journal['transaction_type_type'];
|
$type = $journal['transaction_type_type'];
|
||||||
/** @var TransactionJournal|null $object */
|
/** @var TransactionJournal|null $object */
|
||||||
$object = $user->transactionJournals()->find((int)$journal['transaction_journal_id']);
|
$object = $user->transactionJournals()->find((int)$journal['transaction_journal_id']);
|
||||||
$this->repository = app(AccountRepositoryInterface::class);
|
$this->repository = app(AccountRepositoryInterface::class);
|
||||||
@@ -108,8 +108,9 @@ class SetDestinationAccount implements ActionInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if this is a withdrawal, the new destination account must be a expense account and may be created:
|
// if this is a withdrawal, the new destination account must be a expense account and may be created:
|
||||||
|
// or it is a liability, in which case it must be returned.
|
||||||
if (TransactionType::WITHDRAWAL === $type) {
|
if (TransactionType::WITHDRAWAL === $type) {
|
||||||
$newAccount = $this->findExpenseAccount();
|
$newAccount = $this->findWithdrawalDestinationAccount();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::debug(sprintf('New destination account is #%d ("%s").', $newAccount->id, $newAccount->name));
|
Log::debug(sprintf('New destination account is #%d ("%s").', $newAccount->id, $newAccount->name));
|
||||||
@@ -145,9 +146,10 @@ class SetDestinationAccount implements ActionInterface
|
|||||||
/**
|
/**
|
||||||
* @return Account
|
* @return Account
|
||||||
*/
|
*/
|
||||||
private function findExpenseAccount(): Account
|
private function findWithdrawalDestinationAccount(): Account
|
||||||
{
|
{
|
||||||
$account = $this->repository->findByName($this->action->action_value, [AccountType::EXPENSE]);
|
$allowed = config('firefly.expected_source_types.destination.Withdrawal');
|
||||||
|
$account = $this->repository->findByName($this->action->action_value, $allowed);
|
||||||
if (null === $account) {
|
if (null === $account) {
|
||||||
$data = [
|
$data = [
|
||||||
'name' => $this->action->action_value,
|
'name' => $this->action->action_value,
|
||||||
|
@@ -105,8 +105,9 @@ class SetSourceAccount implements ActionInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if this is a deposit, the new source account must be a revenue account and may be created:
|
// if this is a deposit, the new source account must be a revenue account and may be created:
|
||||||
|
// or its a liability
|
||||||
if (TransactionType::DEPOSIT === $type) {
|
if (TransactionType::DEPOSIT === $type) {
|
||||||
$newAccount = $this->findRevenueAccount();
|
$newAccount = $this->findDepositSourceAccount();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::debug(sprintf('New source account is #%d ("%s").', $newAccount->id, $newAccount->name));
|
Log::debug(sprintf('New source account is #%d ("%s").', $newAccount->id, $newAccount->name));
|
||||||
@@ -140,7 +141,7 @@ class SetSourceAccount implements ActionInterface
|
|||||||
/**
|
/**
|
||||||
* @return Account
|
* @return Account
|
||||||
*/
|
*/
|
||||||
private function findRevenueAccount(): Account
|
private function findDepositSourceAccount(): Account
|
||||||
{
|
{
|
||||||
$allowed = config('firefly.expected_source_types.source.Deposit');
|
$allowed = config('firefly.expected_source_types.source.Deposit');
|
||||||
$account = $this->repository->findByName($this->action->action_value, $allowed);
|
$account = $this->repository->findByName($this->action->action_value, $allowed);
|
||||||
|
Reference in New Issue
Block a user