mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-18 12:28:46 +00:00
Fixed a bug that would recreate accounts if they existed had an old account type.
This commit is contained in:
@@ -231,6 +231,7 @@ class Transaction implements TransactionInterface
|
|||||||
}
|
}
|
||||||
if (isset($data['expense_account'])) {
|
if (isset($data['expense_account'])) {
|
||||||
$to = $this->_accounts->findExpenseAccountByName($data['expense_account']);
|
$to = $this->_accounts->findExpenseAccountByName($data['expense_account']);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (isset($data['revenue_account'])) {
|
if (isset($data['revenue_account'])) {
|
||||||
$from = $this->_accounts->findRevenueAccountByName($data['revenue_account']);
|
$from = $this->_accounts->findRevenueAccountByName($data['revenue_account']);
|
||||||
@@ -243,7 +244,6 @@ class Transaction implements TransactionInterface
|
|||||||
$to = $this->_accounts->findAssetAccountById($data['account_to_id']);
|
$to = $this->_accounts->findAssetAccountById($data['account_to_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add a custom error when they are the same.
|
* Add a custom error when they are the same.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
namespace Firefly\Storage\Account;
|
namespace Firefly\Storage\Account;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Firefly\Exception\FireflyException;
|
|
||||||
use Illuminate\Database\QueryException;
|
use Illuminate\Database\QueryException;
|
||||||
use Illuminate\Queue\Jobs\Job;
|
use Illuminate\Queue\Jobs\Job;
|
||||||
|
|
||||||
@@ -61,11 +60,14 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// find account:
|
// find account:
|
||||||
$type = $this->findAccountType('Expense account');
|
|
||||||
$account = $this->_user->accounts()->where('name', $name)->where('account_type_id', $type->id)->first();
|
$account = $this->_user->accounts()->where('name', $name)->accountTypeIn(
|
||||||
|
['Expense account', 'Beneficiary account']
|
||||||
|
)->first(['accounts.*']);
|
||||||
|
|
||||||
// create if not found:
|
// create if not found:
|
||||||
if (strlen($name) > 0) {
|
if (strlen($name) > 0 && is_null($account)) {
|
||||||
|
$type = $this->findAccountType('Expense account');
|
||||||
$set = [
|
$set = [
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'user_id' => $this->_user->id,
|
'user_id' => $this->_user->id,
|
||||||
@@ -675,6 +677,7 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
|||||||
)
|
)
|
||||||
->get(['accounts.*']);
|
->get(['accounts.*']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user