Fixed budget controller. [skip ci]

This commit is contained in:
James Cole
2014-07-28 21:33:32 +02:00
parent b0ddc04a0d
commit 1b919b1dab
20 changed files with 540 additions and 217 deletions

View File

@@ -1,4 +1,6 @@
<?php
use Carbon\Carbon;
return [
'index_periods' => '1D', '1W', '1M', '3M', '6M', 'custom',
'budget_periods' => 'daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly',
@@ -25,19 +27,4 @@ return [
'6M' => 'half-year',
'custom' => 'monthly'
],
'date_formats_by_period' => [
'monthly' => [
'group_date' => 'Y-m',
'display_date' => 'F Y'
],
'weekly' => [
'group_date' => 'Y-W',
'display_date' => '\W\e\e\k W, Y'
],
'quarterly' => [
'group_date' => 'Y-m',
'display_date' => '\T\O\D\O \C\L\O\S\U\R\E m-Y'
]
]
];

View File

@@ -14,7 +14,7 @@ class AccountController extends \BaseController
/**
* @param ARI $repository
* @param AI $accounts
* @param AI $accounts
*/
public function __construct(ARI $repository, AI $accounts)
{
@@ -54,6 +54,7 @@ class AccountController extends \BaseController
} else {
Session::flash('error', 'Could not delete the account. Check the logs to be sure.');
}
return Redirect::route('accounts.index');

View File

