Added print versions of the reports.
This commit is contained in:
@@ -186,6 +186,78 @@ class ReportsController extends Controller
|
||||
abort(404);
|
||||
}
|
||||
}
|
||||
|
||||
public function printScopes($type, $year)
|
||||
{
|
||||
if ($type == 'compact') {
|
||||
$yearFilter = function($query) use ($year) {
|
||||
$query->whereHas('booking', function($query) use ($year) {
|
||||
$query->whereYear('date', $year);
|
||||
});
|
||||
};
|
||||
|
||||
$scopes = Scope::select('id', 'name')
|
||||
->with([
|
||||
'accountClasses:id,io_type_id,scope_id,name',
|
||||
'accountClasses.ioType:id,factor',
|
||||
'accountClasses.accountTypes' => function($query) use ($year, $yearFilter) {
|
||||
return $query->select('id', 'account_class_id', 'name', 'number')
|
||||
->whereHas('subBookings', $yearFilter)
|
||||
->with(['subBookings' => $yearFilter]);
|
||||
}
|
||||
])->get();
|
||||
|
||||
foreach ($scopes as $scope) {
|
||||
foreach ($scope->accountClasses as $accountClass) {
|
||||
$accountClass->amount =
|
||||
$accountClass->accountTypes->sum(function ($accountType) {
|
||||
return $accountType->subBookings->sum('amount');
|
||||
});
|
||||
}
|
||||
|
||||
$scope->balance = $scope->accountClasses->sum(function ($accountClass) {
|
||||
return $accountClass->amount * $accountClass->ioType->factor;
|
||||
});
|
||||
}
|
||||
|
||||
$startBalance = SubBooking::balanceAt(lastDayOfYear($year - 1));
|
||||
$endBalance = $startBalance + $scopes->sum('balance');
|
||||
|
||||
return view('reports.scopes.compact_print', compact('scopes', 'year',
|
||||
'startBalance', 'endBalance'));
|
||||
} elseif ($type == 'detailed') {
|
||||
$yearFilter = function($query) use ($year) {
|
||||
$query->whereHas('booking', function($query) use ($year) {
|
||||
$query->whereYear('date', $year);
|
||||
});
|
||||
};
|
||||
|
||||
$scopes = Scope::select('id', 'name')
|
||||
->with([
|
||||
'accountClasses:id,io_type_id,scope_id,name',
|
||||
'accountClasses.ioType:id,factor',
|
||||
'accountClasses.accountTypes' => function($query) use ($year, $yearFilter) {
|
||||
return $query->select('id', 'account_class_id', 'name', 'number')
|
||||
->whereHas('subBookings', $yearFilter)
|
||||
->with(['subBookings' => $yearFilter,
|
||||
'subBookings.booking:id,person_or_company,date']);
|
||||
}
|
||||
])->get();
|
||||
|
||||
foreach ($scopes as $scope) {
|
||||
foreach ($scope->accountClasses as $accountClass) {
|
||||
$accountClass->amount =
|
||||
$accountClass->accountTypes->sum(function ($accountType) {
|
||||
return $accountType->subBookings->sum('amount');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return view('reports.scopes.detailed_print', compact('scopes', 'year'));
|
||||
} else {
|
||||
abort(404);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a list of all open targets.
|
||||
|
||||
@@ -68,7 +68,5 @@
|
||||
$('[data-toggle="tooltip"]').tooltip()
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Pollux - @yield('title')</title>
|
||||
|
||||
<link rel="stylesheet"
|
||||
href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
|
||||
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
|
||||
crossorigin="anonymous">
|
||||
|
||||
<style>
|
||||
body {
|
||||
position: relative;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@yield('content')
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,88 @@
|
||||
@extends('layout.print')
|
||||
|
||||
@section('title', 'Abrechnung ' . $year)
|
||||
|
||||
@section('content')
|
||||
<table class='table table-sm table-borderless'>
|
||||
<tr>
|
||||
<td>
|
||||
<b>Kontostand am 1. 1. {{ $year }}</b>
|
||||
</td>
|
||||
<td>
|
||||
<b>{!! formatAmount($startBalance) !!}</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td colspan='2'></td></tr>
|
||||
@foreach($scopes as $scope)
|
||||
<tr>
|
||||
<td colspan='2'><b>{{ $scope->name }}</b></td>
|
||||
</tr>
|
||||
@foreach($scope->accountClasses as $accountClass)
|
||||
<tr>
|
||||
<td colspan='2' style='text-indent: 2em;'>
|
||||
<u>{{ $accountClass->name }}</u>
|
||||
</td>
|
||||
</tr>
|
||||
@foreach($accountClass->accountTypes as $accountType)
|
||||
<tr>
|
||||
<td style='text-indent: 4em;'>
|
||||
{{$accountType->number}} - {{$accountType->name}}
|
||||
</td>
|
||||
<td>
|
||||
{!! formatAmount($accountType->subBookings->sum('amount')) !!}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
<tr><td colspan='2'></td></tr>
|
||||
@endforeach
|
||||
<tr>
|
||||
<td colspan='2' style='text-indent: 2em;'>
|
||||
<u>GESAMT</u>
|
||||
</td>
|
||||
<tr>
|
||||
@foreach($scope->accountClasses as $accountClass)
|
||||
<tr>
|
||||
<td style='text-indent: 4em;'>
|
||||
{{ $accountClass->name }}
|
||||
</td>
|
||||
<td>
|
||||
{!! formatAmount($accountClass->amount) !!}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
<tr>
|
||||
<td style='text-indent: 4em;'>
|
||||
Saldo {{ $scope->name }}
|
||||
</td>
|
||||
<td>{!! formatAmount($scope->balance) !!}</td>
|
||||
</tr>
|
||||
<tr><td colspan='2'></td></tr>
|
||||
@endforeach
|
||||
<tr>
|
||||
<td colspan='2'>
|
||||
<b>Übersicht</b>
|
||||
</td>
|
||||
<tr>
|
||||
@foreach($scopes as $scope)
|
||||
<tr>
|
||||
<td style='text-indent: 4em;'>
|
||||
Saldo {{ $scope->name }}
|
||||
</td>
|
||||
<td>{!! formatAmount($scope->balance) !!}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
<tr>
|
||||
<td style='text-indent: 4em;'>Gesamtsaldo</td>
|
||||
<td>{!! formatAmount($scopes->sum('balance')) !!}</td>
|
||||
</tr>
|
||||
<tr><td colspan='2'></td></tr>
|
||||
<tr>
|
||||
<td>
|
||||
<b>Kontostand am 31. 12. {{ $year }}</b>
|
||||
</td>
|
||||
<td>
|
||||
<b>{!! formatAmount($endBalance) !!}</b>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@endsection
|
||||
@@ -0,0 +1,43 @@
|
||||
@extends('layout.print')
|
||||
|
||||
@section('title', 'Buchungen nach Konten ' . $year)
|
||||
|
||||
@section('content')
|
||||
@foreach($scopes as $scope)
|
||||
@foreach($scope->accountClasses as $accountClass)
|
||||
<h5>{{ $scope->name }}</h5>
|
||||
<b>{{ $accountClass->name }}</b>
|
||||
<table class='table table-sm table-borderless' style='page-break-after: always'>
|
||||
<thead>
|
||||
<tr style='color: #000080'>
|
||||
<th>Datum</th>
|
||||
<th>Position</th>
|
||||
<th>Person / Firma</th>
|
||||
<th>Betrag</th>
|
||||
</td>
|
||||
</thead>
|
||||
@foreach($accountClass->accountTypes as $accountType)
|
||||
<tr>
|
||||
<th colspan='4' style='color: #000080'>
|
||||
{{ $accountType->number . ' - ' . $accountType->name }}
|
||||
</th>
|
||||
</tr>
|
||||
@foreach($accountType->subBookings as $subBooking)
|
||||
<tr>
|
||||
<td>{{ formatDate($subBooking->date()) }}</td>
|
||||
<td>{{ $subBooking->reference }}</td>
|
||||
<td>{{ $subBooking->personOrCompany() }}</td>
|
||||
<td>{!! formatAmount($subBooking->amount) !!}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
<tr>
|
||||
<th colspan='4' style='text-align: right; color:#ff0000'>
|
||||
{!! formatAmount($accountType->subBookings
|
||||
->sum('amount')) !!}
|
||||
</th>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
@endforeach
|
||||
@endforeach
|
||||
@endsection
|
||||
@@ -74,6 +74,7 @@ Route::middleware(['auth'])->group(function() {
|
||||
Route::get('/reports/projects/{project}', 'ReportsController@project');
|
||||
Route::get('/reports/balances/{year}', 'ReportsController@balances');
|
||||
Route::get('/reports/scopes/{type}/{year}', 'ReportsController@scopes');
|
||||
Route::get('/reports/scopes/{type}/{year}/print', 'ReportsController@printScopes');
|
||||
Route::get('/reports/targets/', 'ReportsController@targets');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user