From ac61dfae6bb2acb44c4f64d178eb86cc72bd2aa8 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 18 Dec 2015 16:38:50 +0100 Subject: [PATCH] File reformatting. --- .../Account/ChartJsAccountChartGenerator.php | 8 +- .../Chart/Budget/BudgetChartGenerator.php | 14 +-- .../Chart/Category/CategoryChartGenerator.php | 19 ++-- .../Report/ChartJsReportChartGenerator.php | 8 +- .../Chart/Report/ReportChartGenerator.php | 18 +-- app/Helpers/Report/ReportHelper.php | 2 +- app/Helpers/Report/ReportQuery.php | 2 +- app/Helpers/Report/ReportQueryInterface.php | 4 +- app/Http/Controllers/Auth/AuthController.php | 11 +- .../Controllers/Auth/PasswordController.php | 12 +- app/Http/Controllers/CurrencyController.php | 2 +- app/Http/Controllers/JsonController.php | 2 +- app/Http/Controllers/ReportController.php | 8 +- .../Controllers/TransactionController.php | 2 +- app/Http/Middleware/Authenticate.php | 4 +- app/Http/routes.php | 2 +- app/Models/Bill.php | 4 +- app/Models/Category.php | 2 +- app/Models/TransactionType.php | 42 +++---- app/Repositories/Budget/BudgetRepository.php | 107 +++++++++--------- .../Category/CategoryRepository.php | 2 + app/Repositories/Tag/TagRepository.php | 4 +- app/Support/Amount.php | 8 +- app/Validation/FireflyValidator.php | 2 +- 24 files changed, 149 insertions(+), 140 deletions(-) diff --git a/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php b/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php index c795f89570..ec8460cdfd 100644 --- a/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php +++ b/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php @@ -42,10 +42,10 @@ class ChartJsAccountChartGenerator implements AccountChartGenerator public function expenseAccounts(Collection $accounts, Carbon $start, Carbon $end) { $data = [ - 'count' => 1, - 'labels' => [], 'datasets' => [[ - 'label' => trans('firefly.spent'), - 'data' => []]]]; + 'count' => 1, + 'labels' => [], 'datasets' => [[ + 'label' => trans('firefly.spent'), + 'data' => []]]]; bcscale(2); $start->subDay(); diff --git a/app/Generator/Chart/Budget/BudgetChartGenerator.php b/app/Generator/Chart/Budget/BudgetChartGenerator.php index c7aa64a863..e17f548ed8 100644 --- a/app/Generator/Chart/Budget/BudgetChartGenerator.php +++ b/app/Generator/Chart/Budget/BudgetChartGenerator.php @@ -18,13 +18,6 @@ interface BudgetChartGenerator */ public function budget(Collection $entries); - /** - * @param Collection $entries - * - * @return array - */ - public function multiYear(Collection $entries); - /** * @param Collection $entries * @@ -39,6 +32,13 @@ interface BudgetChartGenerator */ public function frontpage(Collection $entries); + /** + * @param Collection $entries + * + * @return array + */ + public function multiYear(Collection $entries); + /** * @param Collection $budgets * @param Collection $entries diff --git a/app/Generator/Chart/Category/CategoryChartGenerator.php b/app/Generator/Chart/Category/CategoryChartGenerator.php index 6b52518a34..de6891b556 100644 --- a/app/Generator/Chart/Category/CategoryChartGenerator.php +++ b/app/Generator/Chart/Category/CategoryChartGenerator.php @@ -20,11 +20,12 @@ interface CategoryChartGenerator public function all(Collection $entries); /** + * @param Collection $categories * @param Collection $entries * * @return array */ - public function multiYear(Collection $entries); + public function earnedInYear(Collection $categories, Collection $entries); /** * @param Collection $entries @@ -38,8 +39,14 @@ interface CategoryChartGenerator * * @return array */ - public function period(Collection $entries); + public function multiYear(Collection $entries); + /** + * @param Collection $entries + * + * @return array + */ + public function period(Collection $entries); /** * @param Collection $categories @@ -48,12 +55,4 @@ interface CategoryChartGenerator * @return array */ public function spentInYear(Collection $categories, Collection $entries); - - /** - * @param Collection $categories - * @param Collection $entries - * - * @return array - */ - public function earnedInYear(Collection $categories, Collection $entries); } diff --git a/app/Generator/Chart/Report/ChartJsReportChartGenerator.php b/app/Generator/Chart/Report/ChartJsReportChartGenerator.php index 00d4484eb6..0b2250b39a 100644 --- a/app/Generator/Chart/Report/ChartJsReportChartGenerator.php +++ b/app/Generator/Chart/Report/ChartJsReportChartGenerator.php @@ -107,9 +107,9 @@ class ChartJsReportChartGenerator implements ReportChartGenerator ], ]; $data['datasets'][0]['data'][] = round($income, 2); - $data['datasets'][1]['data'][] = round( $expense, 2); + $data['datasets'][1]['data'][] = round($expense, 2); $data['datasets'][0]['data'][] = round(($income / $count), 2); - $data['datasets'][1]['data'][] = round(( $expense / $count), 2); + $data['datasets'][1]['data'][] = round(($expense / $count), 2); return $data; } @@ -138,9 +138,9 @@ class ChartJsReportChartGenerator implements ReportChartGenerator ], ]; $data['datasets'][0]['data'][] = round($income, 2); - $data['datasets'][1]['data'][] = round( $expense, 2); + $data['datasets'][1]['data'][] = round($expense, 2); $data['datasets'][0]['data'][] = round(($income / $count), 2); - $data['datasets'][1]['data'][] = round(( $expense / $count), 2); + $data['datasets'][1]['data'][] = round(($expense / $count), 2); return $data; } diff --git a/app/Generator/Chart/Report/ReportChartGenerator.php b/app/Generator/Chart/Report/ReportChartGenerator.php index f77ef80e03..0447e96581 100644 --- a/app/Generator/Chart/Report/ReportChartGenerator.php +++ b/app/Generator/Chart/Report/ReportChartGenerator.php @@ -12,13 +12,6 @@ use Illuminate\Support\Collection; interface ReportChartGenerator { - /** - * @param Collection $entries - * - * @return array - */ - public function yearInOut(Collection $entries); - /** * @param Collection $entries * @@ -33,7 +26,14 @@ interface ReportChartGenerator * * @return array */ - public function yearInOutSummarized($income, $expense, $count); + public function multiYearInOutSummarized($income, $expense, $count); + + /** + * @param Collection $entries + * + * @return array + */ + public function yearInOut(Collection $entries); /** * @param string $income @@ -42,6 +42,6 @@ interface ReportChartGenerator * * @return array */ - public function multiYearInOutSummarized($income, $expense, $count); + public function yearInOutSummarized($income, $expense, $count); } diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php index d26ee7512b..7f028d6a10 100644 --- a/app/Helpers/Report/ReportHelper.php +++ b/app/Helpers/Report/ReportHelper.php @@ -237,7 +237,7 @@ class ReportHelper implements ReportHelperInterface $budgetLine = new BudgetLine; $budgetLine->setBudget($budget); $budgetLine->setRepetition($repetition); - $expenses = $repository->balanceInPeriodForList($budget, $start, $end, $accounts); + $expenses = $repository->balanceInPeriodForList($budget, $start, $end, $accounts); // 200 en -100 is 100, vergeleken met 0 === 1 // 200 en -200 is 0, vergeleken met 0 === 0 diff --git a/app/Helpers/Report/ReportQuery.php b/app/Helpers/Report/ReportQuery.php index 878da06a26..545ebaa145 100644 --- a/app/Helpers/Report/ReportQuery.php +++ b/app/Helpers/Report/ReportQuery.php @@ -134,7 +134,7 @@ class ReportQuery implements ReportQueryInterface $query->orWhere( function (Builder $q) use ($ids) { $q->where('transaction_types.type', TransactionType::TRANSFER); - $q->whereNotIn('ac_from.id',$ids); + $q->whereNotIn('ac_from.id', $ids); $q->whereIn('ac_to.id', $ids); } ); diff --git a/app/Helpers/Report/ReportQueryInterface.php b/app/Helpers/Report/ReportQueryInterface.php index 8579c52926..d7fa9cf085 100644 --- a/app/Helpers/Report/ReportQueryInterface.php +++ b/app/Helpers/Report/ReportQueryInterface.php @@ -22,8 +22,8 @@ interface ReportQueryInterface * and "ordinary" withdrawals. The query used is almost equal to ReportQueryInterface::journalsByRevenueAccount but it does * not group and returns different fields. * - * @param Carbon $start - * @param Carbon $end + * @param Carbon $start + * @param Carbon $end * @param Collection $accounts * * @return Collection diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index d7620f07b0..1ea0a985df 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -214,15 +214,17 @@ class AuthController extends Controller /** * @return array */ - protected function getBlockedDomains() { - $set = Config::get('mail.blocked_domains'); + protected function getBlockedDomains() + { + $set = Config::get('mail.blocked_domains'); $domains = []; - foreach($set as $entry) { + foreach ($set as $entry) { $domain = trim($entry); - if(strlen($domain) > 0) { + if (strlen($domain) > 0) { $domains[] = $domain; } } + return $domains; } @@ -234,6 +236,7 @@ class AuthController extends Controller if (isset($parts[1]) && in_array($parts[1], $blocked)) { return true; } + return false; } diff --git a/app/Http/Controllers/Auth/PasswordController.php b/app/Http/Controllers/Auth/PasswordController.php index 7cb3706ecb..a366bd395a 100644 --- a/app/Http/Controllers/Auth/PasswordController.php +++ b/app/Http/Controllers/Auth/PasswordController.php @@ -1,13 +1,12 @@ blocked) === 1) { $response = 'passwords.blocked'; } else { - $response = Password::sendResetLink($request->only('email'), function (Message $message) { + $response = Password::sendResetLink( + $request->only('email'), function (Message $message) { $message->subject($this->getEmailSubject()); - }); + } + ); } switch ($response) { diff --git a/app/Http/Controllers/CurrencyController.php b/app/Http/Controllers/CurrencyController.php index 6c066e5e16..d2bdbf7e06 100644 --- a/app/Http/Controllers/CurrencyController.php +++ b/app/Http/Controllers/CurrencyController.php @@ -147,7 +147,7 @@ class CurrencyController extends Controller public function index(CurrencyRepositoryInterface $repository) { $currencies = $repository->get(); - $defaultCurrency = $repository->getCurrencyByPreference(Preferences::get('currencyPreference', env('DEFAULT_CURRENCY','EUR'))); + $defaultCurrency = $repository->getCurrencyByPreference(Preferences::get('currencyPreference', env('DEFAULT_CURRENCY', 'EUR'))); if (!Auth::user()->hasRole('owner')) { diff --git a/app/Http/Controllers/JsonController.php b/app/Http/Controllers/JsonController.php index 28b331a165..85fc33ee1d 100644 --- a/app/Http/Controllers/JsonController.php +++ b/app/Http/Controllers/JsonController.php @@ -192,7 +192,7 @@ class JsonController extends Controller return Response::json($cache->get()); // @codeCoverageIgnore } $accounts = $accountRepository->getAccounts(['Default account', 'Asset account', 'Cash account']); - $amount = $reportQuery->incomeInPeriod($start, $end, $accounts)->sum('amount'); + $amount = $reportQuery->incomeInPeriod($start, $end, $accounts)->sum('amount'); $data = ['box' => 'in', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]; $cache->store($data); diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index 9387b159be..e9cee699e6 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -46,17 +46,17 @@ class ReportController extends Controller $months = $this->helper->listOfMonths($start); // does the user have shared accounts? - $accounts = $repository->getAccounts(['Default account', 'Asset account']); + $accounts = $repository->getAccounts(['Default account', 'Asset account']); // get id's for quick links: $accountIds = []; /** @var Account $account */ - foreach($accounts as $account) { + foreach ($accounts as $account) { $accountIds [] = $account->id; } - $accountList = join(',',$accountIds); + $accountList = join(',', $accountIds); - return view('reports.index', compact('months', 'accounts', 'start','accountList')); + return view('reports.index', compact('months', 'accounts', 'start', 'accountList')); } /** diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index 8b9e7d92bd..732c6d8047 100644 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -48,7 +48,7 @@ class TransactionController extends Controller */ public function create(AccountRepositoryInterface $repository, $what = TransactionType::DEPOSIT) { - $what = strtolower($what); + $what = strtolower($what); $maxFileSize = Steam::phpBytes(ini_get('upload_max_filesize')); $maxPostSize = Steam::phpBytes(ini_get('post_max_size')); $uploadSize = min($maxFileSize, $maxPostSize); diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index a785f908c9..458e19f62d 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -1,13 +1,14 @@ auth->user()->blocked) == 1) { Auth::logout(); + return redirect()->route('index'); } diff --git a/app/Http/routes.php b/app/Http/routes.php index c5b96ed926..d2bea217e5 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -268,7 +268,7 @@ Route::get('/cron/sendgrid', ['uses' => 'CronController@sendgrid']); Route::controllers( [ - 'auth' => 'Auth\AuthController', + 'auth' => 'Auth\AuthController', 'password' => 'Auth\PasswordController', ] ); diff --git a/app/Models/Bill.php b/app/Models/Bill.php index c976459a11..db88700e82 100644 --- a/app/Models/Bill.php +++ b/app/Models/Bill.php @@ -39,8 +39,8 @@ use Illuminate\Database\Eloquent\Model; * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereSkip($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereNameEncrypted($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereMatchEncrypted($value) - * @property \Carbon\Carbon $nextExpectedMatch - * @property \Carbon\Carbon $lastFoundMatch + * @property \Carbon\Carbon $nextExpectedMatch + * @property \Carbon\Carbon $lastFoundMatch */ class Bill extends Model { diff --git a/app/Models/Category.php b/app/Models/Category.php index a1c65c4667..af8593d06b 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -25,7 +25,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereUserId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereEncrypted($value) * @property-read float $spent - * @property \Carbon\Carbon $lastActivity + * @property \Carbon\Carbon $lastActivity */ class Category extends Model { diff --git a/app/Models/TransactionType.php b/app/Models/TransactionType.php index 1a07dd91d8..0d7323835d 100644 --- a/app/Models/TransactionType.php +++ b/app/Models/TransactionType.php @@ -23,9 +23,9 @@ class TransactionType extends Model { use SoftDeletes; - const WITHDRAWAL = 'Withdrawal'; - const DEPOSIT = 'Deposit'; - const TRANSFER = 'Transfer'; + const WITHDRAWAL = 'Withdrawal'; + const DEPOSIT = 'Deposit'; + const TRANSFER = 'Transfer'; const OPENING_BALANCE = 'Opening balance'; /** @@ -36,22 +36,6 @@ class TransactionType extends Model return ['created_at', 'updated_at', 'deleted_at']; } - /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany - */ - public function transactionJournals() - { - return $this->hasMany('FireflyIII\Models\TransactionJournal'); - } - - /** - * @return bool - */ - public function isWithdrawal() - { - return $this->type === TransactionType::WITHDRAWAL; - } - /** * @return bool */ @@ -60,6 +44,14 @@ class TransactionType extends Model return $this->type === TransactionType::DEPOSIT; } + /** + * @return bool + */ + public function isOpeningBalance() + { + return $this->type === TransactionType::OPENING_BALANCE; + } + /** * @return bool */ @@ -71,8 +63,16 @@ class TransactionType extends Model /** * @return bool */ - public function isOpeningBalance() + public function isWithdrawal() { - return $this->type === TransactionType::OPENING_BALANCE; + return $this->type === TransactionType::WITHDRAWAL; + } + + /** + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function transactionJournals() + { + return $this->hasMany('FireflyIII\Models\TransactionJournal'); } } diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index c9c24eef89..49280c742f 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -14,7 +14,6 @@ use Illuminate\Database\Query\Builder as QueryBuilder; use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Support\Collection; use Input; -use Log; /** * Class BudgetRepository @@ -89,10 +88,10 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn /** @var Collection $repetitions */ return LimitRepetition:: leftJoin('budget_limits', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id') - ->where('limit_repetitions.startdate', '<=', $end->format('Y-m-d 00:00:00')) - ->where('limit_repetitions.startdate', '>=', $start->format('Y-m-d 00:00:00')) - ->where('budget_limits.budget_id', $budget->id) - ->get(['limit_repetitions.*']); + ->where('limit_repetitions.startdate', '<=', $end->format('Y-m-d 00:00:00')) + ->where('limit_repetitions.startdate', '>=', $start->format('Y-m-d 00:00:00')) + ->where('budget_limits.budget_id', $budget->id) + ->get(['limit_repetitions.*']); } /** @@ -141,9 +140,9 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn return $cache->get(); // @codeCoverageIgnore } $data = $budget->limitrepetitions() - ->where('limit_repetitions.startdate', $start->format('Y-m-d 00:00:00')) - ->where('limit_repetitions.enddate', $end->format('Y-m-d 00:00:00')) - ->first(['limit_repetitions.*']); + ->where('limit_repetitions.startdate', $start->format('Y-m-d 00:00:00')) + ->where('limit_repetitions.enddate', $end->format('Y-m-d 00:00:00')) + ->first(['limit_repetitions.*']); //Log::debug('Looking for limit reps for budget #' . $budget->id . ' start [' . $start . '] and end [' . $end . '].'); //Log::debug(DB::getQueryLog()) $cache->store($data); @@ -186,9 +185,9 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn /** * Returns all the transaction journals for a limit, possibly limited by a limit repetition. * - * @param Budget $budget + * @param Budget $budget * @param LimitRepetition $repetition - * @param int $take + * @param int $take * * @return LengthAwarePaginator */ @@ -205,11 +204,11 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn return $cache->get(); // @codeCoverageIgnore } - $offset = intval(Input::get('page')) > 0 ? intval(Input::get('page')) * $take : 0; - $setQuery = $budget->transactionJournals()->withRelevantData()->take($take)->offset($offset) - ->orderBy('transaction_journals.date', 'DESC') - ->orderBy('transaction_journals.order', 'ASC') - ->orderBy('transaction_journals.id', 'DESC'); + $offset = intval(Input::get('page')) > 0 ? intval(Input::get('page')) * $take : 0; + $setQuery = $budget->transactionJournals()->withRelevantData()->take($take)->offset($offset) + ->orderBy('transaction_journals.date', 'DESC') + ->orderBy('transaction_journals.order', 'ASC') + ->orderBy('transaction_journals.id', 'DESC'); $countQuery = $budget->transactionJournals(); @@ -219,7 +218,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn } - $set = $setQuery->get(['transaction_journals.*']); + $set = $setQuery->get(['transaction_journals.*']); $count = $countQuery->count(); @@ -253,9 +252,9 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn public function getLimitAmountOnDate(Budget $budget, Carbon $date) { $repetition = LimitRepetition::leftJoin('budget_limits', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id') - ->where('limit_repetitions.startdate', $date->format('Y-m-d 00:00:00')) - ->where('budget_limits.budget_id', $budget->id) - ->first(['limit_repetitions.*']); + ->where('limit_repetitions.startdate', $date->format('Y-m-d 00:00:00')) + ->where('budget_limits.budget_id', $budget->id) + ->first(['limit_repetitions.*']); if ($repetition) { return $repetition->amount; @@ -273,15 +272,15 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn public function getWithoutBudget(Carbon $start, Carbon $end) { return Auth::user() - ->transactionjournals() - ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id') - ->whereNull('budget_transaction_journal.id') - ->before($end) - ->after($start) - ->orderBy('transaction_journals.date', 'DESC') - ->orderBy('transaction_journals.order', 'ASC') - ->orderBy('transaction_journals.id', 'DESC') - ->get(['transaction_journals.*']); + ->transactionjournals() + ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id') + ->whereNull('budget_transaction_journal.id') + ->before($end) + ->after($start) + ->orderBy('transaction_journals.date', 'DESC') + ->orderBy('transaction_journals.order', 'ASC') + ->orderBy('transaction_journals.id', 'DESC') + ->get(['transaction_journals.*']); } /** @@ -293,30 +292,30 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn public function getWithoutBudgetSum(Carbon $start, Carbon $end) { $noBudgetSet = Auth::user() - ->transactionjournals() - ->whereNotIn( - 'transaction_journals.id', function (QueryBuilder $query) use ($start, $end) { - $query - ->select('transaction_journals.id') - ->from('transaction_journals') - ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id') - ->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00')) - ->where('transaction_journals.date', '<=', $end->format('Y-m-d 00:00:00')) - ->whereNotNull('budget_transaction_journal.budget_id'); - } - ) - ->after($start) - ->before($end) - ->transactionTypes([TransactionType::WITHDRAWAL]) - ->get(['transaction_journals.*'])->sum('amount'); + ->transactionjournals() + ->whereNotIn( + 'transaction_journals.id', function (QueryBuilder $query) use ($start, $end) { + $query + ->select('transaction_journals.id') + ->from('transaction_journals') + ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id') + ->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00')) + ->where('transaction_journals.date', '<=', $end->format('Y-m-d 00:00:00')) + ->whereNotNull('budget_transaction_journal.budget_id'); + } + ) + ->after($start) + ->before($end) + ->transactionTypes([TransactionType::WITHDRAWAL]) + ->get(['transaction_journals.*'])->sum('amount'); return $noBudgetSet; } /** - * @param Budget $budget - * @param Carbon $start - * @param Carbon $end + * @param Budget $budget + * @param Carbon $start + * @param Carbon $end * @param Collection $accounts * * @return string @@ -330,7 +329,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * @param Budget $budget * @param Carbon $start * @param Carbon $end - * @param bool $shared + * @param bool $shared * * @return string */ @@ -349,7 +348,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn $newBudget = new Budget( [ 'user_id' => $data['user'], - 'name' => $data['name'], + 'name' => $data['name'], ] ); $newBudget->save(); @@ -360,14 +359,14 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn /** * @param Budget $budget - * @param array $data + * @param array $data * * @return Budget */ public function update(Budget $budget, array $data) { // update the account: - $budget->name = $data['name']; + $budget->name = $data['name']; $budget->active = $data['active']; $budget->save(); @@ -391,10 +390,10 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn // if not, create one! $limit = new BudgetLimit; $limit->budget()->associate($budget); - $limit->startdate = $date; - $limit->amount = $amount; + $limit->startdate = $date; + $limit->amount = $amount; $limit->repeat_freq = 'monthly'; - $limit->repeats = 0; + $limit->repeats = 0; $limit->save(); // likewise, there should be a limit repetition to match the end date diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.php index 859ac36106..aae38137fe 100644 --- a/app/Repositories/Category/CategoryRepository.php +++ b/app/Repositories/Category/CategoryRepository.php @@ -478,6 +478,7 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito ->transactionTypes([TransactionType::WITHDRAWAL]) ->get(['transaction_journals.*']) ->sum('amount'); + return $sum; } @@ -508,6 +509,7 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito ->after($start) ->get(['transaction_journals.*']) ->sum('amount'); + return $sum; } diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php index 8f395b4218..77d4ca4f41 100644 --- a/app/Repositories/Tag/TagRepository.php +++ b/app/Repositories/Tag/TagRepository.php @@ -77,7 +77,9 @@ class TagRepository implements TagRepositoryInterface /** @var Tag $tag */ foreach ($tags as $tag) { - $journals = $tag->transactionjournals()->after($start)->before($end)->transactionTypes([TransactionType::TRANSFER])->get(['transaction_journals.*']); + $journals = $tag->transactionjournals()->after($start)->before($end)->transactionTypes([TransactionType::TRANSFER])->get( + ['transaction_journals.*'] + ); /** @var TransactionJournal $journal */ foreach ($journals as $journal) { diff --git a/app/Support/Amount.php b/app/Support/Amount.php index 86cac1185b..bd0624f002 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -40,7 +40,7 @@ class Amount if ($cache->has()) { return $cache->get(); } else { - $currencyPreference = Prefs::get('currencyPreference', env('DEFAULT_CURRENCY','EUR')); + $currencyPreference = Prefs::get('currencyPreference', env('DEFAULT_CURRENCY', 'EUR')); $currency = TransactionCurrency::whereCode($currencyPreference->data)->first(); $cache->store($currency->symbol); @@ -152,7 +152,7 @@ class Amount if ($cache->has()) { return $cache->get(); } else { - $currencyPreference = Prefs::get('currencyPreference', env('DEFAULT_CURRENCY','EUR')); + $currencyPreference = Prefs::get('currencyPreference', env('DEFAULT_CURRENCY', 'EUR')); $currency = TransactionCurrency::whereCode($currencyPreference->data)->first(); if ($currency) { @@ -161,9 +161,9 @@ class Amount return $currency->code; } - $cache->store(env('DEFAULT_CURRENCY','EUR')); + $cache->store(env('DEFAULT_CURRENCY', 'EUR')); - return env('DEFAULT_CURRENCY','EUR'); // @codeCoverageIgnore + return env('DEFAULT_CURRENCY', 'EUR'); // @codeCoverageIgnore } } diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index 43a3d44ab0..1cd7aa0cf6 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -273,7 +273,7 @@ class FireflyValidator extends Validator // get entries from table $set = DB::table($table)->where('user_id', Auth::user()->id) - ->where('id', '!=', $exclude)->get([$field]); + ->where('id', '!=', $exclude)->get([$field]); foreach ($set as $entry) { $fieldValue = $this->tryDecrypt($entry->$field);