48 lines
3.4 KiB
PHP
48 lines
3.4 KiB
PHP
<?php
|
|
|
|
// Read-only inspection of the guarded live QA target; no account/key/config changes.
|
|
use App\Models\Opportunity;
|
|
use App\Models\User;
|
|
use App\Services\DeclaredOriginStatistics;
|
|
use App\Services\OpportunityManagement;
|
|
use App\Services\VirtualDesk;
|
|
use Illuminate\Contracts\Console\Kernel;
|
|
use Illuminate\Support\Facades\Crypt;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
$root = dirname(__DIR__);
|
|
require $root.'/vendor/autoload.php';
|
|
require __DIR__.'/portal-qa-environment.php';
|
|
$target = portalQaEnvironment();
|
|
$app = require $root.'/bootstrap/app.php';
|
|
$app->make(Kernel::class)->bootstrap();
|
|
$identity = portalQaAssertTarget($target);
|
|
$dir = $root.'/storage/app/private/investmoz-v2/portal-audit';
|
|
$proof = DB::transaction(function () use ($identity, $dir) {
|
|
DB::statement('SET TRANSACTION READ ONLY');
|
|
$companies = DB::table('investment_company_declarations')->where('user_id', 18)->get()->map(function ($r) {
|
|
$p = json_decode(Crypt::decryptString($r->payload), true, 512, JSON_THROW_ON_ERROR);
|
|
|
|
return ['id' => $r->id, 'version' => $r->version, 'name' => $p['name'], 'incorporation' => $p['incorporation_country_code'] ?? null];
|
|
});
|
|
$roles = json_decode(file_get_contents($dir.'/profiles-v1-actors-private.json'), true, 512, JSON_THROW_ON_ERROR);
|
|
$manager = User::findOrFail(14);
|
|
// Match the QA router's existing synthetic manager configuration in this read-only process.
|
|
config(['portal.managers' => [$manager->email]]);
|
|
$counts = app(DeclaredOriginStatistics::class)->forManager($manager);
|
|
$requests = DB::table('desk_requests')->whereIn('case_id', DB::table('desk_cases')->where('user_id', 18)->select('id'))->get()->map(fn ($r) => ['id' => $r->id, 'case_id' => $r->case_id, 'status' => $r->status, 'version' => $r->version, 'service_version_id' => $r->service_version_id, 'protocol' => $r->protocol, 'origin' => app(VirtualDesk::class)->decode($r->payload)['declared_origin_country_code'] ?? null]);
|
|
$structures = [];
|
|
foreach (['projects', 'economic_clusters', 'development_corridors'] as $table) {
|
|
$structures[$table] = DB::table($table)->where('code', 'like', 'QA-CONSUMER-%')->get(['id', 'code', 'name', 'primary_territory_id', 'territory_version']);
|
|
}
|
|
$workflow = DB::table('opportunities')->where('title', 'like', 'QA visual workflow%')->get(['id', 'title', 'status']);
|
|
$template = Opportunity::findOrFail(18);
|
|
throw_unless(str_contains($template->title, 'sintética QA'), RuntimeException::class, 'Only the existing synthetic fixture may supply scenario inputs.');
|
|
$canonical = app(OpportunityManagement::class)->values($template)['canonical'];
|
|
file_put_contents($dir.'/consumer-workflow-template-qa.json', json_encode(['synthetic_only' => true, 'source_id' => 18, 'canonical' => $canonical], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR));
|
|
|
|
return ['result' => 'passed_read_only_guard', 'target' => $identity, 'read_only' => true, 'active_writes' => 0, 'at' => now()->toIso8601String(), 'companies' => $companies, 'requests' => $requests, 'statistics' => $counts, 'structures' => $structures, 'workflow' => $workflow];
|
|
});
|
|
file_put_contents($dir.'/consumer-completion-persistence-qa.json', json_encode($proof, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR));
|
|
echo json_encode(['result' => $proof['result'], 'target' => $identity, 'companies' => count($proof['companies']), 'requests' => count($proof['requests']), 'active_writes' => 0]).PHP_EOL;
|