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) {
$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;

View File

@ -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');
}
/**

View File

@ -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);

View File

@ -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) {

View File

@ -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;

View File

@ -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'));
}
/**

View File

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

View File

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

View File

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

View File

@ -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');

View File

@ -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'));
}