@@ -15,7 +15,7 @@ class BudgetController extends BaseController
/**
* @param BI $budgets
* @param BI $budgets
* @param BRI $repository
*/
public function __construct(BI $budgets, BRI $repository)
@@ -35,6 +35,35 @@ class BudgetController extends BaseController
return View::make('budgets.create')->with('periods', $periods);
}
public function delete(Budget $budget)
{
return View::make('budgets.delete')->with('budget', $budget);
}
public function destroy()
{
$result = $this->_repository->destroy(Input::get('id'));
if ($result === true) {
Session::flash('success', 'The budget was deleted.');
if (Input::get('from') == 'date') {
return Redirect::route('budgets.index');
} else {
return Redirect::route('budgets.index.budget');
}
} else {
Session::flash('error', 'Could not delete the budget. Check the logs to be sure.');
}
return Redirect::route('budgets.index');
}
public function edit(Budget $budget)
{
return View::make('budgets.edit')->with('budget', $budget);
}
/**
* @return $this|\Illuminate\View\View
*/
@@ -62,48 +91,6 @@ class BudgetController extends BaseController
}
public function edit(Budget $budget)
{
return View::make('budgets.edit')->with('budget', $budget);
}
public function update()
{
$budget = $this->_repository->update(Input::all());
Session::flash('success', 'Budget "' . $budget->name . '" updated.');
if (Input::get('from') == 'date') {
return Redirect::route('budgets.index');
} else {
return Redirect::route('budgets.index.budget');
}
return Redirect::route('budgets.index');
}
public function delete(Budget $budget)
{
return View::make('budgets.delete')->with('budget', $budget);
}
public function destroy()
{
$result = $this->_repository->destroy(Input::get('id'));
if ($result === true) {
Session::flash('success', 'The budget was deleted.');
if (Input::get('from') == 'date') {
return Redirect::route('budgets.index');
} else {
return Redirect::route('budgets.index.budget');
}
} else {
Session::flash('error', 'Could not delete the budget. Check the logs to be sure.');
}
return Redirect::route('budgets.index');
}
/**
* @param Budget $budget
*
@@ -111,43 +98,26 @@ class BudgetController extends BaseController
*/
public function show(Budget $budget)
{
return $budget->id;
// /** @var \Budget $budget */
// $budget = $this->_budgets->find($budgetId);
//
// $list = $budget->transactionjournals()->get();
// $return = [];
// /** @var \TransactionJournal $entry */
// foreach ($list as $entry) {
// $month = $entry->date->format('F Y');
// $return[$month] = isset($return[$month]) ? $return[$month] : [];
// $return[$month][] = $entry;
//
// }
// $str = '';
//
// foreach ($return as $month => $set) {
// $str .= '<h1>' . $month . '</h1>';
// /** @var \TransactionJournal $tj */
// $sum = 0;
// foreach ($set as $tj) {
// $str .= '#' . $tj->id . ' ' . $tj->description . ': ';
//
// foreach ($tj->transactions as $index => $t) {
// $str .= $t->amount . ', ';
// if ($index == 0) {
// $sum += $t->amount;
//
// }
// }
// $str .= '<br>';
//
// }
// $str .= 'sum: ' . $sum . '<br><br>';
// }
//
// return $str;
$filters = [];
if (!is_null(Input::get('rep'))) {
$repetitionId = intval(Input::get('rep'));
$repetitions = $this->_budgets->organizeRepetition($budget, $repetitionId);
$filters[] = $repetitions[0]['limit'];
$filters[] = $repetitions[0]['limitrepetition'];
} else {
if (Input::get('noenvelope') == 'true') {
$repetitions = $this->_budgets->outsideRepetitions($budget);
$filters[] = 'no_envelope';
} else {
// grab all limit repetitions, order them, show them:
$repetitions = $this->_budgets->organizeRepetitions($budget);
}
}
return View::make('budgets.show')->with('budget', $budget)->with('repetitions', $repetitions)->with(
'filters', $filters
);
}
/**
@@ -177,5 +147,19 @@ class BudgetController extends BaseController
}
public function update()
{
$budget = $this->_repository->update(Input::all());
Session::flash('success', 'Budget "' . $budget->name . '" updated.');
if (Input::get('from') == 'date') {
return Redirect::route('budgets.index');
} else {
return Redirect::route('budgets.index.budget');
}
return Redirect::route('budgets.index');
}
}

View File

@@ -21,11 +21,11 @@ class ChartController extends BaseController
/**
* @param ARI $accounts
* @param ARI $accounts
* @param TJRI $journals
* @param PHI $preferences
* @param tk $toolkit
* @param BRI $budgets
* @param PHI $preferences
* @param tk $toolkit
* @param BRI $budgets
*/
public function __construct(ARI $accounts, TJRI $journals, PHI $preferences, tk $toolkit, BRI $budgets)
{
@@ -85,6 +85,7 @@ class ChartController extends BaseController
$current->addDay();
}
}
return Response::json($return);
}
@@ -118,6 +119,7 @@ class ChartController extends BaseController
}
}
}
return View::make('charts.info')->with('rows', $result)->with('sum', $sum);
}
@@ -179,14 +181,9 @@ class ChartController extends BaseController
$repeatFreq = Config::get('firefly.range_to_repeat_freq.' . Session::get('range'));
$dateFormats = Config::get('firefly.date_formats_by_period.' . $repeatFreq);
if (is_null($dateFormats)) {
throw new FireflyException('No date formats for ' . \Session::get('range'));
}
$limitInPeriod = 'Envelope for ' . $start->format($dateFormats['display_date']);
$spentInPeriod = 'Spent in ' . $start->format($dateFormats['display_date']);
$limitInPeriod = 'Envelope for XXX';
$spentInPeriod = 'Spent in XXX';
$data['series'] = [
[
@@ -217,6 +214,7 @@ class ChartController extends BaseController
}
return Response::json($data);
}
}

View File

@@ -17,11 +17,11 @@ class HomeController extends BaseController
protected $_tk;
/**
* @param ARI $accounts
* @param PHI $preferences
* @param TJRI $journal
* @param ARI $accounts
* @param PHI $preferences
* @param TJRI $journal
* @param Toolkit $toolkit
* @param BRI $budgets
* @param BRI $budgets
*/
public function __construct(ARI $accounts, PHI $preferences, TJRI $journal, Toolkit $toolkit, BRI $budgets)
{
@@ -72,6 +72,7 @@ class HomeController extends BaseController
} else {
$transactions = array_chunk($transactions, 3);
}
// build the home screen:
return View::make('index')->with('count', $count)->with('transactions', $transactions)->with(
'budgets', $budgets
@@ -84,6 +85,7 @@ class HomeController extends BaseController
public function flush()
{
Cache::flush();
return Redirect::route('index');
}
}

View File

