Extra report and cleanup.

This commit is contained in:
James Cole
2015-02-23 21:19:16 +01:00
parent 220d689f69
commit 3e28c0c00a
18 changed files with 415 additions and 191 deletions

View File

@@ -1,10 +1,9 @@
<?php namespace FireflyIII\Events; <?php namespace FireflyIII\Events;
use FireflyIII\Events\Event;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
class JournalDeleted extends Event { class JournalDeleted extends Event
{
use SerializesModels; use SerializesModels;

View File

@@ -1,11 +1,11 @@
<?php namespace FireflyIII\Handlers\Events; <?php namespace FireflyIII\Handlers\Events;
use FireflyIII\Events\JournalDeleted; use FireflyIII\Events\JournalDeleted;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldBeQueued; use Illuminate\Contracts\Queue\ShouldBeQueued;
use Illuminate\Queue\InteractsWithQueue;
class JournalDeletedHandler { class JournalDeletedHandler
{
/** /**
* Create the event handler. * Create the event handler.
@@ -21,6 +21,7 @@ class JournalDeletedHandler {
* Handle the event. * Handle the event.
* *
* @param JournalDeleted $event * @param JournalDeleted $event
*
* @return void * @return void
*/ */
public function handle(JournalDeleted $event) public function handle(JournalDeleted $event)

View File

@@ -71,7 +71,6 @@ class ReportHelper implements ReportHelperInterface
->get(['budgets.*', 'budget_limits.amount as amount']); ->get(['budgets.*', 'budget_limits.amount as amount']);
$budgets = $this->_helper->makeArray($set); $budgets = $this->_helper->makeArray($set);
$amountSet = $this->_queries->journalsByBudget($start, $end); $amountSet = $this->_queries->journalsByBudget($start, $end);
$amounts = $this->_helper->makeArray($amountSet); $amounts = $this->_helper->makeArray($amountSet);

View File

@@ -11,10 +11,12 @@ namespace FireflyIII\Helpers\Report;
use Auth; use Auth;
use Carbon\Carbon; use Carbon\Carbon;
use DB; use DB;
use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Query\JoinClause; use Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Steam;
/** /**
* Class ReportQuery * Class ReportQuery
@@ -31,7 +33,7 @@ class ReportQuery implements ReportQueryInterface
*/ */
public function accountList() public function accountList()
{ {
return \Auth::user()->accounts() return Auth::user()->accounts()
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id') ->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->leftJoin( ->leftJoin(
'account_meta', function (JoinClause $join) { 'account_meta', function (JoinClause $join) {
@@ -49,6 +51,125 @@ class ReportQuery implements ReportQueryInterface
->get(['accounts.*']); ->get(['accounts.*']);
} }
/**
* This method will get a list of all expenses in a certain time period that have no budget
* and are balanced by a transfer to make up for it.
*
* @param Account $account
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
public function balancedTransactionsList(Account $account, Carbon $start, Carbon $end)
{
$set = TransactionJournal::
leftJoin('transaction_group_transaction_journal', 'transaction_group_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin(
'transaction_group_transaction_journal as otherFromGroup', function (JoinClause $join) {
$join->on('otherFromGroup.transaction_group_id', '=', 'transaction_group_transaction_journal.transaction_group_id')
->on('otherFromGroup.transaction_journal_id', '!=', 'transaction_journals.id');
}
)
->leftJoin('transaction_journals as otherJournals', 'otherJournals.id', '=', 'otherFromGroup.transaction_journal_id')
->leftJoin('transaction_types', 'transaction_types.id', '=', 'otherJournals.transaction_type_id')
->leftJoin(
'transactions', function (JoinClause $join) {
$join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('amount', '>', 0);
}
)
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'otherJournals.id')
->before($end)->after($start)
->where('transaction_types.type', 'Withdrawal')
->where('transaction_journals.user_id', \Auth::user()->id)
->whereNull('budget_transaction_journal.budget_id')->whereNull('transaction_journals.deleted_at')
->whereNull('otherJournals.deleted_at')
->where('transactions.account_id', $account->id)
->whereNotNull('transaction_group_transaction_journal.transaction_group_id')->groupBy('transaction_journals.id')
->first(
[
DB::Raw('SUM(`transactions`.`amount`) as `amount`')
]
);
$sum = 0;
if (!is_null($set)) {
$sum = floatval($set->amount);
}
return $sum;
}
/**
* Get a users accounts combined with various meta-data related to the start and end date.
*
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
public function getAllAccounts(Carbon $start, Carbon $end)
{
$set = Auth::user()->accounts()
->accountTypeIn(['Default account', 'Asset account', 'Cash account'])
->leftJoin(
'account_meta', function (JoinClause $join) {
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
}
)
->where(
function (Builder $query) {
$query->where('account_meta.data', '!=', '"sharedExpense"');
$query->orWhereNull('account_meta.data');
}
)
->get(['accounts.*']);
$set->each(
function (Account $account) use ($start, $end) {
/** @noinspection PhpParamsInspection */
$account->startBalance = Steam::balance($account, $start);
$account->endBalance = Steam::balance($account, $end);
}
);
return $set;
}
/**
* Grabs a summary of all expenses grouped by budget, related to the account.
*
* @param Account $account
* @param Carbon $start
* @param Carbon $end
*
* @return mixed
*/
public function getBudgetSummary(Account $account, Carbon $start, Carbon $end)
{
$set = TransactionJournal::
leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('budgets', 'budgets.id', '=', 'budget_transaction_journal.budget_id')
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
->leftJoin(
'transactions', function (JoinClause $join) {
$join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '<', 0);
}
)
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->before($end)
->after($start)
->where('accounts.id', $account->id)
->where('transaction_journals.user_id', Auth::user()->id)
->where('transaction_types.type', 'Withdrawal')
->groupBy('budgets.id')
->orderBy('budgets.id')
->get(['budgets.id', 'budgets.name', DB::Raw('SUM(`transactions`.`amount`) as `amount`')]);
return $set;
}
/** /**
* This method returns all "income" journals in a certain period, which are both transfers from a shared account * This method returns all "income" journals in a certain period, which are both transfers from a shared account
* and "ordinary" deposits. The query used is almost equal to ReportQueryInterface::journalsByRevenueAccount but it does * and "ordinary" deposits. The query used is almost equal to ReportQueryInterface::journalsByRevenueAccount but it does
@@ -124,7 +245,7 @@ class ReportQuery implements ReportQueryInterface
*/ */
public function journalsByBudget(Carbon $start, Carbon $end) public function journalsByBudget(Carbon $start, Carbon $end)
{ {
return \Auth::user()->transactionjournals() return Auth::user()->transactionjournals()
->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')
->leftJoin('budgets', 'budget_transaction_journal.budget_id', '=', 'budgets.id') ->leftJoin('budgets', 'budget_transaction_journal.budget_id', '=', 'budgets.id')
->leftJoin( ->leftJoin(
@@ -145,7 +266,7 @@ class ReportQuery implements ReportQueryInterface
->where('transaction_types.type', 'Withdrawal') ->where('transaction_types.type', 'Withdrawal')
->groupBy('budgets.id') ->groupBy('budgets.id')
->orderBy('budgets.name', 'ASC') ->orderBy('budgets.name', 'ASC')
->get(['budgets.id', 'budgets.name', \DB::Raw('SUM(`transactions`.`amount`) AS `spent`')]); ->get(['budgets.id', 'budgets.name', DB::Raw('SUM(`transactions`.`amount`) AS `spent`')]);
} }
/** /**
@@ -159,7 +280,7 @@ class ReportQuery implements ReportQueryInterface
*/ */
public function journalsByCategory(Carbon $start, Carbon $end) public function journalsByCategory(Carbon $start, Carbon $end)
{ {
return \Auth::user()->transactionjournals() return Auth::user()->transactionjournals()
->leftJoin( ->leftJoin(
'category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id' 'category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'
) )
@@ -182,7 +303,7 @@ class ReportQuery implements ReportQueryInterface
->where('transaction_types.type', 'Withdrawal') ->where('transaction_types.type', 'Withdrawal')
->groupBy('categories.id') ->groupBy('categories.id')
->orderBy('amount') ->orderBy('amount')
->get(['categories.id', 'categories.name', \DB::Raw('SUM(`transactions`.`amount`) AS `amount`')]); ->get(['categories.id', 'categories.name', DB::Raw('SUM(`transactions`.`amount`) AS `amount`')]);
} }
@@ -333,7 +454,7 @@ class ReportQuery implements ReportQueryInterface
->after($start) ->after($start)
->before($end) ->before($end)
->where('transaction_types.type', 'Transfer') ->where('transaction_types.type', 'Transfer')
->where('transaction_journals.user_id', \Auth::user()->id) ->where('transaction_journals.user_id', Auth::user()->id)
->get( ->get(
['transaction_journals.id', 'transaction_journals.description', 'transactions.account_id', 'accounts.name', ['transaction_journals.id', 'transaction_journals.description', 'transactions.account_id', 'accounts.name',
'transactions.amount'] 'transactions.amount']
@@ -375,13 +496,13 @@ class ReportQuery implements ReportQueryInterface
->after($start) ->after($start)
->before($end) ->before($end)
->where('transaction_types.type', 'Transfer') ->where('transaction_types.type', 'Transfer')
->where('transaction_journals.user_id', \Auth::user()->id) ->where('transaction_journals.user_id', Auth::user()->id)
->groupBy('categories.name') ->groupBy('categories.name')
->get( ->get(
[ [
'categories.id', 'categories.id',
'categories.name as name', 'categories.name as name',
\DB::Raw('SUM(`transactions`.`amount`) * -1 AS `amount`') DB::Raw('SUM(`transactions`.`amount`) * -1 AS `amount`')
] ]
); );
} }

View File

@@ -1,14 +1,9 @@
<?php <?php
/**
* Created by PhpStorm.
* User: sander
* Date: 22/02/15
* Time: 18:30
*/
namespace FireflyIII\Helpers\Report; namespace FireflyIII\Helpers\Report;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Models\Account;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
@@ -26,6 +21,16 @@ interface ReportQueryInterface
*/ */
public function accountList(); public function accountList();
/**
* Get a users accounts combined with various meta-data related to the start and end date.
*
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
public function getAllAccounts(Carbon $start, Carbon $end);
/** /**
* This method returns all "income" journals in a certain period, which are both transfers from a shared account * This method returns all "income" journals in a certain period, which are both transfers from a shared account
* and "ordinary" deposits. The query used is almost equal to ReportQueryInterface::journalsByRevenueAccount but it does * and "ordinary" deposits. The query used is almost equal to ReportQueryInterface::journalsByRevenueAccount but it does
@@ -103,4 +108,27 @@ interface ReportQueryInterface
* @return Collection * @return Collection
*/ */
public function sharedExpensesByCategory(Carbon $start, Carbon $end); public function sharedExpensesByCategory(Carbon $start, Carbon $end);
/**
* Grabs a summary of all expenses grouped by budget, related to the account.
*
* @param Account $account
* @param Carbon $start
* @param Carbon $end
*
* @return mixed
*/
public function getBudgetSummary(Account $account, Carbon $start, Carbon $end);
/**
* This method will get a list of all expenses in a certain time period that have no budget
* and are balanced by a transfer to make up for it.
*
* @param Account $account
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
public function balancedTransactionsList(Account $account, Carbon $start, Carbon $end);
} }

View File

@@ -29,6 +29,82 @@ class ReportController extends Controller
} }
/**
* @param string $year
* @param string $month
*
* @return \Illuminate\View\View
*/
public function budget($year = '2014', $month = '1', ReportQueryInterface $query)
{
try {
new Carbon($year . '-' . $month . '-01');
} catch (Exception $e) {
return view('error')->with('message', 'Invalid date');
}
$date = new Carbon($year . '-' . $month . '-01');
$start = clone $date;
$start->startOfMonth();
$end = clone $date;
$end->endOfMonth();
$start->subDay();
$dayEarly = clone $date;
$subTitle = 'Budget report for ' . $date->format('F Y');
$subTitleIcon = 'fa-calendar';
$dayEarly = $dayEarly->subDay();
$accounts = $query->getAllAccounts($start, $end);
$accounts->each(
function (Account $account) use ($start, $end, $query) {
$budgets = $query->getBudgetSummary($account, $start, $end);
$balancedAmount = $query->balancedTransactionsList($account, $start, $end);
$array = [];
foreach ($budgets as $budget) {
$id = intval($budget->id);
$data = $budget->toArray();
$array[$id] = $data;
}
$account->budgetInformation = $array;
$account->balancedAmount = $balancedAmount;
}
);
$start = clone $date;
$start->startOfMonth();
/**
* Start getBudgetsForMonth DONE
*/
$set = Auth::user()->budgets()
->leftJoin(
'budget_limits', function (JoinClause $join) use ($date) {
$join->on('budget_limits.budget_id', '=', 'budgets.id')->where('budget_limits.startdate', '=', $date->format('Y-m-d'));
}
)
->get(['budgets.*', 'budget_limits.amount as amount']);
$budgets = Steam::makeArray($set);
$amountSet = $query->journalsByBudget($start, $end);
$amounts = Steam::makeArray($amountSet);
$budgets = Steam::mergeArrays($budgets, $amounts);
$budgets[0]['spent'] = isset($budgets[0]['spent']) ? $budgets[0]['spent'] : 0.0;
$budgets[0]['amount'] = isset($budgets[0]['amount']) ? $budgets[0]['amount'] : 0.0;
$budgets[0]['name'] = 'No budget';
// find transactions to shared expense accounts, which are without a budget by default:
$transfers = $query->sharedExpenses($start, $end);
foreach ($transfers as $transfer) {
$budgets[0]['spent'] += floatval($transfer->amount) * -1;
}
/**
* End getBudgetsForMonth DONE
*/
return View::make('reports.budget', compact('subTitle', 'subTitleIcon', 'date', 'accounts', 'budgets', 'dayEarly'));
}
/** /**
* @param ReportHelperInterface $helper * @param ReportHelperInterface $helper
@@ -57,7 +133,7 @@ class ReportController extends Controller
try { try {
new Carbon($year . '-' . $month . '-01'); new Carbon($year . '-' . $month . '-01');
} catch (Exception $e) { } catch (Exception $e) {
return View::make('error')->with('message', 'Invalid date.'); return view('error')->with('message', 'Invalid date.');
} }
$date = new Carbon($year . '-' . $month . '-01'); $date = new Carbon($year . '-' . $month . '-01');
$subTitle = 'Report for ' . $date->format('F Y'); $subTitle = 'Report for ' . $date->format('F Y');

View File

@@ -5,7 +5,6 @@ namespace FireflyIII\Http\Middleware;
use Carbon\Carbon; use Carbon\Carbon;
use Closure; use Closure;
use FireflyIII\Exception\FireflyException;
use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\Guard;
use Navigation; use Navigation;
use Preferences; use Preferences;

View File

@@ -3,9 +3,10 @@ use Carbon\Carbon;
use DaveJamesMiller\Breadcrumbs\Generator; use DaveJamesMiller\Breadcrumbs\Generator;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\Category;
use FireflyIII\Models\Budget; use FireflyIII\Models\Budget;
use FireflyIII\Models\Category;
use FireflyIII\Models\LimitRepetition; use FireflyIII\Models\LimitRepetition;
/* /*
* Back home. * Back home.
*/ */

View File

@@ -12,6 +12,7 @@ class AccountMeta extends Model
{ {
use ValidatingTrait; use ValidatingTrait;
protected $fillable = ['account_id', 'name', 'data'];
protected $rules protected $rules
= [ = [
'account_id' => 'required|exists:accounts,id', 'account_id' => 'required|exists:accounts,id',
@@ -20,8 +21,6 @@ class AccountMeta extends Model
]; ];
protected $table = 'account_meta'; protected $table = 'account_meta';
protected $fillable = ['account_id', 'name', 'data'];
/** /**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */

View File

@@ -1,9 +1,9 @@
<?php namespace FireflyIII\Providers; <?php namespace FireflyIII\Providers;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\BudgetLimit; use FireflyIII\Models\BudgetLimit;
use FireflyIII\Models\LimitRepetition; use FireflyIII\Models\LimitRepetition;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Support\Facades\Navigation; use FireflyIII\Support\Facades\Navigation;
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract; use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
@@ -11,7 +11,6 @@ use Illuminate\Database\QueryException;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
/** /**
* Class EventServiceProvider * Class EventServiceProvider
* *
@@ -67,12 +66,14 @@ class EventServiceProvider extends ServiceProvider
} }
); );
BudgetLimit::saved(function(BudgetLimit $budgetLimit) { BudgetLimit::saved(
function (BudgetLimit $budgetLimit) {
$end = Navigation::addPeriod(clone $budgetLimit->startdate, $budgetLimit->repeat_freq, 0); $end = Navigation::addPeriod(clone $budgetLimit->startdate, $budgetLimit->repeat_freq, 0);
$end->subDay(); $end->subDay();
$set = $budgetLimit->limitrepetitions()->where('startdate', $budgetLimit->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: * Create new LimitRepetition:
*/ */
@@ -101,10 +102,8 @@ class EventServiceProvider extends ServiceProvider
} }
} }
}); }
);
} }

