From 8c6972d12d7b3f309eafa3f07c76f070ee02b280 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 25 Feb 2017 05:57:01 +0100 Subject: [PATCH] Various code cleanup. --- .../Collector/JournalExportCollector.php | 1 - app/Export/Entry/Entry.php | 1 - app/Generator/Report/Support.php | 40 ++++++------- .../Attachments/AttachmentHelperInterface.php | 2 + app/Helpers/Collector/JournalCollector.php | 28 ++++----- .../Controllers/Auth/RegisterController.php | 5 +- .../Controllers/Auth/TwoFactorController.php | 4 +- app/Http/Controllers/BudgetController.php | 5 +- .../Chart/BudgetReportController.php | 18 +----- .../Controllers/Chart/CategoryController.php | 58 +++++++++---------- app/Http/Controllers/CurrencyController.php | 4 ++ app/Http/Controllers/ExportController.php | 3 +- app/Http/Controllers/JavascriptController.php | 2 + app/Http/Controllers/JsonController.php | 2 + app/Http/Controllers/SearchController.php | 2 +- app/Http/Controllers/TagController.php | 2 +- .../RedirectIfTwoFactorAuthenticated.php | 6 +- app/Http/Middleware/Sandstorm.php | 36 +++--------- app/Import/Mapper/TransactionCurrencies.php | 4 +- app/Models/LimitRepetition.php | 21 ------- app/Models/PiggyBank.php | 24 ++++---- .../Account/AccountRepository.php | 3 +- app/Repositories/Bill/BillRepository.php | 3 +- .../Currency/CurrencyRepository.php | 1 + .../PiggyBank/PiggyBankRepository.php | 4 +- app/Support/Twig/PiggyBank.php | 2 +- app/Support/Twig/Transaction.php | 1 - public/js/ff/export/index.js | 2 +- public/js/ff/piggy-banks/index.js | 2 +- public/js/ff/reports/index.js | 4 +- public/js/ff/rules/create-edit.js | 2 +- public/js/ff/rules/index.js | 2 +- public/js/ff/transactions/single/create.js | 3 +- tests/Feature/ExampleTest.php | 4 +- tests/Unit/ExampleTest.php | 3 +- 35 files changed, 133 insertions(+), 171 deletions(-) diff --git a/app/Export/Collector/JournalExportCollector.php b/app/Export/Collector/JournalExportCollector.php index 551880ce4f..234c548baa 100644 --- a/app/Export/Collector/JournalExportCollector.php +++ b/app/Export/Collector/JournalExportCollector.php @@ -14,7 +14,6 @@ declare(strict_types = 1); namespace FireflyIII\Export\Collector; use Carbon\Carbon; -use Crypt; use DB; use FireflyIII\Models\Transaction; use Illuminate\Database\Query\JoinClause; diff --git a/app/Export/Entry/Entry.php b/app/Export/Entry/Entry.php index 2fb30850d0..f5300ede71 100644 --- a/app/Export/Entry/Entry.php +++ b/app/Export/Entry/Entry.php @@ -13,7 +13,6 @@ declare(strict_types = 1); namespace FireflyIII\Export\Entry; -use Crypt; use Steam; /** diff --git a/app/Generator/Report/Support.php b/app/Generator/Report/Support.php index 9125031579..9a8e0f7233 100644 --- a/app/Generator/Report/Support.php +++ b/app/Generator/Report/Support.php @@ -80,6 +80,26 @@ class Support return $result; } + /** + * @return Collection + */ + public function getTopExpenses(): Collection + { + $transactions = $this->getExpenses()->sortBy('transaction_amount'); + + return $transactions; + } + + /** + * @return Collection + */ + public function getTopIncome(): Collection + { + $transactions = $this->getIncome()->sortByDesc('transaction_amount'); + + return $transactions; + } + /** * @param Collection $collection * @param int $sortFlag @@ -162,26 +182,6 @@ class Support return $return; } - /** - * @return Collection - */ - public function getTopExpenses(): Collection - { - $transactions = $this->getExpenses()->sortBy('transaction_amount'); - - return $transactions; - } - - /** - * @return Collection - */ - public function getTopIncome(): Collection - { - $transactions = $this->getIncome()->sortByDesc('transaction_amount'); - - return $transactions; - } - /** * @param Collection $collection * diff --git a/app/Helpers/Attachments/AttachmentHelperInterface.php b/app/Helpers/Attachments/AttachmentHelperInterface.php index dc6f9420aa..d380cfe9c6 100644 --- a/app/Helpers/Attachments/AttachmentHelperInterface.php +++ b/app/Helpers/Attachments/AttachmentHelperInterface.php @@ -44,6 +44,8 @@ interface AttachmentHelperInterface /** * @param Model $model * + * @param array $files + * * @return bool */ public function saveAttachmentsForModel(Model $model, array $files = null): bool; diff --git a/app/Helpers/Collector/JournalCollector.php b/app/Helpers/Collector/JournalCollector.php index 39b19b42de..46024ad842 100644 --- a/app/Helpers/Collector/JournalCollector.php +++ b/app/Helpers/Collector/JournalCollector.php @@ -430,6 +430,20 @@ class JournalCollector implements JournalCollectorInterface return $this; } + /** + * @param Collection $tags + * + * @return JournalCollectorInterface + */ + public function setTags(Collection $tags): JournalCollectorInterface + { + $this->joinTagTables(); + $tagIds = $tags->pluck('id')->toArray(); + $this->query->whereIn('tag_transaction_journal.tag_id', $tagIds); + + return $this; + } + /** * @param array $types * @@ -712,18 +726,4 @@ class JournalCollector implements JournalCollectorInterface $this->query->leftJoin('tag_transaction_journal', 'tag_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'); } } - - /** - * @param Collection $tags - * - * @return JournalCollectorInterface - */ - public function setTags(Collection $tags): JournalCollectorInterface - { - $this->joinTagTables(); - $tagIds = $tags->pluck('id')->toArray(); - $this->query->whereIn('tag_transaction_journal.tag_id', $tagIds); - - return $this; - } } diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 2cf28042ba..cd392a925c 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -122,12 +122,15 @@ class RegisterController extends Controller */ protected function create(array $data) { - return User::create( + /** @var User $user */ + $user = User::create( [ 'email' => $data['email'], 'password' => bcrypt($data['password']), ] ); + + return $user; } /** diff --git a/app/Http/Controllers/Auth/TwoFactorController.php b/app/Http/Controllers/Auth/TwoFactorController.php index 9b74cad644..55f581c777 100644 --- a/app/Http/Controllers/Auth/TwoFactorController.php +++ b/app/Http/Controllers/Auth/TwoFactorController.php @@ -79,9 +79,11 @@ class TwoFactorController extends Controller /** * @param TokenFormRequest $request - * @SuppressWarnings(PHPMD.UnusedFormalParameter) // it's unused but the class does some validation. + * @param CookieJar $cookieJar * * @return mixed + * @SuppressWarnings(PHPMD.UnusedFormalParameter) // it's unused but the class does some validation. + * */ public function postIndex(TokenFormRequest $request, CookieJar $cookieJar) { diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index c7c73030f7..717823ddbb 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -105,7 +105,8 @@ class BudgetController extends Controller } /** - * @param Budget $budget + * @param Request $request + * @param Budget $budget * * @return View */ @@ -214,6 +215,8 @@ class BudgetController extends Controller } /** + * @param BudgetIncomeRequest $request + * * @return \Illuminate\Http\RedirectResponse */ public function postUpdateIncome(BudgetIncomeRequest $request) diff --git a/app/Http/Controllers/Chart/BudgetReportController.php b/app/Http/Controllers/Chart/BudgetReportController.php index d570eae6b8..7c7eba81ac 100644 --- a/app/Http/Controllers/Chart/BudgetReportController.php +++ b/app/Http/Controllers/Chart/BudgetReportController.php @@ -203,6 +203,7 @@ class BudgetReportController extends Controller * Returns the budget limits belonging to the given budget and valid on the given day. * * @param Collection $budgetLimits + * @param Budget $budget * @param Carbon $start * @param Carbon $end * @@ -268,21 +269,4 @@ class BudgetReportController extends Controller return $grouped; } - /** - * @param Collection $set - * - * @return array - */ - private function groupByOpposingAccount(Collection $set): array - { - $grouped = []; - /** @var Transaction $transaction */ - foreach ($set as $transaction) { - $accountId = $transaction->opposing_account_id; - $grouped[$accountId] = $grouped[$accountId] ?? '0'; - $grouped[$accountId] = bcadd($transaction->transaction_amount, $grouped[$accountId]); - } - - return $grouped; - } } diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php index 217d122bc8..40645df6d0 100644 --- a/app/Http/Controllers/Chart/CategoryController.php +++ b/app/Http/Controllers/Chart/CategoryController.php @@ -20,7 +20,7 @@ use FireflyIII\Http\Controllers\Controller; use FireflyIII\Models\AccountType; use FireflyIII\Models\Category; use FireflyIII\Repositories\Account\AccountRepositoryInterface; -use FireflyIII\Repositories\Category\CategoryRepositoryInterface as CRI; +use FireflyIII\Repositories\Category\CategoryRepositoryInterface; use FireflyIII\Support\CacheProperties; use Illuminate\Support\Collection; use Navigation; @@ -50,13 +50,13 @@ class CategoryController extends Controller /** * Show an overview for a category for all time, per month/week/year. * - * @param CRI $repository - * @param AccountRepositoryInterface $accountRepository - * @param Category $category + * @param CategoryRepositoryInterface $repository + * @param AccountRepositoryInterface $accountRepository + * @param Category $category * * @return \Symfony\Component\HttpFoundation\Response */ - public function all(CRI $repository, AccountRepositoryInterface $accountRepository, Category $category) + public function all(CategoryRepositoryInterface $repository, AccountRepositoryInterface $accountRepository, Category $category) { $cache = new CacheProperties; $cache->addProperty('chart.category.all'); @@ -106,12 +106,12 @@ class CategoryController extends Controller } /** - * @param CRI $repository - * @param Category $category + * @param CategoryRepositoryInterface $repository + * @param Category $category * * @return \Symfony\Component\HttpFoundation\Response */ - public function currentPeriod(CRI $repository, Category $category) + public function currentPeriod(CategoryRepositoryInterface $repository, Category $category) { $start = clone session('start', Carbon::now()->startOfMonth()); $end = session('end', Carbon::now()->endOfMonth()); @@ -121,12 +121,12 @@ class CategoryController extends Controller } /** - * @param CRI $repository - * @param AccountRepositoryInterface $accountRepository + * @param CategoryRepositoryInterface $repository + * @param AccountRepositoryInterface $accountRepository * * @return \Illuminate\Http\JsonResponse */ - public function frontpage(CRI $repository, AccountRepositoryInterface $accountRepository) + public function frontpage(CategoryRepositoryInterface $repository, AccountRepositoryInterface $accountRepository) { $start = session('start', Carbon::now()->startOfMonth()); $end = session('end', Carbon::now()->endOfMonth()); @@ -161,15 +161,15 @@ class CategoryController extends Controller } /** - * @param CRI $repository - * @param Category $category - * @param Collection $accounts - * @param Carbon $start - * @param Carbon $end + * @param CategoryRepositoryInterface $repository + * @param Category $category + * @param Collection $accounts + * @param Carbon $start + * @param Carbon $end * * @return \Illuminate\Http\JsonResponse|mixed */ - public function reportPeriod(CRI $repository, Category $category, Collection $accounts, Carbon $start, Carbon $end) + public function reportPeriod(CategoryRepositoryInterface $repository, Category $category, Collection $accounts, Carbon $start, Carbon $end) { $cache = new CacheProperties; $cache->addProperty($start); @@ -210,14 +210,14 @@ class CategoryController extends Controller } /** - * @param CRI $repository - * @param Collection $accounts - * @param Carbon $start - * @param Carbon $end + * @param CategoryRepositoryInterface $repository + * @param Collection $accounts + * @param Carbon $start + * @param Carbon $end * * @return \Illuminate\Http\JsonResponse|mixed */ - public function reportPeriodNoCategory(CRI $repository, Collection $accounts, Carbon $start, Carbon $end) + public function reportPeriodNoCategory(CategoryRepositoryInterface $repository, Collection $accounts, Carbon $start, Carbon $end) { $cache = new CacheProperties; $cache->addProperty($start); @@ -257,14 +257,14 @@ class CategoryController extends Controller } /** - * @param CRI $repository + * @param CategoryRepositoryInterface $repository * @param Category $category * * @param $date * * @return \Symfony\Component\HttpFoundation\Response */ - public function specificPeriod(CRI $repository, Category $category, $date) + public function specificPeriod(CategoryRepositoryInterface $repository, Category $category, $date) { $carbon = new Carbon($date); $range = Preferences::get('viewRange', '1M')->data; @@ -277,14 +277,14 @@ class CategoryController extends Controller /** - * @param CRI $repository - * @param Category $category - * @param Carbon $start - * @param Carbon $end + * @param CategoryRepositoryInterface $repository + * @param Category $category + * @param Carbon $start + * @param Carbon $end * * @return array */ - private function makePeriodChart(CRI $repository, Category $category, Carbon $start, Carbon $end) + private function makePeriodChart(CategoryRepositoryInterface $repository, Category $category, Carbon $start, Carbon $end) { $cache = new CacheProperties; $cache->addProperty($start); diff --git a/app/Http/Controllers/CurrencyController.php b/app/Http/Controllers/CurrencyController.php index d38e964c62..606cac686f 100644 --- a/app/Http/Controllers/CurrencyController.php +++ b/app/Http/Controllers/CurrencyController.php @@ -50,6 +50,8 @@ class CurrencyController extends Controller } /** + * @param Request $request + * * @return View */ public function create(Request $request) @@ -90,6 +92,7 @@ class CurrencyController extends Controller /** + * @param Request $request * @param CurrencyRepositoryInterface $repository * @param TransactionCurrency $currency * @@ -115,6 +118,7 @@ class CurrencyController extends Controller } /** + * @param Request $request * @param CurrencyRepositoryInterface $repository * @param TransactionCurrency $currency * diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php index 823c82e928..865f8133eb 100644 --- a/app/Http/Controllers/ExportController.php +++ b/app/Http/Controllers/ExportController.php @@ -55,9 +55,10 @@ class ExportController extends Controller } /** + * @param EJRI $repository * @param ExportJob $job * - * @return \Symfony\Component\HttpFoundation\Response|\Illuminate\Contracts\Routing\ResponseFactory + * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response * @throws FireflyException */ public function download(ExportJobRepositoryInterface $repository, ExportJob $job) diff --git a/app/Http/Controllers/JavascriptController.php b/app/Http/Controllers/JavascriptController.php index 6e63e57a43..c5f76133d9 100644 --- a/app/Http/Controllers/JavascriptController.php +++ b/app/Http/Controllers/JavascriptController.php @@ -27,7 +27,9 @@ class JavascriptController extends Controller { /** + * @param Request $request * + * @return $this */ public function variables(Request $request) { diff --git a/app/Http/Controllers/JsonController.php b/app/Http/Controllers/JsonController.php index 4d95c51fc9..a87dbfba38 100644 --- a/app/Http/Controllers/JsonController.php +++ b/app/Http/Controllers/JsonController.php @@ -329,7 +329,9 @@ class JsonController extends Controller } /** + * @param JournalRepositoryInterface $repository * + * @return \Illuminate\Http\JsonResponse */ public function transactionTypes(JournalRepositoryInterface $repository) { diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 17e868a2fb..bf4b933d7d 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -56,7 +56,7 @@ class SearchController extends Controller $limit = 20; // ui stuff: - $subTitle = ''; + $subTitle = ''; // query stuff $query = null; diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 6b1a7cfa66..b746961419 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -219,7 +219,7 @@ class TagController extends Controller } } - return view('tags.index', compact('title', 'mainTitleIcon', 'types', 'collection','count')); + return view('tags.index', compact('title', 'mainTitleIcon', 'types', 'collection', 'count')); } /** diff --git a/app/Http/Middleware/RedirectIfTwoFactorAuthenticated.php b/app/Http/Middleware/RedirectIfTwoFactorAuthenticated.php index 53dcaa619e..5d58521a7d 100644 --- a/app/Http/Middleware/RedirectIfTwoFactorAuthenticated.php +++ b/app/Http/Middleware/RedirectIfTwoFactorAuthenticated.php @@ -14,11 +14,11 @@ declare(strict_types = 1); namespace FireflyIII\Http\Middleware; use Closure; +use Cookie; use Illuminate\Support\Facades\Auth; use Preferences; -use Session; -use Log; -use Cookie; + + /** * Class RedirectIfTwoFactorAuthenticated * diff --git a/app/Http/Middleware/Sandstorm.php b/app/Http/Middleware/Sandstorm.php index b995bb0e51..e07a0ca1b5 100644 --- a/app/Http/Middleware/Sandstorm.php +++ b/app/Http/Middleware/Sandstorm.php @@ -35,6 +35,7 @@ class Sandstorm * @param string|null $guard * * @return mixed + * @throws FireflyException */ public function handle(Request $request, Closure $next, $guard = null) { @@ -59,30 +60,34 @@ class Sandstorm // and any other differences there may be between these users. if ($count === 1 && strlen($userId) > 0) { // login as first user user. - $user = User::first(); + $user = User::first(); Auth::guard($guard)->login($user); View::share('SANDSTORM_ANON', false); + return $next($request); } if ($count === 1 && strlen($userId) === 0) { // login but indicate anonymous - $user = User::first(); + $user = User::first(); Auth::guard($guard)->login($user); View::share('SANDSTORM_ANON', true); + return $next($request); } if ($count === 0 && strlen($userId) > 0) { // create new user. $email = $userId . '@firefly'; - $user = User::create( + /** @var User $user */ + $user = User::create( [ 'email' => $email, 'password' => str_random(16), ] ); Auth::guard($guard)->login($user); + return $next($request); } @@ -91,30 +96,7 @@ class Sandstorm } if ($count > 1) { - die('Cannot happen.'); - } - exit; - - if (strlen($userId) > 0) { - // find user? - $email = $userId . '@firefly'; - $user = User::whereEmail($email)->first(); - if (is_null($user)) { - $user = User::create( - [ - 'email' => $email, - 'password' => str_random(16), - ] - ); - - } - - - // login user: - Auth::guard($guard)->login($user); - } else { - echo 'user id no length, guest?'; - exit; + throw new FireflyException('Your Firefly III installation has more than one user, which is weird.'); } } diff --git a/app/Import/Mapper/TransactionCurrencies.php b/app/Import/Mapper/TransactionCurrencies.php index f5e157c5a3..94baa13b91 100644 --- a/app/Import/Mapper/TransactionCurrencies.php +++ b/app/Import/Mapper/TransactionCurrencies.php @@ -13,7 +13,7 @@ declare(strict_types = 1); namespace FireflyIII\Import\Mapper; -use FireflyIII\Models\TransactionCurrency as TC; +use FireflyIII\Models\TransactionCurrency; /** * Class TransactionCurrencies @@ -28,7 +28,7 @@ class TransactionCurrencies implements MapperInterface */ public function getMap(): array { - $currencies = TC::get(); + $currencies = TransactionCurrency::get(); $list = []; foreach ($currencies as $currency) { $list[$currency->id] = $currency->name . ' (' . $currency->code . ')'; diff --git a/app/Models/LimitRepetition.php b/app/Models/LimitRepetition.php index d4f5b5f3dc..3c61c378f9 100644 --- a/app/Models/LimitRepetition.php +++ b/app/Models/LimitRepetition.php @@ -16,7 +16,6 @@ namespace FireflyIII\Models; use Carbon\Carbon; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Class LimitRepetition @@ -42,26 +41,6 @@ class LimitRepetition extends Model protected $dates = ['created_at', 'updated_at', 'startdate', 'enddate']; protected $hidden = ['amount_encrypted']; - /** - * @param $value - * - * @return mixed - */ - public static function routeBinder($value) - { - if (auth()->check()) { - $object = self::where('limit_repetitions.id', $value) - ->leftJoin('budget_limits', 'budget_limits.id', '=', 'limit_repetitions.budget_limit_id') - ->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id') - ->where('budgets.user_id', auth()->user()->id) - ->first(['limit_repetitions.*']); - if ($object) { - return $object; - } - } - throw new NotFoundHttpException; - } - /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.php index 997d93fada..b9113a8dbb 100644 --- a/app/Models/PiggyBank.php +++ b/app/Models/PiggyBank.php @@ -108,6 +108,19 @@ class PiggyBank extends Model return $value; } + public function getSuggestedMonthlyAmount() + { + if ($this->targetdate && $this->currentRelevantRep()->currentamount < $this->targetamount) { + $thisMonth = Carbon::now()->month; + $targetMonth = $this->targetdate->month; + $remainingAmount = $this->targetamount - $this->currentRelevantRep()->currentamount; + + return $thisMonth < $targetMonth ? $remainingAmount / ($targetMonth - $thisMonth) : $remainingAmount; + } + + return 0; + } + /** * * @param Carbon $date @@ -129,17 +142,6 @@ class PiggyBank extends Model } - public function getSuggestedMonthlyAmount() - { - if ($this->targetdate && $this->currentRelevantRep()->currentamount < $this->targetamount) { - $thisMonth = Carbon::now()->month; - $targetMonth = $this->targetdate->month; - $remainingAmount = $this->targetamount - $this->currentRelevantRep()->currentamount; - return $thisMonth < $targetMonth ? $remainingAmount / ($targetMonth - $thisMonth) : $remainingAmount ; - } - return 0; - } - /** * Get all of the piggy bank's notes. */ diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 26ba26b6ea..23e53fe8da 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -457,7 +457,8 @@ class AccountRepository implements AccountRepositoryInterface $name = $data['name']; $opposing = $this->storeOpposingAccount($name); $transactionType = TransactionType::whereType(TransactionType::OPENING_BALANCE)->first(); - $journal = TransactionJournal::create( + /** @var TransactionJournal $journal */ + $journal = TransactionJournal::create( [ 'user_id' => $this->user->id, 'transaction_type_id' => $transactionType->id, diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php index 545a29fb96..43874982fa 100644 --- a/app/Repositories/Bill/BillRepository.php +++ b/app/Repositories/Bill/BillRepository.php @@ -525,8 +525,7 @@ class BillRepository implements BillRepositoryInterface */ public function store(array $data): Bill { - - + /** @var Bill $bill */ $bill = Bill::create( [ 'name' => $data['name'], diff --git a/app/Repositories/Currency/CurrencyRepository.php b/app/Repositories/Currency/CurrencyRepository.php index b053780cac..9af830efae 100644 --- a/app/Repositories/Currency/CurrencyRepository.php +++ b/app/Repositories/Currency/CurrencyRepository.php @@ -193,6 +193,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface */ public function store(array $data): TransactionCurrency { + /** @var TransactionCurrency $currency */ $currency = TransactionCurrency::create( [ 'name' => $data['name'], diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php index 1f14467a5b..96226b81e3 100644 --- a/app/Repositories/PiggyBank/PiggyBankRepository.php +++ b/app/Repositories/PiggyBank/PiggyBankRepository.php @@ -40,6 +40,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface */ public function createEvent(PiggyBank $piggyBank, string $amount): PiggyBankEvent { + /** @var PiggyBankEvent $event */ $event = PiggyBankEvent::create(['date' => Carbon::now(), 'amount' => $amount, 'piggy_bank_id' => $piggyBank->id]); return $event; @@ -173,7 +174,8 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface public function store(array $data): PiggyBank { $data['order'] = $this->getMaxOrder() + 1; - $piggyBank = PiggyBank::create($data); + /** @var PiggyBank $piggyBank */ + $piggyBank = PiggyBank::create($data); $this->updateNote($piggyBank, $data['note']); diff --git a/app/Support/Twig/PiggyBank.php b/app/Support/Twig/PiggyBank.php index badb07889e..4263985a82 100644 --- a/app/Support/Twig/PiggyBank.php +++ b/app/Support/Twig/PiggyBank.php @@ -41,7 +41,7 @@ class PiggyBank extends Twig_Extension $functions[] = new Twig_SimpleFunction( 'suggestedMonthlyAmount', function (PB $piggyBank) { - return $piggyBank->getSuggestedMonthlyAmount(); + return $piggyBank->getSuggestedMonthlyAmount(); } ); diff --git a/app/Support/Twig/Transaction.php b/app/Support/Twig/Transaction.php index f1a0b98dd5..70abfc30d4 100644 --- a/app/Support/Twig/Transaction.php +++ b/app/Support/Twig/Transaction.php @@ -14,7 +14,6 @@ declare(strict_types = 1); namespace FireflyIII\Support\Twig; use Amount; -use Crypt; use FireflyIII\Models\AccountType; use FireflyIII\Models\Transaction as TransactionModel; use FireflyIII\Models\TransactionCurrency; diff --git a/public/js/ff/export/index.js b/public/js/ff/export/index.js index e7af126f51..c7d0f3fd40 100644 --- a/public/js/ff/export/index.js +++ b/public/js/ff/export/index.js @@ -79,7 +79,7 @@ function showDownload() { function showError(text) { "use strict"; $('#export-error').show(); - $('#export-error>p').text(text); + $('#export-error').find('p').text(text); } function callExport() { diff --git a/public/js/ff/piggy-banks/index.js b/public/js/ff/piggy-banks/index.js index 70630ad6d5..f83320f24f 100644 --- a/public/js/ff/piggy-banks/index.js +++ b/public/js/ff/piggy-banks/index.js @@ -24,7 +24,7 @@ $(function () { $('.addMoney').on('click', addMoney); $('.removeMoney').on('click', removeMoney); - $('#sortable-piggy tbody').sortable( + $('#sortable-piggy').find('tbody').sortable( { helper: fixHelper, stop: stopSorting, diff --git a/public/js/ff/reports/index.js b/public/js/ff/reports/index.js index df65b9704f..2891c12fd1 100644 --- a/public/js/ff/reports/index.js +++ b/public/js/ff/reports/index.js @@ -29,10 +29,10 @@ $(function () { { locale: { format: 'YYYY-MM-DD', - firstDay: 1, + firstDay: 1 }, minDate: minDate, - drops: 'up', + drops: 'up' } ); diff --git a/public/js/ff/rules/create-edit.js b/public/js/ff/rules/create-edit.js index 9100050012..1652ae804b 100644 --- a/public/js/ff/rules/create-edit.js +++ b/public/js/ff/rules/create-edit.js @@ -300,7 +300,7 @@ function testRuleTriggers() { } // Show the modal dialog - $("#testTriggerModal").modal(); + modal.modal(); }).fail(function () { alert('Cannot get transactions for given triggers.'); }); diff --git a/public/js/ff/rules/index.js b/public/js/ff/rules/index.js index 0fc0ef7371..a64d6a6cc6 100644 --- a/public/js/ff/rules/index.js +++ b/public/js/ff/rules/index.js @@ -25,7 +25,7 @@ $(function () { { helper: fixHelper, stop: sortStop, - cursor: "move", + cursor: "move" } ); diff --git a/public/js/ff/transactions/single/create.js b/public/js/ff/transactions/single/create.js index 7a38946984..7cf2796417 100644 --- a/public/js/ff/transactions/single/create.js +++ b/public/js/ff/transactions/single/create.js @@ -35,8 +35,7 @@ $(document).ready(function () { function updateDescription() { $.getJSON('json/transaction-journals/' + what).done(function (data) { - $('input[name="description"]').typeahead('destroy'); - $('input[name="description"]').typeahead({source: data}); + $('input[name="description"]').typeahead('destroy').typeahead({source: data}); }); } diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php index a8a339029f..11307fa66a 100644 --- a/tests/Feature/ExampleTest.php +++ b/tests/Feature/ExampleTest.php @@ -10,9 +10,7 @@ namespace Tests\Feature; use Tests\TestCase; -use Illuminate\Foundation\Testing\WithoutMiddleware; -use Illuminate\Foundation\Testing\DatabaseMigrations; -use Illuminate\Foundation\Testing\DatabaseTransactions; + class ExampleTest extends TestCase { diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php index 5663bb49f8..9744e771e7 100644 --- a/tests/Unit/ExampleTest.php +++ b/tests/Unit/ExampleTest.php @@ -3,8 +3,7 @@ namespace Tests\Unit; use Tests\TestCase; -use Illuminate\Foundation\Testing\DatabaseMigrations; -use Illuminate\Foundation\Testing\DatabaseTransactions; + class ExampleTest extends TestCase {