@@ -33,11 +33,12 @@ class LimitController extends BaseController
{
$periods = \Config::get('firefly.periods_to_text');
$prefilled = [
'startdate' => Input::get('startdate') ? : date('Y-m-d'),
'startdate' => Input::get('startdate') ? : date('Y-m-d'),
'repeat_freq' => Input::get('repeat_freq') ? : 'monthly'
];
$budgets = $this->_budgets->getAsSelectList();
return View::make('limits.create')->with('budgets', $budgets)->with('budget_id', $budgetId)->with(
'periods', $periods
)->with('prefilled', $prefilled);
@@ -54,11 +55,11 @@ class LimitController extends BaseController
$budgets = $this->_budgets->getAsSelectList();
$periods = [
'weekly' => 'A week',
'monthly' => 'A month',
'weekly' => 'A week',
'monthly' => 'A month',
'quarterly' => 'A quarter',
'half-year' => 'Six months',
'yearly' => 'A year',
'yearly' => 'A year',
];
@@ -67,6 +68,7 @@ class LimitController extends BaseController
'periods', $periods
);
}
return View::make('error')->with('message', 'No such limit.');
}
@@ -87,15 +89,18 @@ class LimitController extends BaseController
$limit->amount = floatval(Input::get('amount'));
if (!$limit->save()) {
Session::flash('error', 'Could not save new limit: ' . $limit->errors()->first());
return Redirect::route('budgets.limits.edit', $limit->id)->withInput();
} else {
Session::flash('success', 'Limit saved!');
foreach ($limit->limitrepetitions()->get() as $rep) {
$rep->delete();
}
return Redirect::route('budgets.index');
}
}
return View::make('error')->with('message', 'No limit!');
}
@@ -143,6 +148,7 @@ class LimitController extends BaseController
if ($limit) {
$limit->delete();
return Redirect::route('budgets.index');
} else {
return View::make('error')->with('message', 'No such limit!');

View File

@@ -39,6 +39,7 @@ class MigrationController extends BaseController
throw new \Firefly\Exception\FireflyException('Invalid file.');
}
}
return '<a href="' . route('index') . '">home</a>';
}
@@ -67,6 +68,7 @@ class MigrationController extends BaseController
return View::make('error')->with('message', 'Invalid JSON content.');
}
$this->_migration->migrate();
return Redirect::route('index');
} else {
return View::make('error')->with('message', 'No file selected');

View File

@@ -35,6 +35,7 @@ class PreferencesController extends BaseController
// pref:
$frontpage = $this->_preferences->get('frontpageAccounts', []);
return View::make('preferences.index')->with('accounts', $accounts)->with('frontpageAccounts', $frontpage)
->with('viewRange', $viewRangeValue);
}
@@ -60,6 +61,7 @@ class PreferencesController extends BaseController
Session::forget('range');
Session::flash('success', 'Preferences saved!');
return Redirect::route('preferences');
}

View File

@@ -44,19 +44,23 @@ class ProfileController extends BaseController
/** @noinspection PhpUndefinedFieldInspection */
if (!Hash::check(Input::get('old'), Auth::user()->password)) {
Session::flash('error', 'Invalid current password!');
return View::make('profile.change-password');
}
if (strlen(Input::get('new1')) == 0 || strlen(Input::get('new2')) == 0) {
Session::flash('error', 'Do fill in a password!');
return View::make('profile.change-password');
}
if (Input::get('new1') == Input::get('old')) {
Session::flash('error', 'The idea is to change your password.');
return View::make('profile.change-password');
}
if (Input::get('new1') !== Input::get('new2')) {
Session::flash('error', 'New passwords do not match!');
return View::make('profile.change-password');
}
@@ -65,6 +69,7 @@ class ProfileController extends BaseController
$this->user->updatePassword(Auth::user(), Input::get('new1'));
Session::flash('success', 'Password changed!');
return Redirect::route('profile');
}

View File

