Skip to content

Firefly III: a personal finances manager

First part of a large code cleanup commit.

James Colee0d87aa11e04
diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php
index 2695684119..0b61d860d9 100644
--- a/app/Repositories/Budget/BudgetRepository.php
+++ b/app/Repositories/Budget/BudgetRepository.php
@@ -43,7 +43,6 @@ use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
use Log;
use Navigation;
-use Symfony\Component\Debug\Exception\FatalThrowableError;
/**
* Class BudgetRepository.
@@ -107,7 +106,7 @@ class BudgetRepository implements BudgetRepositoryInterface
// delete limits with amount 0:
try {
BudgetLimit::where('amount', 0)->delete();
- } catch (Exception|FatalThrowableError $e) {
+ } catch (Exception $e) {
Log::debug(sprintf('Could not delete budget limit: %s', $e->getMessage()));
}
Budget::where('order', 0)->update(['order' => 100]);
@@ -122,7 +121,7 @@ class BudgetRepository implements BudgetRepositoryInterface
// delete it!
try {
BudgetLimit::find($budgetLimit->id)->delete();
- } catch (Exception|FatalThrowableError $e) {
+ } catch (Exception $e) {
Log::debug(sprintf('Could not delete budget limit: %s', $e->getMessage()));
}
}
@@ -863,7 +862,6 @@ class BudgetRepository implements BudgetRepositoryInterface
/**
* @param array $data
*
- * @throws FireflyException
* @return BudgetLimit
*/
public function storeBudgetLimit(array $data): BudgetLimit
diff --git a/app/Repositories/Budget/BudgetRepositoryInterface.php b/app/Repositories/Budget/BudgetRepositoryInterface.php
index e2cd595ec0..3100064f8f 100644
--- a/app/Repositories/Budget/BudgetRepositoryInterface.php
+++ b/app/Repositories/Budget/BudgetRepositoryInterface.php
@@ -120,8 +120,8 @@ interface BudgetRepositoryInterface
public function getAvailableBudget(TransactionCurrency $currency, Carbon $start, Carbon $end): string;
/**
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
*
* @return array
*/
diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.php
index a4b318d529..5d70121862 100644
--- a/app/Repositories/Category/CategoryRepository.php
+++ b/app/Repositories/Category/CategoryRepository.php
@@ -116,6 +116,61 @@ class CategoryRepository implements CategoryRepositoryInterface
return $collector->getTransactions();
}
+ /**
+ * A very cryptic method name that means:
+ *
+ * Get me the amount earned in this period, grouped per currency, where no category was set.
+ *
+ * @param Collection $accounts
+ * @param Carbon $start
+ * @param Carbon $end
+ *
+ * @return array
+ */
+ public function earnedInPeriodPcWoCategory(Collection $accounts, Carbon $start, Carbon $end): array
+ {
+ /** @var TransactionCollectorInterface $collector */
+ $collector = app(TransactionCollectorInterface::class);
+ $collector->setUser($this->user);
+ $collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->withoutCategory();
+
+ if ($accounts->count() > 0) {
+ $collector->setAccounts($accounts);
+ }
+ if (0 === $accounts->count()) {
+ $collector->setAllAssetAccounts();
+ }
+
+ $set = $collector->getTransactions();
+ $set = $set->filter(
+ function (Transaction $transaction) {
+ if (bccomp($transaction->transaction_amount, '0') === 1) {
+ return $transaction;
+ }
+
+ return null;
+ }
+ );
+
+ $return = [];
+ /** @var Transaction $transaction */
+ foreach ($set as $transaction) {
+ $currencyId = $transaction->transaction_currency_id;
+ if (!isset($return[$currencyId])) {
+ $return[$currencyId] = [
+ 'spent' => '0',
+ 'currency_id' => $currencyId,
+ 'currency_symbol' => $transaction->transaction_currency_symbol,
+ 'currency_code' => $transaction->transaction_currency_code,
+ 'currency_decimal_places' => $transaction->transaction_currency_dp,
+ ];
+ }
+ $return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], $transaction->transaction_amount);
+ }
+
+ return $return;
+ }
+
/**
* @param Collection $categories
* @param Collection $accounts
@@ -237,6 +292,8 @@ class CategoryRepository implements CategoryRepositoryInterface
return $firstJournalDate;
}
+ /** @noinspection MoreThanThreeArgumentsInspection */
+
/**
* Get all categories with ID's.
*
@@ -249,8 +306,6 @@ class CategoryRepository implements CategoryRepositoryInterface
return $this->user->categories()->whereIn('id', $categoryIds)->get();
}
- /** @noinspection MoreThanThreeArgumentsInspection */
-
/**
* Returns a list of all the categories belonging to a user.
*
@@ -269,6 +324,8 @@ class CategoryRepository implements CategoryRepositoryInterface
return $set;
}
+ /** @noinspection MoreThanThreeArgumentsInspection */
+
/**
* @param Category $category
* @param Collection $accounts
@@ -299,8 +356,6 @@ class CategoryRepository implements CategoryRepositoryInterface
return $lastJournalDate;
}
- /** @noinspection MoreThanThreeArgumentsInspection */
-
/**
* @param Collection $categories
* @param Collection $accounts
@@ -384,6 +439,8 @@ class CategoryRepository implements CategoryRepositoryInterface
return $result;
}
+ /** @noinspection MoreThanThreeArgumentsInspection */
+
/**
* @param Collection $categories
* @param Collection $accounts
@@ -482,8 +539,6 @@ class CategoryRepository implements CategoryRepositoryInterface
$this->user = $user;
}
- /** @noinspection MoreThanThreeArgumentsInspection */
-
/**
* @param Collection $categories
* @param Collection $accounts
@@ -791,59 +846,4 @@ class CategoryRepository implements CategoryRepositoryInterface
return null;
}
-
- /**
- * A very cryptic method name that means:
- *
- * Get me the amount earned in this period, grouped per currency, where no category was set.
- *
- * @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return array
- */
- public function earnedInPeriodPcWoCategory(Collection $accounts, Carbon $start, Carbon $end): array
- {
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setUser($this->user);
- $collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->withoutCategory();
-
- if ($accounts->count() > 0) {
- $collector->setAccounts($accounts);
- }
- if (0 === $accounts->count()) {
- $collector->setAllAssetAccounts();
- }
-
- $set = $collector->getTransactions();
- $set = $set->filter(
- function (Transaction $transaction) {
- if (bccomp($transaction->transaction_amount, '0') === 1) {
- return $transaction;
- }
-
- return null;
- }
- );
-
- $return = [];
- /** @var Transaction $transaction */
- foreach ($set as $transaction) {
- $currencyId = $transaction->transaction_currency_id;
- if (!isset($return[$currencyId])) {
- $return[$currencyId] = [
- 'spent' => '0',
- 'currency_id' => $currencyId,
- 'currency_symbol' => $transaction->transaction_currency_symbol,
- 'currency_code' => $transaction->transaction_currency_code,
- 'currency_decimal_places' => $transaction->transaction_currency_dp,
- ];
- }
- $return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], $transaction->transaction_amount);
- }
-
- return $return;
- }
}
diff --git a/app/Repositories/Category/CategoryRepositoryInterface.php b/app/Repositories/Category/CategoryRepositoryInterface.php
index 2afe953766..65f0c79b85 100644
--- a/app/Repositories/Category/CategoryRepositoryInterface.php
+++ b/app/Repositories/Category/CategoryRepositoryInterface.php
@@ -62,6 +62,29 @@ interface CategoryRepositoryInterface
*/
public function earnedInPeriodCollection(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): Collection;
+ /**
+ * A very cryptic method name that means:
+ *
+ * Get me the amount earned in this period, grouped per currency, where no category was set.
+ *
+ * @param Collection $accounts
+ * @param Carbon $start
+ * @param Carbon $end
+ *
+ * @return array
+ */
+ public function earnedInPeriodPcWoCategory(Collection $accounts, Carbon $start, Carbon $end): array;
+
+ /**
+ * @param Collection $categories
+ * @param Collection $accounts
+ * @param Carbon $start
+ * @param Carbon $end
+ *
+ * @return array
+ */
+ public function earnedInPeriodPerCurrency(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array;
+
/**
* Find a category.
*
@@ -96,6 +119,8 @@ interface CategoryRepositoryInterface
*/
public function getByIds(array $categoryIds): Collection;
+ /** @noinspection MoreThanThreeArgumentsInspection */
+
/**
* Returns a list of all the categories belonging to a user.
*
@@ -114,6 +139,7 @@ interface CategoryRepositoryInterface
public function lastUseDate(Category $category, Collection $accounts): ?Carbon;
/** @noinspection MoreThanThreeArgumentsInspection */
+
/**
* @param Collection $categories
* @param Collection $accounts
@@ -133,7 +159,6 @@ interface CategoryRepositoryInterface
*/
public function periodExpensesNoCategory(Collection $accounts, Carbon $start, Carbon $end): array;
- /** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Collection $categories
* @param Collection $accounts
@@ -144,6 +169,8 @@ interface CategoryRepositoryInterface
*/
public function periodIncome(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array;
+ /** @noinspection MoreThanThreeArgumentsInspection */
+
/**
* @param Collection $accounts
* @param Carbon $start
@@ -153,12 +180,15 @@ interface CategoryRepositoryInterface
*/
public function periodIncomeNoCategory(Collection $accounts, Carbon $start, Carbon $end): array;
+ /** @noinspection MoreThanThreeArgumentsInspection */
+
/**
* @param User $user
*/
public function setUser(User $user);
/** @noinspection MoreThanThreeArgumentsInspection */
+
/**
* @param Collection $categories
* @param Collection $accounts
@@ -169,7 +199,6 @@ interface CategoryRepositoryInterface
*/
public function spentInPeriod(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): string;
- /** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Collection $categories
* @param Collection $accounts
@@ -180,8 +209,6 @@ interface CategoryRepositoryInterface
*/
public function spentInPeriodCollection(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): Collection;
- /** @noinspection MoreThanThreeArgumentsInspection */
-
/**
* A very cryptic method name that means:
*
@@ -195,19 +222,6 @@ interface CategoryRepositoryInterface
*/
public function spentInPeriodPcWoCategory(Collection $accounts, Carbon $start, Carbon $end): array;
- /**
- * A very cryptic method name that means:
- *
- * Get me the amount earned in this period, grouped per currency, where no category was set.
- *
- * @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return array
- */
- public function earnedInPeriodPcWoCategory(Collection $accounts, Carbon $start, Carbon $end): array;
-
/**
* @param Collection $categories
* @param Collection $accounts
@@ -218,16 +232,6 @@ interface CategoryRepositoryInterface
*/
public function spentInPeriodPerCurrency(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array;
- /**
- * @param Collection $categories
- * @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return array
- */
- public function earnedInPeriodPerCurrency(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array;
-
/**
* @param Collection $accounts
* @param Carbon $start
diff --git a/app/Repositories/ExportJob/ExportJobRepository.php b/app/Repositories/ExportJob/ExportJobRepository.php
index 869585ea90..e11c1b88f6 100644
--- a/app/Repositories/ExportJob/ExportJobRepository.php
+++ b/app/Repositories/ExportJob/ExportJobRepository.php
@@ -22,13 +22,11 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\ExportJob;
-use Carbon\Carbon;
-use Exception;
use FireflyIII\Models\ExportJob;
use FireflyIII\User;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
-use Illuminate\Support\Str;
use Illuminate\Support\Facades\Storage;
+use Illuminate\Support\Str;
use Log;
/**
diff --git a/app/Repositories/Journal/JournalRepositoryInterface.php b/app/Repositories/Journal/JournalRepositoryInterface.php
index 22c5cebd37..13eaf8360f 100644
--- a/app/Repositories/Journal/JournalRepositoryInterface.php
+++ b/app/Repositories/Journal/JournalRepositoryInterface.php
@@ -40,13 +40,6 @@ use Illuminate\Support\MessageBag;
interface JournalRepositoryInterface
{
- /**
- * @param TransactionJournalLink $link
- *
- * @return string
- */
- public function getLinkNoteText(TransactionJournalLink $link): string;
-
/**
* @param TransactionJournal $journal
* @param TransactionType $type
@@ -57,9 +50,6 @@ interface JournalRepositoryInterface
*/
public function convert(TransactionJournal $journal, TransactionType $type, Account $source, Account $destination): MessageBag;
-
- /** @noinspection MoreThanThreeArgumentsInspection */
-
/**
* @param TransactionJournal $journal
*
@@ -67,6 +57,9 @@ interface JournalRepositoryInterface
*/
public function countTransactions(TransactionJournal $journal): int;
+
+ /** @noinspection MoreThanThreeArgumentsInspection */
+
/**
* Deletes a journal.
*
@@ -203,6 +196,13 @@ interface JournalRepositoryInterface
*/
public function getJournalTotal(TransactionJournal $journal): string;
+ /**
+ * @param TransactionJournalLink $link
+ *
+ * @return string
+ */
+ public function getLinkNoteText(TransactionJournalLink $link): string;
+
/**
* Return Carbon value of a meta field (or NULL).
*
diff --git a/app/Repositories/LinkType/LinkTypeRepository.php b/app/Repositories/LinkType/LinkTypeRepository.php
index 4f0c0dbbde..2c87e120b8 100644
--- a/app/Repositories/LinkType/LinkTypeRepository.php
+++ b/app/Repositories/LinkType/LinkTypeRepository.php
@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\LinkType;
+use Exception;
use FireflyIII\Models\LinkType;
use FireflyIII\Models\Note;
use FireflyIII\Models\TransactionJournal;
@@ -362,7 +363,11 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
return;
}
if (null !== $dbNote && '' === $text) {
- $dbNote->delete();
+ try {
+ $dbNote->delete();
+ } catch (Exception $e) {
+ Log::debug(sprintf('Could not delete note: %s', $e->getMessage()));
+ }
}
}
diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php
index d236252ac1..de8600b6ce 100644
--- a/app/Repositories/PiggyBank/PiggyBankRepository.php
+++ b/app/Repositories/PiggyBank/PiggyBankRepository.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\PiggyBank;
use Carbon\Carbon;
+use Exception;
use FireflyIII\Models\Note;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\PiggyBankEvent;
@@ -559,7 +560,11 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
if ('' === $note) {
$dbNote = $piggyBank->notes()->first();
if (null !== $dbNote) {
- $dbNote->delete();
+ try {
+ $dbNote->delete();
+ } catch (Exception $e) {
+ Log::debug(sprintf('Could not delete note: %s', $e->getMessage()));
+ }
}
return true;
diff --git a/app/Repositories/Rule/RuleRepositoryInterface.php b/app/Repositories/Rule/RuleRepositoryInterface.php
index 5b4c3fea5b..7a105bd681 100644
--- a/app/Repositories/Rule/RuleRepositoryInterface.php
+++ b/app/Repositories/Rule/RuleRepositoryInterface.php
@@ -34,21 +34,6 @@ use Illuminate\Support\Collection;
*/
interface RuleRepositoryInterface
{
- /**
- * @param Rule $rule
- *
- * @return Collection
- */
- public function getRuleActions(Rule $rule): Collection;
-
- /**
- * @param Rule $rule
- *
- * @return Collection
- */
- public function getRuleTriggers(Rule $rule): Collection;
-
-
/**
* @return int
*/
@@ -101,6 +86,20 @@ interface RuleRepositoryInterface
*/
public function getPrimaryTrigger(Rule $rule): string;
+ /**
+ * @param Rule $rule
+ *
+ * @return Collection
+ */
+ public function getRuleActions(Rule $rule): Collection;
+
+ /**
+ * @param Rule $rule
+ *
+ * @return Collection
+ */
+ public function getRuleTriggers(Rule $rule): Collection;
+
/**
* @param Rule $rule
*
diff --git a/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php b/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php
index d21029d8c4..17363456e0 100644
--- a/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php
+++ b/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php
@@ -72,13 +72,6 @@ interface RuleGroupRepositoryInterface
*/
public function getActiveRules(RuleGroup $group): Collection;
- /**
- * @param RuleGroup $group
- *
- * @return Collection
- */
- public function getRules(RuleGroup $group): Collection;
-
/**
* @param RuleGroup $group
*
@@ -105,6 +98,13 @@ interface RuleGroupRepositoryInterface
*/
public function getRuleGroupsWithRules(User $user): Collection;
+ /**
+ * @param RuleGroup $group
+ *
+ * @return Collection
+ */
+ public function getRules(RuleGroup $group): Collection;
+
/**
* @param RuleGroup $ruleGroup
*
diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php
index b3f074b4dd..9bca4cb58e 100644
--- a/app/Repositories/Tag/TagRepository.php
+++ b/app/Repositories/Tag/TagRepository.php
@@ -255,6 +255,7 @@ class TagRepository implements TagRepositoryInterface
/** @var TagFactory $factory */
$factory = app(TagFactory::class);
$factory->setUser($this->user);
+
return $factory->create($data);
}
diff --git a/app/Repositories/User/UserRepositoryInterface.php b/app/Repositories/User/UserRepositoryInterface.php
index 33f36a4408..c01be9f65d 100644
--- a/app/Repositories/User/UserRepositoryInterface.php
+++ b/app/Repositories/User/UserRepositoryInterface.php
@@ -32,12 +32,6 @@ use Illuminate\Support\Collection;
interface UserRepositoryInterface
{
- /**
- * @param User $user
- *
- * @return string|null
- */
- public function getRoleByUser(User $user): ?string;
/**
* Returns a collection of all users.
*
@@ -136,6 +130,13 @@ interface UserRepositoryInterface
*/
public function getRole(string $role): ?Role;
+ /**
+ * @param User $user
+ *
+ * @return string|null
+ */
+ public function getRoleByUser(User $user): ?string;
+
/**
* Return basic user information.
*
diff --git a/app/Rules/ZeroOrMore.php b/app/Rules/ZeroOrMore.php
index 0683275733..642a89cf36 100644
--- a/app/Rules/ZeroOrMore.php
+++ b/app/Rules/ZeroOrMore.php
@@ -58,10 +58,7 @@ class ZeroOrMore implements Rule
return true;
}
$res = bccomp('0', $value);
- if ($res > 0) {
- return false;
- }
- return true;
+ return !($res > 0);
}
}
diff --git a/app/Services/Internal/Destroy/AccountDestroyService.php b/app/Services/Internal/Destroy/AccountDestroyService.php
index 5fc61f8557..d0aba6f8f7 100644
--- a/app/Services/Internal/Destroy/AccountDestroyService.php
+++ b/app/Services/Internal/Destroy/AccountDestroyService.php
@@ -62,7 +62,7 @@ class AccountDestroyService
DB::table('transactions')->where('account_id', $account->id)->update(['account_id' => $moveTo->id]);
// also update recurring transactions:
- DB::table('recurrences_transactions')->where('source_id', $account->id)->update(['source_id' => $moveTo->id]);
+ DB::table('recurrences_transactions')->where('source_id', $account->id)->update(['source_id' => $moveTo->id]);
DB::table('recurrences_transactions')->where('destination_id', $account->id)->update(['destination_id' => $moveTo->id]);
}
$service = app(JournalDestroyService::class);
diff --git a/app/Services/Internal/File/EncryptService.php b/app/Services/Internal/File/EncryptService.php
index 97d93a44c8..b72398571e 100644
--- a/app/Services/Internal/File/EncryptService.php
+++ b/app/Services/Internal/File/EncryptService.php
@@ -64,7 +64,7 @@ class EncryptService
throw new FireflyException($message);
}
$newName = sprintf('%s.upload', $key);
- $disk = Storage::disk('upload');
+ $disk = Storage::disk('upload');
$disk->put($newName, $content);
}
diff --git a/app/Services/Internal/Support/AccountServiceTrait.php b/app/Services/Internal/Support/AccountServiceTrait.php
index 06ba9869a1..46f56eea22 100644
--- a/app/Services/Internal/Support/AccountServiceTrait.php
+++ b/app/Services/Internal/Support/AccountServiceTrait.php
@@ -222,7 +222,7 @@ trait AccountServiceTrait
/** @var AccountFactory $factory */
$factory = app(AccountFactory::class);
$factory->setUser($user);
-
+
return $factory->findOrCreate($opposingAccountName, AccountType::INITIAL_BALANCE);
}
diff --git a/app/Services/Internal/Support/BillServiceTrait.php b/app/Services/Internal/Support/BillServiceTrait.php
index 35cef980cd..b9ded1d789 100644
--- a/app/Services/Internal/Support/BillServiceTrait.php
+++ b/app/Services/Internal/Support/BillServiceTrait.php
@@ -23,10 +23,12 @@ declare(strict_types=1);
namespace FireflyIII\Services\Internal\Support;
+use Exception;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Note;
use FireflyIII\Models\RuleAction;
use Illuminate\Support\Collection;
+use Log;
/**
* Trait BillServiceTrait
@@ -70,7 +72,11 @@ trait BillServiceTrait
if ('' === $note) {
$dbNote = $bill->notes()->first();
if (null !== $dbNote) {
- $dbNote->delete(); // @codeCoverageIgnore
+ try {
+ $dbNote->delete();
+ } catch (Exception $e) {
+ Log::debug(sprintf('Error deleting note: %s', $e->getMessage()));
+ }
}
return true;
diff --git a/app/Services/Internal/Support/JournalServiceTrait.php b/app/Services/Internal/Support/JournalServiceTrait.php
index ab66e38ff8..01cfbf4cb9 100644
--- a/app/Services/Internal/Support/JournalServiceTrait.php
+++ b/app/Services/Internal/Support/JournalServiceTrait.php
@@ -55,7 +55,7 @@ trait JournalServiceTrait
return; // @codeCoverageIgnore
}
foreach ($data['tags'] as $string) {
- if (\strlen($string) > 0) {
+ if ('' != $string) {
$tag = $factory->findOrCreate($string);
if (null !== $tag) {
$set[] = $tag->id;
@@ -116,7 +116,7 @@ trait JournalServiceTrait
protected function storeNote(TransactionJournal $journal, ?string $notes): void
{
$notes = (string)$notes;
- if (\strlen($notes) > 0) {
+ if ('' !== $notes) {
$note = $journal->notes()->first();
if (null === $note) {
$note = new Note;
diff --git a/app/Services/Internal/Support/TransactionServiceTrait.php b/app/Services/Internal/Support/TransactionServiceTrait.php
index 0f76b5dd1b..d777bf6308 100644
--- a/app/Services/Internal/Support/TransactionServiceTrait.php
+++ b/app/Services/Internal/Support/TransactionServiceTrait.php
@@ -107,7 +107,7 @@ trait TransactionServiceTrait
return $repository->findByName($accountName, [AccountType::ASSET]);
}
// for revenue and expense:
- if (\strlen($accountName) > 0) {
+ if ('' !== $accountName) {
/** @var AccountFactory $factory */
$factory = app(AccountFactory::class);
$factory->setUser($this->user);
@@ -218,7 +218,7 @@ trait TransactionServiceTrait
return;
}
// enable currency if not enabled:
- if(false === $currency->enabled) {
+ if (false === $currency->enabled) {
$currency->enabled = true;
$currency->save();
}
diff --git a/app/Services/Internal/Update/BillUpdateService.php b/app/Services/Internal/Update/BillUpdateService.php
index 811f7a4832..c1d4f8a621 100644
--- a/app/Services/Internal/Update/BillUpdateService.php
+++ b/app/Services/Internal/Update/BillUpdateService.php
@@ -28,6 +28,7 @@ use FireflyIII\Models\Bill;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Services\Internal\Support\BillServiceTrait;
use Log;
+
/**
* @codeCoverageIgnore
* Class BillUpdateService
@@ -59,7 +60,7 @@ class BillUpdateService
/** @var TransactionCurrency $currency */
$currency = $factory->find($data['currency_id'] ?? null, $data['currency_code'] ?? null);
- if(null === $currency) {
+ if (null === $currency) {
// use default currency:
$currency = app('amount')->getDefaultCurrencyByUser($bill->user);
}
diff --git a/app/Services/Internal/Update/JournalUpdateService.php b/app/Services/Internal/Update/JournalUpdateService.php
index 47027fe87c..bdd17f41f7 100644
--- a/app/Services/Internal/Update/JournalUpdateService.php
+++ b/app/Services/Internal/Update/JournalUpdateService.php
@@ -30,6 +30,7 @@ use FireflyIII\Models\TransactionType;
use FireflyIII\Services\Internal\Support\JournalServiceTrait;
use Illuminate\Support\Collection;
use Log;
+
/**
* Class to centralise code that updates a journal given the input by system.
*
@@ -38,6 +39,7 @@ use Log;
class JournalUpdateService
{
use JournalServiceTrait;
+
/**
* Constructor.
*/
@@ -159,6 +161,7 @@ class JournalUpdateService
foreach ($journal->transactions as $transaction) {
$service->updateBudget($transaction, $budgetId);
}
+
return $journal;
}
// clear budget.
diff --git a/app/Services/Internal/Update/TransactionUpdateService.php b/app/Services/Internal/Update/TransactionUpdateService.php
index 18b3359a5b..78ef4cbabd 100644
--- a/app/Services/Internal/Update/TransactionUpdateService.php
+++ b/app/Services/Internal/Update/TransactionUpdateService.php
@@ -27,6 +27,7 @@ use FireflyIII\Models\Transaction;
use FireflyIII\Services\Internal\Support\TransactionServiceTrait;
use FireflyIII\User;
use Log;
+
/**
* Class TransactionUpdateService
*/
@@ -34,6 +35,9 @@ class TransactionUpdateService
{
use TransactionServiceTrait;
+ /** @var User */
+ private $user;
+
/**
* Constructor.
*/
@@ -44,9 +48,6 @@ class TransactionUpdateService
}
}
- /** @var User */
- private $user;
-
/**
* @param int $transactionId
*
@@ -87,10 +88,10 @@ class TransactionUpdateService
*/
public function update(Transaction $transaction, array $data): Transaction
{
- $currency = $this->findCurrency($data['currency_id'], $data['currency_code']);
- $journal = $transaction->transactionJournal;
- $amount = (string)$data['amount'];
- $account = null;
+ $currency = $this->findCurrency($data['currency_id'], $data['currency_code']);
+ $journal = $transaction->transactionJournal;
+ $amount = (string)$data['amount'];
+ $account = null;
// update description:
$transaction->description = $data['description'];
$foreignAmount = null;
diff --git a/app/Support/Binder/CLIToken.php b/app/Support/Binder/CLIToken.php
index a13c7990b6..65c40b9d57 100644
--- a/app/Support/Binder/CLIToken.php
+++ b/app/Support/Binder/CLIToken.php
@@ -51,7 +51,7 @@ class CLIToken implements BinderInterface
foreach ($users as $user) {
$accessToken = app('preferences')->getForUser($user, 'access_token', null);
- if(null !== $accessToken && $accessToken->data === $value) {
+ if (null !== $accessToken && $accessToken->data === $value) {
Log::info(sprintf('Recognized user #%d (%s) from his acccess token.', $user->id, $user->email));
return $value;
diff --git a/app/Support/Binder/TagList.php b/app/Support/Binder/TagList.php
index 6919034293..b6162cf766 100644
--- a/app/Support/Binder/TagList.php
+++ b/app/Support/Binder/TagList.php
@@ -57,10 +57,10 @@ class TagList implements BinderInterface
$collection = $allTags->filter(
function (Tag $tag) use ($list) {
- if(\in_array(strtolower($tag->tag), $list, true)) {
+ if (\in_array(strtolower($tag->tag), $list, true)) {
return true;
}
- if(\in_array((string)$tag->id, $list, true)) {
+ if (\in_array((string)$tag->id, $list, true)) {
return true;
}
diff --git a/app/Support/Binder/TagOrId.php b/app/Support/Binder/TagOrId.php
index 596de5135b..8873dd5eac 100644
--- a/app/Support/Binder/TagOrId.php
+++ b/app/Support/Binder/TagOrId.php
@@ -25,7 +25,6 @@ namespace FireflyIII\Support\Binder;
use FireflyIII\Models\Tag;
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use Illuminate\Routing\Route;
-use Illuminate\Support\Collection;
use Log;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -38,8 +37,7 @@ class TagOrId implements BinderInterface
* @param string $value
* @param Route $route
*
- * @return Collection
- * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
+ * @return Tag
*/
public static function routeBinder(string $value, Route $route): Tag
{
diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php
index e48a35b1be..ce40e55925 100644
--- a/app/Support/ExpandedForm.php
+++ b/app/Support/ExpandedForm.php
@@ -584,8 +584,6 @@ class ExpandedForm
* @param array $options
*
* @return string
- * @throws \FireflyIII\Exceptions\FireflyException
- *
*/
public function nonSelectableAmount(string $name, $value = null, array $options = null): string
{
@@ -914,6 +912,7 @@ class ExpandedForm
}
/** @noinspection MoreThanThreeArgumentsInspection */
+
/**
* @param string $name
* @param string $view
@@ -921,11 +920,9 @@ class ExpandedForm
* @param array $options
*
* @return string
- * @throws FireflyException
- *
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
- protected function currencyField(string $name, string $view, $value = null, array $options = null): string
+ protected function allCurrencyField(string $name, string $view, $value = null, array $options = null): string
{
$label = $this->label($name, $options);
$options = $this->expandOptionArray($name, $label, $options);
@@ -934,7 +931,7 @@ class ExpandedForm
$options['step'] = 'any';
$defaultCurrency = $options['currency'] ?? Amt::getDefaultCurrency();
/** @var Collection $currencies */
- $currencies = app('amount')->getCurrencies();
+ $currencies = app('amount')->getAllCurrencies();
unset($options['currency'], $options['placeholder']);
// perhaps the currency has been sent to us in the field $amount_currency_id_$name (amount_currency_id_amount)
@@ -968,6 +965,7 @@ class ExpandedForm
}
/** @noinspection MoreThanThreeArgumentsInspection */
+
/**
* @param string $name
* @param string $view
@@ -975,11 +973,9 @@ class ExpandedForm
* @param array $options
*
* @return string
- * @throws FireflyException
- *
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
- protected function allCurrencyField(string $name, string $view, $value = null, array $options = null): string
+ protected function currencyField(string $name, string $view, $value = null, array $options = null): string
{
$label = $this->label($name, $options);
$options = $this->expandOptionArray($name, $label, $options);
@@ -988,7 +984,7 @@ class ExpandedForm
$options['step'] = 'any';
$defaultCurrency = $options['currency'] ?? Amt::getDefaultCurrency();
/** @var Collection $currencies */
- $currencies = app('amount')->getAllCurrencies();
+ $currencies = app('amount')->getCurrencies();
unset($options['currency'], $options['placeholder']);
// perhaps the currency has been sent to us in the field $amount_currency_id_$name (amount_currency_id_amount)
diff --git a/app/Support/FinTS/FinTS.php b/app/Support/FinTS/FinTS.php
index 5ec5a94218..456a9f9b07 100644
--- a/app/Support/FinTS/FinTS.php
+++ b/app/Support/FinTS/FinTS.php
@@ -74,7 +74,7 @@ class FinTS
* @return SEPAAccount
* @throws FireflyException
*/
- public function getAccount(string $accountNumber)
+ public function getAccount(string $accountNumber): SEPAAccount
{
$accounts = $this->getAccounts();
$filteredAccounts = array_filter(
@@ -93,7 +93,7 @@ class FinTS
* @return SEPAAccount[]
* @throws FireflyException
*/
- public function getAccounts()
+ public function getAccounts(): ?array
{
try {
return $this->finTS->getSEPAAccounts();
diff --git a/app/Support/Http/Api/AccountFilter.php b/app/Support/Http/Api/AccountFilter.php
index 3e7594c9ec..f9594baf29 100644
--- a/app/Support/Http/Api/AccountFilter.php
+++ b/app/Support/Http/Api/AccountFilter.php
@@ -80,10 +80,7 @@ trait AccountFilter
'cc' => [AccountType::CREDITCARD],
];
- $return = $types['all'];
- if (isset($types[$type])) {
- $return = $types[$type];
- }
+ $return = $types[$type] ?? $types['all'];
return $return; // @codeCoverageIgnore
}
diff --git a/app/Support/Http/Api/TransactionFilter.php b/app/Support/Http/Api/TransactionFilter.php
index 2759945819..109611c416 100644
--- a/app/Support/Http/Api/TransactionFilter.php
+++ b/app/Support/Http/Api/TransactionFilter.php
@@ -58,10 +58,7 @@ trait TransactionFilter
'specials' => [TransactionType::OPENING_BALANCE, TransactionType::RECONCILIATION,],
'default' => [TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER,],
];
- $return = $types['default'];
- if (isset($types[$type])) {
- $return = $types[$type];
- }
+ $return = $types[$type] ?? $types['default'];
return $return;
diff --git a/app/Support/Http/Controllers/AugumentData.php b/app/Support/Http/Controllers/AugumentData.php
index 4fd45db2fb..29ca5dd501 100644
--- a/app/Support/Http/Controllers/AugumentData.php
+++ b/app/Support/Http/Controllers/AugumentData.php
@@ -27,7 +27,6 @@ use Carbon\Carbon;
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
-use FireflyIII\Models\Bill;
use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit;
use FireflyIII\Models\Tag;
@@ -38,8 +37,6 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Illuminate\Support\Collection;
-use Log;
-use Throwable;
/**
* Trait AugumentData
diff --git a/app/Support/Http/Controllers/BasicDataSupport.php b/app/Support/Http/Controllers/BasicDataSupport.php
index 6d578e0780..ac13cba8c7 100644
--- a/app/Support/Http/Controllers/BasicDataSupport.php
+++ b/app/Support/Http/Controllers/BasicDataSupport.php
@@ -30,6 +30,23 @@ namespace FireflyIII\Support\Http\Controllers;
trait BasicDataSupport
{
+ /**
+ * Sum up an array.
+ *
+ * @param array $array
+ *
+ * @return string
+ */
+ protected function arraySum(array $array): string // filter + group data
+ {
+ $sum = '0';
+ foreach ($array as $entry) {
+ $sum = bcadd($sum, $entry);
+ }
+
+ return $sum;
+ }
+
/**
* Filters empty results from getBudgetPeriodReport.
*
@@ -40,7 +57,7 @@ trait BasicDataSupport
protected function filterPeriodReport(array $data): array // helper function for period overview.
{
/**
- * @var int $entryId
+ * @var int $entryId
* @var array $set
*/
foreach ($data as $entryId => $set) {
@@ -56,22 +73,6 @@ trait BasicDataSupport
return $data;
}
- /**
- * Sum up an array.
- *
- * @param array $array
- *
- * @return string
- */
- protected function arraySum(array $array): string // filter + group data
- {
- $sum = '0';
- foreach ($array as $entry) {
- $sum = bcadd($sum, $entry);
- }
-
- return $sum;
- }
/**
* Find the ID in a given array. Return '0' of not there (amount).
@@ -83,10 +84,7 @@ trait BasicDataSupport
*/
protected function isInArray(array $array, int $entryId) // helper for data (math, calculations)
{
- $result = '0';
- if (isset($array[$entryId])) {
- $result = $array[$entryId];
- }
+ $result = $array[$entryId] ?? '0';
return $result;
}
diff --git a/app/Support/Http/Controllers/GetConfigurationData.php b/app/Support/Http/Controllers/GetConfigurationData.php
index c67dd7a000..37a792333c 100644
--- a/app/Support/Http/Controllers/GetConfigurationData.php
+++ b/app/Support/Http/Controllers/GetConfigurationData.php
@@ -51,10 +51,7 @@ trait GetConfigurationData
E_ALL & ~E_NOTICE & ~E_STRICT => 'E_ALL & ~E_NOTICE & ~E_STRICT',
E_COMPILE_ERROR | E_RECOVERABLE_ERROR | E_ERROR | E_CORE_ERROR => 'E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR',
];
- $result = (string)$value;
- if (isset($array[$value])) {
- $result = $array[$value];
- }
+ $result = $array[$value] ?? (string)$value;
return $result;
}
@@ -188,7 +185,7 @@ trait GetConfigurationData
$routeKey = '';
// user is on page with specific instructions:
- if (\strlen($specificPage) > 0) {
+ if ('' !== $specificPage) {
$routeKey = str_replace('.', '_', $route);
$elements = config(sprintf('intro.%s', $routeKey . '_' . $specificPage));
if (\is_array($elements) && \count($elements) > 0) {
diff --git a/app/Support/Http/Controllers/PeriodOverview.php b/app/Support/Http/Controllers/PeriodOverview.php
index 16251024e9..352f0d56bb 100644
--- a/app/Support/Http/Controllers/PeriodOverview.php
+++ b/app/Support/Http/Controllers/PeriodOverview.php
@@ -351,7 +351,9 @@ trait PeriodOverview
/**
* This shows a period overview for a tag. It goes back in time and lists all relevant transactions and sums.
*
- * @param Tag $tag
+ * @param Tag $tag
+ *
+ * @param Carbon $date
*
* @return Collection
*/
diff --git a/app/Support/Http/Controllers/RenderPartialViews.php b/app/Support/Http/Controllers/RenderPartialViews.php
index 384116ece4..2b74f5d64e 100644
--- a/app/Support/Http/Controllers/RenderPartialViews.php
+++ b/app/Support/Http/Controllers/RenderPartialViews.php
@@ -305,8 +305,8 @@ trait RenderPartialViews
*/
protected function getCurrentTriggers(Rule $rule): array // get info from object and present.
{
- $index = 0;
- $triggers = [];
+ $index = 0;
+ $triggers = [];
// todo must be repos
$currentTriggers = $rule->ruleTriggers()->orderBy('order', 'ASC')->get();
/** @var RuleTrigger $entry */
diff --git a/app/Support/Http/Controllers/RequestInformation.php b/app/Support/Http/Controllers/RequestInformation.php
index b3c0d29cb1..b4a9af27ea 100644
--- a/app/Support/Http/Controllers/RequestInformation.php
+++ b/app/Support/Http/Controllers/RequestInformation.php
@@ -54,44 +54,6 @@ use Symfony\Component\HttpFoundation\ParameterBag;
*/
trait RequestInformation
{
- /**
- * Get info from old input.
- *
- * @param $array
- * @param $old
- *
- * @return array
- *
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
- * @SuppressWarnings(PHPMD.CyclomaticComplexity)
- */
- protected function updateWithPrevious($array, $old): array // update object with new info
- {
- if (0 === \count($old) || !isset($old['transactions'])) {
- return $array;
- }
- $old = $old['transactions'];
-
- foreach ($old as $index => $row) {
- if (isset($array[$index])) {
- /** @noinspection SlowArrayOperationsInLoopInspection */
- $array[$index] = array_merge($array[$index], $row);
- continue;
- }
- // take some info from first transaction, that should at least exist.
- $array[$index] = $row;
- $array[$index]['currency_id'] = $array[0]['currency_id'];
- $array[$index]['currency_code'] = $array[0]['currency_code'] ?? '';
- $array[$index]['currency_symbol'] = $array[0]['currency_symbol'] ?? '';
- $array[$index]['foreign_amount'] = round($array[0]['foreign_destination_amount'] ?? '0', 12);
- $array[$index]['foreign_currency_id'] = $array[0]['foreign_currency_id'];
- $array[$index]['foreign_currency_code'] = $array[0]['foreign_currency_code'];
- $array[$index]['foreign_currency_symbol'] = $array[0]['foreign_currency_symbol'];
- }
-
- return $array;
- }
-
/**
* Create data-array from a journal.
*
@@ -104,7 +66,7 @@ trait RequestInformation
protected function arrayFromJournal(Request $request, TransactionJournal $journal): array // convert user input.
{
/** @var JournalRepositoryInterface $repository */
- $repository = app(JournalRepositoryInterface::class);
+ $repository = app(JournalRepositoryInterface::class);
$sourceAccounts = $repository->getJournalSourceAccounts($journal);
$destinationAccounts = $repository->getJournalDestinationAccounts($journal);
$array = [
@@ -400,6 +362,44 @@ trait RequestInformation
return $attributes;
}
+ /**
+ * Get info from old input.
+ *
+ * @param $array
+ * @param $old
+ *
+ * @return array
+ *
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
+ */
+ protected function updateWithPrevious($array, $old): array // update object with new info
+ {
+ if (0 === \count($old) || !isset($old['transactions'])) {
+ return $array;
+ }
+ $old = $old['transactions'];
+
+ foreach ($old as $index => $row) {
+ if (isset($array[$index])) {
+ /** @noinspection SlowArrayOperationsInLoopInspection */
+ $array[$index] = array_merge($array[$index], $row);
+ continue;
+ }
+ // take some info from first transaction, that should at least exist.
+ $array[$index] = $row;
+ $array[$index]['currency_id'] = $array[0]['currency_id'];
+ $array[$index]['currency_code'] = $array[0]['currency_code'] ?? '';
+ $array[$index]['currency_symbol'] = $array[0]['currency_symbol'] ?? '';
+ $array[$index]['foreign_amount'] = round($array[0]['foreign_destination_amount'] ?? '0', 12);
+ $array[$index]['foreign_currency_id'] = $array[0]['foreign_currency_id'];
+ $array[$index]['foreign_currency_code'] = $array[0]['foreign_currency_code'];
+ $array[$index]['foreign_currency_symbol'] = $array[0]['foreign_currency_symbol'];
+ }
+
+ return $array;
+ }
+
/**
* Validate users new password.
*
diff --git a/app/Support/Import/JobConfiguration/File/ConfigureRolesHandler.php b/app/Support/Import/JobConfiguration/File/ConfigureRolesHandler.php
index f7bd4578a8..c7e0fa14e0 100644
--- a/app/Support/Import/JobConfiguration/File/ConfigureRolesHandler.php
+++ b/app/Support/Import/JobConfiguration/File/ConfigureRolesHandler.php
@@ -151,7 +151,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface
{
foreach ($line as $column => $value) {
$value = trim($value);
- if (\strlen($value) > 0) {
+ if ('' != $value) {
$this->examples[$column][] = $value;
}
}
@@ -219,7 +219,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface
try {
$stmt = (new Statement)->limit(1)->offset(0);
$records = $stmt->process($reader);
- $headers = $records->fetchOne(0);
+ $headers = $records->fetchOne();
// @codeCoverageIgnoreStart
} catch (Exception $e) {
Log::error($e->getMessage());
diff --git a/app/Support/Import/JobConfiguration/FinTS/ChooseAccountHandler.php b/app/Support/Import/JobConfiguration/FinTS/ChooseAccountHandler.php
index dcfcbdc4ff..67ac1caaab 100644
--- a/app/Support/Import/JobConfiguration/FinTS/ChooseAccountHandler.php
+++ b/app/Support/Import/JobConfiguration/FinTS/ChooseAccountHandler.php
@@ -78,7 +78,6 @@ class ChooseAccountHandler implements FinTSConfigurationInterface
* Get the data necessary to show the configuration screen.
*
* @return array
- * @throws \FireflyIII\Exceptions\FireflyException
*/
public function getNextData(): array
{
diff --git a/app/Support/Import/JobConfiguration/FinTS/NewFinTSJobHandler.php b/app/Support/Import/JobConfiguration/FinTS/NewFinTSJobHandler.php
index d5ccb9286a..2c688158e0 100644
--- a/app/Support/Import/JobConfiguration/FinTS/NewFinTSJobHandler.php
+++ b/app/Support/Import/JobConfiguration/FinTS/NewFinTSJobHandler.php
@@ -48,7 +48,6 @@ class NewFinTSJobHandler implements FinTSConfigurationInterface
* @param array $data
*
* @return MessageBag
- * @throws \FireflyIII\Exceptions\FireflyException
*/
public function configureJob(array $data): MessageBag
{
diff --git a/app/Support/Import/JobConfiguration/Ynab/NewYnabJobHandler.php b/app/Support/Import/JobConfiguration/Ynab/NewYnabJobHandler.php
index 4291309779..06e38d875d 100644
--- a/app/Support/Import/JobConfiguration/Ynab/NewYnabJobHandler.php
+++ b/app/Support/Import/JobConfiguration/Ynab/NewYnabJobHandler.php
@@ -152,7 +152,7 @@ class NewYnabJobHandler implements YnabJobConfigurationInterface
$client = new Client();
try {
- $res = $client->request('post', $uri, []);
+ $res = $client->request('post', $uri);
} catch (GuzzleException $e) {
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
diff --git a/app/Support/Import/JobConfiguration/Ynab/SelectAccountsHandler.php b/app/Support/Import/JobConfiguration/Ynab/SelectAccountsHandler.php
index bc48b7e615..87dc940a14 100644
--- a/app/Support/Import/JobConfiguration/Ynab/SelectAccountsHandler.php
+++ b/app/Support/Import/JobConfiguration/Ynab/SelectAccountsHandler.php
@@ -88,7 +88,7 @@ class SelectAccountsHandler implements YnabJobConfigurationInterface
// validate each
$ynabId = $this->validYnabAccount($ynabId);
$accountId = $this->validLocalAccount((int)$localId);
- if ($accountId !== 0) {
+ if (0 !== $accountId) {
$final[$ynabId] = $accountId;
}
}
diff --git a/app/Support/Import/Placeholder/ImportTransaction.php b/app/Support/Import/Placeholder/ImportTransaction.php
index ac88df518a..6a4204b24a 100644
--- a/app/Support/Import/Placeholder/ImportTransaction.php
+++ b/app/Support/Import/Placeholder/ImportTransaction.php
@@ -186,7 +186,7 @@ class ImportTransaction
}
$meta = ['sepa-ct-id', 'sepa-ct-op', 'sepa-db', 'sepa-cc', 'sepa-country', 'sepa-batch-id', 'sepa-ep', 'sepa-ci', 'internal-reference', 'date-interest',
- 'date-invoice', 'date-book', 'date-payment', 'date-process', 'date-due','original-source'];
+ 'date-invoice', 'date-book', 'date-payment', 'date-process', 'date-due', 'original-source'];
Log::debug(sprintf('Now going to check role "%s".', $role));
if (\in_array($role, $meta, true)) {
Log::debug(sprintf('Role "%s" is in allowed meta roles, so store its value "%s".', $role, $columnValue->getValue()));
diff --git a/app/Support/Import/Routine/Bunq/PaymentConverter.php b/app/Support/Import/Routine/Bunq/PaymentConverter.php
index e37da1ecaf..8345f8561c 100644
--- a/app/Support/Import/Routine/Bunq/PaymentConverter.php
+++ b/app/Support/Import/Routine/Bunq/PaymentConverter.php
@@ -65,7 +65,9 @@ class PaymentConverter
/**
* Convert a bunq transaction to a usable transaction for Firefly III.
*
- * @param BunqPayment $payment
+ * @param BunqPayment $payment
+ *
+ * @param LocalAccount $source
*
* @return array
* @throws FireflyException
diff --git a/app/Support/Import/Routine/Fake/StageFinalHandler.php b/app/Support/Import/Routine/Fake/StageFinalHandler.php
index 11cf6962f3..aea3f756de 100644
--- a/app/Support/Import/Routine/Fake/StageFinalHandler.php
+++ b/app/Support/Import/Routine/Fake/StageFinalHandler.php
@@ -39,6 +39,7 @@ class StageFinalHandler
/**
* @return array
+ * @throws \Exception
*/
public function getTransactions(): array
{
diff --git a/app/Support/Import/Routine/File/MappingConverger.php b/app/Support/Import/Routine/File/MappingConverger.php
index bf855707dd..c16afd9e2d 100644
--- a/app/Support/Import/Routine/File/MappingConverger.php
+++ b/app/Support/Import/Routine/File/MappingConverger.php
@@ -183,7 +183,7 @@ class MappingConverger
$value = trim($value);
$originalRole = $this->roles[$columnIndex] ?? '_ignore';
Log::debug(sprintf('Now at column #%d (%s), value "%s"', $columnIndex, $originalRole, $value));
- if ('_ignore' !== $originalRole && \strlen($value) > 0) {
+ if ('_ignore' !== $originalRole && '' != $value) {
// is a mapped value present?
$mapped = $this->mapping[$columnIndex][$value] ?? 0;
diff --git a/app/Support/Import/Routine/FinTS/StageImportDataHandler.php b/app/Support/Import/Routine/FinTS/StageImportDataHandler.php
index d11d8b1c86..7933aa9aea 100644
--- a/app/Support/Import/Routine/FinTS/StageImportDataHandler.php
+++ b/app/Support/Import/Routine/FinTS/StageImportDataHandler.php
@@ -66,13 +66,13 @@ class StageImportDataHandler
/**
* @throws FireflyException
*/
- public function run()
+ public function run(): void
{
Log::debug('Now in StageImportDataHandler::run()');
$localAccount = $this->accountRepository->findNull((int)$this->importJob->configuration['local_account']);
if (null === $localAccount) {
- throw new FireflyException(sprintf('Cannot find Firefly account with id #%d ' , $this->importJob->configuration['local_account']));
+ throw new FireflyException(sprintf('Cannot find Firefly account with id #%d ', $this->importJob->configuration['local_account']));
}
$finTS = app(FinTS::class, ['config' => $this->importJob->configuration]);
$fintTSAccount = $finTS->getAccount($this->importJob->configuration['fints_account']);
@@ -143,8 +143,8 @@ class StageImportDataHandler
}
$metadataParser = new MetadataParser();
- $description = $metadataParser->getDescription($transaction);
-
+ $description = $metadataParser->getDescription($transaction);
+
$storeData = [
'user' => $this->importJob->user_id,
'type' => $type,
diff --git a/app/Support/Import/Routine/Spectre/StageImportDataHandler.php b/app/Support/Import/Routine/Spectre/StageImportDataHandler.php
index 443b889fd6..f92da203ed 100644
--- a/app/Support/Import/Routine/Spectre/StageImportDataHandler.php
+++ b/app/Support/Import/Routine/Spectre/StageImportDataHandler.php
@@ -233,8 +233,10 @@ class StageImportDataHandler
if (null === $account) {
throw new FireflyException(sprintf('Cannot find Firefly III asset account with ID #%d. Job must stop now.', $accountId)); // @codeCoverageIgnore
}
- if (!\in_array($account->accountType->type ,[AccountType::ASSET, AccountType::LOAN, AccountType::MORTGAGE, AccountType::DEBT], true)) {
- throw new FireflyException(sprintf('Account with ID #%d is not an asset/loan/mortgage/debt account. Job must stop now.', $accountId)); // @codeCoverageIgnore
+ if (!\in_array($account->accountType->type, [AccountType::ASSET, AccountType::LOAN, AccountType::MORTGAGE, AccountType::DEBT], true)) {
+ throw new FireflyException(
+ sprintf('Account with ID #%d is not an asset/loan/mortgage/debt account. Job must stop now.', $accountId)
+ ); // @codeCoverageIgnore
}
return $account;
diff --git a/app/Support/Logging/AuditLogger.php b/app/Support/Logging/AuditLogger.php
index 1f303c63cf..1c17d6c37c 100644
--- a/app/Support/Logging/AuditLogger.php
+++ b/app/Support/Logging/AuditLogger.php
@@ -38,7 +38,7 @@ class AuditLogger
*/
public function __invoke($logger)
{
- $processor = new AuditProcessor;
+ $processor = new AuditProcessor;
$logger->pushProcessor($processor);
}
}
diff --git a/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php b/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php
index 4f8dfb0d62..aab5bf92ec 100644
--- a/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php
+++ b/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php
@@ -184,6 +184,7 @@ trait CalculateRangeOccurrences
return $return;
}
+
/**
* Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences.
*
diff --git a/app/Support/Repositories/Recurring/CalculateXOccurrences.php b/app/Support/Repositories/Recurring/CalculateXOccurrences.php
index b640b1475d..3404cf0cad 100644
--- a/app/Support/Repositories/Recurring/CalculateXOccurrences.php
+++ b/app/Support/Repositories/Recurring/CalculateXOccurrences.php
@@ -76,10 +76,10 @@ trait CalculateXOccurrences
*/
protected function getXMonthlyOccurrences(Carbon $date, int $count, int $skipMod, string $moment): array
{
- $return = [];
- $mutator = clone $date;
- $total = 0;
- $attempts = 0;
+ $return = [];
+ $mutator = clone $date;
+ $total = 0;
+ $attempts = 0;
$dayOfMonth = (int)$moment;
if ($mutator->day > $dayOfMonth) {
// day has passed already, add a month.
diff --git a/app/Support/Search/Search.php b/app/Support/Search/Search.php
index 5a73e649ec..43477c3180 100644
--- a/app/Support/Search/Search.php
+++ b/app/Support/Search/Search.php
@@ -99,7 +99,7 @@ class Search implements SearchInterface
$filteredQuery = str_replace($match, '', $filteredQuery);
}
$filteredQuery = trim(str_replace(['"', "'"], '', $filteredQuery));
- if (\strlen($filteredQuery) > 0) {
+ if ('' != $filteredQuery) {
$this->words = array_map('trim', explode(' ', $filteredQuery));
}
}
@@ -251,7 +251,7 @@ class Search implements SearchInterface
private function extractModifier(string $string): void
{
$parts = explode(':', $string);
- if (2 === \count($parts) && '' !== trim((string)$parts[1]) && \strlen(trim((string)$parts[0])) > 0) {
+ if (2 === \count($parts) && '' !== trim((string)$parts[1]) && '' !== trim((string)$parts[0])) {
$type = trim((string)$parts[0]);
$value = trim((string)$parts[1]);
if (\in_array($type, $this->validModifiers, true)) {
diff --git a/app/Support/Steam.php b/app/Support/Steam.php
index 73362b1f50..5de283f50d 100644
--- a/app/Support/Steam.php
+++ b/app/Support/Steam.php
@@ -23,12 +23,10 @@ declare(strict_types=1);
namespace FireflyIII\Support;
use Carbon\Carbon;
-use Crypt;
use DB;
use FireflyIII\Models\Account;
use FireflyIII\Models\Transaction;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
-use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Support\Collection;
use stdClass;
@@ -223,7 +221,7 @@ class Steam
* @param \FireflyIII\Models\Account $account
* @param \Carbon\Carbon $date
*
- * @return string
+ * @return array
*/
public function balancePerCurrency(Account $account, Carbon $date): array
{
diff --git a/app/Support/Twig/Extension/Transaction.php b/app/Support/Twig/Extension/Transaction.php
index 5ce96139e8..9137ee1e9f 100644
--- a/app/Support/Twig/Extension/Transaction.php
+++ b/app/Support/Twig/Extension/Transaction.php
@@ -206,7 +206,7 @@ class Transaction extends Twig_Extension
public function description(TransactionModel $transaction): string
{
$description = $transaction->description;
- if (\strlen((string)$transaction->transaction_description) > 0) {
+ if ('' !== (string)$transaction->transaction_description) {
$description = $transaction->transaction_description . ' (' . $transaction->description . ')';
}
diff --git a/app/Support/Twig/Extension/TransactionJournal.php b/app/Support/Twig/Extension/TransactionJournal.php
index 59e15cfbe6..4e1ee4be73 100644
--- a/app/Support/Twig/Extension/TransactionJournal.php
+++ b/app/Support/Twig/Extension/TransactionJournal.php
@@ -158,8 +158,8 @@ class TransactionJournal extends Twig_Extension
if (null !== $transaction->foreign_currency_id) {
$foreignAmount = $transaction->foreign_amount ?? '0';
- $foreignId = $transaction->foreign_currency_id;
- $foreign = $transaction->foreignCurrency;
+ $foreignId = $transaction->foreign_currency_id;
+ $foreign = $transaction->foreignCurrency;
if (!isset($totals[$foreignId])) {
$totals[$foreignId] = [
'amount' => '0',
diff --git a/app/TransactionRules/Actions/ConvertToDeposit.php b/app/TransactionRules/Actions/ConvertToDeposit.php
index b5f5321a1d..f06ce92b41 100644
--- a/app/TransactionRules/Actions/ConvertToDeposit.php
+++ b/app/TransactionRules/Actions/ConvertToDeposit.php
@@ -102,10 +102,12 @@ class ConvertToDeposit implements ActionInterface
if (TransactionType::WITHDRAWAL === $type) {
Log::debug('Going to transform a withdrawal to a deposit.');
+
return $this->convertWithdrawal($journal);
}
if (TransactionType::TRANSFER === $type) {
Log::debug('Going to transform a transfer to a deposit.');
+
return $this->convertTransfer($journal);
}
@@ -133,7 +135,7 @@ class ConvertToDeposit implements ActionInterface
// get the action value, or use the original source name in case the action value is empty:
// this becomes a new or existing revenue account.
/** @var Account $source */
- $source = $sourceTransactions->first()->account;
+ $source = $sourceTransactions->first()->account;
$revenueName = '' === $this->action->action_value ? $source->name : $this->action->action_value;
$revenue = $factory->findOrCreate($revenueName, AccountType::REVENUE);
diff --git a/app/TransactionRules/Processor.php b/app/TransactionRules/Processor.php
index 8ff61c2b46..ec0ded8198 100644
--- a/app/TransactionRules/Processor.php
+++ b/app/TransactionRules/Processor.php
@@ -62,22 +62,6 @@ class Processor
$this->actions = new Collection;
}
- /**
- * @return bool
- */
- public function isStrict(): bool
- {
- return $this->strict;
- }
-
- /**
- * @param bool $strict
- */
- public function setStrict(bool $strict): void
- {
- $this->strict = $strict;
- }
-
/**
* Return found triggers
*
@@ -170,6 +154,22 @@ class Processor
return false;
}
+ /**
+ * @return bool
+ */
+ public function isStrict(): bool
+ {
+ return $this->strict;
+ }
+
+ /**
+ * @param bool $strict
+ */
+ public function setStrict(bool $strict): void
+ {
+ $this->strict = $strict;
+ }
+
/**
* This method will make a Processor that will process each transaction journal using the triggers
* and actions found in the given Rule.
diff --git a/app/TransactionRules/TransactionMatcher.php b/app/TransactionRules/TransactionMatcher.php
index 920642dd28..b4b568879b 100644
--- a/app/TransactionRules/TransactionMatcher.php
+++ b/app/TransactionRules/TransactionMatcher.php
@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\TransactionRules;
use Carbon\Carbon;
-use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
use FireflyIII\Helpers\Filter\InternalTransferFilter;
use FireflyIII\Models\Rule;
@@ -69,10 +68,8 @@ class TransactionMatcher
*/
public function __construct()
{
- $this->strict = false;
- $this->startDate = null;
- $this->endDate = null;
- $this->accounts = new Collection;
+ $this->strict = false;
+ $this->accounts = new Collection;
Log::debug('Created new transaction matcher');
}
@@ -89,6 +86,7 @@ class TransactionMatcher
Log::debug('Now in findTransactionsByRule()');
if (0 === \count($this->rule->ruleTriggers)) {
Log::error('Rule has no triggers!');
+
return new Collection;
}
@@ -290,7 +288,7 @@ class TransactionMatcher
if ($this->accounts->count() > 0) {
$collector->setAccounts($this->accounts);
}
- if(null !== $this->startDate && null !== $this->endDate) {
+ if (null !== $this->startDate && null !== $this->endDate) {
$collector->setRange($this->startDate, $this->endDate);
}
diff --git a/app/TransactionRules/Triggers/NotesAny.php b/app/TransactionRules/Triggers/NotesAny.php
index b30c93a564..02cce26d53 100644
--- a/app/TransactionRules/Triggers/NotesAny.php
+++ b/app/TransactionRules/Triggers/NotesAny.php
@@ -68,7 +68,7 @@ final class NotesAny extends AbstractTrigger implements TriggerInterface
$text = $note->text;
}
- if (\strlen($text) > 0) {
+ if ('' !== $text) {
Log::debug(sprintf('RuleTrigger NotesEmpty for journal #%d: strlen > 0, return true.', $journal->id));
return true;
diff --git a/app/TransactionRules/Triggers/NotesAre.php b/app/TransactionRules/Triggers/NotesAre.php
index d08ff753bd..5989d7236c 100644
--- a/app/TransactionRules/Triggers/NotesAre.php
+++ b/app/TransactionRules/Triggers/NotesAre.php
@@ -75,7 +75,7 @@ final class NotesAre extends AbstractTrigger implements TriggerInterface
}
$search = strtolower($this->triggerValue);
- if ($text === $search && \strlen($text) > 0) {
+ if ($text === $search && '' != $text) {
Log::debug(sprintf('RuleTrigger NotesAre for journal #%d: "%s" is "%s", return true.', $journal->id, $text, $search));
return true;
diff --git a/app/Transformers/AttachmentTransformer.php b/app/Transformers/AttachmentTransformer.php
index 322c206a89..aedb1598ea 100644
--- a/app/Transformers/AttachmentTransformer.php
+++ b/app/Transformers/AttachmentTransformer.php
@@ -26,9 +26,7 @@ namespace FireflyIII\Transformers;
use FireflyIII\Models\Attachment;
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
-use League\Fractal\TransformerAbstract;
use Log;
-use Symfony\Component\HttpFoundation\ParameterBag;
/**
* Class AttachmentTransformer
@@ -67,7 +65,7 @@ class AttachmentTransformer extends AbstractTransformer
'created_at' => $attachment->created_at->toAtomString(),
'updated_at' => $attachment->updated_at->toAtomString(),
'attachable_id' => $attachment->attachable_id,
- 'attachable_type' => str_replace('FireflyIII\\Models\\','',$attachment->attachable_type),
+ 'attachable_type' => str_replace('FireflyIII\\Models\\', '', $attachment->attachable_type),
'md5' => $attachment->md5,
'filename' => $attachment->filename,
'download_uri' => route('api.v1.attachments.download', [$attachment->id]),
diff --git a/app/Transformers/AvailableBudgetTransformer.php b/app/Transformers/AvailableBudgetTransformer.php
index 845eba5f91..8043a07513 100644
--- a/app/Transformers/AvailableBudgetTransformer.php
+++ b/app/Transformers/AvailableBudgetTransformer.php
@@ -86,7 +86,7 @@ class AvailableBudgetTransformer extends AbstractTransformer
$end = $this->parameters->get('end');
if (null !== $start && null !== $end) {
$data['spent_in_budgets'] = $this->getSpentInBudgets();
- $data['spent_no_budget'] = $this->spentOutsideBudgets();
+ $data['spent_no_budget'] = $this->spentOutsideBudgets();
}
return $data;
@@ -98,6 +98,7 @@ class AvailableBudgetTransformer extends AbstractTransformer
private function getSpentInBudgets(): array
{
$allActive = $this->repository->getActiveBudgets();
+
return $this->repository->spentInPeriodMc(
$allActive, new Collection, $this->parameters->get('start'), $this->parameters->get('end')
);
@@ -109,7 +110,7 @@ class AvailableBudgetTransformer extends AbstractTransformer
*/
private function spentOutsideBudgets(): array
{
- return $this->repository->spentInPeriodWoBudgetMc(new Collection,$this->parameters->get('start'), $this->parameters->get('end'));
+ return $this->repository->spentInPeriodWoBudgetMc(new Collection, $this->parameters->get('start'), $this->parameters->get('end'));
}
}
diff --git a/app/Transformers/CurrencyTransformer.php b/app/Transformers/CurrencyTransformer.php
index 3c8bfbe8c6..0525106d0f 100644
--- a/app/Transformers/CurrencyTransformer.php
+++ b/app/Transformers/CurrencyTransformer.php
@@ -24,9 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Transformers;
use FireflyIII\Models\TransactionCurrency;
-use League\Fractal\TransformerAbstract;
use Log;
-use Symfony\Component\HttpFoundation\ParameterBag;
/**
* Class CurrencyTransformer
diff --git a/app/Transformers/ImportJobTransformer.php b/app/Transformers/ImportJobTransformer.php
index a726e96074..a9356c7e38 100644
--- a/app/Transformers/ImportJobTransformer.php
+++ b/app/Transformers/ImportJobTransformer.php
@@ -25,9 +25,7 @@ namespace FireflyIII\Transformers;
use FireflyIII\Models\ImportJob;
-use League\Fractal\TransformerAbstract;
use Log;
-use Symfony\Component\HttpFoundation\ParameterBag;
/**
* Class ImportJobTransformer
@@ -56,11 +54,11 @@ class ImportJobTransformer extends AbstractTransformer
*/
public function transform(ImportJob $importJob): array
{
- $tag= $importJob->tag;
- $tagId = null;
+ $tag = $importJob->tag;
+ $tagId = null;
$tagTag = null;
- if(null !== $tag) {
- $tagId = $tag->id;
+ if (null !== $tag) {
+ $tagId = $tag->id;
$tagTag = $tag->tag;
}
$data = [
@@ -79,7 +77,7 @@ class ImportJobTransformer extends AbstractTransformer
'transactions' => json_encode($importJob->transactions),
'errors' => json_encode($importJob->errors),
- 'links' => [
+ 'links' => [
[
'rel' => 'self',
'uri' => '/import/' . $importJob->key,
diff --git a/app/Transformers/LinkTypeTransformer.php b/app/Transformers/LinkTypeTransformer.php
index afbd34353a..6471d7b07f 100644
--- a/app/Transformers/LinkTypeTransformer.php
+++ b/app/Transformers/LinkTypeTransformer.php
@@ -25,9 +25,7 @@ namespace FireflyIII\Transformers;
use FireflyIII\Models\LinkType;
-use League\Fractal\TransformerAbstract;
use Log;
-use Symfony\Component\HttpFoundation\ParameterBag;
/**
*
diff --git a/app/Transformers/PreferenceTransformer.php b/app/Transformers/PreferenceTransformer.php
index 54f8a2f6e7..3087487da6 100644
--- a/app/Transformers/PreferenceTransformer.php
+++ b/app/Transformers/PreferenceTransformer.php
@@ -25,9 +25,7 @@ namespace FireflyIII\Transformers;
use FireflyIII\Models\Preference;
-use League\Fractal\TransformerAbstract;
use Log;
-use Symfony\Component\HttpFoundation\ParameterBag;
/**
* Class PreferenceTransformer
diff --git a/app/Transformers/RecurrenceTransformer.php b/app/Transformers/RecurrenceTransformer.php
index 4cc8c8f142..ee11a0a81f 100644
--- a/app/Transformers/RecurrenceTransformer.php
+++ b/app/Transformers/RecurrenceTransformer.php
@@ -127,7 +127,6 @@ class RecurrenceTransformer extends AbstractTransformer
* @param Recurrence $recurrence
*
* @return array
- * @throws FireflyException
*/
private function getMeta(Recurrence $recurrence): array
{
@@ -211,7 +210,6 @@ class RecurrenceTransformer extends AbstractTransformer
* @param RecurrenceTransaction $transaction
*
* @return array
- * @throws FireflyException
*/
private function getTransactionMeta(RecurrenceTransaction $transaction): array
{
diff --git a/app/Transformers/RuleGroupTransformer.php b/app/Transformers/RuleGroupTransformer.php
index f291220c8a..c8a0a87f5f 100644
--- a/app/Transformers/RuleGroupTransformer.php
+++ b/app/Transformers/RuleGroupTransformer.php
@@ -24,9 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Transformers;
use FireflyIII\Models\RuleGroup;
-use League\Fractal\TransformerAbstract;
use Log;
-use Symfony\Component\HttpFoundation\ParameterBag;
/**
* Class RuleGroupTransformer
diff --git a/app/Transformers/TagTransformer.php b/app/Transformers/TagTransformer.php
index 10f0a8b49f..54c9063f03 100644
--- a/app/Transformers/TagTransformer.php
+++ b/app/Transformers/TagTransformer.php
@@ -24,13 +24,8 @@ declare(strict_types=1);
namespace FireflyIII\Transformers;
-use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
use FireflyIII\Models\Tag;
-use League\Fractal\Resource\Collection as FractalCollection;
-use League\Fractal\Resource\Item;
-use League\Fractal\TransformerAbstract;
use Log;
-use Symfony\Component\HttpFoundation\ParameterBag;
/**
* Class TagTransformer
@@ -69,7 +64,7 @@ class TagTransformer extends AbstractTransformer
'date' => $date,
'description' => '' === $tag->description ? null : $tag->description,
'latitude' => null === $tag->latitude ? null : (float)$tag->latitude,
- 'longitude' => null === $tag->longitude? null : (float)$tag->longitude,
+ 'longitude' => null === $tag->longitude ? null : (float)$tag->longitude,
'zoom_level' => null === $tag->zoomLevel ? null : (int)$tag->zoomLevel,
'links' => [
[
diff --git a/app/Transformers/UserTransformer.php b/app/Transformers/UserTransformer.php
index f1d0e3c6fc..78487e2265 100644
--- a/app/Transformers/UserTransformer.php
+++ b/app/Transformers/UserTransformer.php
@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Transformers;
-use FireflyIII\Models\Role;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User;
use Log;
@@ -36,6 +35,7 @@ class UserTransformer extends AbstractTransformer
{
/** @var UserRepositoryInterface */
private $repository;
+
/**
* UserTransformer constructor.
*
diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php
index 66a9e571fe..49a6d95749 100644
--- a/app/Validation/FireflyValidator.php
+++ b/app/Validation/FireflyValidator.php
@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Validation;
use Config;
-use Crypt;
use DB;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountMeta;
@@ -38,7 +37,6 @@ use FireflyIII\Services\Password\Verifier;
use FireflyIII\TransactionRules\Triggers\TriggerInterface;
use FireflyIII\User;
use Google2FA;
-use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Support\Collection;
use Illuminate\Validation\Validator;
@@ -562,7 +560,6 @@ class FireflyValidator extends Validator
$type = $existingAccount->accountType;
$ignore = $existingAccount->id;
- $value = $value;
/** @var Collection $set */
$set = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();
diff --git a/tests/Unit/Support/Import/Routine/File/ImportableConverterTest.php b/tests/Unit/Support/Import/Routine/File/ImportableConverterTest.php
index b43659a3aa..1a6d6a7008 100644
--- a/tests/Unit/Support/Import/Routine/File/ImportableConverterTest.php
+++ b/tests/Unit/Support/Import/Routine/File/ImportableConverterTest.php
@@ -114,7 +114,7 @@ class ImportableConverterTest extends TestCase
// verify content of $result
$this->assertEquals('withdrawal', $result[0]['type']);
- $this->assertEquals('2018-09-17', $result[0]['date']);
+ $this->assertEquals('2018-09-17 00:00:00', $result[0]['date']);
$this->assertEquals($importable->tags, $result[0]['tags']);
$this->assertEquals($usd->id, $result[0]['transactions'][0]['currency_id']);
}
@@ -177,7 +177,7 @@ class ImportableConverterTest extends TestCase
// verify content of $result
$today = new Carbon();
$this->assertEquals('transfer', $result[0]['type']);
- $this->assertEquals($today->format('Y-m-d'), $result[0]['date']);
+ $this->assertEquals($today->format('Y-m-d H:i:s'), $result[0]['date']);
$this->assertEquals([], $result[0]['tags']);
$this->assertEquals($euro->id, $result[0]['transactions'][0]['currency_id']);
}
@@ -238,12 +238,12 @@ class ImportableConverterTest extends TestCase
// verify content of $result
$this->assertEquals('deposit', $result[0]['type']);
- $this->assertEquals('2018-09-17', $result[0]['date']);
+ $this->assertEquals('2018-09-17 00:00:00', $result[0]['date']);
$this->assertEquals([], $result[0]['tags']);
$this->assertEquals($usd->id, $result[0]['transactions'][0]['currency_id']);
$this->assertEquals($revenue->id, $result[0]['transactions'][0]['source_id']);
$this->assertEquals($asset->id, $result[0]['transactions'][0]['destination_id']);
- $this->assertEquals('2018-01-02', $result[0]['book_date']);
+ $this->assertEquals('2018-01-02 00:00:00', $result[0]['book_date']);
}
@@ -362,7 +362,7 @@ class ImportableConverterTest extends TestCase
// verify content of $result
$this->assertEquals('transfer', $result[0]['type']);
- $this->assertEquals('2018-09-17', $result[0]['date']);
+ $this->assertEquals('2018-09-17 00:00:00', $result[0]['date']);
$this->assertEquals([], $result[0]['tags']);
$this->assertEquals(2, $result[0]['bill_id']); // will NOT be ignored.
$this->assertEquals($importable->billName, $result[0]['bill_name']);
@@ -435,7 +435,7 @@ class ImportableConverterTest extends TestCase
// verify content of $result
$this->assertEquals('transfer', $result[0]['type']);
- $this->assertEquals('2018-09-17', $result[0]['date']);
+ $this->assertEquals('2018-09-17 00:00:00', $result[0]['date']);
$this->assertEquals([], $result[0]['tags']);
$this->assertEquals(3, $result[0]['bill_id']);
$this->assertEquals($importable->billName, $result[0]['bill_name']);