Skip to content

Firefly III: a personal finances manager

Code cleanup.

James Cole3cfa3f3b27f9
diff --git a/app/breadcrumbs.php b/app/breadcrumbs.php
index 9772319edf..3269c6e773 100644
--- a/app/breadcrumbs.php
+++ b/app/breadcrumbs.php
@@ -90,7 +90,7 @@ Breadcrumbs::register(
$breadcrumbs->push($budget->name, route('budgets.show', $budget->id));
if (!is_null($repetition)) {
$breadcrumbs->push(
- DateKit::periodShow($repetition->startdate, $repetition->limit->repeat_freq), route('budgets.show', $budget->id, $repetition->id)
+ DateKit::periodShow($repetition->startdate, $repetition->budgetlimit->repeat_freq), route('budgets.show', $budget->id, $repetition->id)
);
}
}
diff --git a/app/controllers/BudgetController.php b/app/controllers/BudgetController.php
index 1a90a92afd..b004435e7a 100644
--- a/app/controllers/BudgetController.php
+++ b/app/controllers/BudgetController.php
@@ -7,7 +7,7 @@ use FireflyIII\Shared\Preferences\PreferencesInterface as Pref;
/**
* Class BudgetController
*
- * TODO move AJAX methods to their own BudgetAjaxControlle
+ * TODO move AJAX methods to their own BudgetAjaxController
* TODO Find out what constitutes proper camelCase
* TODO How is object coupling counted?
*
@@ -44,7 +44,7 @@ class BudgetController extends BaseController
public function amount(Budget $budget)
{
$amount = intval(Input::get('amount'));
- $date = Session::get('start',Carbon::now()->startOfMonth());
+ $date = Session::get('start', Carbon::now()->startOfMonth());
$limitRepetition = $this->_repository->updateLimitAmount($budget, $date, $amount);
return Response::json(['name' => $budget->name, 'repetition' => $limitRepetition->id]);
@@ -112,16 +112,18 @@ class BudgetController extends BaseController
$budgets->each(
function (Budget $budget) {
/** @noinspection PhpUndefinedFieldInspection */
- $budget->spent = $this->_repository->spentInMonth($budget, \Session::get('start',Carbon::now()->startOfMonth()));
+ $budget->spent = $this->_repository->spentInMonth($budget, \Session::get('start', Carbon::now()->startOfMonth()));
/** @noinspection PhpUndefinedFieldInspection */
- $budget->currentRep = $budget->limitrepetitions()->where('limit_repetitions.startdate', \Session::get('start',Carbon::now()->startOfMonth())->format('Y-m-d'))->first(
+ $budget->currentRep = $budget->limitrepetitions()->where(
+ 'limit_repetitions.startdate', \Session::get('start', Carbon::now()->startOfMonth())->format('Y-m-d')
+ )->first(
['limit_repetitions.*']
);
}
);
$spent = $budgets->sum('spent');
- $amount = $this->_preferences->get('budgetIncomeTotal' . \Session::get('start',Carbon::now()->startOfMonth())->format('FY'), 1000)->data;
+ $amount = $this->_preferences->get('budgetIncomeTotal' . \Session::get('start', Carbon::now()->startOfMonth())->format('FY'), 1000)->data;
$overspent = $spent > $amount;
$spentPCT = $overspent ? ceil($amount / $spent * 100) : ceil($spent / $amount * 100);
@@ -133,7 +135,7 @@ class BudgetController extends BaseController
*/
public function postUpdateIncome()
{
- $this->_preferences->set('budgetIncomeTotal' . Session::get('start',Carbon::now()->startOfMonth())->format('FY'), intval(Input::get('amount')));
+ $this->_preferences->set('budgetIncomeTotal' . Session::get('start', Carbon::now()->startOfMonth())->format('FY'), intval(Input::get('amount')));
return Redirect::route('budgets.index');
}
@@ -146,13 +148,13 @@ class BudgetController extends BaseController
*/
public function show(Budget $budget, LimitRepetition $repetition = null)
{
- if (!is_null($repetition) && $repetition->limit->budget->id != $budget->id) {
+ if (!is_null($repetition) && $repetition->budgetlimit->budget->id != $budget->id) {
App::abort(500);
}
$hideBudget = true; // used in transaction list.
$journals = $this->_repository->getJournals($budget, $repetition);
- $limits = $repetition ? [$repetition->limit] : $budget->limits()->orderBy('startdate', 'DESC')->get();
+ $limits = $repetition ? [$repetition->limit] : $budget->budgetlimits()->orderBy('startdate', 'DESC')->get();
$subTitle = $repetition ? e($budget->name) . ' in ' . $repetition->startdate->format('F Y') : e($budget->name);
return View::make('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle', 'hideBudget'));
@@ -244,7 +246,7 @@ class BudgetController extends BaseController
*/
public function updateIncome()
{
- $budgetAmount = $this->_preferences->get('budgetIncomeTotal' . Session::get('start',Carbon::now()->startOfMonth())->format('FY'), 1000);
+ $budgetAmount = $this->_preferences->get('budgetIncomeTotal' . Session::get('start', Carbon::now()->startOfMonth())->format('FY'), 1000);
return View::make('budgets.income')->with('amount', $budgetAmount);
}
diff --git a/app/controllers/GoogleChartController.php b/app/controllers/GoogleChartController.php
index c31c66c354..c61be7cc12 100644
--- a/app/controllers/GoogleChartController.php
+++ b/app/controllers/GoogleChartController.php
@@ -1,9 +1,10 @@
<?php
use Carbon\Carbon;
use Grumpydictator\Gchart\GChart as GChart;
-use Illuminate\Database\Query\JoinClause;
/**
+ * @SuppressWarnings("CamelCase")
+ *
* Class GoogleChartController
*/
class GoogleChartController extends BaseController
@@ -119,11 +120,9 @@ class GoogleChartController extends BaseController
*/
public function allBudgetsHomeChart()
{
- /** @var \Grumpydictator\Gchart\GChart $chart */
- $chart = App::make('gchart');
- $chart->addColumn('Budget', 'string');
- $chart->addColumn('Budgeted', 'number');
- $chart->addColumn('Spent', 'number');
+ $this->_chart->addColumn('Budget', 'string');
+ $this->_chart->addColumn('Budgeted', 'number');
+ $this->_chart->addColumn('Spent', 'number');
/** @var \FireflyIII\Database\Budget $bdt */
$bdt = App::make('FireflyIII\Database\Budget');
@@ -165,7 +164,7 @@ class GoogleChartController extends BaseController
*/
$expenses = floatval($budget->transactionjournals()->before($searchEnd)->after($searchStart)->lessThan(0)->sum('amount')) * -1;
if ($expenses > 0) {
- $chart->addRow($budget->name, $limit, $expenses);
+ $this->_chart->addRow($budget->name, $limit, $expenses);
}
}
@@ -175,12 +174,12 @@ class GoogleChartController extends BaseController
*/
$noBudgetSet = $bdt->transactionsWithoutBudgetInDateRange(Session::get('start', Carbon::now()->startOfMonth()), Session::get('end'));
$sum = $noBudgetSet->sum('amount') * -1;
- $chart->addRow('No budget', 0, $sum);
+ $this->_chart->addRow('No budget', 0, $sum);
- $chart->generate();
+ $this->_chart->generate();
- return Response::json($chart->getData());
+ return Response::json($this->_chart->getData());
}
/**
diff --git a/app/controllers/HelpController.php b/app/controllers/HelpController.php
index 1424351c40..4d3bb54dcb 100644
--- a/app/controllers/HelpController.php
+++ b/app/controllers/HelpController.php
@@ -29,9 +29,9 @@ class HelpController extends BaseController
}
// get the help-content from Github:
- $URL = 'https://raw.githubusercontent.com/JC5/firefly-iii-help/master/' . e($route) . '.md';
+ $uri = 'https://raw.githubusercontent.com/JC5/firefly-iii-help/master/' . e($route) . '.md';
try {
- $content = file_get_contents($URL);
+ $content = file_get_contents($uri);
} catch (ErrorException $e) {
$content = '<p>There is no help for this route.</p>';
}
diff --git a/app/controllers/ReportController.php b/app/controllers/ReportController.php
index 81ff131fdd..04eef366f8 100644
--- a/app/controllers/ReportController.php
+++ b/app/controllers/ReportController.php
@@ -6,6 +6,8 @@ use FireflyIII\Database\TransactionJournal as TransactionJournalRepository;
use FireflyIII\Report\ReportInterface as ReportHelper;
/**
+ * @SuppressWarnings("CamelCase")
+ *
* Class ReportController
*/
class ReportController extends BaseController
@@ -163,7 +165,7 @@ class ReportController extends BaseController
public function unbalanced($year, $month)
{
try {
- $date = new Carbon($year . '-' . $month . '-01');
+ new Carbon($year . '-' . $month . '-01');
} catch (Exception $e) {
App::abort(500);
}
diff --git a/app/controllers/TransactionController.php b/app/controllers/TransactionController.php
index 5885f53f2d..cce380bad4 100644
--- a/app/controllers/TransactionController.php
+++ b/app/controllers/TransactionController.php
@@ -45,11 +45,11 @@ class TransactionController extends BaseController
}
}
$unique = array_unique($ids);
- if (count($ids) > 0) {
+ if (count($unique) > 0) {
/** @var \FireflyIII\Database\TransactionJournal $repository */
$repository = App::make('FireflyIII\Database\TransactionJournal');
- $set = $repository->getByIds($ids);
+ $set = $repository->getByIds($unique);
$set->each(
function (TransactionJournal $journal) {
$journal->amount = mf($journal->getAmount());
@@ -544,6 +544,7 @@ class TransactionController extends BaseController
/**
* @param TransactionJournal $journal
*
+ * @return $this
* @throws FireflyException
*/
public function update(TransactionJournal $journal)
diff --git a/app/database/migrations/2014_07_05_171326_create_component_transaction_journal_table.php b/app/database/migrations/2014_07_05_171326_create_component_transaction_journal_table.php
index 4474c18ec7..ba819428d3 100644
--- a/app/database/migrations/2014_07_05_171326_create_component_transaction_journal_table.php
+++ b/app/database/migrations/2014_07_05_171326_create_component_transaction_journal_table.php
@@ -30,19 +30,19 @@ class CreateComponentTransactionJournalTable extends Migration
{
Schema::create(
'component_transaction_journal', function (Blueprint $table) {
- $table->increments('id');
- $table->integer('component_id')->unsigned();
- $table->integer('transaction_journal_id')->unsigned();
+ $table->increments('id');
+ $table->integer('component_id')->unsigned();
+ $table->integer('transaction_journal_id')->unsigned();
- // link components with component_id
- $table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
+ // link components with component_id
+ $table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
- // link transaction journals with transaction_journal_id
- $table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
+ // link transaction journals with transaction_journal_id
+ $table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
- // combo must be unique:
- $table->unique(['component_id', 'transaction_journal_id'],'cid_tjid_unique');
- }
+ // combo must be unique:
+ $table->unique(['component_id', 'transaction_journal_id'], 'cid_tjid_unique');
+ }
);
}
diff --git a/app/database/migrations/2014_08_06_044416_create_component_recurring_transaction_table.php b/app/database/migrations/2014_08_06_044416_create_component_recurring_transaction_table.php
index e6f25ed2ec..1b0b56e384 100644
--- a/app/database/migrations/2014_08_06_044416_create_component_recurring_transaction_table.php
+++ b/app/database/migrations/2014_08_06_044416_create_component_recurring_transaction_table.php
@@ -30,21 +30,21 @@ class CreateComponentRecurringTransactionTable extends Migration
{
Schema::create(
'component_recurring_transaction', function (Blueprint $table) {
- $table->increments('id');
- $table->integer('component_id')->unsigned();
- $table->integer('recurring_transaction_id')->unsigned();
- $table->boolean('optional');
+ $table->increments('id');
+ $table->integer('component_id')->unsigned();
+ $table->integer('recurring_transaction_id')->unsigned();
+ $table->boolean('optional');
- // link components with component_id
- $table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
+ // link components with component_id
+ $table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
- // link transaction journals with transaction_journal_id
- $table->foreign('recurring_transaction_id')->references('id')->on('recurring_transactions')->onDelete('cascade');
+ // link transaction journals with transaction_journal_id
+ $table->foreign('recurring_transaction_id')->references('id')->on('recurring_transactions')->onDelete('cascade');
- // component and recurring transaction must be unique.
- $table->unique(['component_id','recurring_transaction_id'],'cid_rtid_unique');
+ // component and recurring transaction must be unique.
+ $table->unique(['component_id', 'recurring_transaction_id'], 'cid_rtid_unique');
- }
+ }
);
}
diff --git a/app/database/migrations/2014_12_13_190730_changes_for_v321.php b/app/database/migrations/2014_12_13_190730_changes_for_v321.php
new file mode 100644
index 0000000000..1b8f084771
--- /dev/null
+++ b/app/database/migrations/2014_12_13_190730_changes_for_v321.php
@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+
+/**
+ * Class ChangesForV321
+ */
+class ChangesForV321 extends Migration
+{
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ DB::update(DB::raw('RENAME TABLE `budget_limits` TO `limits`;'));
+ DB::update(DB::raw('ALTER TABLE `limit_repetitions` ALGORITHM=INPLACE, CHANGE `budget_limit_id` `limit_id` INT UNSIGNED NOT NULL'));
+
+ }
+
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ DB::update(DB::raw('RENAME TABLE `limits` TO `budget_limits`;'));
+ DB::update(DB::raw('ALTER TABLE `limit_repetitions` ALGORITHM=INPLACE, CHANGE `limit_id` `budget_limit_id` INT UNSIGNED NOT NULL'));
+
+ }
+
+}
diff --git a/app/database/seeds/TestContentSeeder.php b/app/database/seeds/TestContentSeeder.php
index 70154a8072..286c26ad84 100644
--- a/app/database/seeds/TestContentSeeder.php
+++ b/app/database/seeds/TestContentSeeder.php
@@ -17,8 +17,6 @@ class TestContentSeeder extends Seeder
$revenueType = AccountType::whereType('Revenue account')->first();
$ibType = AccountType::whereType('Initial balance account')->first();
- $euro = TransactionCurrency::whereCode('EUR')->first();
-
$obType = TransactionType::whereType('Opening balance')->first();
$withdrawal = TransactionType::whereType('Withdrawal')->first();
$transfer = TransactionType::whereType('Transfer')->first();
@@ -132,11 +130,15 @@ class TestContentSeeder extends Seeder
* @param $description
* @param $date
*
+ * @param Budget $budget
+ * @param Category $category
+ *
* @return TransactionJournal
*/
public function createTransaction(
Account $from, Account $to, $amount, TransactionType $type, $description, $date, Budget $budget = null, Category $category = null
- ) {
+ )
+ {
$user = User::whereEmail('[email protected]')->first();
$euro = TransactionCurrency::whereCode('EUR')->first();
diff --git a/app/lib/FireflyIII/Collection/PiggybankPart.php b/app/lib/FireflyIII/Collection/PiggybankPart.php
index faf28173b2..bf26edee5b 100644
--- a/app/lib/FireflyIII/Collection/PiggybankPart.php
+++ b/app/lib/FireflyIII/Collection/PiggybankPart.php
@@ -5,6 +5,11 @@ namespace FireflyIII\Collection;
use Carbon\Carbon;
+/**
+ * Class PiggybankPart
+ *
+ * @package FireflyIII\Collection
+ */
class PiggybankPart
{
/** @var float */
@@ -92,11 +97,17 @@ class PiggybankPart
$this->targetdate = $targetdate;
}
+ /**
+ * @return bool
+ */
public function hasReminder()
{
return !is_null($this->reminder);
}
+ /**
+ * @return float|int
+ */
public function percentage()
{
if ($this->getCurrentamount() < $this->getCumulativeAmount()) {
diff --git a/app/lib/FireflyIII/Database/Account.php b/app/lib/FireflyIII/Database/Account.php
index 5ccd858ec3..d1d91bce21 100644
--- a/app/lib/FireflyIII/Database/Account.php
+++ b/app/lib/FireflyIII/Database/Account.php
@@ -221,7 +221,7 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
{
// delete journals:
- $journals = \TransactionJournal::whereIn(
+ \TransactionJournal::whereIn(
'id', function ($query) use ($model) {
$query->select('transaction_journal_id')
->from('transactions')->whereIn(
@@ -454,10 +454,9 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
}
/**
- * Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
- *
* @param $what
*
+ * @throws NotImplementedException
* @return \AccountType|null
*/
public function findByWhat($what)
@@ -470,6 +469,7 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
* Returns all objects.
*
* @return Collection
+ * @throws NotImplementedException
*/
public function get()
{
@@ -487,6 +487,12 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
return $this->getUser()->accounts()->whereIn('id', $ids)->get();
}
+ /**
+ * @param $name
+ *
+ * @return static
+ * @throws \FireflyIII\Exception\FireflyException
+ */
public function firstExpenseAccountOrCreate($name)
{
/** @var \FireflyIII\Database\AccountType $accountTypeRepos */
@@ -510,6 +516,12 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
}
+ /**
+ * @param $name
+ *
+ * @return static
+ * @throws \FireflyIII\Exception\FireflyException
+ */
public function firstRevenueAccountOrCreate($name)
{
/** @var \FireflyIII\Database\AccountType $accountTypeRepos */
@@ -523,6 +535,12 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
}
+ /**
+ * @param \Account $account
+ * @param int $limit
+ *
+ * @return \Illuminate\Pagination\Paginator
+ */
public function getAllTransactionJournals(\Account $account, $limit = 50)
{
$offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $limit : 0;
@@ -568,6 +586,13 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
return $date;
}
+ /**
+ * @param \Account $account
+ * @param int $limit
+ * @param string $range
+ *
+ * @return \Illuminate\Pagination\Paginator
+ */
public function getTransactionJournals(\Account $account, $limit = 50, $range = 'session')
{
$offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $limit : 0;
@@ -580,8 +605,8 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
->orderBy('date', 'DESC');
if ($range == 'session') {
- $query->before(\Session::get('end', \Carbon\Carbon::now()->startOfMonth()));
- $query->after(\Session::get('start', \Carbon\Carbon::now()->startOfMonth()));
+ $query->before(\Session::get('end', Carbon::now()->startOfMonth()));
+ $query->after(\Session::get('start', Carbon::now()->startOfMonth()));
}
$count = $query->count();
$set = $query->take($limit)->offset($offset)->get(['transaction_journals.*']);
diff --git a/app/lib/FireflyIII/Database/AccountType.php b/app/lib/FireflyIII/Database/AccountType.php
index 6a7131d2b1..5015214a2a 100644
--- a/app/lib/FireflyIII/Database/AccountType.php
+++ b/app/lib/FireflyIII/Database/AccountType.php
@@ -21,6 +21,7 @@ class AccountType implements CUD, CommonDatabaseCalls
* @param \Eloquent $model
*
* @return bool
+ * @throws NotImplementedException
*/
public function destroy(\Eloquent $model)
{
@@ -32,6 +33,7 @@ class AccountType implements CUD, CommonDatabaseCalls
* @param array $data
*
* @return \Eloquent
+ * @throws NotImplementedException
*/
public function store(array $data)
{
@@ -41,9 +43,10 @@ class AccountType implements CUD, CommonDatabaseCalls
/**
* @param \Eloquent $model
- * @param array $data
+ * @param array $data
*
* @return bool
+ * @throws NotImplementedException
*/
public function update(\Eloquent $model, array $data)
{
@@ -58,6 +61,7 @@ class AccountType implements CUD, CommonDatabaseCalls
* @param array $model
*
* @return array
+ * @throws NotImplementedException
*/
public function validate(array $model)
{
@@ -71,6 +75,7 @@ class AccountType implements CUD, CommonDatabaseCalls
* @param int $id
*
* @return \Eloquent
+ * @throws NotImplementedException
*/
public function find($id)
{
@@ -115,6 +120,7 @@ class AccountType implements CUD, CommonDatabaseCalls
* Returns all objects.
*
* @return Collection
+ * @throws NotImplementedException
*/
public function get()
{
@@ -126,6 +132,7 @@ class AccountType implements CUD, CommonDatabaseCalls
* @param array $ids
*
* @return Collection
+ * @throws NotImplementedException
*/
public function getByIds(array $ids)
{
diff --git a/app/lib/FireflyIII/Database/Budget.php b/app/lib/FireflyIII/Database/Budget.php
index 5ed3b18e6d..16adbb4e6d 100644
--- a/app/lib/FireflyIII/Database/Budget.php
+++ b/app/lib/FireflyIII/Database/Budget.php
@@ -136,6 +136,7 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
* @param $what
*
* @return \AccountType|null
+ * @throws NotImplementedException
*/
public function findByWhat($what)
{
@@ -159,6 +160,7 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
* @param array $ids
*
* @return Collection
+ * @throws NotImplementedException
*/
public function getByIds(array $ids)
{
@@ -200,6 +202,12 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
return \Paginator::make($items, $count, $take);
}
+ /**
+ * @param \Budget $budget
+ * @param int $limit
+ *
+ * @return \Illuminate\Pagination\Paginator
+ */
public function getTransactionJournals(\Budget $budget, $limit = 50)
{
$offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $limit : 0;
@@ -214,6 +222,13 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
}
+ /**
+ * @param \Budget $budget
+ * @param \LimitRepetition $repetition
+ * @param int $limit
+ *
+ * @return \Illuminate\Pagination\Paginator
+ */
public function getTransactionJournalsInRepetition(\Budget $budget, \LimitRepetition $repetition, $limit = 50)
{
$start = $repetition->startdate;
@@ -241,8 +256,8 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
public function repetitionOnStartingOnDate(\Budget $budget, Carbon $date)
{
return \LimitRepetition::
- leftJoin('limits', 'limit_repetitions.limit_id', '=', 'limits.id')->leftJoin(
- 'components', 'limits.component_id', '=', 'components.id'
+ leftJoin('budget_limits', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')->leftJoin(
+ 'components', 'budget_limits.component_id', '=', 'components.id'
)->where('limit_repetitions.startdate', $date->format('Y-m-d'))->where(
'components.id', $budget->id
)->first(['limit_repetitions.*']);
diff --git a/app/lib/FireflyIII/Database/Category.php b/app/lib/FireflyIII/Database/Category.php
index 649dfc47ea..88b1c59b35 100644
--- a/app/lib/FireflyIII/Database/Category.php
+++ b/app/lib/FireflyIII/Database/Category.php
@@ -124,6 +124,7 @@ class Category implements CUD, CommonDatabaseCalls
* @param int $id
*
* @return \Eloquent
+ * @throws NotImplementedException
*/
public function find($id)
{
@@ -137,6 +138,7 @@ class Category implements CUD, CommonDatabaseCalls
* @param $what
*
* @return \AccountType|null
+ * @throws NotImplementedException
*/
public function findByWhat($what)
{
@@ -158,6 +160,7 @@ class Category implements CUD, CommonDatabaseCalls
* @param array $ids
*
* @return Collection
+ * @throws NotImplementedException
*/
public function getByIds(array $ids)
{
@@ -165,11 +168,22 @@ class Category implements CUD, CommonDatabaseCalls
throw new NotImplementedException;
}
+ /**
+ * @param $name
+ *
+ * @return static
+ */
public function firstOrCreate($name)
{
return \Category::firstOrCreate(['user_id' => $this->getUser()->id, 'name' => $name]);
}
+ /**
+ * @param \Category $category
+ * @param int $limit
+ *
+ * @return \Illuminate\Pagination\Paginator
+ */
public function getTransactionJournals(\Category $category, $limit = 50)
{
$offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $limit : 0;
@@ -185,10 +199,11 @@ class Category implements CUD, CommonDatabaseCalls
}
/**
- * @param \Category $budget
+ * @param \Category $category
* @param Carbon $date
*
* @return null
+ * @internal param \Category $budget
*/
public function repetitionOnStartingOnDate(\Category $category, Carbon $date)
{
diff --git a/app/lib/FireflyIII/Database/Ifaces/RecurringInterface.php b/app/lib/FireflyIII/Database/Ifaces/RecurringInterface.php
index 5ff9a7aabb..426b507a76 100644
--- a/app/lib/FireflyIII/Database/Ifaces/RecurringInterface.php
+++ b/app/lib/FireflyIII/Database/Ifaces/RecurringInterface.php
@@ -13,10 +13,13 @@ interface RecurringInterface
{
/**
* @param \RecurringTransaction $recurring
- * @param Carbon $current
- * @param Carbon $currentEnd
+ * @param Carbon $start
+ * @param Carbon $end
+ *
+ * @return null|\TransactionJournal
+ * @internal param Carbon $current
+ * @internal param Carbon $currentEnd
*
- * @return \TransactionJournal|null
*/
public function getJournalForRecurringInRange(\RecurringTransaction $recurring, Carbon $start, Carbon $end);
diff --git a/app/lib/FireflyIII/Database/Ifaces/ReportInterface.php b/app/lib/FireflyIII/Database/Ifaces/ReportInterface.php
index 192d388c90..90aef7181a 100644
--- a/app/lib/FireflyIII/Database/Ifaces/ReportInterface.php
+++ b/app/lib/FireflyIII/Database/Ifaces/ReportInterface.php
@@ -5,6 +5,11 @@ namespace FireflyIII\Database\Ifaces;
use Carbon\Carbon;
+/**
+ * Interface ReportInterface
+ *
+ * @package FireflyIII\Database\Ifaces
+ */
interface ReportInterface
{
diff --git a/app/lib/FireflyIII/Database/Piggybank.php b/app/lib/FireflyIII/Database/Piggybank.php
index f416900a4c..0f8c4e58f6 100644
--- a/app/lib/FireflyIII/Database/Piggybank.php
+++ b/app/lib/FireflyIII/Database/Piggybank.php
@@ -203,6 +203,7 @@ class Piggybank implements CUD, CommonDatabaseCalls, PiggybankInterface
* @param $what
*
* @return \AccountType|null
+ * @throws NotImplementedException
*/
public function findByWhat($what)
{
@@ -224,6 +225,7 @@ class Piggybank implements CUD, CommonDatabaseCalls, PiggybankInterface
* @param array $ids
*
* @return Collection
+ * @throws NotImplementedException
*/
public function getByIds(array $ids)
{
@@ -231,7 +233,16 @@ class Piggybank implements CUD, CommonDatabaseCalls, PiggybankInterface
throw new NotImplementedException;
}
- public function findRepetitionByDate(\Piggybank $piggybank, Carbon $date)
+ /**
+ * @param \Piggybank $piggybank
+ * @param Carbon $date
+ *
+ * @return mixed
+ * @throws FireflyException
+ * @throws NotImplementedException
+ */
+ public function findRepetitionByDate(\Piggybank $piggybank, /** @noinspection PhpUnusedParameterInspection */
+ Carbon $date)
{
$reps = $piggybank->piggybankrepetitions()->get();
if ($reps->count() == 1) {
diff --git a/app/lib/FireflyIII/Database/Recurring.php b/app/lib/FireflyIII/Database/Recurring.php
index d87a7f2b33..d503230d97 100644
--- a/app/lib/FireflyIII/Database/Recurring.php
+++ b/app/lib/FireflyIII/Database/Recurring.php
@@ -183,6 +183,7 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
* @param int $id
*
* @return \Eloquent
+ * @throws NotImplementedException
*/
public function find($id)
{
@@ -196,6 +197,7 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
* @param $what
*
* @return \AccountType|null
+ * @throws NotImplementedException
*/
public function findByWhat($what)
{
@@ -217,6 +219,7 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
* @param array $ids
*
* @return Collection
+ * @throws NotImplementedException
*/
public function getByIds(array $ids)
{
diff --git a/app/lib/FireflyIII/Database/RepeatedExpense.php b/app/lib/FireflyIII/Database/RepeatedExpense.php
index e0294558ce..18d098bd8f 100644
--- a/app/lib/FireflyIII/Database/RepeatedExpense.php
+++ b/app/lib/FireflyIII/Database/RepeatedExpense.php
@@ -13,6 +13,11 @@ use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag;
+/**
+ * Class RepeatedExpense
+ *
+ * @package FireflyIII\Database
+ */
class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
{
use SwitchUser;
@@ -30,6 +35,8 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
* other variables this method tries to divide the piggy bank into equal parts. Each is
* accommodated by a reminder (if everything goes to plan).
*
+ * @param \PiggybankRepetition $repetition
+ *
* @return \PiggybankRepetition
*/
public function calculateParts(\PiggybankRepetition $repetition)
@@ -98,7 +105,7 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
foreach ($bars as $index => $bar) {
$bar->setAmountPerBar($amountPerBar);
$bar->setCumulativeAmount($cumulative);
- if($parts -1 == $index) {
+ if ($parts - 1 == $index) {
$bar->setCumulativeAmount($piggyBank->targetamount);
}
@@ -275,6 +282,7 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
* @param \Eloquent $model
*
* @return bool
+ * @throws NotImplementedException
*/
public function destroy(\Eloquent $model)
{
@@ -316,9 +324,10 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
/**
* @param \Eloquent $model
- * @param array $data
+ * @param array $data
*
* @return bool
+ * @throws NotImplementedException
*/
public function update(\Eloquent $model, array $data)
{
@@ -426,6 +435,7 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
* @param int $id
*
* @return \Eloquent
+ * @throws NotImplementedException
*/
public function find($id)
{
@@ -439,6 +449,7 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
* @param $what
*
* @return \AccountType|null
+ * @throws NotImplementedException
*/
public function findByWhat($what)
{
@@ -460,6 +471,7 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
* @param array $ids
*
* @return Collection
+ * @throws NotImplementedException
*/
public function getByIds(array $ids)
{
@@ -471,6 +483,7 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
* @param \Account $account
*
* @return float
+ * @throws NotImplementedException
*/
public function leftOnAccount(\Account $account)
{
diff --git a/app/lib/FireflyIII/Database/Report.php b/app/lib/FireflyIII/Database/Report.php
index 4cd5d5238c..7de6f79481 100644
--- a/app/lib/FireflyIII/Database/Report.php
+++ b/app/lib/FireflyIII/Database/Report.php
@@ -12,6 +12,11 @@ namespace FireflyIII\Database;
use Carbon\Carbon;
use FireflyIII\Database\Ifaces\ReportInterface;
+/**
+ * Class Report
+ *
+ * @package FireflyIII\Database
+ */
class Report implements ReportInterface
{
use SwitchUser;
diff --git a/app/lib/FireflyIII/Database/Transaction.php b/app/lib/FireflyIII/Database/Transaction.php
index 514ea66217..566c41c9de 100644
--- a/app/lib/FireflyIII/Database/Transaction.php
+++ b/app/lib/FireflyIII/Database/Transaction.php
@@ -24,6 +24,7 @@ class Transaction implements CUD, CommonDatabaseCalls
* @param \Eloquent $model
*
* @return bool
+ * @throws NotImplementedException
*/
public function destroy(\Eloquent $model)
{
@@ -35,6 +36,7 @@ class Transaction implements CUD, CommonDatabaseCalls
* @param array $data
*
* @return \Eloquent
+ * @throws FireflyException
*/
public function store(array $data)
{
@@ -59,9 +61,10 @@ class Transaction implements CUD, CommonDatabaseCalls
/**
* @param \Eloquent $model
- * @param array $data
+ * @param array $data
*
* @return bool
+ * @throws NotImplementedException
*/
public function update(\Eloquent $model, array $data)
{
@@ -141,6 +144,7 @@ class Transaction implements CUD, CommonDatabaseCalls
* @param int $id
*
* @return \Eloquent
+ * @throws NotImplementedException
*/
public function find($id)
{
@@ -154,6 +158,7 @@ class Transaction implements CUD, CommonDatabaseCalls
* @param $what
*
* @return \AccountType|null
+ * @throws NotImplementedException
*/
public function findByWhat($what)
{
@@ -165,6 +170,7 @@ class Transaction implements CUD, CommonDatabaseCalls
* Returns all objects.
*
* @return Collection
+ * @throws NotImplementedException
*/
public function get()
{
@@ -176,6 +182,7 @@ class Transaction implements CUD, CommonDatabaseCalls
* @param array $ids
*
* @return Collection
+ * @throws NotImplementedException
*/
public function getByIds(array $ids)
{
diff --git a/app/lib/FireflyIII/Database/TransactionJournal.php b/app/lib/FireflyIII/Database/TransactionJournal.php
index 4a51e9e607..a05f8d5e62 100644
--- a/app/lib/FireflyIII/Database/TransactionJournal.php
+++ b/app/lib/FireflyIII/Database/TransactionJournal.php
@@ -58,6 +58,7 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
* @param array $data
*
* @return \Eloquent
+ * @throws FireflyException
*/
public function store(array $data)
{
@@ -174,6 +175,7 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
* @param array $data
*
* @return bool
+ * @throws FireflyException
*/
public function update(\Eloquent $model, array $data)
{
@@ -186,9 +188,6 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
/** @var \FireflyIII\Database\TransactionCurrency $currencyRepository */
$currencyRepository = \App::make('FireflyIII\Database\TransactionCurrency');
- /** @var \FireflyIII\Database\Transaction $transactionRepository */
- $transactionRepository = \App::make('FireflyIII\Database\Transaction');
-
$journalType = $typeRepository->findByWhat($data['what']);
$currency = $currencyRepository->findByCode($data['currency']);
@@ -284,6 +283,7 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
* @param array $model
*
* @return array
+ * @throws FireflyException
*/
public function validate(array $model)
{
@@ -350,7 +350,6 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
/*
* Many checks to catch invalid or not-existing accounts.
*/
- $accountError = false;
switch (true) {
// this combination is often seen in withdrawals.
case (isset($model['account_id']) && isset($model['expense_account'])):
@@ -458,6 +457,7 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
* @param $what
*
* @return \AccountType|null
+ * @throws NotImplementedException
*/
public function findByWhat($what)
{
@@ -560,6 +560,11 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
return $sum;
}
+ /**
+ * @param int $limit
+ *
+ * @return \Illuminate\Pagination\Paginator
+ */
public function getDepositsPaginated($limit = 50)
{
$offset = intval(\Input::get('page')) > 0 ? (intval(\Input::get('page')) - 1) * $limit : 0;
@@ -599,6 +604,11 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
return $query;
}
+ /**
+ * @param int $limit
+ *
+ * @return \Illuminate\Pagination\Paginator
+ */
public function getTransfersPaginated($limit = 50)
{
$offset = intval(\Input::get('page')) > 0 ? (intval(\Input::get('page')) - 1) * $limit : 0;
@@ -615,6 +625,11 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
return \Paginator::make($items, $count, $limit);
}
+ /**
+ * @param int $limit
+ *
+ * @return \Illuminate\Pagination\Paginator
+ */
public function getWithdrawalsPaginated($limit = 50)
{
$offset = intval(\Input::get('page')) > 0 ? (intval(\Input::get('page')) - 1) * $limit : 0;
diff --git a/app/lib/FireflyIII/Database/TransactionType.php b/app/lib/FireflyIII/Database/TransactionType.php
index 566c60ba45..8c19431c34 100644
--- a/app/lib/FireflyIII/Database/TransactionType.php
+++ b/app/lib/FireflyIII/Database/TransactionType.php
@@ -23,6 +23,7 @@ class TransactionType implements CUD, CommonDatabaseCalls
* @param \Eloquent $model
*
* @return bool
+ * @throws NotImplementedException
*/
public function destroy(\Eloquent $model)
{
@@ -34,6 +35,7 @@ class TransactionType implements CUD, CommonDatabaseCalls
* @param array $data
*
* @return \Eloquent
+ * @throws NotImplementedException
*/
public function store(array $data)
{
@@ -43,9 +45,10 @@ class TransactionType implements CUD, CommonDatabaseCalls
/**
* @param \Eloquent $model
- * @param array $data
+ * @param array $data
*
* @return bool
+ * @throws NotImplementedException
*/
public function update(\Eloquent $model, array $data)
{
@@ -60,6 +63,7 @@ class TransactionType implements CUD, CommonDatabaseCalls
* @param array $model
*
* @return array
+ * @throws NotImplementedException
*/
public function validate(array $model)
{
@@ -73,6 +77,7 @@ class TransactionType implements CUD, CommonDatabaseCalls
* @param int $id
*
* @return \Eloquent
+ * @throws NotImplementedException
*/
public function find($id)
{
@@ -86,6 +91,7 @@ class TransactionType implements CUD, CommonDatabaseCalls
* @param $what
*
* @return \AccountType|null
+ * @throws FireflyException
*/
public function findByWhat($what)
{
@@ -114,6 +120,7 @@ class TransactionType implements CUD, CommonDatabaseCalls
* Returns all objects.
*
* @return Collection
+ * @throws NotImplementedException
*/
public function get()
{
@@ -125,6 +132,7 @@ class TransactionType implements CUD, CommonDatabaseCalls
* @param array $ids
*
* @return Collection
+ * @throws NotImplementedException
*/
public function getByIds(array $ids)
{
diff --git a/app/lib/FireflyIII/Event/Account.php b/app/lib/FireflyIII/Event/Account.php
index 7b265b9816..bdc87d8e9a 100644
--- a/app/lib/FireflyIII/Event/Account.php
+++ b/app/lib/FireflyIII/Event/Account.php
@@ -5,14 +5,25 @@ namespace FireflyIII\Event;
use Illuminate\Events\Dispatcher;
+/**
+ * Class Account
+ *
+ * @package FireflyIII\Event
+ */
class Account
{
+ /**
+ * @param \Account $account
+ */
public function destroy(\Account $account)
{
\Cache::forget('account.' . $account->id . '.latestBalance');
\Cache::forget('account.' . $account->id . '.lastActivityDate');
}
+ /**
+ * @param \Account $account
+ */
public function store(\Account $account)
{
@@ -31,6 +42,9 @@ class Account
$events->listen('account.destroy', 'FireflyIII\Event\Account@destroy');
}
+ /**
+ * @param \Account $account
+ */
public function update(\Account $account)
{
\Cache::forget('account.' . $account->id . '.latestBalance');
diff --git a/app/lib/FireflyIII/Event/Budget.php b/app/lib/FireflyIII/Event/Budget.php
index adbd8abb95..f40e02b958 100644
--- a/app/lib/FireflyIII/Event/Budget.php
+++ b/app/lib/FireflyIII/Event/Budget.php
@@ -5,35 +5,40 @@ namespace FireflyIII\Event;
use Illuminate\Database\QueryException;
use Illuminate\Events\Dispatcher;
+/**
+ * Class Budget
+ *
+ * @package FireflyIII\Event
+ */
class Budget
{
/**
- * @param \Limit $limit
+ * @param \BudgetLimit $budgetLimit
*/
- public function storeOrUpdateLimit(\Limit $limit)
+ public function storeOrUpdateLimit(\BudgetLimit $budgetLimit)
{
- $end = \DateKit::addPeriod(clone $limit->startdate, $limit->repeat_freq, 0);
+ $end = \DateKit::addPeriod(clone $budgetLimit->startdate, $budgetLimit->repeat_freq, 0);
$end->subDay();
- $set = $limit->limitrepetitions()->where('startdate', $limit->startdate->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'))->get();
+ $set = $budgetLimit->limitrepetitions()->where('startdate', $budgetLimit->startdate->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'))->get();
/*
* Create new LimitRepetition:
*/
if ($set->count() == 0) {
$repetition = new \LimitRepetition();
- $repetition->startdate = $limit->startdate;
+ $repetition->startdate = $budgetLimit->startdate;
$repetition->enddate = $end;
- $repetition->amount = $limit->amount;
- $repetition->limit()->associate($limit);
+ $repetition->amount = $budgetLimit->amount;
+ $repetition->budgetLimit()->associate($budgetLimit);
try {
$repetition->save();
} catch (QueryException $e) {
- \Log::error('Trying to save new Limitrepetition failed!');
+ \Log::error('Trying to save new LimitRepetition failed!');
\Log::error($e->getMessage());
}
} else {
@@ -42,7 +47,7 @@ class Budget
* Update existing one.
*/
$repetition = $set->first();
- $repetition->amount = $limit->amount;
+ $repetition->amount = $budgetLimit->amount;
$repetition->save();
}
diff --git a/app/lib/FireflyIII/Event/Event.php b/app/lib/FireflyIII/Event/Event.php
index 1f670ccb20..0f4bfda97a 100644
--- a/app/lib/FireflyIII/Event/Event.php
+++ b/app/lib/FireflyIII/Event/Event.php
@@ -4,9 +4,19 @@ namespace FireflyIII\Event;
use Illuminate\Events\Dispatcher;
+/**
+ * Class Event
+ *
+ * @package FireflyIII\Event
+ */
class Event
{
+ /**
+ * @param \Account $account
+ *
+ * @throws \Exception
+ */
public function deleteAccount(\Account $account)
{
// get piggy banks
diff --git a/app/lib/FireflyIII/Event/Piggybank.php b/app/lib/FireflyIII/Event/Piggybank.php
index 05657efafb..206c165988 100644
--- a/app/lib/FireflyIII/Event/Piggybank.php
+++ b/app/lib/FireflyIII/Event/Piggybank.php
@@ -6,6 +6,11 @@ namespace FireflyIII\Event;
use Carbon\Carbon;
use Illuminate\Events\Dispatcher;
+/**
+ * Class Piggybank
+ *
+ * @package FireflyIII\Event
+ */
class Piggybank
{
@@ -21,13 +26,19 @@ class Piggybank
$event->amount = floatval($amount);
$event->date = new Carbon;
if (!$event->isValid()) {
- var_dump($event->getErrors());
- exit();
+ \Log::error($event->getErrors());
+ \App::abort(500);
}
$event->save();
}
}
+ /**
+ * @param \TransactionJournal $journal
+ *
+ * @throws \FireflyIII\Exception\FireflyException
+ * @throws \FireflyIII\Exception\NotImplementedException
+ */
public function destroyTransfer(\TransactionJournal $journal)
{
if ($journal->piggybankevents()->count() > 0) {
@@ -88,6 +99,9 @@ class Piggybank
}
}
+ /**
+ * @param \Piggybank $piggybank
+ */
public function storePiggybank(\Piggybank $piggybank)
{
if (intval($piggybank->repeats) == 0) {
@@ -250,6 +264,9 @@ class Piggybank
}
}
+ /**
+ * @param \Piggybank $piggyBank
+ */
public function updatePiggybank(\Piggybank $piggyBank)
{
// get the repetition:
@@ -259,6 +276,12 @@ class Piggybank
$repetition->save();
}
+ /**
+ * @param \TransactionJournal $journal
+ *
+ * @throws \FireflyIII\Exception\FireflyException
+ * @throws \FireflyIII\Exception\NotImplementedException
+ */
public function updateTransfer(\TransactionJournal $journal)
{
diff --git a/app/lib/FireflyIII/Event/Transaction.php b/app/lib/FireflyIII/Event/Transaction.php
index 285e942875..e5d53e04f5 100644
--- a/app/lib/FireflyIII/Event/Transaction.php
+++ b/app/lib/FireflyIII/Event/Transaction.php
@@ -5,14 +5,25 @@ namespace FireflyIII\Event;
use Illuminate\Events\Dispatcher;
+/**
+ * Class Transaction
+ *
+ * @package FireflyIII\Event
+ */
class Transaction
{
+ /**
+ * @param \Transaction $transaction
+ */
public function destroy(\Transaction $transaction)
{
\Cache::forget('account.' . $transaction->account_id . '.latestBalance');
\Cache::forget('account.' . $transaction->account_id . '.lastActivityDate');
}
+ /**
+ * @param \Transaction $transaction
+ */
public function store(\Transaction $transaction)
{
\Cache::forget('account.' . $transaction->account_id . '.latestBalance');
@@ -30,6 +41,9 @@ class Transaction
$events->listen('transaction.destroy', 'FireflyIII\Event\Transaction@destroy');
}
+ /**
+ * @param \Transaction $transaction
+ */
public function update(\Transaction $transaction)
{
\Cache::forget('account.' . $transaction->account_id . '.latestBalance');
diff --git a/app/lib/FireflyIII/Event/TransactionJournal.php b/app/lib/FireflyIII/Event/TransactionJournal.php
index aabc4c0537..88353e34ee 100644
--- a/app/lib/FireflyIII/Event/TransactionJournal.php
+++ b/app/lib/FireflyIII/Event/TransactionJournal.php
@@ -4,10 +4,19 @@ namespace FireflyIII\Event;
use Illuminate\Events\Dispatcher;
+/**
+ * Class TransactionJournal
+ *
+ * @package FireflyIII\Event
+ */
class TransactionJournal
{
- public function store(\TransactionJournal $journal, $id = 0)
+ /**
+ * @param \TransactionJournal $journal
+ * @param int $id
+ */
+ public function store(\TransactionJournal $journal)
{
/** @var \FireflyIII\Database\Recurring $repository */
$repository = \App::make('FireflyIII\Database\Recurring');
@@ -30,6 +39,9 @@ class TransactionJournal
$events->listen('transactionJournal.update', 'FireflyIII\Event\TransactionJournal@update');
}
+ /**
+ * @param \TransactionJournal $journal
+ */
public function update(\TransactionJournal $journal)
{
/** @var \FireflyIII\Database\Recurring $repository */
diff --git a/app/lib/FireflyIII/Form/Form.php b/app/lib/FireflyIII/Form/Form.php
index 9b11b13678..4f8bda184d 100644
--- a/app/lib/FireflyIII/Form/Form.php
+++ b/app/lib/FireflyIII/Form/Form.php
@@ -287,18 +287,17 @@ class Form
/*
* Store.
*/
- $store = '';
switch ($type) {
case 'create':
- $store = '<div class="form-group"><label for="default" class="col-sm-4 control-label">Store</label>';
+ $store = '<div class="form-group"><label for="' . $name . '_store" class="col-sm-4 control-label">Store</label>';
$store .= '<div class="col-sm-8"><div class="radio"><label>';
- $store .= \Form::radio('post_submit_action', 'store', $previousValue == 'store');
+ $store .= \Form::radio('post_submit_action', 'store', $previousValue == 'store', ['id' => $name . '_store']);
$store .= 'Store ' . $name . '</label></div></div></div>';
break;
case 'update':
- $store = '<div class="form-group"><label for="default" class="col-sm-4 control-label">Store</label>';
+ $store = '<div class="form-group"><label for="' . $name . 'update" class="col-sm-4 control-label">Store</label>';
$store .= '<div class="col-sm-8"><div class="radio"><label>';
- $store .= \Form::radio('post_submit_action', 'update', $previousValue == 'store');
+ $store .= \Form::radio('post_submit_action', 'update', $previousValue == 'update', ['id' => $name . '_update']);
$store .= 'Update ' . $name . '</label></div></div></div>';
break;
default:
@@ -309,9 +308,9 @@ class Form
/*
* validate is always the same:
*/
- $validate = '<div class="form-group"><label for="validate_only" class="col-sm-4 control-label">Validate only';
+ $validate = '<div class="form-group"><label for="' . $name . 'validate_only" class="col-sm-4 control-label">Validate only';
$validate .= '</label><div class="col-sm-8"><div class="radio"><label>';
- $validate .= \Form::radio('post_submit_action', 'validate_only', $previousValue == 'validate_only');
+ $validate .= \Form::radio('post_submit_action', 'validate_only', $previousValue == 'validate_only', ['id' => $name . '_validate_only']);
$validate .= 'Only validate, do not save</label></div></div></div>';
/*
@@ -319,15 +318,15 @@ class Form
*/
switch ($type) {
case 'create':
- $return = '<div class="form-group"><label for="return_to_form" class="col-sm-4 control-label">';
+ $return = '<div class="form-group"><label for="' . $name . 'return_to_form" class="col-sm-4 control-label">';
$return .= 'Return here</label><div class="col-sm-8"><div class="radio"><label>';
- $return .= \Form::radio('post_submit_action', 'create_another', $previousValue == 'create_another');
+ $return .= \Form::radio('post_submit_action', 'create_another', $previousValue == 'create_another', ['id' => $name . '_create_another']);
$return .= 'After storing, return here to create another one.</label></div></div></div>';
break;
case 'update':
- $return = '<div class="form-group"><label for="return_to_edit" class="col-sm-4 control-label">';
+ $return = '<div class="form-group"><label for="' . $name . 'return_to_edit" class="col-sm-4 control-label">';
$return .= 'Return here</label><div class="col-sm-8"><div class="radio"><label>';
- $return .= \Form::radio('post_submit_action', 'return_to_edit', $previousValue == 'return_to_edit');
+ $return .= \Form::radio('post_submit_action', 'return_to_edit', $previousValue == 'return_to_edit', ['id' => $name . '_return_to_edit']);
$return .= 'After updating, return here.</label></div></div></div>';
break;
default:
diff --git a/app/lib/FireflyIII/Report/Report.php b/app/lib/FireflyIII/Report/Report.php
index d1e6c2a6e4..bb74faaafc 100644
--- a/app/lib/FireflyIII/Report/Report.php
+++ b/app/lib/FireflyIII/Report/Report.php
@@ -9,6 +9,8 @@ use Illuminate\Support\Collection;
/**
* Class Report
*
+ * @SuppressWarnings("CamelCase")
+ *
* @package FireflyIII\Report
*/
class Report implements ReportInterface
diff --git a/app/lib/FireflyIII/Search/Search.php b/app/lib/FireflyIII/Search/Search.php
index 6af5a92c15..810c8f01f6 100644
--- a/app/lib/FireflyIII/Search/Search.php
+++ b/app/lib/FireflyIII/Search/Search.php
@@ -5,6 +5,11 @@ namespace FireflyIII\Search;
use Illuminate\Support\Collection;
+/**
+ * Class Search
+ *
+ * @package FireflyIII\Search
+ */
class Search
{
/**
diff --git a/app/lib/FireflyIII/Shared/Facade/DateKit.php b/app/lib/FireflyIII/Shared/Facade/DateKit.php
index 387d3c7372..3a0e75ca7e 100644
--- a/app/lib/FireflyIII/Shared/Facade/DateKit.php
+++ b/app/lib/FireflyIII/Shared/Facade/DateKit.php
@@ -4,10 +4,18 @@ namespace FireflyIII\Shared\Facade;
use Illuminate\Support\Facades\Facade;
+/**
+ * Class DateKit
+ *
+ * @package FireflyIII\Shared\Facade
+ */
class DateKit extends Facade
{
+ /**
+ * @return string
+ */
protected static function getFacadeAccessor()
{
return 'datekit';
diff --git a/app/lib/FireflyIII/Shared/Facade/FFForm.php b/app/lib/FireflyIII/Shared/Facade/FFForm.php
index 9f62786350..c5aefd74b8 100644
--- a/app/lib/FireflyIII/Shared/Facade/FFForm.php
+++ b/app/lib/FireflyIII/Shared/Facade/FFForm.php
@@ -4,10 +4,18 @@ namespace FireflyIII\Shared\Facade;
use Illuminate\Support\Facades\Facade;
+/**
+ * Class FFForm
+ *
+ * @package FireflyIII\Shared\Facade
+ */
class FFForm extends Facade
{
+ /**
+ * @return string
+ */
protected static function getFacadeAccessor()
{
return 'ffform';
diff --git a/app/lib/FireflyIII/Shared/Facade/Filter.php b/app/lib/FireflyIII/Shared/Facade/Filter.php
index d1ca6e6435..f37019bb56 100644
--- a/app/lib/FireflyIII/Shared/Facade/Filter.php
+++ b/app/lib/FireflyIII/Shared/Facade/Filter.php
@@ -4,10 +4,18 @@ namespace FireflyIII\Shared\Facade;
use Illuminate\Support\Facades\Facade;
+/**
+ * Class Filter
+ *
+ * @package FireflyIII\Shared\Facade
+ */
class Filter extends Facade
{
+ /**
+ * @return string
+ */
protected static function getFacadeAccessor()
{
return 'filter';
diff --git a/app/lib/FireflyIII/Shared/Facade/Navigation.php b/app/lib/FireflyIII/Shared/Facade/Navigation.php
index 10bcd6ab5f..19892870fa 100644
--- a/app/lib/FireflyIII/Shared/Facade/Navigation.php
+++ b/app/lib/FireflyIII/Shared/Facade/Navigation.php
@@ -4,10 +4,18 @@ namespace FireflyIII\Shared\Facade;
use Illuminate\Support\Facades\Facade;
+/**
+ * Class Navigation
+ *
+ * @package FireflyIII\Shared\Facade
+ */
class Navigation extends Facade
{
+ /**
+ * @return string
+ */
protected static function getFacadeAccessor()
{
return 'navigation';
diff --git a/app/lib/FireflyIII/Shared/Facade/Reminders.php b/app/lib/FireflyIII/Shared/Facade/Reminders.php
index 20105e2be0..b0052a11b7 100644
--- a/app/lib/FireflyIII/Shared/Facade/Reminders.php
+++ b/app/lib/FireflyIII/Shared/Facade/Reminders.php
@@ -4,10 +4,18 @@ namespace FireflyIII\Shared\Facade;
use Illuminate\Support\Facades\Facade;
+/**
+ * Class Reminders
+ *
+ * @package FireflyIII\Shared\Facade
+ */
class Reminders extends Facade
{
+ /**
+ * @return string
+ */
protected static function getFacadeAccessor()
{
return 'reminders';
diff --git a/app/lib/FireflyIII/Shared/Facade/Steam.php b/app/lib/FireflyIII/Shared/Facade/Steam.php
index 7b21a65619..2d5b6b8d86 100644
--- a/app/lib/FireflyIII/Shared/Facade/Steam.php
+++ b/app/lib/FireflyIII/Shared/Facade/Steam.php
@@ -4,10 +4,18 @@ namespace FireflyIII\Shared\Facade;
use Illuminate\Support\Facades\Facade;
+/**
+ * Class Steam
+ *
+ * @package FireflyIII\Shared\Facade
+ */
class Steam extends Facade
{
+ /**
+ * @return string
+ */
protected static function getFacadeAccessor()
{
return 'steam';
diff --git a/app/lib/FireflyIII/Shared/Mail/Registration.php b/app/lib/FireflyIII/Shared/Mail/Registration.php
index eecfd4a135..774deaf203 100644
--- a/app/lib/FireflyIII/Shared/Mail/Registration.php
+++ b/app/lib/FireflyIII/Shared/Mail/Registration.php
@@ -1,5 +1,6 @@
<?php
namespace FireflyIII\Shared\Mail;
+
use Swift_RfcComplianceException;
/**
@@ -28,10 +29,11 @@ class Registration implements RegistrationInterface
try {
\Mail::send(
['emails.user.register-html', 'emails.user.register-text'], $data, function ($message) use ($email) {
- $message->to($email, $email)->subject('Welcome to Firefly!');
- }
+ $message->to($email, $email)->subject('Welcome to Firefly!');
+ }
);
- } catch(Swift_RfcComplianceException $e) {}
+ } catch (Swift_RfcComplianceException $e) {
+ }
}
/**
@@ -49,8 +51,8 @@ class Registration implements RegistrationInterface
$data = ['reset' => $reset];
\Mail::send(
['emails.user.remindme-html', 'emails.user.remindme-text'], $data, function ($message) use ($email) {
- $message->to($email, $email)->subject('Forgot your password?');
- }
+ $message->to($email, $email)->subject('Forgot your password?');
+ }
);
@@ -72,8 +74,8 @@ class Registration implements RegistrationInterface
\Mail::send(
['emails.user.verify-html', 'emails.user.verify-text'], $data, function ($message) use ($email) {
- $message->to($email, $email)->subject('Verify your e-mail address.');
- }
+ $message->to($email, $email)->subject('Verify your e-mail address.');
+ }
);
}
diff --git a/app/lib/FireflyIII/Shared/SingleTableInheritanceEntity.php b/app/lib/FireflyIII/Shared/SingleTableInheritanceEntity.php
index eb43e60b6a..8af9b11e3d 100644
--- a/app/lib/FireflyIII/Shared/SingleTableInheritanceEntity.php
+++ b/app/lib/FireflyIII/Shared/SingleTableInheritanceEntity.php
@@ -13,13 +13,10 @@ abstract class SingleTableInheritanceEntity extends \Eloquent
*
* @var bool
*/
- protected $isSubclass = false;
- /**
- * The field that stores the subclass
- *
- * @var string
- */
+ // @codingStandardsIgnoreStart
+ protected $isSubclass = false;
protected $subclassField = null;
+ // @codingStandardsIgnoreEnd
/**
* @param array $attributes
@@ -77,9 +74,8 @@ abstract class SingleTableInheritanceEntity extends \Eloquent
*
* @return bool
*/
- public function save(
- array $rules = [], array $customMessages = [], array $options = [], \Closure $beforeSave = null, \Closure $afterSave = null
- ) {
+ public function save(array $rules = [], array $customMessages = [], array $options = [], \Closure $beforeSave = null, \Closure $afterSave = null)
+ {
if ($this->subclassField) {
$this->attributes[$this->subclassField] = get_class($this);
}
diff --git a/app/lib/FireflyIII/Shared/Toolkit/Date.php b/app/lib/FireflyIII/Shared/Toolkit/Date.php
index 90152551ae..c34f320e5a 100644
--- a/app/lib/FireflyIII/Shared/Toolkit/Date.php
+++ b/app/lib/FireflyIII/Shared/Toolkit/Date.php
@@ -143,6 +143,13 @@ class Date
return $currentEnd;
}
+ /**
+ * @param Carbon $date
+ * @param $repeatFrequency
+ *
+ * @return string
+ * @throws FireflyException
+ */
public function periodShow(Carbon $date, $repeatFrequency)
{
switch ($repeatFrequency) {
@@ -216,12 +223,13 @@ class Date
}
/**
- * @param Carbon $date
+ * @param Carbon $theDate
* @param $repeatFreq
* @param int $subtract
*
* @return Carbon
* @throws FireflyException
+ * @internal param Carbon $date
*/
public function subtractPeriod(Carbon $theDate, $repeatFreq, $subtract = 1)
{
diff --git a/app/lib/FireflyIII/Shared/Validation/FireflyValidator.php b/app/lib/FireflyIII/Shared/Validation/FireflyValidator.php
index 1f26103651..4b656d2723 100644
--- a/app/lib/FireflyIII/Shared/Validation/FireflyValidator.php
+++ b/app/lib/FireflyIII/Shared/Validation/FireflyValidator.php
@@ -10,6 +10,13 @@ use Illuminate\Validation\Validator;
*/
class FireflyValidator extends Validator
{
+ /**
+ * @param $attribute
+ * @param $value
+ * @param $parameters
+ *
+ * @return bool
+ */
public function validateAlphabasic($attribute, $value, $parameters)
{
$pattern = '/[^[:alnum:]_\-\.\& \(\)\'"]/iu';
diff --git a/app/models/Account.php b/app/models/Account.php
index 96c07b06f0..e96ee4efdd 100644
--- a/app/models/Account.php
+++ b/app/models/Account.php
@@ -3,6 +3,9 @@ use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingTrait;
use Watson\Validating\ValidatingTrait;
+/**
+ * Class Account
+ */
class Account extends Eloquent
{
use SoftDeletingTrait, ValidatingTrait;
@@ -12,20 +15,17 @@ class Account extends Eloquent
* @var array
*/
public static $rules
- = [
+ = [
'name' => ['required', 'between:1,100'],
'user_id' => 'required|exists:users,id',
'account_type_id' => 'required|exists:account_types,id',
'active' => 'required|boolean'
];
- protected $dates = ['deleted_at', 'created_at', 'updated_at'];
- /**
- * Fillable fields.
- *
- * @var array
- */
+ // @codingStandardsIgnoreStart
+ protected $dates = ['deleted_at', 'created_at', 'updated_at'];
protected $fillable = ['name', 'user_id', 'account_type_id', 'active'];
+ // @codingStandardsIgnoreEnd
/**
* Account type.
@@ -96,6 +96,12 @@ class Account extends Eloquent
return $this->hasMany('Transaction');
}
+ /**
+ * @param $fieldName
+ * @param $fieldValue
+ *
+ * @return AccountMeta
+ */
public function updateMeta($fieldName, $fieldValue)
{
$meta = $this->accountMeta()->get();
@@ -117,6 +123,9 @@ class Account extends Eloquent
return $meta;
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function accountMeta()
{
return $this->hasMany('AccountMeta');
diff --git a/app/models/AccountMeta.php b/app/models/AccountMeta.php
index 78dbc159dd..002d4fc6e9 100644
--- a/app/models/AccountMeta.php
+++ b/app/models/AccountMeta.php
@@ -1,6 +1,9 @@
<?php
use Watson\Validating\ValidatingTrait;
+/**
+ * Class AccountMeta
+ */
class AccountMeta extends Eloquent
{
use ValidatingTrait;
@@ -16,8 +19,10 @@ class AccountMeta extends Eloquent
/**
* @var array
*/
+ // @codingStandardsIgnoreStart
protected $fillable = ['account_id', 'name', 'date'];
protected $table = 'account_meta';
+ // @codingStandardsIgnoreEnd
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
diff --git a/app/models/AccountType.php b/app/models/AccountType.php
index b5857f1fc2..5650ea15f0 100644
--- a/app/models/AccountType.php
+++ b/app/models/AccountType.php
@@ -3,6 +3,9 @@
use Illuminate\Database\Eloquent\Model as Eloquent;
use Watson\Validating\ValidatingTrait;
+/**
+ * Class AccountType
+ */
class AccountType extends Eloquent
{
use ValidatingTrait;
diff --git a/app/models/Budget.php b/app/models/Budget.php
index ba7ca58652..50c2e4cf62 100644
--- a/app/models/Budget.php
+++ b/app/models/Budget.php
@@ -1,20 +1,26 @@
<?php
+/**
+ * Class Budget
+ */
class Budget extends Component
{
protected $isSubclass = true;
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
+ */
public function limitrepetitions()
{
- return $this->hasManyThrough('LimitRepetition', 'Limit', 'component_id');
+ return $this->hasManyThrough('LimitRepetition', 'BudgetLimit', 'component_id');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
- public function limits()
+ public function budgetlimits()
{
- return $this->hasMany('Limit', 'component_id');
+ return $this->hasMany('BudgetLimit', 'component_id');
}
diff --git a/app/models/Limit.php b/app/models/BudgetLimit.php
similarity index 90%
rename from app/models/Limit.php
rename to app/models/BudgetLimit.php
index a215c98623..148d6e6081 100644
--- a/app/models/Limit.php
+++ b/app/models/BudgetLimit.php
@@ -4,7 +4,10 @@ use Carbon\Carbon;
use Illuminate\Database\QueryException;
use Watson\Validating\ValidatingTrait;
-class Limit extends Eloquent
+/**
+ * Class Limit
+ */
+class BudgetLimit extends Eloquent
{
use ValidatingTrait;
@@ -61,8 +64,6 @@ class Limit extends Eloquent
}
$end->subDay();
$count = $this->limitrepetitions()->where('startdate', $start->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'))->count();
- \Log::debug('All: ' . $this->limitrepetitions()->count() . ' (#' . $this->id . ')');
- \Log::debug('Found ' . $count . ' limit-reps for limit #' . $this->id . ' with start ' . $start->format('Y-m-d') . ' and end ' . $end->format('Y-m-d'));
if ($count == 0) {
@@ -70,7 +71,7 @@ class Limit extends Eloquent
$repetition->startdate = $start;
$repetition->enddate = $end;
$repetition->amount = $this->amount;
- $repetition->limit()->associate($this);
+ $repetition->budgetLimit()->associate($this);
try {
$repetition->save();
diff --git a/app/models/Category.php b/app/models/Category.php
index 50dda8a466..76d693d44d 100644
--- a/app/models/Category.php
+++ b/app/models/Category.php
@@ -1,8 +1,14 @@
<?php
+/**
+ * Class Category
+ */
class Category extends Component
{
+
+ // @codingStandardsIgnoreStart
protected $isSubclass = true;
+ // @codingStandardsIgnoreEnd
}
\ No newline at end of file
diff --git a/app/models/Component.php b/app/models/Component.php
index a67d457a53..7973ebd3b5 100644
--- a/app/models/Component.php
+++ b/app/models/Component.php
@@ -4,6 +4,9 @@ use FireflyIII\Shared\SingleTableInheritanceEntity;
use Illuminate\Database\Eloquent\SoftDeletingTrait;
use Watson\Validating\ValidatingTrait;
+/**
+ * Class Component
+ */
class Component extends SingleTableInheritanceEntity
{
@@ -13,10 +16,12 @@ class Component extends SingleTableInheritanceEntity
'name' => 'required|between:1,100|alphabasic',
'class' => 'required',
];
+ // @codingStandardsIgnoreStart
protected $dates = ['deleted_at', 'created_at', 'updated_at'];
protected $fillable = ['name', 'user_id'];
protected $subclassField = 'class';
protected $table = 'components';
+ // @codingStandardsIgnoreEnd
use SoftDeletingTrait, ValidatingTrait;
/**
diff --git a/app/models/LimitRepetition.php b/app/models/LimitRepetition.php
index 07e9da433b..43b49c00aa 100644
--- a/app/models/LimitRepetition.php
+++ b/app/models/LimitRepetition.php
@@ -3,31 +3,34 @@
use FireflyIII\Exception\FireflyException;
use Watson\Validating\ValidatingTrait;
+/**
+ * Class LimitRepetition
+ */
class LimitRepetition extends Eloquent
{
use ValidatingTrait;
public static $rules
= [
- 'limit_id' => 'required|exists:limits,id',
- 'startdate' => 'required|date',
- 'enddate' => 'required|date',
- 'amount' => 'numeric|required|min:0.01',
+ 'budgetlimit_id' => 'required|exists:budgetlimits,id',
+ 'startdate' => 'required|date',
+ 'enddate' => 'required|date',
+ 'amount' => 'numeric|required|min:0.01',
];
/**
- * @return array
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
- public function getDates()
+ public function budgetLimit()
{
- return ['created_at', 'updated_at', 'startdate', 'enddate'];
+ return $this->belongsTo('BudgetLimit');
}
/**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ * @return array
*/
- public function limit()
+ public function getDates()
{
- return $this->belongsTo('Limit');
+ return ['created_at', 'updated_at', 'startdate', 'enddate'];
}
/**
@@ -51,8 +54,8 @@ class LimitRepetition extends Eloquent
$sum = \DB::table('transactions')->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->leftJoin(
'component_transaction_journal', 'component_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'
)->leftJoin('components', 'components.id', '=', 'component_transaction_journal.component_id')->leftJoin(
- 'limits', 'limits.component_id', '=', 'components.id'
- )->leftJoin('limit_repetitions', 'limit_repetitions.limit_id', '=', 'limits.id')->where(
+ 'budgetlimits', 'budgetlimits.component_id', '=', 'components.id'
+ )->leftJoin('limit_repetitions', 'limit_repetitions.limit_id', '=', 'budgetlimits.id')->where(
'transaction_journals.date', '>=', $this->startdate->format('Y-m-d')
)->where('transaction_journals.date', '<=', $this->enddate->format('Y-m-d'))->where('transactions.amount', '>', 0)->where(
'limit_repetitions.id', '=', $this->id
diff --git a/app/models/Piggybank.php b/app/models/Piggybank.php
index a35f60e67d..79fd1f2619 100644
--- a/app/models/Piggybank.php
+++ b/app/models/Piggybank.php
@@ -2,6 +2,9 @@
use Carbon\Carbon;
use Watson\Validating\ValidatingTrait;
+/**
+ * Class Piggybank
+ */
class Piggybank extends Eloquent
{
use ValidatingTrait;
@@ -155,6 +158,9 @@ class Piggybank extends Eloquent
return $this->hasMany('PiggybankEvent');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\MorphMany
+ */
public function reminders()
{
return $this->morphMany('Reminder', 'remindersable');
@@ -197,6 +203,9 @@ class Piggybank extends Eloquent
return $result;
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function transactions()
{
return $this->hasMany('Transaction');
diff --git a/app/models/PiggybankEvent.php b/app/models/PiggybankEvent.php
index ecb85a8654..fda32062e0 100644
--- a/app/models/PiggybankEvent.php
+++ b/app/models/PiggybankEvent.php
@@ -1,6 +1,9 @@
<?php
use Watson\Validating\ValidatingTrait;
+/**
+ * Class PiggybankEvent
+ */
class PiggybankEvent extends Eloquent
{
diff --git a/app/models/PiggybankRepetition.php b/app/models/PiggybankRepetition.php
index a7cfe38bb5..a6d602025f 100644
--- a/app/models/PiggybankRepetition.php
+++ b/app/models/PiggybankRepetition.php
@@ -3,6 +3,9 @@ use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Watson\Validating\ValidatingTrait;
+/**
+ * Class PiggybankRepetition
+ */
class PiggybankRepetition extends Eloquent
{
use ValidatingTrait;
@@ -46,11 +49,19 @@ class PiggybankRepetition extends Eloquent
return $this->belongsTo('Piggybank');
}
+ /**
+ * @param Builder $query
+ * @param Carbon $date
+ */
public function scopeStarts(Builder $query, Carbon $date)
{
$query->where('startdate', $date->format('Y-m-d'));
}
+ /**
+ * @param Builder $query
+ * @param Carbon $date
+ */
public function scopeTargets(Builder $query, Carbon $date)
{
$query->where('targetdate', $date->format('Y-m-d'));
diff --git a/app/models/Preference.php b/app/models/Preference.php
index 0f3c9700cf..496a889067 100644
--- a/app/models/Preference.php
+++ b/app/models/Preference.php
@@ -1,6 +1,9 @@
<?php
use Watson\Validating\ValidatingTrait;
+/**
+ * Class Preference
+ */
class Preference extends Eloquent
{
use ValidatingTrait;
diff --git a/app/models/RecurringTransaction.php b/app/models/RecurringTransaction.php
index b3f5c4e9ae..fd598cf2c1 100644
--- a/app/models/RecurringTransaction.php
+++ b/app/models/RecurringTransaction.php
@@ -2,6 +2,9 @@
use Carbon\Carbon;
use Watson\Validating\ValidatingTrait;
+/**
+ * Class RecurringTransaction
+ */
class RecurringTransaction extends Eloquent
{
@@ -18,8 +21,9 @@ class RecurringTransaction extends Eloquent
'automatch' => 'required|between:0,1',
'repeat_freq' => 'required|in:daily,weekly,monthly,quarterly,half-year,yearly',
'skip' => 'required|between:0,31',];
-
+ // @codingStandardsIgnoreStart
protected $fillable = ['user_id', 'name', 'match', 'amount_min', 'amount_max', 'date', 'repeat_freq', 'skip', 'active', 'automatch'];
+ // @codingStandardsIgnoreEnd
/**
* @return array
diff --git a/app/models/Reminder.php b/app/models/Reminder.php
index 8b61d63db2..51dd924638 100644
--- a/app/models/Reminder.php
+++ b/app/models/Reminder.php
@@ -3,12 +3,22 @@
use Carbon\Carbon;
use Watson\Validating\ValidatingTrait;
+/**
+ * Class Reminder
+ */
class Reminder extends Eloquent
{
use ValidatingTrait;
+ // @codingStandardsIgnoreStart
protected $table = 'reminders';
+ // @codingStandardsIgnoreEnd
+ /**
+ * @param $value
+ *
+ * @return mixed
+ */
public function getDataAttribute($value)
{
return json_decode($value);
@@ -32,6 +42,13 @@ class Reminder extends Eloquent
return $this->morphTo();
}
+ /**
+ * @param $query
+ * @param Carbon $start
+ * @param Carbon $end
+ *
+ * @return mixed
+ */
public function scopeDateIs($query, Carbon $start, Carbon $end)
{
return $query->where('startdate', $start->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'));
diff --git a/app/models/Transaction.php b/app/models/Transaction.php
index 6e549cee8b..5ecaa7a2df 100644
--- a/app/models/Transaction.php
+++ b/app/models/Transaction.php
@@ -5,6 +5,9 @@ use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingTrait;
use Watson\Validating\ValidatingTrait;
+/**
+ * Class Transaction
+ */
class Transaction extends Eloquent
{
use SoftDeletingTrait, ValidatingTrait;
@@ -56,11 +59,19 @@ class Transaction extends Eloquent
return $this->belongsTo('Piggybank');
}
+ /**
+ * @param Builder $query
+ * @param Account $account
+ */
public function scopeAccountIs(Builder $query, Account $account)
{
$query->where('transactions.account_id', $account->id);
}
+ /**
+ * @param Builder $query
+ * @param Carbon $date
+ */
public function scopeAfter(Builder $query, Carbon $date)
{
if (is_null($this->joinedJournals)) {
@@ -72,6 +83,10 @@ class Transaction extends Eloquent
$query->where('transaction_journals.date', '>=', $date->format('Y-m-d'));
}
+ /**
+ * @param Builder $query
+ * @param Carbon $date
+ */
public function scopeBefore(Builder $query, Carbon $date)
{
if (is_null($this->joinedJournals)) {
@@ -83,16 +98,28 @@ class Transaction extends Eloquent
$query->where('transaction_journals.date', '<=', $date->format('Y-m-d'));
}
+ /**
+ * @param Builder $query
+ * @param $amount
+ */
public function scopeLessThan(Builder $query, $amount)
{
$query->where('amount', '<', $amount);
}
+ /**
+ * @param Builder $query
+ * @param $amount
+ */
public function scopeMoreThan(Builder $query, $amount)
{
$query->where('amount', '>', $amount);
}
+ /**
+ * @param Builder $query
+ * @param array $types
+ */
public function scopeTransactionTypes(Builder $query, array $types)
{
if (is_null($this->joinedJournals)) {
diff --git a/app/models/TransactionCurrency.php b/app/models/TransactionCurrency.php
index 9fded03565..c96bd9ad92 100644
--- a/app/models/TransactionCurrency.php
+++ b/app/models/TransactionCurrency.php
@@ -3,6 +3,9 @@ use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Database\Eloquent\SoftDeletingTrait;
use Watson\Validating\ValidatingTrait;
+/**
+ * Class TransactionCurrency
+ */
class TransactionCurrency extends Eloquent
{
diff --git a/app/models/TransactionGroup.php b/app/models/TransactionGroup.php
index f689c97b49..ec83225bc5 100644
--- a/app/models/TransactionGroup.php
+++ b/app/models/TransactionGroup.php
@@ -2,6 +2,9 @@
use Illuminate\Database\Eloquent\SoftDeletingTrait;
use Watson\Validating\ValidatingTrait;
+/**
+ * Class TransactionGroup
+ */
class TransactionGroup extends Eloquent
{
use SoftDeletingTrait, ValidatingTrait;
diff --git a/app/models/TransactionJournal.php b/app/models/TransactionJournal.php
index a1bcb40794..2dadaf2026 100644
--- a/app/models/TransactionJournal.php
+++ b/app/models/TransactionJournal.php
@@ -5,6 +5,9 @@ use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingTrait;
use Watson\Validating\ValidatingTrait;
+/**
+ * Class TransactionJournal
+ */
class TransactionJournal extends Eloquent
{
use SoftDeletingTrait, ValidatingTrait;
@@ -47,6 +50,8 @@ class TransactionJournal extends Eloquent
/**
* TODO remove this method in favour of something in the FireflyIII libraries.
*
+ * @param Account $account
+ *
* @return float
*/
public function getAmount(\Account $account = null)
@@ -123,11 +128,18 @@ class TransactionJournal extends Eloquent
return $query->where('date', '<=', $date->format('Y-m-d'));
}
+ /**
+ * @param Builder $query
+ */
public function scopeDefaultSorting(Builder $query)
{
$query->orderBy('date', 'DESC')->orderBy('transaction_journals.id', 'DESC');
}
+ /**
+ * @param Builder $query
+ * @param $amount
+ */
public function scopeLessThan(Builder $query, $amount)
{
if (is_null($this->joinedTransactions)) {
@@ -140,6 +152,10 @@ class TransactionJournal extends Eloquent
$query->where('transactions.amount', '<=', $amount);
}
+ /**
+ * @param Builder $query
+ * @param $amount
+ */
public function scopeMoreThan(Builder $query, $amount)
{
if (is_null($this->joinedTransactions)) {
@@ -163,6 +179,10 @@ class TransactionJournal extends Eloquent
return $query->where('date', '=', $date->format('Y-m-d'));
}
+ /**
+ * @param Builder $query
+ * @param array $types
+ */
public function scopeTransactionTypes(Builder $query, array $types)
{
if (is_null($this->joinedTransactionTypes)) {
@@ -207,6 +227,9 @@ class TransactionJournal extends Eloquent
return $this->belongsTo('TransactionType');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
+ */
public function transactiongroups()
{
return $this->belongsToMany('TransactionGroup');
diff --git a/app/models/TransactionRelation.php b/app/models/TransactionRelation.php
index 93109b2490..bb45f08f1c 100644
--- a/app/models/TransactionRelation.php
+++ b/app/models/TransactionRelation.php
@@ -1,5 +1,8 @@
<?php
+/**
+ * Class TransactionRelation
+ */
class TransactionRelation extends Eloquent
{
diff --git a/app/models/TransactionType.php b/app/models/TransactionType.php
index aefd5c7afa..27ca56f203 100644
--- a/app/models/TransactionType.php
+++ b/app/models/TransactionType.php
@@ -3,6 +3,9 @@
use Illuminate\Database\Eloquent\SoftDeletingTrait;
use Watson\Validating\ValidatingTrait;
+/**
+ * Class TransactionType
+ */
class TransactionType extends Eloquent
{
use SoftDeletingTrait, ValidatingTrait;
diff --git a/app/models/User.php b/app/models/User.php
index 1d5ac84bde..553620bd9a 100644
--- a/app/models/User.php
+++ b/app/models/User.php
@@ -6,6 +6,9 @@ use Illuminate\Auth\UserInterface;
use Illuminate\Auth\UserTrait;
use Watson\Validating\ValidatingTrait;
+/**
+ * Class User
+ */
class User extends Eloquent implements UserInterface, RemindableInterface
{
@@ -13,24 +16,16 @@ class User extends Eloquent implements UserInterface, RemindableInterface
public static $rules
- = [
+ = [
'email' => 'required|email|unique:users,email',
'password' => 'required|between:60,60',
'reset' => 'between:32,32',
];
- protected $fillable = ['email'];
- /**
- * The attributes excluded from the model's JSON form.
- *
- * @var array
- */
- protected $hidden = ['remember_token'];
- /**
- * The database table used by the model.
- *
- * @var string
- */
- protected $table = 'users';
+ // @codingStandardsIgnoreStart
+ protected $fillable = ['email'];
+ protected $hidden = ['remember_token'];
+ protected $table = 'users';
+ // @codingStandardsIgnoreEnd
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
@@ -64,6 +59,9 @@ class User extends Eloquent implements UserInterface, RemindableInterface
return $this->hasMany('Component');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
+ */
public function piggybanks()
{
return $this->hasManyThrough('Piggybank', 'Account');
@@ -109,6 +107,9 @@ class User extends Eloquent implements UserInterface, RemindableInterface
return $this->hasMany('TransactionJournal');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
+ */
public function transactions()
{
return $this->hasManyThrough('TransactionJournal', 'Transaction');
diff --git a/app/routes.php b/app/routes.php
index 73def8cf0a..31f89af7cc 100644
--- a/app/routes.php
+++ b/app/routes.php
@@ -99,8 +99,8 @@ Route::bind(
'limitrepetition', function ($value, $route) {
if (Auth::check()) {
return LimitRepetition::
- where('limit_repetitions.id', $value)->leftjoin('limits', 'limits.id', '=', 'limit_repetitions.limit_id')->leftJoin(
- 'components', 'components.id', '=', 'limits.component_id'
+ where('limit_repetitions.id', $value)->leftjoin('budgetlimits', 'budgetlimits.id', '=', 'limit_repetitions.limit_id')->leftJoin(
+ 'components', 'components.id', '=', 'budgetlimits.component_id'
)->where('components.class', 'Budget')->where('components.user_id', Auth::user()->id)->first(['limit_repetitions.*']);
}
diff --git a/app/start/global.php b/app/start/global.php
index 5604f492bb..36f6db85a9 100644
--- a/app/start/global.php
+++ b/app/start/global.php
@@ -47,7 +47,7 @@ Log::useDailyFiles(storage_path('logs') . DIRECTORY_SEPARATOR . 'laravel.log', 3
App::error(
function (Exception $exception, $code) {
- Log::error($exception);
+ Log::error($code . ': ' . $exception);
}
);
@@ -71,48 +71,48 @@ App::down(
// forms:
\Form::macro(
'ffText', function ($name, $value = null, array $options = []) {
- return \FireflyIII\Form\Form::ffText($name, $value, $options);
- }
+ return \FireflyIII\Form\Form::ffText($name, $value, $options);
+}
);
\Form::macro(
'ffSelect', function ($name, array $list = [], $selected = null, array $options = []) {
- return \FireflyIII\Form\Form::ffSelect($name, $list, $selected, $options);
- }
+ return \FireflyIII\Form\Form::ffSelect($name, $list, $selected, $options);
+}
);
\Form::macro(
'ffInteger', function ($name, $value = null, array $options = []) {
- return \FireflyIII\Form\Form::ffInteger($name, $value, $options);
- }
+ return \FireflyIII\Form\Form::ffInteger($name, $value, $options);
+}
);
\Form::macro(
'ffAmount', function ($name, $value = null, array $options = []) {
- return \FireflyIII\Form\Form::ffAmount($name, $value, $options);
- }
+ return \FireflyIII\Form\Form::ffAmount($name, $value, $options);
+}
);
\Form::macro(
'ffBalance', function ($name, $value = null, array $options = []) {
- return \FireflyIII\Form\Form::ffBalance($name, $value, $options);
- }
+ return \FireflyIII\Form\Form::ffBalance($name, $value, $options);
+}
);
\Form::macro(
'ffDate', function ($name, $value = null, array $options = []) {
- return \FireflyIII\Form\Form::ffDate($name, $value, $options);
- }
+ return \FireflyIII\Form\Form::ffDate($name, $value, $options);
+}
);
\Form::macro(
'ffTags', function ($name, $value = null, array $options = []) {
- return \FireflyIII\Form\Form::ffTags($name, $value, $options);
- }
+ return \FireflyIII\Form\Form::ffTags($name, $value, $options);
+}
);
\Form::macro(
'ffCheckbox', function ($name, $value = 1, $checked = null, $options = []) {
- return \FireflyIII\Form\Form::ffCheckbox($name, $value, $checked, $options);
- }
+ return \FireflyIII\Form\Form::ffCheckbox($name, $value, $checked, $options);
+}
);
\Form::macro(
'ffOptionsList', function ($type, $name) {
- return \FireflyIII\Form\Form::ffOptionsList($type, $name);
- }
+ return \FireflyIII\Form\Form::ffOptionsList($type, $name);
+}
);
diff --git a/tests/functional/CategoryControllerCest.php b/tests/functional/CategoryControllerCest.php
index b0e9ceab87..34057e1e90 100644
--- a/tests/functional/CategoryControllerCest.php
+++ b/tests/functional/CategoryControllerCest.php
@@ -38,7 +38,6 @@ class CategoryControllerCest
public function delete(FunctionalTester $I)
{
$I->wantTo('delete a category');
- $I->amOnPage('/categories/delete/1');
}
/**
@@ -56,7 +55,6 @@ class CategoryControllerCest
public function edit(FunctionalTester $I)
{
$I->wantTo('edit a category');
- $I->amOnPage('/categories/edit/1');
}
/**
@@ -74,7 +72,6 @@ class CategoryControllerCest
public function show(FunctionalTester $I)
{
$I->wantTo('show a category');
- $I->amOnPage('/categories/delete/1');
}
/**