@@ -18,9 +18,9 @@ class TransactionController extends BaseController
protected $_journal;
/**
* @param ARI $accounts
* @param Bud $budgets
* @param Cat $categories
* @param ARI $accounts
* @param Bud $budgets
* @param Cat $categories
* @param TJRI $journal
*/
public function __construct(ARI $accounts, Bud $budgets, Cat $categories, TJRI $journal)
@@ -129,6 +129,7 @@ class TransactionController extends BaseController
public function index()
{
$transactions = $this->_journal->paginate(25);
return View::make('transactions.index')->with('transactions', $transactions);
}
@@ -143,6 +144,7 @@ class TransactionController extends BaseController
if ($journal) {
return View::make('transactions.show')->with('journal', $journal);
}
return View::make('error')->with('message', 'Invalid journal');
}
@@ -167,8 +169,8 @@ class TransactionController extends BaseController
// data to properly display form:
$data = [
'date' => $journal->date->format('Y-m-d'),
'category' => '',
'date' => $journal->date->format('Y-m-d'),
'category' => '',
'budget_id' => 0
];
$category = $journal->categories()->first();
@@ -196,10 +198,12 @@ class TransactionController extends BaseController
$data['amount'] = floatval($journal->transactions[1]->amount);
break;
}
return View::make('transactions.edit')->with('journal', $journal)->with('accounts', $accounts)->with(
'what', $what
)->with('budgets', $budgets)->with('data', $data);
}
return View::make('error')->with('message', 'Invalid journal');
}
@@ -270,6 +274,7 @@ class TransactionController extends BaseController
$journal->transactions[0]->save();
$journal->transactions[1]->save();
$journal->save();
return Redirect::route('transactions.edit', $journal->id);
}

View File

@@ -42,14 +42,16 @@ class UserController extends BaseController
{
$rememberMe = Input::get('remember_me') == '1';
$data = [
'email' => Input::get('email'),
'email' => Input::get('email'),
'password' => Input::get('password')
];
if (Auth::attempt($data, $rememberMe)) {
Session::flash('success', 'Logged in!');
return Redirect::route('index');
}
Session::flash('error', 'No good!');
return View::make('user.login');
}
@@ -63,6 +65,7 @@ class UserController extends BaseController
if (Config::get('auth.allow_register') !== true) {
return View::make('error')->with('message', 'Not possible');
}
return View::make('user.register');
}
@@ -85,11 +88,14 @@ class UserController extends BaseController
if ($user) {
if (Config::get('auth.verify_mail') === true) {
$this->email->sendVerificationMail($user);
return View::make('user.verification-pending');
}
$this->email->sendPasswordMail($user);
return View::make('user.registered');
}
return View::make('user.register');
}
@@ -102,6 +108,7 @@ class UserController extends BaseController
{
Auth::logout();
Session::flush();
return Redirect::route('index');
}
@@ -126,13 +133,16 @@ class UserController extends BaseController
$user = $this->user->findByEmail(Input::get('email'));
if (!$user) {
Session::flash('error', 'No good!');
return View::make('user.remindme');
}
if (Config::get('auth.verify_reset') === true) {
$this->email->sendResetVerification($user);
return View::make('user.verification-pending');
}
$this->email->sendPasswordMail($user);
return View::make('user.registered');
}
@@ -149,8 +159,10 @@ class UserController extends BaseController
$user = $this->user->findByReset($reset);
if ($user) {
$this->email->sendPasswordMail($user);
return View::make('user.registered');
}
return View::make('error')->with('message', 'Yo no hablo reset code!');
}

View File

