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,21 +1,20 @@
<?php namespace FireflyIII\Events;
use FireflyIII\Events\Event;
use Illuminate\Queue\SerializesModels;
class JournalDeleted extends Event {
class JournalDeleted extends Event
{
use SerializesModels;
use SerializesModels;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Create a new event instance.
*
* @return void
*/
public function __construct()
{
//
}
}

View File

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

View File

@ -62,14 +62,13 @@ class ReportHelper implements ReportHelperInterface
$end = clone $date;
$end->endOfMonth();
// all budgets
$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']);
$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 = $this->_helper->makeArray($set);

View File

@ -33,11 +33,11 @@ interface ReportHelperInterface
*/
public function listOfYears(Carbon $date);
/**
* @param Carbon $date
*
* @return array
*/
/**
* @param Carbon $date
*
* @return array
*/
public function yearBalanceReport(Carbon $date);
/**

View File

@ -11,10 +11,12 @@ namespace FireflyIII\Helpers\Report;
use Auth;
use Carbon\Carbon;
use DB;
use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Collection;
use Steam;
/**
* Class ReportQuery
@ -31,22 +33,141 @@ class ReportQuery implements ReportQueryInterface
*/
public function accountList()
{
return \Auth::user()->accounts()
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->leftJoin(
'account_meta', function (JoinClause $join) {
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', "accountRole");
}
)
->whereIn('account_types.type', ['Default account', 'Cash account', 'Asset account'])
->where('active', 1)
->where(
function (Builder $query) {
$query->where('account_meta.data', '!=', '"sharedExpense"');
$query->orWhereNull('account_meta.data');
}
)
->get(['accounts.*']);
return Auth::user()->accounts()
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->leftJoin(
'account_meta', function (JoinClause $join) {
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', "accountRole");
}
)
->whereIn('account_types.type', ['Default account', 'Cash account', 'Asset account'])
->where('active', 1)
->where(
function (Builder $query) {
$query->where('account_meta.data', '!=', '"sharedExpense"');
$query->orWhereNull('account_meta.data');
}
)
->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;
}
/**
@ -124,28 +245,28 @@ class ReportQuery implements ReportQueryInterface
*/
public function journalsByBudget(Carbon $start, Carbon $end)
{
return \Auth::user()->transactionjournals()
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('budgets', 'budget_transaction_journal.budget_id', '=', 'budgets.id')
->leftJoin(
'transactions', function (JoinClause $join) {
$join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('transactions.amount', '<', 0);
}
)
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin(
'account_meta', function (JoinClause $join) {
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
}
)
->leftJoin('transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id')
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
->where('account_meta.data', '!=', '"sharedExpense"')
->where('transaction_types.type', 'Withdrawal')
->groupBy('budgets.id')
->orderBy('budgets.name', 'ASC')
->get(['budgets.id', 'budgets.name', \DB::Raw('SUM(`transactions`.`amount`) AS `spent`')]);
return Auth::user()->transactionjournals()
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('budgets', 'budget_transaction_journal.budget_id', '=', 'budgets.id')
->leftJoin(
'transactions', function (JoinClause $join) {
$join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('transactions.amount', '<', 0);
}
)
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin(
'account_meta', function (JoinClause $join) {
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
}
)
->leftJoin('transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id')
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
->where('account_meta.data', '!=', '"sharedExpense"')
->where('transaction_types.type', 'Withdrawal')
->groupBy('budgets.id')
->orderBy('budgets.name', 'ASC')
->get(['budgets.id', 'budgets.name', DB::Raw('SUM(`transactions`.`amount`) AS `spent`')]);
}
/**
@ -159,30 +280,30 @@ class ReportQuery implements ReportQueryInterface
*/
public function journalsByCategory(Carbon $start, Carbon $end)
{
return \Auth::user()->transactionjournals()
->leftJoin(
'category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'
)
->leftJoin('categories', 'category_transaction_journal.category_id', '=', 'categories.id')
->leftJoin(
'transactions', function (JoinClause $join) {
$join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('transactions.amount', '<', 0);
}
)
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin(
'account_meta', function (JoinClause $join) {
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
}
)
->leftJoin('transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id')
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
->where('account_meta.data', '!=', '"sharedExpense"')
->where('transaction_types.type', 'Withdrawal')
->groupBy('categories.id')
->orderBy('amount')
->get(['categories.id', 'categories.name', \DB::Raw('SUM(`transactions`.`amount`) AS `amount`')]);
return Auth::user()->transactionjournals()
->leftJoin(
'category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'
)
->leftJoin('categories', 'category_transaction_journal.category_id', '=', 'categories.id')
->leftJoin(
'transactions', function (JoinClause $join) {
$join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('transactions.amount', '<', 0);
}
)
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin(
'account_meta', function (JoinClause $join) {
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
}
)
->leftJoin('transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id')
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
->where('account_meta.data', '!=', '"sharedExpense"')
->where('transaction_types.type', 'Withdrawal')
->groupBy('categories.id')
->orderBy('amount')
->get(['categories.id', 'categories.name', DB::Raw('SUM(`transactions`.`amount`) AS `amount`')]);
}
@ -333,7 +454,7 @@ class ReportQuery implements ReportQueryInterface
->after($start)
->before($end)
->where('transaction_types.type', 'Transfer')
->where('transaction_journals.user_id', \Auth::user()->id)
->where('transaction_journals.user_id', Auth::user()->id)
->get(
['transaction_journals.id', 'transaction_journals.description', 'transactions.account_id', 'accounts.name',
'transactions.amount']
@ -375,13 +496,13 @@ class ReportQuery implements ReportQueryInterface
->after($start)
->before($end)
->where('transaction_types.type', 'Transfer')
->where('transaction_journals.user_id', \Auth::user()->id)
->where('transaction_journals.user_id', Auth::user()->id)
->groupBy('categories.name')
->get(
[
'categories.id',
'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
/**
* Created by PhpStorm.
* User: sander
* Date: 22/02/15
* Time: 18:30
*/
namespace FireflyIII\Helpers\Report;
use Carbon\Carbon;
use FireflyIII\Models\Account;
use Illuminate\Support\Collection;
/**
@ -26,6 +21,16 @@ interface ReportQueryInterface
*/
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
* and "ordinary" deposits. The query used is almost equal to ReportQueryInterface::journalsByRevenueAccount but it does
@ -103,4 +108,27 @@ interface ReportQueryInterface
* @return Collection
*/
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

@ -492,7 +492,7 @@ class GoogleChartController extends Controller
} catch (Exception $e) {
return view('error')->with('message', 'Invalid year.');
}
$budgets = Auth::user()->budgets()->get();
$budgets = Auth::user()->budgets()->get();
$budgets->sortBy('name');
$chart->addColumn('Month', 'date');
foreach ($budgets as $budget) {

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
@ -57,7 +133,7 @@ class ReportController extends Controller
try {
new Carbon($year . '-' . $month . '-01');
} catch (Exception $e) {
return View::make('error')->with('message', 'Invalid date.');
return view('error')->with('message', 'Invalid date.');
}
$date = new Carbon($year . '-' . $month . '-01');
$subTitle = 'Report for ' . $date->format('F Y');

View File

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

View File

@ -3,9 +3,10 @@ use Carbon\Carbon;
use DaveJamesMiller\Breadcrumbs\Generator;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account;
use FireflyIII\Models\Category;
use FireflyIII\Models\Budget;
use FireflyIII\Models\Category;
use FireflyIII\Models\LimitRepetition;
/*
* Back home.
*/
@ -345,7 +346,7 @@ Breadcrumbs::register(
Breadcrumbs::register(
'transactions.create', function (Generator $breadcrumbs, $what) {
$breadcrumbs->parent('transactions.index', $what);
$breadcrumbs->push('Create new ' .e($what), route('transactions.create', $what));
$breadcrumbs->push('Create new ' . e($what), route('transactions.create', $what));
}
);

View File

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

View File

@ -1,9 +1,9 @@
<?php namespace FireflyIII\Providers;
use FireflyIII\Models\Account;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\BudgetLimit;
use FireflyIII\Models\LimitRepetition;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Support\Facades\Navigation;
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
@ -11,7 +11,6 @@ use Illuminate\Database\QueryException;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
/**
* Class EventServiceProvider
*
@ -67,44 +66,44 @@ 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->subDay();
$end = Navigation::addPeriod(clone $budgetLimit->startdate, $budgetLimit->repeat_freq, 0);
$end->subDay();
$set = $budgetLimit->limitrepetitions()->where('startdate', $budgetLimit->startdate->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'))->get();
/*
* Create new LimitRepetition:
*/
if ($set->count() == 0) {
$set = $budgetLimit->limitrepetitions()->where('startdate', $budgetLimit->startdate->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'))
->get();
/*
* Create new LimitRepetition:
*/
if ($set->count() == 0) {
$repetition = new LimitRepetition;
$repetition->startdate = $budgetLimit->startdate;
$repetition->enddate = $end;
$repetition->amount = $budgetLimit->amount;
$repetition->budgetLimit()->associate($budgetLimit);
$repetition = new LimitRepetition;
$repetition->startdate = $budgetLimit->startdate;
$repetition->enddate = $end;
$repetition->amount = $budgetLimit->amount;
$repetition->budgetLimit()->associate($budgetLimit);
try {
$repetition->save();
} catch (QueryException $e) {
\Log::error('Trying to save new LimitRepetition failed!');
\Log::error($e->getMessage());
}
} else {
if ($set->count() == 1) {
/*
* Update existing one.
*/
$repetition = $set->first();
$repetition->amount = $budgetLimit->amount;
$repetition->save();
try {
$repetition->save();
} catch (QueryException $e) {
\Log::error('Trying to save new LimitRepetition failed!');
\Log::error($e->getMessage());
}
} else {
if ($set->count() == 1) {
/*
* Update existing one.
*/
$repetition = $set->first();
$repetition->amount = $budgetLimit->amount;
$repetition->save();
}
}
}
});
);
}

View File

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

View File

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

View File

@ -1,9 +1,11 @@
<?php
namespace FireflyIII\Repositories\Budget;
use Carbon\Carbon;
use FireflyIII\Models\Budget;
use FireflyIII\Models\LimitRepetition;
use Carbon\Carbon;
/**
* Interface BudgetRepositoryInterface
*
@ -44,7 +46,7 @@ interface BudgetRepositoryInterface
/**
* @param Budget $budget
* @param array $data
* @param array $data
*
* @return Budget
*/
@ -55,7 +57,7 @@ interface BudgetRepositoryInterface
*
* @param Budget $budget
* @param LimitRepetition $repetition
* @param int $take
* @param int $take
*
* @return \Illuminate\Pagination\Paginator
*/

View File

@ -1,7 +1,9 @@
<?php
namespace FireflyIII\Repositories\Category;
use FireflyIII\Models\Category;
/**
* Interface CategoryRepositoryInterface
*
@ -25,7 +27,7 @@ interface CategoryRepositoryInterface
/**
* @param Category $category
* @param array $data
* @param array $data
*
* @return Category
*/

View File

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

View File

@ -1,6 +1,6 @@
@extends('layouts.default')
@section('content')
{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $date) }}
{!! Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $date) !!}
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12">
<table class="table table-bordered table-striped">
@ -13,9 +13,9 @@
@foreach($accounts as $account)
<tr>
<td><a href="{{route('accounts.show',$account->id)}}">{{{$account->name}}}</a></td>
<td>{{Amount::format($account->startBalance)}}</td>
<td>{{Amount::format($account->endBalance)}}</td>
<td>{{Amount::format($account->startBalance - $account->endBalance,false)}}</td>
<td>{!! Amount::format($account->startBalance) !!}</td>
<td>{!! Amount::format($account->endBalance) !!}</td>
<td>{!! Amount::format($account->startBalance - $account->endBalance,false) !!}</td>
</tr>
@endforeach
</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>
@endif
</td>
<td>{{Amount::format($budget['amount'])}}</td>
<td>{!! Amount::format($budget['amount']) !!}</td>
<?php $spent = 0;?>
@foreach($accounts as $account)
@if(isset($account->budgetInformation[$id]))
<td>
@if($id == 0)
<a href="#">{{Amount::format($account->budgetInformation[$id]['amount'])}}</a>
<a href="#">{!! Amount::format($account->budgetInformation[$id]['amount']) !!}</a>
@else
{{Amount::format($account->budgetInformation[$id]['amount'])}}
{!! Amount::format($account->budgetInformation[$id]['amount']) !!}
@endif
</td>
<?php
@ -63,11 +63,11 @@
$accountSums[$account->id] += floatval($account->budgetInformation[$id]['amount']);
?>
@else
<td>{{Amount::format(0)}}</td>
<td>{!! Amount::format(0) !!}</td>
@endif
@endforeach
<td>{{Amount::format($budget['amount'] + $budget['spent'])}}</td>
<td>{{Amount::format($budget['amount'] + $spent)}}</td>
<td>{!! Amount::format($budget['amount'] + $budget['spent']) !!}</td>
<td>{!! Amount::format($budget['amount'] + $spent) !!}</td>
</tr>
@endforeach
<tr>
@ -77,10 +77,10 @@
@foreach($accounts as $account)
@if(isset($account->budgetInformation[0]))
<td>
<a href="#">{{Amount::format($account->budgetInformation[0]['amount'])}}</a>
<a href="#">{!! Amount::format($account->budgetInformation[0]['amount']) !!}</a>
</td>
@else
<td>{{Amount::format(0)}}</td>
<td>{!! Amount::format(0) !!}</td>
@endif
@endforeach
<td colspan="2">&nbsp;</td>
@ -89,7 +89,7 @@
<td colspan="2">Balanced by transfers</td>
@foreach($accounts as $account)
<td>
<a href="#">{{Amount::format($account->balancedAmount)}}</a>
<a href="#">{!! Amount::format($account->balancedAmount) !!}</a>
</td>
@endforeach
<td colspan="2">&nbsp;</td>
@ -98,14 +98,14 @@
<tr>
<td colspan="2">Balancing transfers</td>
@foreach($accounts as $account)
<td>{{Amount::format(0)}}</td>
<td>{!! Amount::format(0) !!}</td>
@endforeach
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2">Income</td>
@foreach($accounts as $account)
<td>{{Amount::format(0)}}</td>
<td>{!! Amount::format(0) !!}</td>
@endforeach
<td colspan="2">&nbsp;</td>
</tr>
@ -118,10 +118,10 @@
?>
@if(isset($account->budgetInformation[0]))
<td>
<a href="#">{{Amount::format($account->budgetInformation[0]['amount'] + $account->balancedAmount)}}</a>
<a href="#">{!! Amount::format($account->budgetInformation[0]['amount'] + $account->balancedAmount) !!}</a>
</td>
@else
<td>{{Amount::format(0)}}</td>
<td>{!! Amount::format(0) !!}</td>
@endif
@endforeach
<td colspan="2">&nbsp;</td>
@ -129,14 +129,14 @@
<tr>
<td colspan="2"><em>Sum</em></td>
@foreach($accounts as $account)
<td>{{Amount::format($accountSums[$account->id])}}</td>
<td>{!! Amount::format($accountSums[$account->id]) !!}</td>
@endforeach
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2">Expected balance</td>
@foreach($accounts as $account)
<td>{{Amount::format($account->startBalance + $accountSums[$account->id])}}</td>
<td>{!! Amount::format($account->startBalance + $accountSums[$account->id]) !!}</td>
@endforeach
<td colspan="2">&nbsp;</td>
</tr>
@ -152,5 +152,5 @@
@stop
@section('scripts')
{{HTML::script('assets/javascript/firefly/reports.js')}}
<script type="text/javascript" src="js/reports.js"></script>
@stop