@@ -11,6 +11,27 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
final class ExpenseAllocationController extends Controller
|
||||
{
|
||||
public function commonShow(Request $request, int $allocation, ExpenseAllocations $service): Response
|
||||
{
|
||||
$actor = $request->user('web');
|
||||
abort_unless($actor instanceof User, 403);
|
||||
$request->validate(['page' => 'nullable|integer|min:1|max:1000000']);
|
||||
Inertia::encryptHistory();
|
||||
$response = Inertia::render('payments/expense-allocation', $service->workspace($actor, $allocation, 'common_allocation'))->toResponse($request);
|
||||
$response->headers->set('Cache-Control', 'private, no-store, max-age=0');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function commonStore(Request $request, int $allocation, ExpenseAllocations $service): Response
|
||||
{
|
||||
$actor = $request->user('web');
|
||||
abort_unless($actor instanceof User, 403);
|
||||
$service->save($actor, $allocation, $request->all(), 'common_allocation');
|
||||
|
||||
return back()->with('success', 'Imputação da despesa por categoria preservada.');
|
||||
}
|
||||
|
||||
public function show(Request $request, ExternalPayment $payment, ExpenseAllocations $service): Response
|
||||
{
|
||||
$actor = $request->user('web');
|
||||
|
||||
@@ -49,7 +49,7 @@ final class GeneralLedgerController extends Controller
|
||||
|
||||
public function command(Request $r, string $action, GeneralLedger $ledger): JsonResponse
|
||||
{
|
||||
abort_unless(config('general-ledger.cycle_enabled') === true, 403);
|
||||
abort_unless($ledger->cycleEnabled(), 403);
|
||||
try {
|
||||
return response()->json($ledger->engine($this->actor($r))->command($action, $r->all(), (string) $r->header('Idempotency-Key')))->header('Cache-Control', 'no-store');
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Services\ExpenseAllocations;
|
||||
use App\Services\GeneralLedger;
|
||||
use App\Services\StandaloneRuntime;
|
||||
use App\Services\StandaloneSchema;
|
||||
use App\Services\SupplierPayables;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tempo\Finance\Payables\SettlementHttp;
|
||||
|
||||
final class SupplierPaymentsController extends SettlementHttp
|
||||
@@ -14,15 +18,30 @@ final class SupplierPaymentsController extends SettlementHttp
|
||||
|
||||
protected const SERVICE = SupplierPayables::class;
|
||||
|
||||
protected function guard(): void
|
||||
{
|
||||
if (! app(StandaloneRuntime::class)->enabled()) {
|
||||
parent::guard();
|
||||
|
||||
return;
|
||||
}
|
||||
abort_unless(app(StandaloneRuntime::class)->feature('supplier-settlements', DB::connection()), 403);
|
||||
StandaloneSchema::verify(DB::getSchemaBuilder(), ['supplier-payables' => true, 'supplier-settlements' => true]);
|
||||
}
|
||||
|
||||
/** @return array<string,mixed> */
|
||||
protected function ledgerSettings(Request $request): array
|
||||
{
|
||||
if (config('general-ledger.cycle_enabled') !== true) {
|
||||
return [];
|
||||
}
|
||||
$user = $request->user();
|
||||
abort_unless($user instanceof User, 403);
|
||||
$settings = [];
|
||||
if (app(StandaloneRuntime::class)->enabled() && app(ExpenseAllocations::class)->ready() && $user->hasFunctions(['admin', 'finance'])) {
|
||||
$settings['expense_allocation_base_url'] = '/afectacoes-fornecedores/';
|
||||
}
|
||||
if (app(GeneralLedger::class)->cycleEnabled() && app(GeneralLedger::class)->can($user, 'view')) {
|
||||
$settings['ledger_cycle_url'] = '/general-ledger/cycle';
|
||||
}
|
||||
|
||||
return app(GeneralLedger::class)->can($user, 'view') ? ['ledger_cycle_url' => '/general-ledger/cycle'] : [];
|
||||
return $settings;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user