mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Code cleanup
This commit is contained in:
@@ -75,7 +75,7 @@ trait JournalServiceTrait
|
||||
|
||||
// if $result (find by name) is NULL, but IBAN is set, any result of the search by NAME can't overrule
|
||||
// this account. In such a case, the name search must be retried with a new name.
|
||||
if (null !== $nameResult && null === $numberResult && null === $ibanResult && '' !== (string)$data['iban'] && '' !== (string)$nameResult->iban) {
|
||||
if (null !== $nameResult && null === $numberResult && null === $ibanResult && '' !== (string) $data['iban'] && '' !== (string) $nameResult->iban) {
|
||||
$data['name'] = sprintf('%s (%s)', $data['name'], $data['iban']);
|
||||
app('log')->debug(sprintf('Search again using the new name, "%s".', $data['name']));
|
||||
$result = $this->findAccountByName(null, $data, $expectedTypes[$transactionType]);
|
||||
@@ -115,7 +115,7 @@ trait JournalServiceTrait
|
||||
{
|
||||
// first attempt, find by ID.
|
||||
if (null !== $data['id']) {
|
||||
$search = $this->accountRepository->find((int)$data['id']);
|
||||
$search = $this->accountRepository->find((int) $data['id']);
|
||||
if (null !== $search && in_array($search->accountType->type, $types, true)) {
|
||||
app('log')->debug(
|
||||
sprintf('Found "account_id" object: #%d, "%s" of type %s (1)', $search->id, $search->name, $search->accountType->type)
|
||||
@@ -176,10 +176,10 @@ trait JournalServiceTrait
|
||||
return null;
|
||||
}
|
||||
// find by preferred type.
|
||||
$source = $this->accountRepository->findByAccountNumber((string)$data['number'], [$types[0]]);
|
||||
$source = $this->accountRepository->findByAccountNumber((string) $data['number'], [$types[0]]);
|
||||
|
||||
// or any expected type.
|
||||
$source ??= $this->accountRepository->findByAccountNumber((string)$data['number'], $types);
|
||||
$source ??= $this->accountRepository->findByAccountNumber((string) $data['number'], $types);
|
||||
|
||||
if (null !== $source) {
|
||||
app('log')->debug(sprintf('Found account: #%d, %s', $source->id, $source->name));
|
||||
@@ -261,17 +261,17 @@ trait JournalServiceTrait
|
||||
throw new FireflyException(sprintf('TransactionFactory: Cannot create asset account with these values: %s', json_encode($data)));
|
||||
}
|
||||
// fix name of account if only IBAN is given:
|
||||
if ('' === (string)$data['name'] && '' !== (string)$data['iban']) {
|
||||
if ('' === (string) $data['name'] && '' !== (string) $data['iban']) {
|
||||
app('log')->debug(sprintf('Account name is now IBAN ("%s")', $data['iban']));
|
||||
$data['name'] = $data['iban'];
|
||||
}
|
||||
// fix name of account if only number is given:
|
||||
if ('' === (string)$data['name'] && '' !== (string)$data['number']) {
|
||||
if ('' === (string) $data['name'] && '' !== (string) $data['number']) {
|
||||
app('log')->debug(sprintf('Account name is now account number ("%s")', $data['number']));
|
||||
$data['name'] = $data['number'];
|
||||
}
|
||||
// if name is still NULL, return NULL.
|
||||
if ('' === (string)$data['name']) {
|
||||
if ('' === (string) $data['name']) {
|
||||
app('log')->debug('Account name is still NULL, return NULL.');
|
||||
|
||||
return null;
|
||||
@@ -310,7 +310,7 @@ trait JournalServiceTrait
|
||||
private function getCashAccount(?Account $account, array $data, array $types): ?Account
|
||||
{
|
||||
// return cash account.
|
||||
if (null === $account && '' === (string)$data['name']
|
||||
if (null === $account && '' === (string) $data['name']
|
||||
&& in_array(AccountType::CASH, $types, true)) {
|
||||
$account = $this->accountRepository->getCashAccount();
|
||||
}
|
||||
@@ -390,7 +390,7 @@ trait JournalServiceTrait
|
||||
|
||||
protected function storeNotes(TransactionJournal $journal, ?string $notes): void
|
||||
{
|
||||
$notes = (string)$notes;
|
||||
$notes = (string) $notes;
|
||||
$note = $journal->notes()->first();
|
||||
if ('' !== $notes) {
|
||||
if (null === $note) {
|
||||
@@ -422,7 +422,7 @@ trait JournalServiceTrait
|
||||
}
|
||||
app('log')->debug('Start of loop.');
|
||||
foreach ($tags as $string) {
|
||||
$string = (string)$string;
|
||||
$string = (string) $string;
|
||||
app('log')->debug(sprintf('Now at tag "%s"', $string));
|
||||
if ('' !== $string) {
|
||||
$tag = $this->tagFactory->findOrCreate($string);
|
||||
|
Reference in New Issue
Block a user