@@ -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