commit compras2 3011
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-11-30 23:04:25 +02:00
parent 318b62f458
commit c9bd6db90b
39 changed files with 2235 additions and 42 deletions
+40 -2
View File
@@ -6,14 +6,30 @@ use Illuminate\Support\Facades\DB;
use LogicException;
use Tempo\Finance\Budget\BudgetContext;
use Tempo\Finance\OrderCancellation\CommitmentReversal;
use Tempo\Purchasing\Composition\ExecutionContext;
/** Version selection for the existing additive reversal writer, never another budget ledger. */
final class OrderCancellationRuntime
{
public const MANIFEST_SHA256 = '52df7927aa2689598ce1be92de1483694347a696245704abb9e3925db7abfc0f';
public function assertAction(string $action): void
{
if (! in_array($action, ['prepare', 'approve', 'revise'], true)) {
throw new LogicException('COMPRAS_CANCELLATION_ACTION');
}
if (app()->bound(ExecutionContext::class)) {
abort_unless(app(ExecutionContext::class)->permits('purchasing_order_cancellations.'.$action, DB::connection()), 403);
}
}
public function assertReady(): void
{
if (app()->bound(ExecutionContext::class)) {
$this->compositionRoot();
return;
}
$runtime = app(StandaloneRuntime::class);
if (! $runtime->enabled()) {
return;
@@ -56,8 +72,11 @@ final class OrderCancellationRuntime
/** Returns whether the writer requires the explicit cycle map in its financial context. */
public function load(int $origin): bool
{
$operational = app(StandaloneRuntime::class)->enabled();
if ($operational) {
$composed = app()->bound(ExecutionContext::class);
$operational = $composed || app(StandaloneRuntime::class)->enabled();
if ($composed) {
$path = $this->compositionRoot().'/src/CommitmentReversal.php';
} elseif ($operational) {
$this->assertReady();
$path = config('order_cancellation.root').'/src/CommitmentReversal.php';
} else {
@@ -75,4 +94,23 @@ final class OrderCancellationRuntime
return $operational;
}
private function compositionRoot(): string
{
$db = DB::connection();
$component = app(ExecutionContext::class)->component('order-cancellation-cycles', $db);
if (! hash_equals(self::MANIFEST_SHA256, $component['manifest_sha256']) || ! property_exists(BudgetContext::class, 'requisitionCycles')) {
throw new LogicException('COMPRAS_CANCELLATION_COMPOSITION');
}
foreach (['order_cancellations' => ['operation_key', 'basis_hash', 'status'],
'order_cancellation_policies' => ['revision', 'status'], 'order_cancellation_policy_reviews' => ['reviewed_by'],
'budget_entries' => ['requisition_cycle'], 'budget_requisition_cycles' => ['cycle', 'state']] as $table => $columns) {
if (! $db->getSchemaBuilder()->hasColumns($table, $columns)) {
throw new LogicException('COMPRAS_CANCELLATION_SCHEMA');
}
}
self::verifyArtifact($component['root']);
return $component['root'];
}
}