@@ -10,9 +10,28 @@ use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Tempo\Finance\Payables\Payables;
|
||||
use Tempo\Finance\Payables\SupplierSettlements;
|
||||
|
||||
final class SupplierPayables
|
||||
{
|
||||
public function settlements(User $actor): SupplierSettlements
|
||||
{
|
||||
$runtime = app(StandaloneRuntime::class);
|
||||
if (! $runtime->enabled()) {
|
||||
return $this->engine($actor)->settlements();
|
||||
}
|
||||
abort_unless($runtime->feature('supplier-settlements', DB::connection()), 403);
|
||||
$engine = $this->engine($actor);
|
||||
$class = new \ReflectionClass($engine);
|
||||
abort_unless($class->hasMethod('hostSettlements'), 503, 'Contrato financeiro de instalação incompatível.');
|
||||
$settlements = $class->getMethod('hostSettlements')->invoke($engine, 'COMMON-SUPPLIER-SETTLEMENT-v1', $runtime->syntheticOnly());
|
||||
if (! $settlements instanceof SupplierSettlements) {
|
||||
throw new \LogicException('COMPRAS_RUNTIME_SETTLEMENT_ENGINE');
|
||||
}
|
||||
|
||||
return $settlements;
|
||||
}
|
||||
|
||||
public static function enabled(): bool
|
||||
{
|
||||
if (app(StandaloneRuntime::class)->enabled()) {
|
||||
|
||||
Reference in New Issue
Block a user