77 lines
1.9 KiB
PHP
77 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Project;
|
|
use App\SubBooking;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
class ReportsController extends Controller
|
|
{
|
|
/**
|
|
* Display the port of a project.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function project(Project $project)
|
|
{
|
|
$id = $project->id;
|
|
|
|
$projectBookings =
|
|
SubBooking::select('id', 'account_type_id', 'reference', 'amount',
|
|
'booking_id')
|
|
->whereHas('project', function($query) use ($id) {
|
|
return $query->whereId($id);
|
|
})
|
|
->with('accountType:id,name,account_class_id',
|
|
'accountType.accountClass:id,io_type_id,name,scope_id',
|
|
'accountType.accountClass.scope:id,name',
|
|
'accountType.accountClass.ioType:id,name,factor',
|
|
'booking:id,date,person_or_company')
|
|
->get()
|
|
->sortBy('booking.date');
|
|
|
|
$incomes = $projectBookings
|
|
->where('accountType.accountClass.ioType.factor', '>', 0)
|
|
->sum('amount');
|
|
|
|
$expeditures = $projectBookings
|
|
->where('accountType.accountClass.ioType.factor', '<', 0)
|
|
->sum('amount');
|
|
|
|
return view('reports.project', compact('project', 'projectBookings',
|
|
'incomes', 'expeditures'));
|
|
}
|
|
|
|
/**
|
|
* Display the monthly balances during a year.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function balances($year)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Display the bookings sorted by scopes.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function scopes($type, $year)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Display a list of all open targets.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function targets()
|
|
{
|
|
//
|
|
}
|
|
}
|