mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Routes and views for transactions without a budget / category [skip ci]
This commit is contained in:
parent
da0c0742bf
commit
ae16a2b14f
@ -124,6 +124,19 @@ class BudgetController extends BaseController
|
||||
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 = $this->_repository->journalsNoBudget($start, $end);
|
||||
$subTitle = 'Transactions without a budget in ' . $start->format('F Y');
|
||||
|
||||
return View::make('budgets.noBudget', compact('list', 'subTitle'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
@ -189,7 +202,6 @@ class BudgetController extends BaseController
|
||||
return Redirect::route('budgets.create')->withInput();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
*
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Database\Category\Category as CategoryRepository;
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
|
||||
@ -34,6 +35,19 @@ class CategoryController extends BaseController
|
||||
return View::make('categories.create')->with('subTitle', 'Create a new category');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function noCategory()
|
||||
{
|
||||
$start = \Session::get('start', Carbon::now()->startOfMonth());
|
||||
$end = \Session::get('end', Carbon::now()->startOfMonth());
|
||||
$list = $this->_repository->journalsNoCategory($start, $end);
|
||||
$subTitle = 'Transactions without a category in ' . $start->format('F Y');
|
||||
|
||||
return View::make('categories.noCategory', compact('list', 'subTitle'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
*
|
||||
|
@ -155,7 +155,7 @@ class GoogleChartController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
$noBudgetSet = $bdt->transactionsWithoutBudgetInDateRange($this->_start, $this->_end);
|
||||
$noBudgetSet = $bdt->expenseNoBudget($this->_start, $this->_end);
|
||||
$sum = $noBudgetSet->sum('amount') * -1;
|
||||
$this->_chart->addRow('No budget', 0, $sum);
|
||||
$this->_chart->generate();
|
||||
|
@ -10,7 +10,7 @@ use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Database\Query\Builder as QueryBuilder;
|
||||
|
||||
/**
|
||||
* Class Budget
|
||||
@ -258,7 +258,7 @@ class Budget implements CUDInterface, CommonDatabaseCallsInterface, BudgetInterf
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function transactionsWithoutBudgetInDateRange(Carbon $start, Carbon $end)
|
||||
public function expenseNoBudget(Carbon $start, Carbon $end)
|
||||
{
|
||||
// Add expenses that have no budget:
|
||||
return $this->getUser()
|
||||
@ -269,8 +269,8 @@ class Budget implements CUDInterface, CommonDatabaseCallsInterface, BudgetInterf
|
||||
->select('transaction_journals.id')
|
||||
->from('transaction_journals')
|
||||
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
|
||||
->where('transaction_journals.date', '<=', $end->format('Y-m-d'));
|
||||
->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00'))
|
||||
->where('transaction_journals.date', '<=', $end->format('Y-m-d 00:00:00'));
|
||||
}
|
||||
)
|
||||
->before($end)
|
||||
@ -280,6 +280,26 @@ class Budget implements CUDInterface, CommonDatabaseCallsInterface, BudgetInterf
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function journalsNoBudget(Carbon $start, Carbon $end)
|
||||
{
|
||||
$set = $this->getUser()
|
||||
->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.*']);
|
||||
|
||||
return $set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Budget $budget
|
||||
* @param Carbon $date
|
||||
|
@ -26,6 +26,15 @@ interface BudgetInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function transactionsWithoutBudgetInDateRange(Carbon $start, Carbon $end);
|
||||
public function expenseNoBudget(Carbon $start, Carbon $end);
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function journalsNoBudget(Carbon $start, Carbon $end);
|
||||
|
||||
|
||||
}
|
||||
|
@ -175,6 +175,26 @@ class Category implements CUDInterface, CommonDatabaseCallsInterface
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function journalsNoCategory(Carbon $start, Carbon $end)
|
||||
{
|
||||
$set = $this->getUser()
|
||||
->transactionjournals()
|
||||
->leftJoin('category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->whereNull('category_transaction_journal.id')
|
||||
->before($end)
|
||||
->after($start)
|
||||
->orderBy('transaction_journals.date')
|
||||
->get(['transaction_journals.*']);
|
||||
|
||||
return $set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Category $category
|
||||
* @param Carbon $date
|
||||
|
@ -196,6 +196,7 @@ Route::group(
|
||||
Route::get('/budgets/edit/{budget}', ['uses' => 'BudgetController@edit', 'as' => 'budgets.edit']);
|
||||
Route::get('/budgets/delete/{budget}', ['uses' => 'BudgetController@delete', 'as' => 'budgets.delete']);
|
||||
Route::get('/budgets/show/{budget}/{limitrepetition?}', ['uses' => 'BudgetController@show', 'as' => 'budgets.show']);
|
||||
Route::get('/budgets/list/noBudget', ['uses' => 'BudgetController@noBudget','as' => 'budgets.noBudget']);
|
||||
|
||||
// category controller:
|
||||
Route::get('/categories', ['uses' => 'CategoryController@index', 'as' => 'categories.index']);
|
||||
@ -203,6 +204,7 @@ Route::group(
|
||||
Route::get('/categories/edit/{category}', ['uses' => 'CategoryController@edit', 'as' => 'categories.edit']);
|
||||
Route::get('/categories/delete/{category}', ['uses' => 'CategoryController@delete', 'as' => 'categories.delete']);
|
||||
Route::get('/categories/show/{category}', ['uses' => 'CategoryController@show', 'as' => 'categories.show']);
|
||||
Route::get('/categories/list/noCategory', ['uses' => 'CategoryController@noCategory','as' => 'categories.noBudget']);
|
||||
|
||||
// currency controller
|
||||
Route::get('/currency', ['uses' => 'CurrencyController@index', 'as' => 'currency.index']);
|
||||
|
@ -51,6 +51,18 @@
|
||||
<div class="col-lg-3 col-sm-4 col-md-4">
|
||||
<!-- time based navigation -->
|
||||
@include('partials.date_nav')
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
Transactions without a budget
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<p>
|
||||
<a href="{{route('budgets.noBudget')}}">Transactions without a budget in
|
||||
{{\Session::get('start', \Carbon\Carbon::now()->startOfMonth())->format('F Y')}}.</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
24
app/views/budgets/noBudget.blade.php
Normal file
24
app/views/budgets/noBudget.blade.php
Normal file
@ -0,0 +1,24 @@
|
||||
@extends('layouts.default')
|
||||
@section('content')
|
||||
{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName()) }}
|
||||
<div class="row">
|
||||
<div class="col-lg-4 col-md-4 col-sm-12 ">
|
||||
<!-- time based navigation -->
|
||||
@include('partials.date_nav')
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
{{{$subTitle}}}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
@include('list.journals-full',['journals' => $list])
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@stop
|
24
app/views/categories/noCategory.blade.php
Normal file
24
app/views/categories/noCategory.blade.php
Normal file
@ -0,0 +1,24 @@
|
||||
@extends('layouts.default')
|
||||
@section('content')
|
||||
{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName()) }}
|
||||
<div class="row">
|
||||
<div class="col-lg-4 col-md-4 col-sm-12 ">
|
||||
<!-- time based navigation -->
|
||||
@include('partials.date_nav')
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
{{{$subTitle}}}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
@include('list.journals-full',['journals' => $list])
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@stop
|
Loading…
Reference in New Issue
Block a user