mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
First attempt at new month report.
This commit is contained in:
parent
1659904f81
commit
290f25f1a0
@ -30,6 +30,9 @@ class ReportController extends BaseController
|
||||
$this->_journals = $journals;
|
||||
$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'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 $month
|
||||
@ -83,7 +113,7 @@ class ReportController extends BaseController
|
||||
return null;
|
||||
}
|
||||
);
|
||||
$deposits = $journals->filter(
|
||||
$deposits = $journals->filter(
|
||||
function (TransactionJournal $journal) {
|
||||
$relations = $journal->transactiongroups()->where('relation', 'balance')->count();
|
||||
$budgets = $journal->budgets()->count();
|
||||
|
@ -13,7 +13,7 @@ class ChangesForV322 extends Migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
@ -27,6 +27,8 @@ class ChangesForV322 extends Migration
|
||||
// rename tables:
|
||||
Schema::rename('piggybank_repetitions', 'piggy_bank_repetitions');
|
||||
Schema::rename('piggybanks', 'piggy_banks');
|
||||
|
||||
// rename fields
|
||||
Schema::table(
|
||||
'piggy_bank_events', function (Blueprint $table) {
|
||||
$table->renameColumn('piggybank_id', 'piggy_bank_id');
|
||||
@ -38,6 +40,13 @@ class ChangesForV322 extends Migration
|
||||
$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 FireflyIII\Database\Account\Account as AccountRepository;
|
||||
use FireflyIII\Database\SwitchUser;
|
||||
use FireflyIII\Database\TransactionJournal\TransactionJournal as JournalRepository;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
// todo add methods to itnerface
|
||||
@ -23,12 +24,16 @@ class Report implements ReportInterface
|
||||
/** @var AccountRepository */
|
||||
protected $_accounts;
|
||||
|
||||
/** @var JournalRepository */
|
||||
protected $_journals;
|
||||
|
||||
/**
|
||||
* @param AccountRepository $accounts
|
||||
*/
|
||||
public function __construct(AccountRepository $accounts)
|
||||
public function __construct(AccountRepository $accounts, JournalRepository $journals)
|
||||
{
|
||||
$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
|
||||
*
|
||||
|
@ -50,4 +50,12 @@ interface ReportInterface
|
||||
* @return array
|
||||
*/
|
||||
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;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
|
||||
/**
|
||||
@ -13,14 +12,14 @@ use FireflyIII\Exception\FireflyException;
|
||||
class Date
|
||||
{
|
||||
/**
|
||||
* @param Carbon $theDate
|
||||
* @param $repeatFreq
|
||||
* @param $skip
|
||||
* @param \Carbon\Carbon $theDate
|
||||
* @param $repeatFreq
|
||||
* @param $skip
|
||||
*
|
||||
* @return Carbon
|
||||
* @return \Carbon\Carbon
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function addPeriod(Carbon $theDate, $repeatFreq, $skip)
|
||||
public function addPeriod(\Carbon\Carbon $theDate, $repeatFreq, $skip)
|
||||
{
|
||||
$date = clone $theDate;
|
||||
$add = ($skip + 1);
|
||||
@ -59,13 +58,13 @@ class Date
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $theCurrentEnd
|
||||
* @param $repeatFreq
|
||||
* @param \Carbon\Carbon $theCurrentEnd
|
||||
* @param $repeatFreq
|
||||
*
|
||||
* @return mixed
|
||||
* @return \Carbon\Carbon
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function endOfPeriod(Carbon $theCurrentEnd, $repeatFreq)
|
||||
public function endOfPeriod(\Carbon\Carbon $theCurrentEnd, $repeatFreq)
|
||||
{
|
||||
$currentEnd = clone $theCurrentEnd;
|
||||
switch ($repeatFreq) {
|
||||
@ -100,14 +99,14 @@ class Date
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $theCurrentEnd
|
||||
* @param $repeatFreq
|
||||
* @param Carbon $maxDate
|
||||
* @param \Carbon\Carbon $theCurrentEnd
|
||||
* @param $repeatFreq
|
||||
* @param \Carbon\Carbon $maxDate
|
||||
*
|
||||
* @return mixed
|
||||
* @return \Carbon\Carbon
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function endOfX(Carbon $theCurrentEnd, $repeatFreq, Carbon $maxDate)
|
||||
public function endOfX(\Carbon\Carbon $theCurrentEnd, $repeatFreq, \Carbon\Carbon $maxDate)
|
||||
{
|
||||
$currentEnd = clone $theCurrentEnd;
|
||||
switch ($repeatFreq) {
|
||||
@ -149,13 +148,13 @@ class Date
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
* @param $repeatFrequency
|
||||
* @param \Carbon\Carbon $date
|
||||
* @param $repeatFrequency
|
||||
*
|
||||
* @return string
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function periodShow(Carbon $date, $repeatFrequency)
|
||||
public function periodShow(\Carbon\Carbon $date, $repeatFrequency)
|
||||
{
|
||||
switch ($repeatFrequency) {
|
||||
default:
|
||||
@ -183,13 +182,13 @@ class Date
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $theDate
|
||||
* @param $repeatFreq
|
||||
* @param \Carbon\Carbon $theDate
|
||||
* @param $repeatFreq
|
||||
*
|
||||
* @return Carbon
|
||||
* @return \Carbon\Carbon
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function startOfPeriod(Carbon $theDate, $repeatFreq)
|
||||
public function startOfPeriod(\Carbon\Carbon $theDate, $repeatFreq)
|
||||
{
|
||||
$date = clone $theDate;
|
||||
switch ($repeatFreq) {
|
||||
@ -228,14 +227,14 @@ class Date
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $theDate
|
||||
* @param $repeatFreq
|
||||
* @param int $subtract
|
||||
* @param \Carbon\Carbon $theDate
|
||||
* @param $repeatFreq
|
||||
* @param int $subtract
|
||||
*
|
||||
* @return Carbon
|
||||
* @return \Carbon\Carbon
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function subtractPeriod(Carbon $theDate, $repeatFreq, $subtract = 1)
|
||||
public function subtractPeriod(\Carbon\Carbon $theDate, $repeatFreq, $subtract = 1)
|
||||
{
|
||||
$date = clone $theDate;
|
||||
switch ($repeatFreq) {
|
||||
|
@ -247,7 +247,8 @@ Route::group(
|
||||
// report controller:
|
||||
Route::get('/reports', ['uses' => 'ReportController@index', 'as' => 'reports.index']);
|
||||
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
|
||||
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 class="col-lg-4 col-md-4 col-sm-4">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
Budget reports
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<ul>
|
||||
@foreach($months as $month)
|
||||
<li><a href="#{{$month['year']}}-{{$month['month']}}">{{$month['formatted']}}</a></li>
|
||||
@endforeach
|
||||
</ul>
|
||||
|
||||
<div class="col-lg-4 col-md-4 col-sm-4">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
Monthly reports
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<ul>
|
||||
@foreach($months as $month)
|
||||
<li><a href="{{route('reports.month',[$month['year'],$month['month']])}}">{{$month['formatted']}}</a></li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</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>
|
||||
@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
|
Loading…
Reference in New Issue
Block a user