48 lines
1.5 KiB
PHP
48 lines
1.5 KiB
PHP
<?php
|
|
|
|
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
|
|
{
|
|
protected const MODE = 'compras';
|
|
|
|
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
|
|
{
|
|
$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 $settings;
|
|
}
|
|
}
|