Skip to content

Firefly III: a personal finances manager

Some code cleanup [skip ci]

James Cole8bd445ab198e
diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php
index 4790b1d81c..9c24abe6df 100644
--- a/app/Helpers/Report/ReportHelper.php
+++ b/app/Helpers/Report/ReportHelper.php
@@ -163,7 +163,8 @@ class ReportHelper implements ReportHelperInterface
foreach ($accounts as $account) {
$spent = $this->query->spentNoBudget($account, $start, $end);
$left = $tagRepository->coveredByBalancingActs($account, $start, $end);
- $diff = $spent + $left;
+ bcscale(2);
+ $diff = bcadd($spent, $left);
// budget
$budgetEntry = new BalanceEntry;
diff --git a/app/Helpers/Report/ReportQuery.php b/app/Helpers/Report/ReportQuery.php
index 2e720e0653..e22f663722 100644
--- a/app/Helpers/Report/ReportQuery.php
+++ b/app/Helpers/Report/ReportQuery.php
@@ -230,11 +230,11 @@ class ReportQuery implements ReportQueryInterface
* @param Carbon $end
* @param bool $shared
*
- * @return float
+ * @return string
*/
public function spentNoBudget(Account $account, Carbon $start, Carbon $end, $shared = false)
{
- return floatval(
+ return
Auth::user()->transactionjournals()
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
@@ -242,8 +242,7 @@ class ReportQuery implements ReportQueryInterface
->where('transactions.account_id', $account->id)
->before($end)
->after($start)
- ->whereNull('budget_transaction_journal.budget_id')->get(['transaction_journals.*'])->sum('amount')
- );
+ ->whereNull('budget_transaction_journal.budget_id')->get(['transaction_journals.*'])->sum('amount');
}
/**
diff --git a/app/Helpers/Report/ReportQueryInterface.php b/app/Helpers/Report/ReportQueryInterface.php
index fc46ab8255..9705193dd0 100644
--- a/app/Helpers/Report/ReportQueryInterface.php
+++ b/app/Helpers/Report/ReportQueryInterface.php
@@ -73,7 +73,7 @@ interface ReportQueryInterface
* @param Carbon $end
* @param bool $shared
*
- * @return float
+ * @return string
*/
public function spentNoBudget(Account $account, Carbon $start, Carbon $end, $shared = false);
diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php
index f115ee0526..04f3b4706a 100644
--- a/app/Http/Controllers/BudgetController.php
+++ b/app/Http/Controllers/BudgetController.php
@@ -116,7 +116,7 @@ class BudgetController extends Controller
*/
public function edit(Budget $budget)
{
- $subTitle = trans('firefly.edit_budget',['name' => $budget->name]);
+ $subTitle = trans('firefly.edit_budget', ['name' => $budget->name]);
// put previous url in session if not redirect from store (not "return_to_edit").
if (Session::get('budgets.edit.fromUpdate') !== true) {
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
index 0d51404abb..03a9a8d31c 100644
--- a/app/Http/Controllers/Controller.php
+++ b/app/Http/Controllers/Controller.php
@@ -2,7 +2,7 @@
use Auth;
use Config;
-use Illuminate\Foundation\Bus\DispatchesCommands;
+use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use Preferences;
@@ -16,7 +16,7 @@ use View;
abstract class Controller extends BaseController
{
- use DispatchesCommands, ValidatesRequests;
+ use DispatchesJobs, ValidatesRequests;
/** @var string */
protected $monthAndDayFormat;
diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php
index 6eee693adf..0cb81a0ccc 100644
--- a/app/Http/Controllers/TransactionController.php
+++ b/app/Http/Controllers/TransactionController.php
@@ -88,7 +88,7 @@ class TransactionController extends Controller
Session::flash('gaEventCategory', 'transactions');
Session::flash('gaEventAction', 'delete-' . $what);
- return view('transactions.delete', compact('journal', 'subTitle','what'));
+ return view('transactions.delete', compact('journal', 'subTitle', 'what'));
}
@@ -261,7 +261,7 @@ class TransactionController extends Controller
$what = strtolower($journal->transactionType->type);
$subTitle = trans('firefly.' . $journal->transactionType->type) . ' "' . e($journal->description) . '"';
- return view('transactions.show', compact('journal', 'subTitle','what'));
+ return view('transactions.show', compact('journal', 'subTitle', 'what'));
}
/**
diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php
index cf2c8d2860..3d27a90d3c 100644
--- a/app/Repositories/Bill/BillRepository.php
+++ b/app/Repositories/Bill/BillRepository.php
@@ -284,6 +284,8 @@ class BillRepository implements BillRepositoryInterface
return true;
}
+ return false;
+
}
/**
diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php
index 5b5de681f4..3550a119ae 100644
--- a/app/Repositories/Tag/TagRepository.php
+++ b/app/Repositories/Tag/TagRepository.php
@@ -332,6 +332,7 @@ class TagRepository implements TagRepositoryInterface
}
if ($match) {
$journal->tags()->save($tag);
+
return true;
}
diff --git a/app/Support/Amount.php b/app/Support/Amount.php
index c823d7736a..30259dbc68 100644
--- a/app/Support/Amount.php
+++ b/app/Support/Amount.php
@@ -37,6 +37,7 @@ class Amount
{
$currencyPreference = Prefs::get('currencyPreference', 'EUR');
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
+
return $currency->symbol;
}
diff --git a/tests/controllers/PiggyBankControllerTest.php b/tests/controllers/PiggyBankControllerTest.php
index 9504fe50f9..0d8f154656 100644
--- a/tests/controllers/PiggyBankControllerTest.php
+++ b/tests/controllers/PiggyBankControllerTest.php
@@ -269,7 +269,6 @@ class PiggyBankControllerTest extends TestCase
// mock!
$accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
- $piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
$accounts->shouldReceive('leftOnAccount')->andReturn(20);
Amount::shouldReceive('format')->andReturn('something');
@@ -307,7 +306,6 @@ class PiggyBankControllerTest extends TestCase
// mock!
$accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
- $piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
$accounts->shouldReceive('leftOnAccount')->andReturn(20);
Amount::shouldReceive('format')->andReturn('something');
diff --git a/tests/helpers/ReportHelperTest.php b/tests/helpers/ReportHelperTest.php
index a97578afb8..91a3576d47 100644
--- a/tests/helpers/ReportHelperTest.php
+++ b/tests/helpers/ReportHelperTest.php
@@ -123,8 +123,8 @@ class ReportHelperTest extends TestCase
// factory!
$set = new Collection;
$journals = new Collection;
- $left = FactoryMuffin::create('FireflyIII\Models\Account');
- $right = FactoryMuffin::create('FireflyIII\Models\Account');
+ FactoryMuffin::create('FireflyIII\Models\Account');
+ FactoryMuffin::create('FireflyIII\Models\Account');
for ($i = 0; $i < 5; $i++) {
$set->push(FactoryMuffin::create('FireflyIII\Models\Bill'));
}