@@ -12,7 +12,7 @@ final class StandaloneRuntime
|
||||
'urgent-reviews', 'urgent-quotations', 'conflict-releases', 'private-audit', 'expense-allocations',
|
||||
'agreement-order-limits', 'order-parts', 'import-tariffs', 'import-legal', 'import-dossier',
|
||||
'import-bank-support', 'import-readiness', 'import-estimates', 'import-landed-costs', 'budget-distributions',
|
||||
'supplier-payables', 'general-ledger', 'supplier-settlements', 'general-ledger-cycle'];
|
||||
'supplier-payables', 'general-ledger', 'supplier-settlements', 'general-ledger-cycle', 'finance-configuration'];
|
||||
|
||||
/** @var array{root:string,manifest:array<string,mixed>,paths:array<string,string>}|null */
|
||||
private ?array $artifact = null;
|
||||
@@ -30,6 +30,16 @@ final class StandaloneRuntime
|
||||
return $this->enabled() && ($this->settings['features'][$feature] ?? false) === true;
|
||||
}
|
||||
|
||||
public function syntheticOnly(): bool
|
||||
{
|
||||
$value = $this->enabled() ? ($this->settings['synthetic_only'] ?? true) : true;
|
||||
if (! is_bool($value)) {
|
||||
throw new LogicException('COMPRAS_RUNTIME_DATA_CLASSIFICATION');
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/** @return array<string,string>|null */
|
||||
public function configure(Connection $db): ?array
|
||||
{
|
||||
@@ -46,6 +56,17 @@ final class StandaloneRuntime
|
||||
public function assertLoadedPackages(bool $allowMissing = false): void
|
||||
{
|
||||
$artifact = $this->artifact();
|
||||
foreach ([...get_declared_classes(), ...get_declared_interfaces(), ...get_declared_traits()] as $class) {
|
||||
if (! str_starts_with($class, 'Tempo\\Finance\\Budget\\') && ! str_starts_with($class, 'Tempo\\Purchasing\\')
|
||||
&& ! str_starts_with($class, 'Tempo\\Finance\\Payables\\') && ! str_starts_with($class, 'Tempo\\Finance\\GeneralLedger\\')) {
|
||||
continue;
|
||||
}
|
||||
$loaded = (new \ReflectionClass($class))->getFileName();
|
||||
$root = realpath($artifact['root']);
|
||||
if (! is_string($loaded) || $root === false || ! str_starts_with(realpath($loaded) ?: '', $root.DIRECTORY_SEPARATOR)) {
|
||||
throw new LogicException('COMPRAS_RUNTIME_CLASS_LOCATION');
|
||||
}
|
||||
}
|
||||
foreach ([
|
||||
'Tempo\\Finance\\Budget\\BudgetControl' => 'budget-control/src/BudgetControl.php',
|
||||
'Tempo\\Purchasing\\Internal\\InternalRequisitions' => 'purchasing/src/InternalRequisitions.php',
|
||||
@@ -64,12 +85,30 @@ final class StandaloneRuntime
|
||||
}
|
||||
}
|
||||
if (! $allowMissing) {
|
||||
if ($this->requested('finance-configuration')) {
|
||||
$configuration = 'Tempo\\Finance\\GeneralLedger\\LedgerConfiguration';
|
||||
if (! class_exists($configuration, false) || (new \ReflectionClass($configuration))->getConstant('VERSION') !== 'COMMON-FINANCE-CONFIGURATION-v1') {
|
||||
throw new LogicException('COMPRAS_RUNTIME_FINANCE_CONFIGURATION');
|
||||
}
|
||||
}
|
||||
if ($this->requested('supplier-settlements')) {
|
||||
$settlements = new \ReflectionClass('Tempo\\Finance\\Payables\\SupplierSettlements');
|
||||
$payables = new \ReflectionClass('Tempo\\Finance\\Payables\\Payables');
|
||||
if (! $settlements->hasConstant('HOST_POLICY') || $settlements->getConstant('HOST_POLICY') !== 'COMMON-SUPPLIER-SETTLEMENT-v1'
|
||||
|| ! $payables->hasMethod('hostSettlements')) {
|
||||
throw new LogicException('COMPRAS_RUNTIME_SETTLEMENT_POLICY');
|
||||
}
|
||||
}
|
||||
if ($this->requested('general-ledger')) {
|
||||
$journal = new \ReflectionClass('Tempo\\Finance\\GeneralLedger\\PayableJournal');
|
||||
if (! $journal->hasConstant('HOST_POLICY') || $journal->getConstant('HOST_POLICY') !== 'COMMON-PAYABLE-JOURNAL-v1'
|
||||
|| ! in_array('hostPolicy', array_map(fn ($parameter) => $parameter->getName(), $journal->getConstructor()?->getParameters() ?? []), true)) {
|
||||
throw new LogicException('COMPRAS_RUNTIME_JOURNAL_POLICY');
|
||||
}
|
||||
if ($this->requested('general-ledger-cycle') && (! $journal->hasConstant('CONFIGURED_CORRECTIONS_VERSION')
|
||||
|| $journal->getConstant('CONFIGURED_CORRECTIONS_VERSION') !== 'COMMON-LEDGER-CONFIGURED-CORRECTION-v1')) {
|
||||
throw new LogicException('COMPRAS_RUNTIME_CORRECTION_POLICY');
|
||||
}
|
||||
}
|
||||
$budget = new \ReflectionClass('Tempo\\Finance\\Budget\\BudgetControl');
|
||||
foreach ([
|
||||
@@ -114,6 +153,7 @@ final class StandaloneRuntime
|
||||
throw new LogicException('COMPRAS_RUNTIME_CONFIGURATION');
|
||||
}
|
||||
$artifact = $this->verifier->verify($root, $pin);
|
||||
$this->syntheticOnly();
|
||||
$features = $this->settings['features'] ?? [];
|
||||
if (! is_array($features)) {
|
||||
throw new LogicException('COMPRAS_RUNTIME_FEATURES');
|
||||
|
||||
Reference in New Issue
Block a user