View File

@@ -10,7 +10,8 @@ use Illuminate\Support\ServiceProvider;
* *
* @package FireflyIII\Providers * @package FireflyIII\Providers
*/ */
class TestingServiceProvider extends ServiceProvider { class TestingServiceProvider extends ServiceProvider
{
/** /**
* Register the service provider. * Register the service provider.
@@ -19,8 +20,7 @@ class TestingServiceProvider extends ServiceProvider {
*/ */
public function register() public function register()
{ {
if ($this->app->environment() == 'testing') if ($this->app->environment() == 'testing') {
{
$this->app['config']['session.driver'] = 'native'; $this->app['config']['session.driver'] = 'native';
} }
} }

View File

@@ -58,6 +58,7 @@ class BudgetRepository implements BudgetRepositoryInterface
foreach ($set as $entry) { foreach ($set as $entry) {
$items[] = $entry; $items[] = $entry;
} }
return new LengthAwarePaginator($items, $count, $take, $offset); return new LengthAwarePaginator($items, $count, $take, $offset);
} }

View File

@@ -1,9 +1,11 @@
<?php <?php
namespace FireflyIII\Repositories\Budget; namespace FireflyIII\Repositories\Budget;
use Carbon\Carbon;
use FireflyIII\Models\Budget; use FireflyIII\Models\Budget;
use FireflyIII\Models\LimitRepetition; use FireflyIII\Models\LimitRepetition;
use Carbon\Carbon;
/** /**
* Interface BudgetRepositoryInterface * Interface BudgetRepositoryInterface
* *

View File

@@ -1,7 +1,9 @@
<?php <?php
namespace FireflyIII\Repositories\Category; namespace FireflyIII\Repositories\Category;
use FireflyIII\Models\Category; use FireflyIII\Models\Category;
/** /**
* Interface CategoryRepositoryInterface * Interface CategoryRepositoryInterface
* *

View File

@@ -37,14 +37,11 @@
"codeception/codeception": "@stable", "codeception/codeception": "@stable",
"codeception/c3": "@stable", "codeception/c3": "@stable",
"league/factory-muffin": "~2.1", "league/factory-muffin": "~2.1",
"codeception/phpbuiltinserver": "*", "codeception/phpbuiltinserver": "*",
"codeception/specify": "*", "codeception/specify": "*",
"codeception/verify": "*", "codeception/verify": "*",
"fzaninotto/faker": "1.*", "fzaninotto/faker": "1.*",
"codeclimate/php-test-reporter": "dev-master", "codeclimate/php-test-reporter": "dev-master"
"janhenkgerritsen/codeception-laravel5": "~1.0"
}, },
"autoload": { "autoload": {

View File

@@ -1,6 +1,6 @@
@extends('layouts.default') @extends('layouts.default')
@section('content') @section('content')
{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $date) }} {!! Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $date) !!}
<div class="row"> <div class="row">
<div class="col-lg-6 col-md-6 col-sm-12"> <div class="col-lg-6 col-md-6 col-sm-12">
<table class="table table-bordered table-striped"> <table class="table table-bordered table-striped">
@@ -13,9 +13,9 @@
@foreach($accounts as $account) @foreach($accounts as $account)
<tr> <tr>
<td><a href="{{route('accounts.show',$account->id)}}">{{{$account->name}}}</a></td> <td><a href="{{route('accounts.show',$account->id)}}">{{{$account->name}}}</a></td>
<td>{{Amount::format($account->startBalance)}}</td> <td>{!! Amount::format($account->startBalance) !!}</td>
<td>{{Amount::format($account->endBalance)}}</td> <td>{!! Amount::format($account->endBalance) !!}</td>
<td>{{Amount::format($account->startBalance - $account->endBalance,false)}}</td> <td>{!! Amount::format($account->startBalance - $account->endBalance,false) !!}</td>
</tr> </tr>
@endforeach @endforeach
</table> </table>
@@ -47,15 +47,15 @@
<i class="fa fa-fw fa-question-circle" data-toggle="tooltip" data-placement="top" title="The calculation used here is slightly different from the row below. The numbers should match."></i> <i class="fa fa-fw fa-question-circle" data-toggle="tooltip" data-placement="top" title="The calculation used here is slightly different from the row below. The numbers should match."></i>
@endif @endif
</td> </td>
<td>{{Amount::format($budget['amount'])}}</td> <td>{!! Amount::format($budget['amount']) !!}</td>
<?php $spent = 0;?> <?php $spent = 0;?>
@foreach($accounts as $account) @foreach($accounts as $account)
@if(isset($account->budgetInformation[$id])) @if(isset($account->budgetInformation[$id]))
<td> <td>
@if($id == 0) @if($id == 0)
<a href="#">{{Amount::format($account->budgetInformation[$id]['amount'])}}</a> <a href="#">{!! Amount::format($account->budgetInformation[$id]['amount']) !!}</a>
@else @else
{{Amount::format($account->budgetInformation[$id]['amount'])}} {!! Amount::format($account->budgetInformation[$id]['amount']) !!}
@endif @endif
</td> </td>
<?php <?php
@@ -63,11 +63,11 @@
$accountSums[$account->id] += floatval($account->budgetInformation[$id]['amount']); $accountSums[$account->id] += floatval($account->budgetInformation[$id]['amount']);
?> ?>
@else @else
<td>{{Amount::format(0)}}</td> <td>{!! Amount::format(0) !!}</td>
@endif @endif
@endforeach @endforeach
<td>{{Amount::format($budget['amount'] + $budget['spent'])}}</td> <td>{!! Amount::format($budget['amount'] + $budget['spent']) !!}</td>
<td>{{Amount::format($budget['amount'] + $spent)}}</td> <td>{!! Amount::format($budget['amount'] + $spent) !!}</td>
</tr> </tr>
@endforeach @endforeach
<tr> <tr>
@@ -77,10 +77,10 @@
@foreach($accounts as $account) @foreach($accounts as $account)
@if(isset($account->budgetInformation[0])) @if(isset($account->budgetInformation[0]))
<td> <td>
<a href="#">{{Amount::format($account->budgetInformation[0]['amount'])}}</a> <a href="#">{!! Amount::format($account->budgetInformation[0]['amount']) !!}</a>
</td> </td>
@else @else
<td>{{Amount::format(0)}}</td> <td>{!! Amount::format(0) !!}</td>
@endif @endif
@endforeach @endforeach
<td colspan="2">&nbsp;</td> <td colspan="2">&nbsp;</td>
@@ -89,7 +89,7 @@
<td colspan="2">Balanced by transfers</td> <td colspan="2">Balanced by transfers</td>
@foreach($accounts as $account) @foreach($accounts as $account)
<td> <td>
<a href="#">{{Amount::format($account->balancedAmount)}}</a> <a href="#">{!! Amount::format($account->balancedAmount) !!}</a>
</td> </td>
@endforeach @endforeach
<td colspan="2">&nbsp;</td> <td colspan="2">&nbsp;</td>
@@ -98,14 +98,14 @@
<tr> <tr>
<td colspan="2">Balancing transfers</td> <td colspan="2">Balancing transfers</td>
@foreach($accounts as $account) @foreach($accounts as $account)
<td>{{Amount::format(0)}}</td> <td>{!! Amount::format(0) !!}</td>
@endforeach @endforeach
<td colspan="2">&nbsp;</td> <td colspan="2">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td colspan="2">Income</td> <td colspan="2">Income</td>
@foreach($accounts as $account) @foreach($accounts as $account)
<td>{{Amount::format(0)}}</td> <td>{!! Amount::format(0) !!}</td>
@endforeach @endforeach
<td colspan="2">&nbsp;</td> <td colspan="2">&nbsp;</td>
</tr> </tr>
@@ -118,10 +118,10 @@
?> ?>
@if(isset($account->budgetInformation[0])) @if(isset($account->budgetInformation[0]))
<td> <td>
<a href="#">{{Amount::format($account->budgetInformation[0]['amount'] + $account->balancedAmount)}}</a> <a href="#">{!! Amount::format($account->budgetInformation[0]['amount'] + $account->balancedAmount) !!}</a>
</td> </td>
@else @else
<td>{{Amount::format(0)}}</td> <td>{!! Amount::format(0) !!}</td>
@endif @endif
@endforeach @endforeach
<td colspan="2">&nbsp;</td> <td colspan="2">&nbsp;</td>
@@ -129,14 +129,14 @@
<tr> <tr>
<td colspan="2"><em>Sum</em></td> <td colspan="2"><em>Sum</em></td>
@foreach($accounts as $account) @foreach($accounts as $account)
<td>{{Amount::format($accountSums[$account->id])}}</td> <td>{!! Amount::format($accountSums[$account->id]) !!}</td>
@endforeach @endforeach
<td colspan="2">&nbsp;</td> <td colspan="2">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td colspan="2">Expected balance</td> <td colspan="2">Expected balance</td>
@foreach($accounts as $account) @foreach($accounts as $account)
<td>{{Amount::format($account->startBalance + $accountSums[$account->id])}}</td> <td>{!! Amount::format($account->startBalance + $accountSums[$account->id]) !!}</td>
@endforeach @endforeach
<td colspan="2">&nbsp;</td> <td colspan="2">&nbsp;</td>
</tr> </tr>
@@ -152,5 +152,5 @@
@stop @stop
@section('scripts') @section('scripts')
{{HTML::script('assets/javascript/firefly/reports.js')}} <script type="text/javascript" src="js/reports.js"></script>
@stop @stop