@@ -29,15 +29,14 @@ class Budget implements BudgetInterface
foreach ($budgets as $budget) {
foreach ($budget->limits as $limit) {
$dateFormats = \Config::get('firefly.date_formats_by_period.' . $limit->repeat_freq);
if (is_null($dateFormats)) {
throw new \Firefly\Exception\FireflyException('No date formats for ' . $limit->repeat_freq);
}
foreach ($limit->limitrepetitions as $rep) {
$periodOrder = $rep->startdate->format($dateFormats['group_date']);
$period = $rep->startdate->format($dateFormats['display_date']);
$return[$periodOrder] = isset($return[$periodOrder]) ? $return[$periodOrder] : ['date' => $period];
$periodOrder = $rep->periodOrder();
$period = $rep->periodShow();
$return[$periodOrder] = isset($return[$periodOrder])
? $return[$periodOrder]
: ['date' => $period,
'budget_id' => $limit->budget_id];
}
}
@@ -45,17 +44,177 @@ class Budget implements BudgetInterface
// put all the budgets under their respective date:
foreach ($budgets as $budget) {
foreach ($budget->limits as $limit) {
$dateFormats = \Config::get('firefly.date_formats_by_period.' . $limit->repeat_freq);
foreach ($limit->limitrepetitions as $rep) {
$rep->left = $rep->left();
$month = $rep->startdate->format($dateFormats['group_date']);
$month = $rep->periodOrder();
$return[$month]['limitrepetitions'][] = $rep;
}
}
}
krsort($return);
return $return;
}
}
/**
* @param \Budget $budget
* @param $repetitionId
*
* @return array
*/
public function organizeRepetition(\Budget $budget, $repetitionId)
{
$result = [];
$inRepetition = [];
$repetition = \LimitRepetition::with('limit', 'limit.budget')->leftJoin(
'limits', 'limit_repetitions.limit_id', '=', 'limits.id'
)->leftJoin('components', 'limits.component_id', '=', 'components.id')->where(
'components.user_id', \Auth::user()->id
)
->where('limit_repetitions.id', $repetitionId)->first(['limit_repetitions.*']);
// get transactions:
$set = $repetition->limit->budget->transactionjournals()->with(
'transactions', 'transactions.account', 'components', 'transactiontype'
)->leftJoin(
'transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id'
)->where('transaction_types.type', 'Withdrawal')->where(
'date', '>=', $repetition->startdate->format('Y-m-d')
)->where('date', '<=', $repetition->enddate->format('Y-m-d'))->orderBy('date', 'DESC')->orderBy(
'id', 'DESC'
)->get(['transaction_journals.*']);
$result[0] = [
'date' => $repetition->periodShow(),
'limit' => $repetition->limit,
'limitrepetition' => $repetition,
'journals' => $set,
'paginated' => false
];
return $result;
}
/**
* @param \Budget $budget
*
* @return mixed|void
*/
public function organizeRepetitions(\Budget $budget)
{
$result = [];
$inRepetition = [];
foreach ($budget->limits as $limit) {
foreach ($limit->limitrepetitions as $repetition) {
$order = $repetition->periodOrder();
$result[$order] = [
'date' => $repetition->periodShow(),
'limitrepetition' => $repetition,
'limit' => $limit,
'journals' => [],
'paginated' => false
];
$transactions = [];
$set = $budget->transactionjournals()->with(
'transactions', 'transactions.account', 'components', 'transactiontype'
)->leftJoin(
'transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id'
)->where('transaction_types.type', 'Withdrawal')->where(
'date', '>=', $repetition->startdate->format('Y-m-d')
)->where('date', '<=', $repetition->enddate->format('Y-m-d'))->orderBy('date', 'DESC')->orderBy(
'id', 'DESC'
)->get(['transaction_journals.*']);
foreach ($set as $entry) {
$transactions[] = $entry;
$inRepetition[] = $entry->id;
}
$result[$order]['journals'] = $transactions;
}
}
$query = $budget->transactionjournals()->with(
'transactions', 'transactions.account', 'components', 'transactiontype',
'transactions.account.accounttype'
)->whereNotIn(
'transaction_journals.id', $inRepetition
)->orderBy('date', 'DESC')->orderBy(
'transaction_journals.id', 'DESC'
);
// build paginator:
$perPage = 25;
$totalItems = $query->count();
$page = intval(\Input::get('page')) > 1 ? intval(\Input::get('page')) : 1;
$skip = ($page - 1) * $perPage;
$set = $query->skip($skip)->take($perPage)->get();
// stupid paginator!
$items = [];
/** @var $item \TransactionJournal */
foreach ($set as $item) {
$items[] = $item;
}
$paginator = \Paginator::make($items, $totalItems, $perPage);
$result['0000'] = ['date' => 'Not in an envelope', 'limit' => null, 'paginated' => true,
'journals' => $paginator];
krsort($result);
return $result;
}
/**
* @param \Budget $budget
*
* @return mixed|void
*/
public function outsideRepetitions(\Budget $budget)
{
$inRepetitions = [];
foreach ($budget->limits as $limit) {
foreach ($limit->limitrepetitions as $repetition) {
$set = $budget->transactionjournals()->leftJoin(
'transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id'
)->where('transaction_types.type', 'Withdrawal')->where(
'date', '>=', $repetition->startdate->format('Y-m-d')
)->where('date', '<=', $repetition->enddate->format('Y-m-d'))->orderBy('date', 'DESC')->get(
['transaction_journals.id']
);
foreach ($set as $item) {
$inRepetitions[] = $item->id;
}
}
}
$query = $budget->transactionjournals()->with(
'transactions', 'transactions.account', 'components', 'transactiontype',
'transactions.account.accounttype'
)->whereNotIn(
'transaction_journals.id', $inRepetitions
)->orderBy('date', 'DESC')->orderBy(
'transaction_journals.id', 'DESC'
);
// build paginator:
$perPage = 25;
$totalItems = $query->count();
$page = intval(\Input::get('page')) > 1 ? intval(\Input::get('page')) : 1;
$skip = ($page - 1) * $perPage;
$set = $query->skip($skip)->take($perPage)->get();
// stupid paginator!
$items = [];
/** @var $item \TransactionJournal */
foreach ($set as $item) {
$items[] = $item;
}
$paginator = \Paginator::make($items, $totalItems, $perPage);
$result = [0 => ['date' => 'Not in an envelope', 'limit' => null, 'paginated' => true,
'journals' => $paginator]];
return $result;
}
}

