mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
New code.
This commit is contained in:
parent
182fe170fd
commit
fcbe10f5ec
@ -186,7 +186,7 @@ class AccountController extends Controller
|
||||
|
||||
$repository->update($account, $accountData);
|
||||
|
||||
Session::flash('success', 'New account "' . $account->name . '" updated.');
|
||||
Session::flash('success', 'Account "' . $account->name . '" updated.');
|
||||
|
||||
return Redirect::route('accounts.index', $what);
|
||||
|
||||
|
@ -3,14 +3,16 @@
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Http\Requests;
|
||||
use FireflyIII\Http\Requests\BudgetFormRequest;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\LimitRepetition;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use Input;
|
||||
use Preferences;
|
||||
use Redirect;
|
||||
use Response;
|
||||
use Session;
|
||||
use View;
|
||||
use Response;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class BudgetController
|
||||
@ -36,16 +38,61 @@ class BudgetController extends Controller
|
||||
{
|
||||
$amount = intval(Input::get('amount'));
|
||||
$date = Session::get('start', Carbon::now()->startOfMonth());
|
||||
Log::debug('Budget: '. $budget->id);
|
||||
Log::debug('Budget (full) ' . print_r($budget->toArray(),true));
|
||||
Log::debug('Amount:' . $amount);
|
||||
Log::debug('Date: ' . $date);
|
||||
$limitRepetition = $repository->updateLimitAmount($budget, $date, $amount);
|
||||
|
||||
return Response::json(['name' => $budget->name, 'repetition' => $limitRepetition ? $limitRepetition->id : 0]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return View::make('budgets.create')->with('subTitle', 'Create a new budget');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function delete(Budget $budget)
|
||||
{
|
||||
$subTitle = 'Delete budget' . e($budget->name) . '"';
|
||||
|
||||
return View::make('budgets.delete', compact('budget', 'subTitle'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(Budget $budget, BudgetRepositoryInterface $repository)
|
||||
{
|
||||
|
||||
$name = $budget->name;
|
||||
$repository->destroy($budget);
|
||||
|
||||
Session::flash('success', 'The budget "' . e($name) . '" was deleted.');
|
||||
|
||||
return Redirect::route('budgets.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function edit(Budget $budget)
|
||||
{
|
||||
$subTitle = 'Edit budget "' . e($budget->name) . '"';
|
||||
|
||||
return View::make('budgets.edit', compact('budget', 'subTitle'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
@ -73,4 +120,103 @@ class BudgetController extends Controller
|
||||
return View::make('budgets.index', compact('budgetMaximum', 'budgets', 'spent', 'spentPCT', 'overspent', 'amount'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function noBudget()
|
||||
{
|
||||
$start = \Session::get('start', Carbon::now()->startOfMonth());
|
||||
$end = \Session::get('end', Carbon::now()->startOfMonth());
|
||||
$list = Auth::user()
|
||||
->transactionjournals()
|
||||
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->whereNull('budget_transaction_journal.id')
|
||||
->before($end)
|
||||
->after($start)
|
||||
->orderBy('transaction_journals.date')
|
||||
->get(['transaction_journals.*']);
|
||||
$subTitle = 'Transactions without a budget in ' . $start->format('F Y');
|
||||
|
||||
return View::make('budgets.noBudget', compact('list', 'subTitle'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function postUpdateIncome()
|
||||
{
|
||||
|
||||
$date = Session::get('start', Carbon::now()->startOfMonth())->format('FY');
|
||||
Preferences::set('budgetIncomeTotal' . $date, intval(Input::get('amount')));
|
||||
|
||||
return Redirect::route('budgets.index');
|
||||
}
|
||||
|
||||
public function store(BudgetFormRequest $request, BudgetRepositoryInterface $repository)
|
||||
{
|
||||
$budgetData = [
|
||||
'name' => $request->input('name'),
|
||||
'user' => Auth::user()->id,
|
||||
];
|
||||
$budget = $repository->store($budgetData);
|
||||
|
||||
Session::flash('success', 'New budget "' . $budget->name . '" stored!');
|
||||
|
||||
return Redirect::route('budgets.index');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param LimitRepetition $repetition
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function show(Budget $budget, LimitRepetition $repetition = null, BudgetRepositoryInterface $repository)
|
||||
{
|
||||
if (!is_null($repetition->id) && $repetition->budgetLimit->budget->id != $budget->id) {
|
||||
return View::make('error')->with('message', 'Invalid selection.');
|
||||
}
|
||||
|
||||
$hideBudget = true; // used in transaction list.
|
||||
$journals = $repository->getJournals($budget, $repetition);
|
||||
$limits = !is_null($repetition->id) ? [$repetition->budgetLimit] : $budget->budgetLimits()->orderBy('startdate', 'DESC')->get();
|
||||
$subTitle = !is_null($repetition->id) ? e($budget->name) . ' in ' . $repetition->startdate->format('F Y') : e($budget->name);
|
||||
|
||||
return View::make('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle', 'hideBudget'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
* @param BudgetFormRequest $request
|
||||
* @param BudgetRepositoryInterface $repository
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(Budget $budget, BudgetFormRequest $request, BudgetRepositoryInterface $repository)
|
||||
{
|
||||
$budgetData = [
|
||||
'name' => $request->input('name'),
|
||||
];
|
||||
|
||||
$repository->update($budget, $budgetData);
|
||||
|
||||
Session::flash('success', 'Budget "' . $budget->name . '" updated.');
|
||||
|
||||
return Redirect::route('budgets.index');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function updateIncome()
|
||||
{
|
||||
$date = Session::get('start', Carbon::now()->startOfMonth())->format('FY');
|
||||
$budgetAmount = Preferences::get('budgetIncomeTotal' . $date, 1000);
|
||||
|
||||
return View::make('budgets.income')->with('amount', $budgetAmount);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use App;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use Crypt;
|
||||
@ -26,6 +27,46 @@ class GoogleChartController extends Controller
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param string $view
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function accountBalanceChart(Account $account, $view = 'session', GChart $chart)
|
||||
{
|
||||
$chart->addColumn('Day of month', 'date');
|
||||
$chart->addColumn('Balance for ' . $account->name, 'number');
|
||||
$chart->addCertainty(1);
|
||||
|
||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||
$count = $account->transactions()->count();
|
||||
|
||||
if ($view == 'all' && $count > 0) {
|
||||
$first = $account->transactions()->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->orderBy(
|
||||
'date', 'ASC'
|
||||
)->first(['transaction_journals.date']);
|
||||
$last = $account->transactions()->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->orderBy(
|
||||
'date', 'DESC'
|
||||
)->first(['transaction_journals.date']);
|
||||
$start = new Carbon($first->date);
|
||||
$end = new Carbon($last->date);
|
||||
}
|
||||
|
||||
$current = clone $start;
|
||||
|
||||
while ($end >= $current) {
|
||||
$chart->addRow(clone $current, Steam::balance($account, $current), false);
|
||||
$current->addDay();
|
||||
}
|
||||
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param GChart $chart
|
||||
*
|
||||
@ -234,43 +275,99 @@ class GoogleChartController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param string $view
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param LimitRepetition $repetition
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function accountBalanceChart(Account $account, $view = 'session', GChart $chart)
|
||||
public function budgetLimitSpending(Budget $budget, LimitRepetition $repetition, GChart $chart)
|
||||
{
|
||||
$chart->addColumn('Day of month', 'date');
|
||||
$chart->addColumn('Balance for ' . $account->name, 'number');
|
||||
$chart->addCertainty(1);
|
||||
$start = clone $repetition->startdate;
|
||||
$end = $repetition->enddate;
|
||||
|
||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||
$count = $account->transactions()->count();
|
||||
$chart->addColumn('Day', 'date');
|
||||
$chart->addColumn('Left', 'number');
|
||||
|
||||
if ($view == 'all' && $count > 0) {
|
||||
$first = $account->transactions()->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->orderBy(
|
||||
'date', 'ASC'
|
||||
)->first(['transaction_journals.date']);
|
||||
$last = $account->transactions()->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->orderBy(
|
||||
'date', 'DESC'
|
||||
)->first(['transaction_journals.date']);
|
||||
$start = new Carbon($first->date);
|
||||
$end = new Carbon($last->date);
|
||||
|
||||
$amount = $repetition->amount;
|
||||
|
||||
while ($start <= $end) {
|
||||
/*
|
||||
* Sum of expenses on this day:
|
||||
*/
|
||||
$sum = floatval($budget->transactionjournals()->lessThan(0)->transactionTypes(['Withdrawal'])->onDate($start)->sum('amount'));
|
||||
$amount += $sum;
|
||||
$chart->addRow(clone $start, $amount);
|
||||
$start->addDay();
|
||||
}
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @param int $year
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function budgetsAndSpending(Budget $budget, $year = 0)
|
||||
{
|
||||
|
||||
$chart = App::make('Grumpydictator\Gchart\GChart');
|
||||
$repository = App::make('FireflyIII\Repositories\Budget\BudgetRepository');
|
||||
$chart->addColumn('Month', 'date');
|
||||
$chart->addColumn('Budgeted', 'number');
|
||||
$chart->addColumn('Spent', 'number');
|
||||
if ($year == 0) {
|
||||
// grab the first budgetlimit ever:
|
||||
$firstLimit = $budget->budgetlimits()->orderBy('startdate', 'ASC')->first();
|
||||
if ($firstLimit) {
|
||||
$start = new Carbon($firstLimit->startdate);
|
||||
} else {
|
||||
$start = Carbon::now()->startOfYear();
|
||||
}
|
||||
|
||||
// grab the last budget limit ever:
|
||||
$lastLimit = $budget->budgetlimits()->orderBy('startdate', 'DESC')->first();
|
||||
if ($lastLimit) {
|
||||
$end = new Carbon($lastLimit->startdate);
|
||||
} else {
|
||||
$end = Carbon::now()->endOfYear();
|
||||
}
|
||||
} else {
|
||||
$start = Carbon::createFromDate(intval($year), 1, 1);
|
||||
$end = clone $start;
|
||||
$end->endOfYear();
|
||||
}
|
||||
|
||||
$current = clone $start;
|
||||
while ($start <= $end) {
|
||||
$spent = $repository->spentInMonth($budget, $start);
|
||||
$repetition = LimitRepetition::leftJoin('budget_limits', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
|
||||
->where('limit_repetitions.startdate', $start->format('Y-m-d 00:00:00'))
|
||||
->where('budget_limits.budget_id', $budget->id)
|
||||
->first(['limit_repetitions.*']);
|
||||
|
||||
while ($end >= $current) {
|
||||
$chart->addRow(clone $current, Steam::balance($account, $current), false);
|
||||
$current->addDay();
|
||||
if ($repetition) {
|
||||
$budgeted = floatval($repetition->amount);
|
||||
\Log::debug('Found a repetition on ' . $start->format('Y-m-d') . ' for budget ' . $budget->name . '!');
|
||||
} else {
|
||||
\Log::debug('No repetition on ' . $start->format('Y-m-d') . ' for budget ' . $budget->name);
|
||||
$budgeted = null;
|
||||
}
|
||||
$chart->addRow(clone $start, $budgeted, $spent);
|
||||
$start->addMonth();
|
||||
}
|
||||
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
40
app/Http/Requests/BudgetFormRequest.php
Normal file
40
app/Http/Requests/BudgetFormRequest.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Models\Budget;
|
||||
use Input;
|
||||
|
||||
/**
|
||||
* Class BudgetFormRequest
|
||||
*
|
||||
* @package FireflyIII\Http\Requests
|
||||
*/
|
||||
class BudgetFormRequest extends Request
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
// Only allow logged in users
|
||||
return Auth::check();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
|
||||
$nameRule = 'required|between:1,100|uniqueForUser:budgets,name';
|
||||
if (Budget::find(Input::get('id'))) {
|
||||
$nameRule = 'required|between:1,100';
|
||||
}
|
||||
|
||||
return [
|
||||
'name' => $nameRule,
|
||||
];
|
||||
}
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
use Carbon\Carbon;
|
||||
use DaveJamesMiller\Breadcrumbs\Generator;
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\LimitRepetition;
|
||||
/*
|
||||
* Back home.
|
||||
*/
|
||||
@ -22,7 +24,7 @@ Breadcrumbs::register(
|
||||
}
|
||||
);
|
||||
Breadcrumbs::register(
|
||||
'accounts.show', function (Generator $breadcrumbs, \Account $account) {
|
||||
'accounts.show', function (Generator $breadcrumbs, Account $account) {
|
||||
switch ($account->accountType->type) {
|
||||
default:
|
||||
throw new FireflyException('Cannot handle account type "' . e($account->accountType->type) . '"');
|
||||
@ -47,14 +49,14 @@ Breadcrumbs::register(
|
||||
}
|
||||
);
|
||||
Breadcrumbs::register(
|
||||
'accounts.delete', function (Generator $breadcrumbs, \Account $account) {
|
||||
'accounts.delete', function (Generator $breadcrumbs, Account $account) {
|
||||
$breadcrumbs->parent('accounts.show', $account);
|
||||
$breadcrumbs->push('Delete ' . e($account->name), route('accounts.delete', $account->id));
|
||||
}
|
||||
);
|
||||
|
||||
Breadcrumbs::register(
|
||||
'accounts.edit', function (Generator $breadcrumbs, \Account $account) {
|
||||
'accounts.edit', function (Generator $breadcrumbs, Account $account) {
|
||||
$breadcrumbs->parent('accounts.show', $account);
|
||||
$breadcrumbs->push('Edit ' . e($account->name), route('accounts.edit', $account->id));
|
||||
}
|
||||
@ -91,9 +93,9 @@ Breadcrumbs::register(
|
||||
'budgets.show', function (Generator $breadcrumbs, Budget $budget, LimitRepetition $repetition = null) {
|
||||
$breadcrumbs->parent('budgets.index');
|
||||
$breadcrumbs->push(e($budget->name), route('budgets.show', $budget->id));
|
||||
if (!is_null($repetition)) {
|
||||
if (!is_null($repetition) && !is_null($repetition->id)) {
|
||||
$breadcrumbs->push(
|
||||
DateKit::periodShow($repetition->startdate, $repetition->budgetlimit->repeat_freq), route('budgets.show', $budget->id, $repetition->id)
|
||||
Navigation::periodShow($repetition->startdate, $repetition->budgetlimit->repeat_freq), route('budgets.show', $budget->id, $repetition->id)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,9 @@
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\LimitRepetition;
|
||||
|
||||
|
||||
// models
|
||||
Route::bind(
|
||||
'account',
|
||||
@ -43,6 +46,19 @@ Route::bind(
|
||||
}
|
||||
);
|
||||
|
||||
Route::bind(
|
||||
'limitrepetition', function ($value, $route) {
|
||||
if (Auth::check()) {
|
||||
return LimitRepetition::where('limit_repetitions.id', $value)
|
||||
->leftjoin('budget_limits', 'budget_limits.id', '=', 'limit_repetitions.budget_limit_id')
|
||||
->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')
|
||||
->where('budgets.user_id', Auth::user()->id)
|
||||
->first(['limit_repetitions.*']);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Home Controller
|
||||
@ -120,6 +136,9 @@ Route::group(
|
||||
Route::get('/chart/home/categories', ['uses' => 'GoogleChartController@allCategoriesHomeChart']);
|
||||
Route::get('/chart/home/bills', ['uses' => 'GoogleChartController@billsOverview']);
|
||||
Route::get('/chart/account/{account}/{view?}', ['uses' => 'GoogleChartController@accountBalanceChart']);
|
||||
|
||||
Route::get('/chart/budget/{budget}/spending/{year?}', ['uses' => 'GoogleChartController@budgetsAndSpending']);
|
||||
Route::get('/chart/budget/{budget}/{limitrepetition}', ['uses' => 'GoogleChartController@budgetLimitSpending']);
|
||||
//Route::get('/chart/reports/income-expenses/{year}', ['uses' => 'GoogleChartController@yearInExp']);
|
||||
//Route::get('/chart/reports/income-expenses-sum/{year}', ['uses' => 'GoogleChartController@yearInExpSum']);
|
||||
//Route::get('/chart/bills/{bill}', ['uses' => 'GoogleChartController@billOverview']);
|
||||
|
@ -13,6 +13,8 @@ class Budget extends Model
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = ['user_id', 'name'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
|
@ -26,4 +26,20 @@ class LimitRepetition extends Model
|
||||
return ['created_at', 'updated_at', 'startdate', 'enddate'];
|
||||
}
|
||||
|
||||
public function spentInRepetition()
|
||||
{
|
||||
$sum = \DB::table('transactions')
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budget_transaction_journal.budget_id')
|
||||
->leftJoin('limit_repetitions', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
|
||||
->where('transaction_journals.date', '>=', $this->startdate->format('Y-m-d'))
|
||||
->where('transaction_journals.date', '<=', $this->enddate->format('Y-m-d'))
|
||||
->where('transactions.amount', '>', 0)
|
||||
->where('limit_repetitions.id', '=', $this->id)
|
||||
->sum('transactions.amount');
|
||||
|
||||
return floatval($sum);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -87,6 +87,19 @@ class TransactionJournal extends Model
|
||||
return $this->hasMany('FireflyIII\Models\PiggyBankEvent');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EloquentBuilder $query
|
||||
* @param Account $account
|
||||
*/
|
||||
public function scopeAccountIs(EloquentBuilder $query, Account $account)
|
||||
{
|
||||
if (!isset($this->joinedTransactions)) {
|
||||
$query->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id');
|
||||
$this->joinedTransactions = true;
|
||||
}
|
||||
$query->where('transactions.account_id', $account->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EloquentBuilder $query
|
||||
* @param Carbon $date
|
||||
@ -125,6 +138,17 @@ class TransactionJournal extends Model
|
||||
$query->where('transactions.amount', '<=', $amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EloquentBuilder $query
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopeOnDate(EloquentBuilder $query, Carbon $date)
|
||||
{
|
||||
return $query->where('date', '=', $date->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EloquentBuilder $query
|
||||
* @param array $types
|
||||
@ -140,6 +164,21 @@ class TransactionJournal extends Model
|
||||
$query->whereIn('transaction_types.type', $types);
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically includes the 'with' parameters to get relevant related
|
||||
* objects.
|
||||
*
|
||||
* @param EloquentBuilder $query
|
||||
*/
|
||||
public function scopeWithRelevantData(EloquentBuilder $query)
|
||||
{
|
||||
$query->with(
|
||||
['transactions' => function (HasMany $q) {
|
||||
$q->orderBy('amount', 'ASC');
|
||||
}, 'transactiontype', 'transactioncurrency', 'budgets', 'categories', 'transactions.account.accounttype', 'bill', 'budgets', 'categories']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*/
|
||||
@ -173,21 +212,6 @@ class TransactionJournal extends Model
|
||||
return $this->belongsToMany('FireflyIII\Models\TransactionGroup');
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically includes the 'with' parameters to get relevant related
|
||||
* objects.
|
||||
*
|
||||
* @param EloquentBuilder $query
|
||||
*/
|
||||
public function scopeWithRelevantData(EloquentBuilder $query)
|
||||
{
|
||||
$query->with(
|
||||
['transactions' => function (HasMany $q) {
|
||||
$q->orderBy('amount', 'ASC');
|
||||
}, 'transactiontype', 'transactioncurrency','budgets', 'categories', 'transactions.account.accounttype', 'bill', 'budgets', 'categories']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
@ -204,17 +228,4 @@ class TransactionJournal extends Model
|
||||
return $this->belongsTo('FireflyIII\User');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EloquentBuilder $query
|
||||
* @param Account $account
|
||||
*/
|
||||
public function scopeAccountIs(EloquentBuilder $query, Account $account)
|
||||
{
|
||||
if (!isset($this->joinedTransactions)) {
|
||||
$query->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id');
|
||||
$this->joinedTransactions = true;
|
||||
}
|
||||
$query->where('transactions.account_id', $account->id);
|
||||
}
|
||||
|
||||
}
|
||||
|
28
app/Providers/TestingServiceProvider.php
Normal file
28
app/Providers/TestingServiceProvider.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Providers;
|
||||
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
/**
|
||||
* Class TestingServiceProvider
|
||||
*
|
||||
* @package FireflyIII\Providers
|
||||
*/
|
||||
class TestingServiceProvider extends ServiceProvider {
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
if ($this->app->environment() == 'testing')
|
||||
{
|
||||
$this->app['config']['session.driver'] = 'native';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -6,6 +6,7 @@ use Carbon\Carbon;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Models\LimitRepetition;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* Class BudgetRepository
|
||||
@ -15,6 +16,51 @@ use FireflyIII\Models\LimitRepetition;
|
||||
class BudgetRepository implements BudgetRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function destroy(Budget $budget)
|
||||
{
|
||||
$budget->delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the transaction journals for a limit, possibly limited by a limit repetition.
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param LimitRepetition $repetition
|
||||
* @param int $take
|
||||
*
|
||||
* @return \Illuminate\Pagination\Paginator
|
||||
*/
|
||||
public function getJournals(Budget $budget, LimitRepetition $repetition = null, $take = 50)
|
||||
{
|
||||
$offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $take : 0;
|
||||
|
||||
|
||||
$setQuery = $budget->transactionJournals()->withRelevantData()->take($take)->offset($offset)->orderBy('date', 'DESC');
|
||||
$countQuery = $budget->transactionJournals();
|
||||
|
||||
|
||||
if (!is_null($repetition->id)) {
|
||||
$setQuery->after($repetition->startdate)->before($repetition->enddate);
|
||||
$countQuery->after($repetition->startdate)->before($repetition->enddate);
|
||||
}
|
||||
|
||||
|
||||
$set = $setQuery->get(['transaction_journals.*']);
|
||||
$count = $countQuery->count();
|
||||
$items = [];
|
||||
foreach ($set as $entry) {
|
||||
$items[] = $entry;
|
||||
}
|
||||
return new LengthAwarePaginator($items, $count, $take, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
* @param Carbon $date
|
||||
@ -31,6 +77,39 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
return $sum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return Budget
|
||||
*/
|
||||
public function store(array $data)
|
||||
{
|
||||
$newBudget = new Budget(
|
||||
[
|
||||
'user_id' => $data['user'],
|
||||
'name' => $data['name'],
|
||||
]
|
||||
);
|
||||
$newBudget->save();
|
||||
|
||||
return $newBudget;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
* @param array $data
|
||||
*
|
||||
* @return Budget
|
||||
*/
|
||||
public function update(Budget $budget, array $data)
|
||||
{
|
||||
// update the account:
|
||||
$budget->name = $data['name'];
|
||||
$budget->save();
|
||||
|
||||
return $budget;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
* @param Carbon $date
|
||||
@ -59,6 +138,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
$limit->delete();
|
||||
}
|
||||
}
|
||||
|
||||
return $limit;
|
||||
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace FireflyIII\Repositories\Budget;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\LimitRepetition;
|
||||
use Carbon\Carbon;
|
||||
/**
|
||||
* Interface BudgetRepositoryInterface
|
||||
@ -10,6 +11,12 @@ use Carbon\Carbon;
|
||||
*/
|
||||
interface BudgetRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function destroy(Budget $budget);
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
@ -28,4 +35,30 @@ interface BudgetRepositoryInterface
|
||||
*/
|
||||
public function updateLimitAmount(Budget $budget, Carbon $date, $amount);
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return Budget
|
||||
*/
|
||||
public function store(array $data);
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
* @param array $data
|
||||
*
|
||||
* @return Budget
|
||||
*/
|
||||
public function update(Budget $budget, array $data);
|
||||
|
||||
/**
|
||||
* Returns all the transaction journals for a limit, possibly limited by a limit repetition.
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param LimitRepetition $repetition
|
||||
* @param int $take
|
||||
*
|
||||
* @return \Illuminate\Pagination\Paginator
|
||||
*/
|
||||
public function getJournals(Budget $budget, LimitRepetition $repetition = null, $take = 50);
|
||||
|
||||
}
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace FireflyIII\Support;
|
||||
|
||||
use Amount;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Input;
|
||||
|
@ -14,6 +14,33 @@ class Navigation
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
* @param $repeatFrequency
|
||||
*
|
||||
* @return string
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function periodShow(Carbon $date, $repeatFrequency)
|
||||
{
|
||||
$formatMap = [
|
||||
'daily' => 'j F Y',
|
||||
'week' => '\W\e\e\k W, Y',
|
||||
'weekly' => '\W\e\e\k W, Y',
|
||||
'quarter' => 'F Y',
|
||||
'month' => 'F Y',
|
||||
'monthly' => 'F Y',
|
||||
'year' => 'Y',
|
||||
'yearly' => 'Y',
|
||||
|
||||
];
|
||||
if (isset($formatMap[$repeatFrequency])) {
|
||||
return $date->format($formatMap[$repeatFrequency]);
|
||||
}
|
||||
throw new FireflyException('No date formats for frequency "' . $repeatFrequency . '"!');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $range
|
||||
* @param Carbon $date
|
||||
|
71
composer.lock
generated
71
composer.lock
generated
@ -131,16 +131,16 @@
|
||||
},
|
||||
{
|
||||
"name": "danielstjules/stringy",
|
||||
"version": "1.8.1",
|
||||
"version": "1.9.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/danielstjules/Stringy.git",
|
||||
"reference": "6a7b0391b2baf0bfdca3ec0c8d33ff379c2835ad"
|
||||
"reference": "3cf18e9e424a6dedc38b7eb7ef580edb0929461b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/danielstjules/Stringy/zipball/6a7b0391b2baf0bfdca3ec0c8d33ff379c2835ad",
|
||||
"reference": "6a7b0391b2baf0bfdca3ec0c8d33ff379c2835ad",
|
||||
"url": "https://api.github.com/repos/danielstjules/Stringy/zipball/3cf18e9e424a6dedc38b7eb7ef580edb0929461b",
|
||||
"reference": "3cf18e9e424a6dedc38b7eb7ef580edb0929461b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -183,7 +183,7 @@
|
||||
"utility",
|
||||
"utils"
|
||||
],
|
||||
"time": "2015-01-08 15:21:43"
|
||||
"time": "2015-02-10 06:19:18"
|
||||
},
|
||||
{
|
||||
"name": "davejamesmiller/laravel-breadcrumbs",
|
||||
@ -749,12 +749,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/JC5/gchart.git",
|
||||
"reference": "0cbefaf7ea75f4ce23791d9764787f3b617208dd"
|
||||
"reference": "24d06101cfda7ff336ecb10f7f0cb0d6004cb83c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/JC5/gchart/zipball/0cbefaf7ea75f4ce23791d9764787f3b617208dd",
|
||||
"reference": "0cbefaf7ea75f4ce23791d9764787f3b617208dd",
|
||||
"url": "https://api.github.com/repos/JC5/gchart/zipball/24d06101cfda7ff336ecb10f7f0cb0d6004cb83c",
|
||||
"reference": "24d06101cfda7ff336ecb10f7f0cb0d6004cb83c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -777,7 +777,7 @@
|
||||
}
|
||||
],
|
||||
"description": "GChart is a small package that allows you to easily generate data for the Google Charts API.",
|
||||
"time": "2015-02-08 00:18:35"
|
||||
"time": "2015-02-20 20:07:26"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/html",
|
||||
@ -1013,16 +1013,16 @@
|
||||
},
|
||||
{
|
||||
"name": "laravel/framework",
|
||||
"version": "v5.0.2",
|
||||
"version": "v5.0.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/framework.git",
|
||||
"reference": "30391aa20874c30725f653bea1ea5b895a5217cf"
|
||||
"reference": "43637b796f1ac0b1a960984231251ff04b438006"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/30391aa20874c30725f653bea1ea5b895a5217cf",
|
||||
"reference": "30391aa20874c30725f653bea1ea5b895a5217cf",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/43637b796f1ac0b1a960984231251ff04b438006",
|
||||
"reference": "43637b796f1ac0b1a960984231251ff04b438006",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1134,7 +1134,7 @@
|
||||
"framework",
|
||||
"laravel"
|
||||
],
|
||||
"time": "2015-02-06 23:14:12"
|
||||
"time": "2015-02-20 16:22:21"
|
||||
},
|
||||
{
|
||||
"name": "league/flysystem",
|
||||
@ -1566,16 +1566,16 @@
|
||||
},
|
||||
{
|
||||
"name": "psy/psysh",
|
||||
"version": "v0.3.3",
|
||||
"version": "v0.3.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/bobthecow/psysh.git",
|
||||
"reference": "0355cecab0591c83fed019a9572c510b0da29174"
|
||||
"reference": "2ce0e8f3020fd292c2ad2a496c5d83939823f642"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/0355cecab0591c83fed019a9572c510b0da29174",
|
||||
"reference": "0355cecab0591c83fed019a9572c510b0da29174",
|
||||
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/2ce0e8f3020fd292c2ad2a496c5d83939823f642",
|
||||
"reference": "2ce0e8f3020fd292c2ad2a496c5d83939823f642",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1625,14 +1625,14 @@
|
||||
}
|
||||
],
|
||||
"description": "An interactive shell for modern PHP.",
|
||||
"homepage": "https://github.com/bobthecow/psysh",
|
||||
"homepage": "http://psysh.org",
|
||||
"keywords": [
|
||||
"REPL",
|
||||
"console",
|
||||
"interactive",
|
||||
"shell"
|
||||
],
|
||||
"time": "2015-01-20 21:18:03"
|
||||
"time": "2015-02-12 19:35:52"
|
||||
},
|
||||
{
|
||||
"name": "swiftmailer/swiftmailer",
|
||||
@ -2537,20 +2537,20 @@
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "barryvdh/laravel-debugbar",
|
||||
"version": "v2.0.0",
|
||||
"version": "v2.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/barryvdh/laravel-debugbar.git",
|
||||
"reference": "343dbc07007272511727c9272e568d707682fc24"
|
||||
"reference": "77b9cc071f4bbd839923269668b14d308778d8b0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/343dbc07007272511727c9272e568d707682fc24",
|
||||
"reference": "343dbc07007272511727c9272e568d707682fc24",
|
||||
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/77b9cc071f4bbd839923269668b14d308778d8b0",
|
||||
"reference": "77b9cc071f4bbd839923269668b14d308778d8b0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/support": "5.0.*",
|
||||
"illuminate/support": "5.0.x",
|
||||
"maximebf/debugbar": "~1.10.2",
|
||||
"php": ">=5.4.0",
|
||||
"symfony/finder": "~2.6"
|
||||
@ -2587,7 +2587,7 @@
|
||||
"profiler",
|
||||
"webprofiler"
|
||||
],
|
||||
"time": "2015-02-03 19:52:06"
|
||||
"time": "2015-02-15 14:11:42"
|
||||
},
|
||||
{
|
||||
"name": "codeception/c3",
|
||||
@ -2830,12 +2830,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/codeclimate/php-test-reporter.git",
|
||||
"reference": "2dd8395f81874333d15de3a598f722997ba42fb5"
|
||||
"reference": "2a67d5d940e175fddba15f29c81a646ace26dc38"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/codeclimate/php-test-reporter/zipball/2dd8395f81874333d15de3a598f722997ba42fb5",
|
||||
"reference": "2dd8395f81874333d15de3a598f722997ba42fb5",
|
||||
"url": "https://api.github.com/repos/codeclimate/php-test-reporter/zipball/2a67d5d940e175fddba15f29c81a646ace26dc38",
|
||||
"reference": "2a67d5d940e175fddba15f29c81a646ace26dc38",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2845,6 +2845,7 @@
|
||||
"symfony/console": ">=2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-xdebug": "*",
|
||||
"phpunit/phpunit": "3.7.*@stable"
|
||||
},
|
||||
"bin": [
|
||||
@ -2879,7 +2880,7 @@
|
||||
"codeclimate",
|
||||
"coverage"
|
||||
],
|
||||
"time": "2014-12-29 16:17:04"
|
||||
"time": "2015-02-20 22:40:35"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/instantiator",
|
||||
@ -3276,16 +3277,16 @@
|
||||
},
|
||||
{
|
||||
"name": "janhenkgerritsen/codeception-laravel5",
|
||||
"version": "1.0.10",
|
||||
"version": "1.0.11",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/janhenkgerritsen/codeception-laravel5.git",
|
||||
"reference": "6308e72a73dfb015164689646676cda6827409d5"
|
||||
"reference": "b4aef07d548b6becfd54ebf909e1f49de1ca5392"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/janhenkgerritsen/codeception-laravel5/zipball/6308e72a73dfb015164689646676cda6827409d5",
|
||||
"reference": "6308e72a73dfb015164689646676cda6827409d5",
|
||||
"url": "https://api.github.com/repos/janhenkgerritsen/codeception-laravel5/zipball/b4aef07d548b6becfd54ebf909e1f49de1ca5392",
|
||||
"reference": "b4aef07d548b6becfd54ebf909e1f49de1ca5392",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -3314,7 +3315,7 @@
|
||||
"laravel",
|
||||
"laravel5"
|
||||
],
|
||||
"time": "2015-02-07 10:02:06"
|
||||
"time": "2015-02-14 11:20:37"
|
||||
},
|
||||
{
|
||||
"name": "league/factory-muffin",
|
||||
|
@ -149,6 +149,7 @@ return [
|
||||
'FireflyIII\Providers\EventServiceProvider',
|
||||
'FireflyIII\Providers\RouteServiceProvider',
|
||||
'FireflyIII\Providers\FireflyServiceProvider',
|
||||
'FireflyIII\Providers\TestingServiceProvider',
|
||||
|
||||
],
|
||||
|
||||
|
@ -236,7 +236,9 @@ class ChangesForV321 extends Migration
|
||||
{
|
||||
Schema::table(
|
||||
'limit_repetitions', function (Blueprint $table) {
|
||||
$table->dropForeign('limit_repetitions_budget_limit_id_foreign');
|
||||
$table->renameColumn('budget_limit_id', 'limit_id');
|
||||
$table->foreign('limit_id')->references('id')->on('limits')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -404,7 +406,9 @@ class ChangesForV321 extends Migration
|
||||
{
|
||||
Schema::table(
|
||||
'limit_repetitions', function (Blueprint $table) {
|
||||
$table->dropForeign('limit_repetitions_limit_id_foreign');
|
||||
$table->renameColumn('limit_id', 'budget_limit_id');
|
||||
$table->foreign('budget_limit_id')->references('id')->on('budget_limits')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -108,13 +108,17 @@ class ChangesForV322 extends Migration
|
||||
// rename fields
|
||||
Schema::table(
|
||||
'piggy_bank_events', function (Blueprint $table) {
|
||||
$table->dropForeign('piggybank_events_piggybank_id_foreign');
|
||||
$table->renameColumn('piggybank_id', 'piggy_bank_id');
|
||||
$table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
|
||||
Schema::table(
|
||||
'piggy_bank_repetitions', function (Blueprint $table) {
|
||||
$table->dropForeign('piggybank_repetitions_piggybank_id_foreign');
|
||||
$table->renameColumn('piggybank_id', 'piggy_bank_id');
|
||||
$table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -215,9 +215,9 @@ class TestDataSeeder extends Seeder
|
||||
);
|
||||
|
||||
// and because we have no filters, some repetitions:
|
||||
LimitRepetition::create(['budget_limit_id' => $groceriesLimit->id, 'startdate' => $this->som, 'enddate' => $this->eom, 'amount' => 201]);
|
||||
LimitRepetition::create(['budget_limit_id' => $billsLimit->id, 'startdate' => $this->som, 'enddate' => $this->eom, 'amount' => 202]);
|
||||
LimitRepetition::create(['budget_limit_id' => $deleteMeLimit->id, 'startdate' => $this->som, 'enddate' => $this->eom, 'amount' => 203]);
|
||||
// LimitRepetition::create(['budget_limit_id' => $groceriesLimit->id, 'startdate' => $this->som, 'enddate' => $this->eom, 'amount' => 201]);
|
||||
// LimitRepetition::create(['budget_limit_id' => $billsLimit->id, 'startdate' => $this->som, 'enddate' => $this->eom, 'amount' => 202]);
|
||||
// LimitRepetition::create(['budget_limit_id' => $deleteMeLimit->id, 'startdate' => $this->som, 'enddate' => $this->eom, 'amount' => 203]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,7 @@
|
||||
@extends('layouts.default')
|
||||
@section('content')
|
||||
{!! Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName()) !!}
|
||||
{{Form::open(['class' => 'form-horizontal','id' => 'store','url' => route('budgets.store')])}}
|
||||
{!! Form::open(['class' => 'form-horizontal','id' => 'store','url' => route('budgets.store')]) !!}
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||
<div class="panel panel-primary">
|
||||
@ -9,7 +9,7 @@
|
||||
<i class="fa fa-exclamation"></i> Mandatory fields
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{{Form::ffText('name')}}
|
||||
{!! ExpandedForm::text('name') !!}
|
||||
</div>
|
||||
</div>
|
||||
<p>
|
||||
@ -26,7 +26,7 @@
|
||||
<i class="fa fa-bolt"></i> Options
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{{Form::ffOptionsList('create','budget')}}
|
||||
{!! ExpandedForm::optionsList('create','budget') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
|
||||
|
||||
|
||||
{{Form::close()}}
|
||||
{!! Form::close() !!}
|
||||
|
||||
|
||||
@stop
|
||||
|
@ -1,7 +1,7 @@
|
||||
@extends('layouts.default')
|
||||
@section('content')
|
||||
{!! Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $budget) !!}
|
||||
{{Form::open(['class' => 'form-horizontal','id' => 'destroy','url' => route('budgets.destroy',$budget->id)])}}
|
||||
{!! Form::open(['class' => 'form-horizontal','id' => 'destroy','url' => route('budgets.destroy',$budget->id)]) !!}
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-12 col-sm-12">
|
||||
<div class="panel panel-red">
|
||||
@ -33,5 +33,5 @@
|
||||
</div>
|
||||
|
||||
|
||||
{{Form::close()}}
|
||||
{!! Form::close() !!}
|
||||
@stop
|
||||
|
@ -1,42 +1,43 @@
|
||||
@extends('layouts.default')
|
||||
@section('content')
|
||||
{!! Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $budget) !!}
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<p class="lead">Use budgets to organize and limit your expenses.</p>
|
||||
{!! Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $budget) !!}
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<p class="lead">Use budgets to organize and limit your expenses.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{Form::model($budget, ['class' => 'form-horizontal','id' => 'update','url' => route('budgets.update',$budget->id)])}}
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-12 col-sm-6">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-fw fa-exclamation"></i> Mandatory fields
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{{Form::ffText('name')}}
|
||||
{!! Form::model($budget, ['class' => 'form-horizontal','id' => 'update','url' => route('budgets.update',$budget->id)]) !!}
|
||||
<input type="hidden" name="id" value="{{$budget->id}}" />
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-12 col-sm-6">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-fw fa-exclamation"></i> Mandatory fields
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{!! ExpandedForm::text('name') !!}
|
||||
</div>
|
||||
</div>
|
||||
<p>
|
||||
<button type="submit" class="btn btn-lg btn-success">
|
||||
<i class="fa fa-pencil"></i> Update budget
|
||||
</button>
|
||||
</p>
|
||||
</div>
|
||||
<p>
|
||||
<button type="submit" class="btn btn-lg btn-success">
|
||||
<i class="fa fa-pencil"></i> Update budget
|
||||
</button>
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-12 col-sm-6">
|
||||
<!-- panel for options -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-bolt"></i> Options
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{{Form::ffOptionsList('update','budget')}}
|
||||
<div class="col-lg-6 col-md-12 col-sm-6">
|
||||
<!-- panel for options -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-bolt"></i> Options
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{!! ExpandedForm::optionsList('update','budget') !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{Form::close()}}
|
||||
{!! Form::close() !!}
|
||||
|
||||
|
||||
@stop
|
||||
|
@ -1,5 +1,6 @@
|
||||
<form style="display: inline;" id="income" action="{{route('budgets.postIncome')}}" method="POST">
|
||||
{{Form::token()}}
|
||||
|
||||
{!! Form::token() !!}
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
|
@ -29,10 +29,10 @@
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
Amount: {{Amount::format($rep->amount)}}
|
||||
Amount: {!! Amount::format($rep->amount) !!}
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
Spent: {{Amount::format($rep->spentInRepetition())}}
|
||||
Spent: {!! Amount::format($rep->spentInRepetition()) !!}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@ -73,7 +73,7 @@
|
||||
<script type="text/javascript">
|
||||
var budgetID = {{$budget->id}};
|
||||
var currencyCode = '{{Amount::getCurrencyCode()}}';
|
||||
@if(!is_null($repetition))
|
||||
@if(!is_null($repetition->id))
|
||||
var repetitionID = {{$repetition->id}};
|
||||
var year = {{$repetition->startdate->format('Y')}};
|
||||
@else
|
||||
@ -84,8 +84,8 @@
|
||||
|
||||
<!-- load the libraries and scripts necessary for Google Charts: -->
|
||||
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
|
||||
{{HTML::script('assets/javascript/firefly/gcharts.options.js')}}
|
||||
{{HTML::script('assets/javascript/firefly/gcharts.js')}}
|
||||
{{HTML::script('assets/javascript/firefly/budgets.js')}}
|
||||
<script type="text/javascript" src="js/gcharts.options.js"></script>
|
||||
<script type="text/javascript" src="js/gcharts.js"></script>
|
||||
<script type="text/javascript" src="js/budgets.js"></script>
|
||||
|
||||
@stop
|
||||
|
16
resources/views/error.blade.php
Normal file
16
resources/views/error.blade.php
Normal file
@ -0,0 +1,16 @@
|
||||
@extends('layouts.guest')
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<h1 class="text-danger">Firefly<br/>
|
||||
<small>Error</small>
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
{{$message or 'General unknown errror'}}
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use FireflyIII\Models\Budget;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("CamelCase")
|
||||
* @SuppressWarnings("short")
|
||||
@ -23,23 +25,6 @@ class BudgetControllerCest
|
||||
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FunctionalTester $I
|
||||
*/
|
||||
public function amount(FunctionalTester $I)
|
||||
{
|
||||
$I->wantTo('update the amount for a budget and limit repetition');
|
||||
$I->amOnPage('/budgets');
|
||||
|
||||
///budgets/income
|
||||
|
||||
$I->sendAjaxPostRequest('/budgets/amount/1', ['amount' => 100]);
|
||||
$I->canSeeResponseCodeIs(200);
|
||||
$I->see('Groceries');
|
||||
$I->seeInDatabase('budgets', ['id' => 1]);
|
||||
#$I->seeInDatabase('budget_limits', ['budget_id' => 1, 'amount' => 100.00]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FunctionalTester $I
|
||||
*/
|
||||
@ -55,9 +40,11 @@ class BudgetControllerCest
|
||||
*/
|
||||
public function delete(FunctionalTester $I)
|
||||
{
|
||||
$budget = Budget::where('name', 'Delete me')->first();
|
||||
$I->wantTo('delete a budget');
|
||||
$I->amOnPage('/budgets/delete/3');
|
||||
$I->see('Delete budget "Delete me"');
|
||||
$I->amOnPage('/budgets/delete/' . $budget->id);
|
||||
$I->see('Delete budget');
|
||||
$I->see($budget->name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,11 +52,14 @@ class BudgetControllerCest
|
||||
*/
|
||||
public function destroy(FunctionalTester $I)
|
||||
{
|
||||
$budget = Budget::where('name', 'Delete me')->first();
|
||||
$I->wantTo('destroy a budget');
|
||||
$I->amOnPage('/budgets/delete/3');
|
||||
$I->see('Delete budget "Delete me"');
|
||||
$I->amOnPage('/budgets/delete/' . $budget->id);
|
||||
$I->see('Delete budget');
|
||||
$I->see($budget->name);
|
||||
$I->submitForm('#destroy', []);
|
||||
$I->see('Budget "Delete me" was deleted.');
|
||||
$I->see(' was deleted.');
|
||||
$I->see($budget->name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,9 +67,11 @@ class BudgetControllerCest
|
||||
*/
|
||||
public function edit(FunctionalTester $I)
|
||||
{
|
||||
$budget = Budget::where('name', 'Delete me')->first();
|
||||
$I->wantTo('edit a budget');
|
||||
$I->amOnPage('/budgets/edit/3');
|
||||
$I->see('Edit budget "Delete me"');
|
||||
$I->amOnPage('/budgets/edit/' . $budget->id);
|
||||
$I->see('Edit budget');
|
||||
$I->see($budget->name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -87,11 +79,13 @@ class BudgetControllerCest
|
||||
*/
|
||||
public function failUpdate(FunctionalTester $I)
|
||||
{
|
||||
$budget = Budget::where('name', 'Delete me')->first();
|
||||
$I->wantTo('update a budget and fail');
|
||||
$I->amOnPage('/budgets/edit/3');
|
||||
$I->see('Edit budget "Delete me"');
|
||||
$I->amOnPage('/budgets/edit/' . $budget->id);
|
||||
$I->see('Edit budget');
|
||||
$I->see($budget->name);
|
||||
$I->submitForm('#update', ['name' => '', 'post_submit_action' => 'update']);
|
||||
$I->seeRecord('budgets', ['name' => 'Delete me']);
|
||||
$I->seeRecord('budgets', ['name' => $budget->name]);
|
||||
|
||||
}
|
||||
|
||||
@ -187,13 +181,19 @@ class BudgetControllerCest
|
||||
/**
|
||||
* @param FunctionalTester $I
|
||||
*/
|
||||
public function storeValidateOnly(FunctionalTester $I)
|
||||
public function testAmount(FunctionalTester $I)
|
||||
{
|
||||
$I->amOnPage('/budgets/create');
|
||||
$I->wantTo('validate a new budget');
|
||||
$I->see('Create a new budget');
|
||||
$I->submitForm('#store', ['name' => 'New budget.', 'post_submit_action' => 'validate_only']);
|
||||
$I->dontSeeRecord('budgets', ['name' => 'New budget.']);
|
||||
$I->wantTo('update the amount for a budget and limit repetition');
|
||||
$I->amOnPage('/budgets');
|
||||
|
||||
///budgets/income
|
||||
|
||||
|
||||
$I->sendAjaxPostRequest('/budgets/amount/1', ['amount' => 100]);
|
||||
$I->canSeeResponseCodeIs(200);
|
||||
$I->see('Groceries');
|
||||
$I->seeInDatabase('budgets', ['id' => 1]);
|
||||
#$I->seeInDatabase('budget_limits', ['budget_id' => 1, 'amount' => 100.00]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user