mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-19 08:00:19 +00:00
Code clean up.
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\TransactionRules\Actions;
|
||||
@@ -32,24 +31,21 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class SetDestinationAccount
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Action
|
||||
* Class SetDestinationAccount.
|
||||
*/
|
||||
class SetDestinationAccount implements ActionInterface
|
||||
{
|
||||
private $action;
|
||||
|
||||
/** @var TransactionJournal */
|
||||
/** @var TransactionJournal */
|
||||
private $journal;
|
||||
|
||||
/** @var Account */
|
||||
/** @var Account */
|
||||
private $newDestinationAccount;
|
||||
|
||||
/** @var AccountRepositoryInterface */
|
||||
private $repository;
|
||||
|
||||
|
||||
/**
|
||||
* TriggerInterface constructor.
|
||||
*
|
||||
@@ -81,7 +77,7 @@ class SetDestinationAccount implements ActionInterface
|
||||
$type = $journal->transactionType->type;
|
||||
|
||||
// if this is a deposit or a transfer, the destination account must be an asset account or a default account, and it MUST exist:
|
||||
if (($type === TransactionType::DEPOSIT || $type === TransactionType::TRANSFER) && !$this->findAssetAccount()) {
|
||||
if ((TransactionType::DEPOSIT === $type || TransactionType::TRANSFER === $type) && !$this->findAssetAccount()) {
|
||||
Log::error(
|
||||
sprintf(
|
||||
'Cannot change destination account of journal #%d because no asset account with name "%s" exists.',
|
||||
@@ -94,7 +90,7 @@ class SetDestinationAccount implements ActionInterface
|
||||
}
|
||||
|
||||
// if this is a withdrawal, the new destination account must be a expense account and may be created:
|
||||
if ($type === TransactionType::WITHDRAWAL) {
|
||||
if (TransactionType::WITHDRAWAL === $type) {
|
||||
$this->findExpenseAccount();
|
||||
}
|
||||
|
||||
@@ -117,7 +113,7 @@ class SetDestinationAccount implements ActionInterface
|
||||
{
|
||||
$account = $this->repository->findByName($this->action->action_value, [AccountType::DEFAULT, AccountType::ASSET]);
|
||||
|
||||
if (is_null($account->id)) {
|
||||
if (null === $account->id) {
|
||||
Log::debug(sprintf('There is NO asset account called "%s".', $this->action->action_value));
|
||||
|
||||
return false;
|
||||
@@ -134,7 +130,7 @@ class SetDestinationAccount implements ActionInterface
|
||||
private function findExpenseAccount()
|
||||
{
|
||||
$account = $this->repository->findByName($this->action->action_value, [AccountType::EXPENSE]);
|
||||
if (is_null($account->id)) {
|
||||
if (null === $account->id) {
|
||||
// create new revenue account with this name:
|
||||
$data = [
|
||||
'name' => $this->action->action_value,
|
||||
|
||||
Reference in New Issue
Block a user