60 lines
2.0 KiB
PHP
60 lines
2.0 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;
|
|
use Tempo\Finance\Payables\SupplierSettlements;
|
|
|
|
final class SupplierPaymentsController extends SettlementHttp
|
|
{
|
|
protected const MODE = 'compras';
|
|
|
|
protected const SERVICE = SupplierPayables::class;
|
|
|
|
protected function settlementEngine(Request $request): SupplierSettlements
|
|
{
|
|
$user = $request->user();
|
|
abort_unless($user instanceof User, 403);
|
|
|
|
return app(SupplierPayables::class)->settlements($user);
|
|
}
|
|
|
|
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 = app(StandaloneRuntime::class)->enabled() ? [
|
|
'host_settlement_policy' => true, 'synthetic_only' => app(StandaloneRuntime::class)->syntheticOnly(),
|
|
'return_url' => '/dashboard',
|
|
] : [];
|
|
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;
|
|
}
|
|
}
|