View File

@@ -15,4 +15,27 @@ interface BudgetInterface {
*/
public function organizeByDate(Collection $budgets);
/**
* @param \Budget $budget
*
* @return mixed
*/
public function organizeRepetitions(\Budget $budget);
/**
* @param \Budget $budget
* @param $repetitionId
*
* @return mixed
*/
public function organizeRepetition(\Budget $budget, $repetitionId);
/**
* @param \Budget $budget
*
* @return mixed
*/
public function outsideRepetitions(\Budget $budget);
}

View File

@@ -81,5 +81,74 @@ class LimitRepetition extends Ardent
return $this->belongsTo('Limit');
}
/**
* Returns a string used to sort this particular repetition
* based on the date and period it falls into. Ie. the limit
* repeats monthly and the start date is 12 dec 2012, this will
* return 2012-12.
*/
public function periodOrder()
{
if (is_null($this->repeat_freq)) {
$this->repeat_freq = $this->limit->repeat_freq;
}
switch ($this->repeat_freq) {
default:
throw new \Firefly\Exception\FireflyException('No date formats for frequency "' . $this->repeat_freq
. '"!');
break;
case 'daily':
return $this->startdate->format('Ymd').'-5';
break;
case 'weekly':
return $this->startdate->format('Ymd').'4';
break;
case 'monthly':
return $this->startdate->format('Ymd') . '-3';
break;
case 'quarterly':
return $this->startdate->format('Ymd') . '-2';
break;
case 'half-year':
return $this->startdate->format('Ymd') . '-1';
break;
case 'yearly':
return $this->startdate->format('Ymd').'-0';
break;
}
}
/**
* Same as above, just with a more natural view. So "March 2012".
*/
public function periodShow()
{
if (is_null($this->repeat_freq)) {
$this->repeat_freq = $this->limit->repeat_freq;
}
switch ($this->repeat_freq) {
default:
throw new \Firefly\Exception\FireflyException('No date formats for frequency "' . $this->repeat_freq
. '"!');
break;
case 'daily':
return $this->startdate->format('j F Y');
break;
case 'weekly':
return $this->startdate->format('\W\e\e\k W, Y');
break;
case 'monthly':
return $this->startdate->format('F Y');
break;
case 'half-year':
case 'quarterly':
return $this->startdate->format('M Y') . ' - ' . $this->enddate->format('M Y');
break;
case 'yearly':
return $this->startdate->format('Y');
break;
}
}
}

View File

@@ -74,7 +74,7 @@
</div>
<div class="col-sm-3">
<small>
CLOSURE TODO
{{$rep->periodShow()}}
</small>
</div>
@if($limit->repeats == 1)
@@ -94,7 +94,7 @@
@endforeach
@endforeach
<p style="margin-top:5px;">
<a href="{{route('budgets.limits.create',$budget->id)}}" class="btn btn-default btn-xs"><span
<a href="{{route('budgets.limits.create',$budget->id)}}?from=budget" class="btn btn-default btn-xs"><span
class="glyphicon-plus-sign glyphicon"></span> Add another envelope</a>
</p>
</td>

