mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix #4710
This commit is contained in:
parent
97a0110931
commit
0949a264b8
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user