mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-28 09:51:21 -06:00
Some code cleanup [skip ci]
This commit is contained in:
parent
fdef0de163
commit
8bd445ab19
@ -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;
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -284,6 +284,8 @@ class BillRepository implements BillRepositoryInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -332,6 +332,7 @@ class TagRepository implements TagRepositoryInterface
|
||||
}
|
||||
if ($match) {
|
||||
$journal->tags()->save($tag);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,7 @@ class Amount
|
||||
{
|
||||
$currencyPreference = Prefs::get('currencyPreference', 'EUR');
|
||||
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
|
||||
|
||||
return $currency->symbol;
|
||||
}
|
||||
|
||||
|
@ -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');
|
||||
|
@ -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'));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user