View File

@@ -53,7 +53,7 @@
</div>
</td>
<td>
<a href="{{route('budgets.show',$repetition->limit->budget->id)}}#transactions-in-this-period">
<a href="{{route('budgets.show',$repetition->limit->budget->id)}}?rep={{$repetition->id}}">
{{{$repetition->limit->budget->name}}}
</a>
</td>

View File

@@ -1,4 +1,69 @@
@extends('layouts.default')
@section('content')
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<h1>Firefly
<small>Overview for budget "{{{$budget->name}}}"</small>
</h1>
@if(count($filters) == 0)
<p class="lead">Budgets can help you cut back on spending.</p>
@else
<p class="lead">
@if(isset($filters[0]) && is_object($filters[0]) && get_class($filters[0]) == 'Limit')
{{{$repetitions[0]['limitrepetition']->periodShow()}}}, {{mf($repetitions[0]['limit']->amount,false)}}
@elseif(isset($filters[0]) && $filters[0] == 'no_envelope')
These transactions are not caught in an envelope.
@endif
</p>
<p class="text-info">
<a href="{{route('budgets.show',$budget->id)}}">See the whole picture</a>
</p>
@endif
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<p class="small text-center">(Some sort of chart here)</p>
</div>
</div>
@foreach($repetitions as $repetition)
@if(isset($repetition['journals']) && count($repetition['journals']) > 0)
<div class="row">
<div class="col-lg-12">
@if($repetition['paginated'] == true)
<h4>
<a href="{{route('budgets.show',$budget->id)}}?noenvelope=true">
{{$repetition['date']}}</a> <small>paginated</small></h4>
@else
<h4>
<a href="{{route('budgets.show',$budget->id)}}?rep={{$repetition['limitrepetition']->id}}">
{{$repetition['date']}}
</a>
</h4>
<small>{{mf($repetition['limit']->amount,false)}} (left: {{mf($repetition['limitrepetition']->left(),false)}})</small>
@endif
</h4>
@if($repetition['paginated'] == true)
@include('paginated.transactions',['journals' => $repetition['journals']])
@else
@include('lists.transactions',['journals' => $repetition['journals'],'sum' => true])
@endif
</div>
</div>
@else
<div class="row">
<div class="col-lg-12">
<h4>{{$repetition['date']}}
</h4>
<p><em>No transactions</em></p>
</div>
</div>
@endif
@endforeach
@stop

View File

@@ -0,0 +1,79 @@
<table class="table table-striped table-condensed">
<tr>
<th colspan="2"></th>
<th>Date</th>
<th>Description</th>
<th>Amount (&euro;)</th>
<th>From</th>
<th>To</th>
<th></th>
</tr>
<?php $total = 0; ?>
@foreach($journals as $journal)
<tr>
<td>
@if($journal->transactiontype->type == 'Withdrawal')
<span class="glyphicon glyphicon-arrow-left" title="Withdrawal"></span>
@endif
@if($journal->transactiontype->type == 'Deposit')
<span class="glyphicon glyphicon-arrow-right" title="Deposit"></span>
@endif
@if($journal->transactiontype->type == 'Transfer')
<span class="glyphicon glyphicon-resize-full" title="Transfer"></span>
@endif
@if($journal->transactiontype->type == 'Opening balance')
<span class="glyphicon glyphicon-ban-circle" title="Opening balance"></span>
@endif
</td>
<td>
@foreach($journal->components as $component)
@if($component->class == 'Budget')
<a href="#budget-overview"><span class="glyphicon glyphicon-tasks" title="Budget: {{{$component->name}}}"></span></a>
@endif
@if($component->class == 'Category')
<a href="#category-overview"><span class="glyphicon glyphicon-tag" title="Category: {{{$component->name}}}"></span></a>
@endif
@endforeach
</td>
<td>
{{$journal->date->format('d F Y')}}
</td>
<td><a href="{{route('transactions.show',$journal->id)}}" title="{{{$journal->description}}}">{{{$journal->description}}}</a></td>
<td>
@if($journal->transactiontype->type == 'Withdrawal')
<span class="text-danger">{{mf($journal->transactions[1]->amount,false)}}</span>
<?php $total -= $journal->transactions[1]->amount;?>
@endif
@if($journal->transactiontype->type == 'Deposit')
<span class="text-success">{{mf($journal->transactions[1]->amount,false)}}</span>
@endif
@if($journal->transactiontype->type == 'Transfer')
<span class="text-info">{{mf($journal->transactions[1]->amount,false)}}</span>
@endif
</td>
<td>
<a href="{{route('accounts.show',$journal->transactions[0]->account_id)}}">{{{$journal->transactions[0]->account->name}}}</a>
</td>
<td>
<a href="{{route('accounts.show',$journal->transactions[1]->account_id)}}">{{{$journal->transactions[1]->account->name}}}</a>
</td>
<td>
<div class="btn-group btn-group-xs">
<a href="{{route('transactions.edit',$journal->id)}}" class="btn btn-default">
<span class="glyphicon glyphicon-pencil"></span>
<a href="{{route('transactions.delete',$journal->id)}}" class="btn btn-danger">
<span class="glyphicon glyphicon-trash"></span>
</a>
</div>
</td>
</tr>
@endforeach
@if(isset($sum) && $sum == true)
<tr>
<td colspan="4">Sum:</td>
<td colspan="4">{{mf($total)}}</td>
</tr>
@endif
</table>

