@@ -5,7 +5,9 @@ use App\Models\Department;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
use App\Services\AgreementOrderLimits;
|
||||
use App\Services\BudgetDistributionSchema;
|
||||
use App\Services\CapitalRegister;
|
||||
use App\Services\CommonFinanceAdministration;
|
||||
use App\Services\ConflictReleases;
|
||||
use App\Services\ExpenseAllocations;
|
||||
use App\Services\GeneralLedger;
|
||||
@@ -22,6 +24,8 @@ use App\Services\PrivateAuditAccess;
|
||||
use App\Services\RequisitionBudgetDistributions;
|
||||
use App\Services\RequisitionExpiry;
|
||||
use App\Services\RequisitionLedgerAccounts;
|
||||
use App\Services\StandaloneArtifact;
|
||||
use App\Services\StandaloneComponentSchema;
|
||||
use App\Services\StandaloneInstallation;
|
||||
use App\Services\StandaloneRuntime;
|
||||
use App\Services\SupplierPayables;
|
||||
@@ -33,7 +37,9 @@ use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
use Tempo\Finance\GeneralLedger\LedgerConfiguration;
|
||||
use Tempo\Finance\GeneralLedger\LedgerSchema;
|
||||
use Tempo\Finance\Payables\SettlementSchema;
|
||||
|
||||
require dirname(__DIR__, 2).'/vendor/autoload.php';
|
||||
$database = $argv[1] ?? '';
|
||||
@@ -44,8 +50,9 @@ if (! preg_match('/^compras_standalone_qa_([a-f0-9]{12})(_restored)?$/D', $datab
|
||||
|| $root === false || $parent === false || dirname($root) !== $parent || basename($root) !== 'rq01-ledger-qa-'.$match[1]
|
||||
|| getenv('DB_DATABASE') !== $database || getenv('DB_USERNAME') !== 'compras_standalone_app_'.$match[1].($match[2] ?? '')
|
||||
|| getenv('DB_HOST') !== '127.0.0.1' || getenv('DB_PORT') !== '55439'
|
||||
|| getenv('APP_ENV') !== 'standalone-qa' || ! in_array($mode, ['prepare', 'verify', 'reject-restore', 'rebind',
|
||||
'reject-foreign', 'reject-pin', 'reject-dependency', 'reject-old'], true)) {
|
||||
|| getenv('APP_ENV') !== 'standalone-qa' || ! in_array($mode, ['prepare', 'verify', 'prepare-ui', 'read-ui', 'reject-restore', 'rebind',
|
||||
'prepare-configuration-race', 'run-configuration-race', 'read-configuration-race', 'prepare-component-profile',
|
||||
'reject-foreign', 'reject-pin', 'reject-prepare-pin', 'reject-dependency', 'reject-old'], true)) {
|
||||
throw new LogicException('Owned standalone QA composition required.');
|
||||
}
|
||||
$app = require dirname(__DIR__, 2).'/bootstrap/app.php';
|
||||
@@ -56,7 +63,7 @@ if ($mode === 'reject-foreign') {
|
||||
$expectedRejection = match ($mode) {
|
||||
'reject-restore' => 'COMPRAS_RUNTIME_INSTALLATION_MISMATCH',
|
||||
'reject-foreign' => 'COMPRAS_RUNTIME_CLASS_LOCATION',
|
||||
'reject-pin' => 'COMPRAS_RUNTIME_MANIFEST_HASH',
|
||||
'reject-pin', 'reject-prepare-pin' => 'COMPRAS_RUNTIME_MANIFEST_HASH',
|
||||
'reject-dependency' => 'COMPRAS_RUNTIME_FEATURE_DEPENDENCY:import-bank-support:import-dossier',
|
||||
'reject-old' => 'COMPRAS_RUNTIME_CAPABILITY_UNAVAILABLE',
|
||||
default => null,
|
||||
@@ -67,6 +74,9 @@ try {
|
||||
if ($expectedRejection === null || $e->getMessage() !== $expectedRejection) {
|
||||
throw $e;
|
||||
}
|
||||
if ($mode === 'reject-prepare-pin' && class_exists(LedgerConfiguration::class, false)) {
|
||||
throw new LogicException('Unverified preparation executed a candidate package.');
|
||||
}
|
||||
echo json_encode(['rejected' => true, 'reason' => $e->getMessage()], JSON_THROW_ON_ERROR).PHP_EOL;
|
||||
exit;
|
||||
}
|
||||
@@ -78,6 +88,67 @@ $identity = $db->selectOne("SELECT current_database() AS d,current_setting('clus
|
||||
if ($identity->d !== $database || $identity->c !== 'sgf_modular_regression_'.$match[1]) {
|
||||
throw new LogicException('Owned standalone QA database identity mismatch.');
|
||||
}
|
||||
if ($mode === 'prepare-component-profile') {
|
||||
if (config('standalone-runtime.prepare_only') !== true || config('standalone-runtime.enabled') === true) {
|
||||
throw new LogicException('Profile fixture requires disabled business runtime and verified console composition.');
|
||||
}
|
||||
$settings = config('standalone-runtime');
|
||||
$settings['enabled'] = true;
|
||||
$loader = new StandaloneRuntime($settings, new StandaloneArtifact);
|
||||
$loader->artifact();
|
||||
$loader->assertLoadedPackages();
|
||||
BudgetDistributionSchema::install();
|
||||
SettlementSchema::installForHost('COMMON-PAYABLE-SETTLEMENT-HOST-SCHEMA-v1', function ($connection) use ($database) {
|
||||
if ($connection->getDatabaseName() !== $database) {
|
||||
throw new LogicException('Synthetic component fixture changed database.');
|
||||
}
|
||||
});
|
||||
$profiles = [];
|
||||
foreach (array_keys(StandaloneComponentSchema::GROUPS) as $group) {
|
||||
$profiles[$group] = StandaloneComponentSchema::inspect($db, $group);
|
||||
}
|
||||
echo json_encode(['synthetic_canonical_component_profiles' => $profiles], JSON_THROW_ON_ERROR).PHP_EOL;
|
||||
exit;
|
||||
}
|
||||
if (in_array($mode, ['prepare-configuration-race', 'run-configuration-race', 'read-configuration-race'], true)) {
|
||||
require __DIR__.'/StandaloneConfigurationRace.php';
|
||||
exit;
|
||||
}
|
||||
if (in_array($mode, ['prepare-ui', 'read-ui'], true)) {
|
||||
$runtime = app(StandaloneRuntime::class);
|
||||
$runtime->assertInstallation($db);
|
||||
$runtime->assertLoadedPackages();
|
||||
if (! $runtime->syntheticOnly()) {
|
||||
throw new LogicException('Only synthetic UI review allowed.');
|
||||
}
|
||||
$frames = [];
|
||||
foreach (['budget_entries', 'stock_movements', 'purchase_orders', 'invoices', 'gl_journals', 'gl_lines', 'ps_payments', 'ps_allocations'] as $table) {
|
||||
$frames[$table] = hash('sha256', $db->table($table)->orderBy('id')->get()->toJson());
|
||||
}
|
||||
if ($mode === 'read-ui') {
|
||||
$saved = json_decode(file_get_contents($root.'/standalone-ui.json'), true, 32, JSON_THROW_ON_ERROR);
|
||||
if ($saved['frames'] !== $frames) {
|
||||
throw new LogicException('UI setup changed protected financial or stock facts.');
|
||||
}
|
||||
echo json_encode(['ui_conservation_verified' => true, 'protected_frames' => count($frames), 'synthetic_only' => true], JSON_THROW_ON_ERROR);
|
||||
exit;
|
||||
}
|
||||
if (is_file($root.'/standalone-ui.json')) {
|
||||
throw new LogicException('UI fixture already prepared.');
|
||||
}
|
||||
$tenant = Tenant::query()->create(['name' => 'Synthetic standalone finance UI review']);
|
||||
$department = Department::query()->create(['tenant_id' => $tenant->id, 'name' => 'Synthetic company']);
|
||||
$admin = User::factory()->create(['tenant_id' => $tenant->id, 'department_id' => $department->id,
|
||||
'name' => 'QA Finance Administrator', 'email' => 'qa-finance-admin@example.invalid', 'purchasing_role' => PurchasingRole::Admin]);
|
||||
$finance = User::factory()->create(['tenant_id' => $tenant->id, 'department_id' => $department->id,
|
||||
'name' => 'QA Financial Reviewer', 'email' => 'qa-finance-reviewer@example.invalid', 'purchasing_role' => PurchasingRole::Finance]);
|
||||
$proof = ['admin_login' => $admin->email, 'finance_login' => $finance->email, 'finance_id' => $finance->id,
|
||||
'tenant_id' => $tenant->id, 'frames' => $frames, 'no_initial_financial_grants' => ! $db->table('pa_access')->where('tenant_id', $tenant->id)->exists()];
|
||||
file_put_contents($root.'/standalone-ui.json', json_encode($proof, JSON_THROW_ON_ERROR));
|
||||
unset($proof['frames']);
|
||||
echo json_encode(['ui_prepared' => true] + $proof, JSON_THROW_ON_ERROR);
|
||||
exit;
|
||||
}
|
||||
if (in_array($mode, ['prepare', 'rebind'], true)) {
|
||||
$arguments = ['--expected-database' => $database, '--expected-role' => getenv('DB_USERNAME'),
|
||||
'--operator' => 'Synthetic named QA deployment operator', '--reason' => 'Authorised candidate installation and recovery verification'];
|
||||
@@ -140,7 +211,7 @@ if (in_array($mode, ['prepare', 'rebind'], true)) {
|
||||
$runtime = app(StandaloneRuntime::class);
|
||||
$runtime->assertLoadedPackages();
|
||||
$checks = 0;
|
||||
foreach ([CapitalRegister::class, OperationalOrders::class, PrivateAuditAccess::class, ConflictReleases::class,
|
||||
foreach ([CommonFinanceAdministration::class, CapitalRegister::class, OperationalOrders::class, PrivateAuditAccess::class, ConflictReleases::class,
|
||||
UrgentQuotationBasis::class, UrgentRequisitionReviews::class, RequisitionLedgerAccounts::class,
|
||||
RequisitionExpiry::class, RequisitionBudgetDistributions::class,
|
||||
ExpenseAllocations::class, AgreementOrderLimits::class, OrderPartsPreparation::class,
|
||||
|
||||
Reference in New Issue
Block a user