Some code cleanup [skip ci]

This commit is contained in:
James Cole 2015-06-13 10:02:36 +02:00
parent fdef0de163
commit 8bd445ab19
11 changed files with 17 additions and 15 deletions

View File

@ -163,7 +163,8 @@ class ReportHelper implements ReportHelperInterface
foreach ($accounts as $account) { foreach ($accounts as $account) {
$spent = $this->query->spentNoBudget($account, $start, $end); $spent = $this->query->spentNoBudget($account, $start, $end);
$left = $tagRepository->coveredByBalancingActs($account, $start, $end); $left = $tagRepository->coveredByBalancingActs($account, $start, $end);
$diff = $spent + $left; bcscale(2);
$diff = bcadd($spent, $left);
// budget // budget
$budgetEntry = new BalanceEntry; $budgetEntry = new BalanceEntry;

View File

@ -230,11 +230,11 @@ class ReportQuery implements ReportQueryInterface
* @param Carbon $end * @param Carbon $end
* @param bool $shared * @param bool $shared
* *
* @return float * @return string
*/ */
public function spentNoBudget(Account $account, Carbon $start, Carbon $end, $shared = false) public function spentNoBudget(Account $account, Carbon $start, Carbon $end, $shared = false)
{ {
return floatval( return
Auth::user()->transactionjournals() Auth::user()->transactionjournals()
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.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) ->where('transactions.account_id', $account->id)
->before($end) ->before($end)
->after($start) ->after($start)
->whereNull('budget_transaction_journal.budget_id')->get(['transaction_journals.*'])->sum('amount') ->whereNull('budget_transaction_journal.budget_id')->get(['transaction_journals.*'])->sum('amount');
);
} }
/** /**

View File

@ -73,7 +73,7 @@ interface ReportQueryInterface
* @param Carbon $end * @param Carbon $end
* @param bool $shared * @param bool $shared
* *
* @return float * @return string
*/ */
public function spentNoBudget(Account $account, Carbon $start, Carbon $end, $shared = false); public function spentNoBudget(Account $account, Carbon $start, Carbon $end, $shared = false);

View File

@ -116,7 +116,7 @@ class BudgetController extends Controller
*/ */
public function edit(Budget $budget) 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"). // put previous url in session if not redirect from store (not "return_to_edit").
if (Session::get('budgets.edit.fromUpdate') !== true) { if (Session::get('budgets.edit.fromUpdate') !== true) {

View File

@ -2,7 +2,7 @@
use Auth; use Auth;
use Config; use Config;
use Illuminate\Foundation\Bus\DispatchesCommands; use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController; use Illuminate\Routing\Controller as BaseController;
use Preferences; use Preferences;
@ -16,7 +16,7 @@ use View;
abstract class Controller extends BaseController abstract class Controller extends BaseController
{ {
use DispatchesCommands, ValidatesRequests; use DispatchesJobs, ValidatesRequests;
/** @var string */ /** @var string */
protected $monthAndDayFormat; protected $monthAndDayFormat;

View File

@ -88,7 +88,7 @@ class TransactionController extends Controller
Session::flash('gaEventCategory', 'transactions'); Session::flash('gaEventCategory', 'transactions');
Session::flash('gaEventAction', 'delete-' . $what); 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); $what = strtolower($journal->transactionType->type);
$subTitle = trans('firefly.' . $journal->transactionType->type) . ' "' . e($journal->description) . '"'; $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'));
} }
/** /**

View File

@ -284,6 +284,8 @@ class BillRepository implements BillRepositoryInterface
return true; return true;
} }
return false;
} }
/** /**

View File

@ -332,6 +332,7 @@ class TagRepository implements TagRepositoryInterface
} }
if ($match) { if ($match) {
$journal->tags()->save($tag); $journal->tags()->save($tag);
return true; return true;
} }

View File

@ -37,6 +37,7 @@ class Amount
{ {
$currencyPreference = Prefs::get('currencyPreference', 'EUR'); $currencyPreference = Prefs::get('currencyPreference', 'EUR');
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first(); $currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
return $currency->symbol; return $currency->symbol;
} }

View File

@ -269,7 +269,6 @@ class PiggyBankControllerTest extends TestCase
// mock! // mock!
$accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); $accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
$piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
$accounts->shouldReceive('leftOnAccount')->andReturn(20); $accounts->shouldReceive('leftOnAccount')->andReturn(20);
Amount::shouldReceive('format')->andReturn('something'); Amount::shouldReceive('format')->andReturn('something');
@ -307,7 +306,6 @@ class PiggyBankControllerTest extends TestCase
// mock! // mock!
$accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); $accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
$piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
$accounts->shouldReceive('leftOnAccount')->andReturn(20); $accounts->shouldReceive('leftOnAccount')->andReturn(20);
Amount::shouldReceive('format')->andReturn('something'); Amount::shouldReceive('format')->andReturn('something');

View File

@ -123,8 +123,8 @@ class ReportHelperTest extends TestCase
// factory! // factory!
$set = new Collection; $set = new Collection;
$journals = new Collection; $journals = new Collection;
$left = FactoryMuffin::create('FireflyIII\Models\Account'); FactoryMuffin::create('FireflyIII\Models\Account');
$right = FactoryMuffin::create('FireflyIII\Models\Account'); FactoryMuffin::create('FireflyIII\Models\Account');
for ($i = 0; $i < 5; $i++) { for ($i = 0; $i < 5; $i++) {
$set->push(FactoryMuffin::create('FireflyIII\Models\Bill')); $set->push(FactoryMuffin::create('FireflyIII\Models\Bill'));
} }