View File

@@ -1,71 +1,3 @@
<table class="table table-striped table-condensed">
<tr>
<th colspan="2"></th>
<th>Date</th>
<th>Description</th>
<th>Amount (&euro;)</th>
<th>From</th>
<th>To</th>
<th></th>
</tr>
@foreach($journals as $journal)
<tr>
<td>
@if($journal->transactiontype->type == 'Withdrawal')
<span class="glyphicon glyphicon-arrow-left" title="Withdrawal"></span>
@endif
@if($journal->transactiontype->type == 'Deposit')
<span class="glyphicon glyphicon-arrow-right" title="Deposit"></span>
@endif
@if($journal->transactiontype->type == 'Transfer')
<span class="glyphicon glyphicon-resize-full" title="Transfer"></span>
@endif
@if($journal->transactiontype->type == 'Opening balance')
<span class="glyphicon glyphicon-ban-circle" title="Opening balance"></span>
@endif
</td>
<td>
@foreach($journal->components as $component)
@if($component->class == 'Budget')
<a href="#budget-overview"><span class="glyphicon glyphicon-tasks" title="Budget: {{{$component->name}}}"></span></a>
@endif
@if($component->class == 'Category')
<a href="#category-overview"><span class="glyphicon glyphicon-tag" title="Category: {{{$component->name}}}"></span></a>
@endif
@endforeach
</td>
<td>
{{$journal->date->format('d F Y')}}
</td>
<td><a href="{{route('transactions.show',$journal->id)}}" title="{{{$journal->description}}}">{{{$journal->description}}}</a></td>
<td>
@if($journal->transactiontype->type == 'Withdrawal')
<span class="text-danger">{{mf($journal->transactions[1]->amount,false)}}</span>
@endif
@if($journal->transactiontype->type == 'Deposit')
<span class="text-success">{{mf($journal->transactions[1]->amount,false)}}</span>
@endif
@if($journal->transactiontype->type == 'Transfer')
<span class="text-info">{{mf($journal->transactions[1]->amount,false)}}</span>
@endif
</td>
<td>
<a href="{{route('accounts.show',$journal->transactions[0]->account_id)}}">{{{$journal->transactions[0]->account->name}}}</a>
</td>
<td>
<a href="{{route('accounts.show',$journal->transactions[1]->account_id)}}">{{{$journal->transactions[1]->account->name}}}</a>
</td>
<td>
<div class="btn-group btn-group-xs">
<a href="{{route('transactions.edit',$journal->id)}}" class="btn btn-default">
<span class="glyphicon glyphicon-pencil"></span>
<a href="{{route('transactions.delete',$journal->id)}}" class="btn btn-danger">
<span class="glyphicon glyphicon-trash"></span>
</a>
</div>
</td>
</tr>
@endforeach
</table>
{{$journals->links()}}
@include('lists.transactions')
{{$journals->links()}}