mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 23:45:10 +00:00
First attempt at new month report.
This commit is contained in:
@@ -30,6 +30,9 @@ class ReportController extends BaseController
|
|||||||
$this->_journals = $journals;
|
$this->_journals = $journals;
|
||||||
$this->_repository = $repository;
|
$this->_repository = $repository;
|
||||||
|
|
||||||
|
View::share('title', 'Reports');
|
||||||
|
View::share('mainTitleIcon', 'fa-line-chart');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,6 +49,33 @@ class ReportController extends BaseController
|
|||||||
return View::make('reports.index', compact('years', 'months', 'title', 'mainTitleIcon'));
|
return View::make('reports.index', compact('years', 'months', 'title', 'mainTitleIcon'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $year
|
||||||
|
* @param string $month
|
||||||
|
*
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function month($year = '2014', $month = '1')
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
new Carbon($year . '-' . $month . '-01');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
View::make('error')->with('message', 'Invalid date');
|
||||||
|
}
|
||||||
|
$date = new Carbon($year . '-' . $month . '-01');
|
||||||
|
$subTitle = 'Report for ' . $date->format('F Y');
|
||||||
|
$subTitleIcon = 'fa-calendar';
|
||||||
|
$income = $this->_repository->getIncomeForMonth($date,false);
|
||||||
|
|
||||||
|
// var_dump($income->toArray());
|
||||||
|
// exit;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return View::make('reports.month', compact('date', 'subTitle', 'subTitleIcon','income'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $year
|
* @param $year
|
||||||
* @param $month
|
* @param $month
|
||||||
@@ -83,7 +113,7 @@ class ReportController extends BaseController
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
$deposits = $journals->filter(
|
$deposits = $journals->filter(
|
||||||
function (TransactionJournal $journal) {
|
function (TransactionJournal $journal) {
|
||||||
$relations = $journal->transactiongroups()->where('relation', 'balance')->count();
|
$relations = $journal->transactiongroups()->where('relation', 'balance')->count();
|
||||||
$budgets = $journal->budgets()->count();
|
$budgets = $journal->budgets()->count();
|
||||||
|
@@ -13,7 +13,7 @@ class ChangesForV322 extends Migration
|
|||||||
*/
|
*/
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -27,6 +27,8 @@ class ChangesForV322 extends Migration
|
|||||||
// rename tables:
|
// rename tables:
|
||||||
Schema::rename('piggybank_repetitions', 'piggy_bank_repetitions');
|
Schema::rename('piggybank_repetitions', 'piggy_bank_repetitions');
|
||||||
Schema::rename('piggybanks', 'piggy_banks');
|
Schema::rename('piggybanks', 'piggy_banks');
|
||||||
|
|
||||||
|
// rename fields
|
||||||
Schema::table(
|
Schema::table(
|
||||||
'piggy_bank_events', function (Blueprint $table) {
|
'piggy_bank_events', function (Blueprint $table) {
|
||||||
$table->renameColumn('piggybank_id', 'piggy_bank_id');
|
$table->renameColumn('piggybank_id', 'piggy_bank_id');
|
||||||
@@ -38,6 +40,13 @@ class ChangesForV322 extends Migration
|
|||||||
$table->renameColumn('piggybank_id', 'piggy_bank_id');
|
$table->renameColumn('piggybank_id', 'piggy_bank_id');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// add soft delete to piggy banks
|
||||||
|
Schema::table(
|
||||||
|
'piggy_banks', function (Blueprint $table) {
|
||||||
|
$table->softDeletes();
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,7 @@ namespace FireflyIII\Report;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Database\Account\Account as AccountRepository;
|
use FireflyIII\Database\Account\Account as AccountRepository;
|
||||||
use FireflyIII\Database\SwitchUser;
|
use FireflyIII\Database\SwitchUser;
|
||||||
|
use FireflyIII\Database\TransactionJournal\TransactionJournal as JournalRepository;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
// todo add methods to itnerface
|
// todo add methods to itnerface
|
||||||
@@ -23,12 +24,16 @@ class Report implements ReportInterface
|
|||||||
/** @var AccountRepository */
|
/** @var AccountRepository */
|
||||||
protected $_accounts;
|
protected $_accounts;
|
||||||
|
|
||||||
|
/** @var JournalRepository */
|
||||||
|
protected $_journals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AccountRepository $accounts
|
* @param AccountRepository $accounts
|
||||||
*/
|
*/
|
||||||
public function __construct(AccountRepository $accounts)
|
public function __construct(AccountRepository $accounts, JournalRepository $journals)
|
||||||
{
|
{
|
||||||
$this->_accounts = $accounts;
|
$this->_accounts = $accounts;
|
||||||
|
$this->_journals = $journals;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,6 +80,30 @@ class Report implements ReportInterface
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $date
|
||||||
|
* @param bool $shared
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getIncomeForMonth(Carbon $date, $shared = false)
|
||||||
|
{
|
||||||
|
$start = clone $date;
|
||||||
|
$start->startOfMonth();
|
||||||
|
$end = clone $date;
|
||||||
|
$end->endOfMonth();
|
||||||
|
$userId = $this->_accounts->getUser()->id;
|
||||||
|
|
||||||
|
$list = \TransactionJournal::withRelevantData()
|
||||||
|
->transactionTypes(['Deposit'])
|
||||||
|
->where('user_id', $userId)
|
||||||
|
->orderBy('date','DESC')
|
||||||
|
->before($end)->after($start)->get(['transaction_journals.*']);
|
||||||
|
|
||||||
|
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
*
|
*
|
||||||
|
@@ -50,4 +50,12 @@ interface ReportInterface
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function yearBalanceReport(Carbon $date);
|
public function yearBalanceReport(Carbon $date);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $date
|
||||||
|
* @param bool $shared
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getIncomeForMonth(Carbon $date, $shared = false);
|
||||||
}
|
}
|
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace FireflyIII\Shared\Toolkit;
|
namespace FireflyIII\Shared\Toolkit;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use FireflyIII\Exception\FireflyException;
|
use FireflyIII\Exception\FireflyException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,14 +12,14 @@ use FireflyIII\Exception\FireflyException;
|
|||||||
class Date
|
class Date
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param Carbon $theDate
|
* @param \Carbon\Carbon $theDate
|
||||||
* @param $repeatFreq
|
* @param $repeatFreq
|
||||||
* @param $skip
|
* @param $skip
|
||||||
*
|
*
|
||||||
* @return Carbon
|
* @return \Carbon\Carbon
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function addPeriod(Carbon $theDate, $repeatFreq, $skip)
|
public function addPeriod(\Carbon\Carbon $theDate, $repeatFreq, $skip)
|
||||||
{
|
{
|
||||||
$date = clone $theDate;
|
$date = clone $theDate;
|
||||||
$add = ($skip + 1);
|
$add = ($skip + 1);
|
||||||
@@ -59,13 +58,13 @@ class Date
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Carbon $theCurrentEnd
|
* @param \Carbon\Carbon $theCurrentEnd
|
||||||
* @param $repeatFreq
|
* @param $repeatFreq
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return \Carbon\Carbon
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function endOfPeriod(Carbon $theCurrentEnd, $repeatFreq)
|
public function endOfPeriod(\Carbon\Carbon $theCurrentEnd, $repeatFreq)
|
||||||
{
|
{
|
||||||
$currentEnd = clone $theCurrentEnd;
|
$currentEnd = clone $theCurrentEnd;
|
||||||
switch ($repeatFreq) {
|
switch ($repeatFreq) {
|
||||||
@@ -100,14 +99,14 @@ class Date
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Carbon $theCurrentEnd
|
* @param \Carbon\Carbon $theCurrentEnd
|
||||||
* @param $repeatFreq
|
* @param $repeatFreq
|
||||||
* @param Carbon $maxDate
|
* @param \Carbon\Carbon $maxDate
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return \Carbon\Carbon
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function endOfX(Carbon $theCurrentEnd, $repeatFreq, Carbon $maxDate)
|
public function endOfX(\Carbon\Carbon $theCurrentEnd, $repeatFreq, \Carbon\Carbon $maxDate)
|
||||||
{
|
{
|
||||||
$currentEnd = clone $theCurrentEnd;
|
$currentEnd = clone $theCurrentEnd;
|
||||||
switch ($repeatFreq) {
|
switch ($repeatFreq) {
|
||||||
@@ -149,13 +148,13 @@ class Date
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Carbon $date
|
* @param \Carbon\Carbon $date
|
||||||
* @param $repeatFrequency
|
* @param $repeatFrequency
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function periodShow(Carbon $date, $repeatFrequency)
|
public function periodShow(\Carbon\Carbon $date, $repeatFrequency)
|
||||||
{
|
{
|
||||||
switch ($repeatFrequency) {
|
switch ($repeatFrequency) {
|
||||||
default:
|
default:
|
||||||
@@ -183,13 +182,13 @@ class Date
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Carbon $theDate
|
* @param \Carbon\Carbon $theDate
|
||||||
* @param $repeatFreq
|
* @param $repeatFreq
|
||||||
*
|
*
|
||||||
* @return Carbon
|
* @return \Carbon\Carbon
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function startOfPeriod(Carbon $theDate, $repeatFreq)
|
public function startOfPeriod(\Carbon\Carbon $theDate, $repeatFreq)
|
||||||
{
|
{
|
||||||
$date = clone $theDate;
|
$date = clone $theDate;
|
||||||
switch ($repeatFreq) {
|
switch ($repeatFreq) {
|
||||||
@@ -228,14 +227,14 @@ class Date
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Carbon $theDate
|
* @param \Carbon\Carbon $theDate
|
||||||
* @param $repeatFreq
|
* @param $repeatFreq
|
||||||
* @param int $subtract
|
* @param int $subtract
|
||||||
*
|
*
|
||||||
* @return Carbon
|
* @return \Carbon\Carbon
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function subtractPeriod(Carbon $theDate, $repeatFreq, $subtract = 1)
|
public function subtractPeriod(\Carbon\Carbon $theDate, $repeatFreq, $subtract = 1)
|
||||||
{
|
{
|
||||||
$date = clone $theDate;
|
$date = clone $theDate;
|
||||||
switch ($repeatFreq) {
|
switch ($repeatFreq) {
|
||||||
|
@@ -247,7 +247,8 @@ Route::group(
|
|||||||
// report controller:
|
// report controller:
|
||||||
Route::get('/reports', ['uses' => 'ReportController@index', 'as' => 'reports.index']);
|
Route::get('/reports', ['uses' => 'ReportController@index', 'as' => 'reports.index']);
|
||||||
Route::get('/reports/{year}', ['uses' => 'ReportController@year', 'as' => 'reports.year']);
|
Route::get('/reports/{year}', ['uses' => 'ReportController@year', 'as' => 'reports.year']);
|
||||||
Route::get('/reports/unbalanced/{year}/{month}', ['uses' => 'ReportController@unbalanced', 'as' => 'reports.unbalanced']);
|
Route::get('/reports/{year}/{month}', ['uses' => 'ReportController@month', 'as' => 'reports.month']);
|
||||||
|
#Route::get('/reports/unbalanced/{year}/{month}', ['uses' => 'ReportController@unbalanced', 'as' => 'reports.unbalanced']);
|
||||||
|
|
||||||
// reminder controller
|
// reminder controller
|
||||||
Route::get('/reminders/{reminder}', ['uses' => 'ReminderController@show', 'as' => 'reminders.show']);
|
Route::get('/reminders/{reminder}', ['uses' => 'ReminderController@show', 'as' => 'reminders.show']);
|
||||||
|
31
app/views/list/journals-small.blade.php
Normal file
31
app/views/list/journals-small.blade.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<table class="table table-bordered">
|
||||||
|
@foreach($journals as $journal)
|
||||||
|
<tr>
|
||||||
|
<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>
|
||||||
|
{{$journal->date->format('j F Y')}}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@if($journal->transactions[1]->account->accounttype->description == 'Cash account')
|
||||||
|
<span class="text-success">(cash)</span>
|
||||||
|
@else
|
||||||
|
<a href="{{route('accounts.show',$journal->transactions[1]->account_id)}}">{{{$journal->transactions[1]->account->name}}}</a>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
@endforeach
|
||||||
|
</table>
|
@@ -16,33 +16,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-4 col-md-4 col-sm-4">
|
|
||||||
<div class="panel panel-default">
|
<div class="col-lg-4 col-md-4 col-sm-4">
|
||||||
<div class="panel-heading">
|
<div class="panel panel-default">
|
||||||
Budget reports
|
<div class="panel-heading">
|
||||||
</div>
|
Monthly reports
|
||||||
<div class="panel-body">
|
</div>
|
||||||
<ul>
|
<div class="panel-body">
|
||||||
@foreach($months as $month)
|
<ul>
|
||||||
<li><a href="#{{$month['year']}}-{{$month['month']}}">{{$month['formatted']}}</a></li>
|
@foreach($months as $month)
|
||||||
@endforeach
|
<li><a href="{{route('reports.month',[$month['year'],$month['month']])}}">{{$month['formatted']}}</a></li>
|
||||||
</ul>
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="col-lg-4 col-md-4 col-sm-4">
|
|
||||||
<div class="panel panel-default">
|
|
||||||
<div class="panel-heading">
|
|
||||||
Unbalanced transactions
|
|
||||||
</div>
|
|
||||||
<div class="panel-body">
|
|
||||||
<ul>
|
|
||||||
@foreach($months as $month)
|
|
||||||
<li><a href="{{route('reports.unbalanced',[$month['year'],$month['month']])}}">{{$month['formatted']}}</a></li>
|
|
||||||
@endforeach
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
@stop
|
@stop
|
70
app/views/reports/month.blade.php
Normal file
70
app/views/reports/month.blade.php
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
@extends('layouts.default')
|
||||||
|
@section('content')
|
||||||
|
{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName()) }}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">Income</div>
|
||||||
|
@include('list.journals-small',['journals' => $income])
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">Expenses (top 10)</div>
|
||||||
|
<div class="panel-body">Body</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">Budgets</div>
|
||||||
|
<div class="panel-body">Body</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">Categories</div>
|
||||||
|
<div class="panel-body">Body</div>
|
||||||
|
</div>
|
||||||
|
</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">Accounts</div>
|
||||||
|
<div class="panel-body">Body</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">Piggy banks</div>
|
||||||
|
<div class="panel-body">Body</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">Repeated expenses</div>
|
||||||
|
<div class="panel-body">Body</div>
|
||||||
|
</div>
|
||||||
|
</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">Recurring transactions</div>
|
||||||
|
<div class="panel-body">Body</div>
|
||||||
|
</div>
|
||||||
|
</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">Outside of budgets</div>
|
||||||
|
<div class="panel-body">Body</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@stop
|
Reference in New Issue
Block a user