15 lines
1.1 KiB
PHP
15 lines
1.1 KiB
PHP
<?php
|
|
namespace App\Modules\Accounting;
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
final class LedgerCompositionController extends Controller
|
|
{
|
|
public function index(Request $r,LedgerComposition $workspace)
|
|
{
|
|
if(config('sgf_single_installation.ledger_enabled')===true)return app(ComposedLedgerController::class)->page($r,app(ComposedLedger::class));
|
|
$rules=['period_key'=>'sometimes|required|string|max:80'];foreach(['industrial_page','invoices_page','costs_page','suppliers_page','journals_page','checks_page'] as $k)$rules[$k]='sometimes|integer|min:1|max:100000';$d=$r->validate($rules);abort_if(array_diff(array_keys($r->query()),array_keys($d))!==[],422);
|
|
try{$data=$workspace->workspace($r->user(),$d);}catch(\DomainException $e){abort(403,$e->getMessage());}catch(\InvalidArgumentException $e){abort(422,$e->getMessage());}
|
|
return $r->is('api/*')?response()->json($data)->header('Cache-Control','no-store'):response()->view('accounting.ledger-composition',['data'=>$data])->header('Cache-Control','no-store');
|
|
}
|
|
}
|