Files
SGF/scripts/document-proof-metrics.php
nala f8d57b52aa Preserva classificacao contabilistica aceite e bases locais
Regista aceitacao funcional do primeiro incremento PGC-NIRF e preserva as dependencias documentais e tecnicas existentes. A validacao do calculo fiscal continua separada e pendente. Sem credenciais, bases operacionais ou publicacao.
2026-10-26 13:47:11 +02:00

17 lines
1.9 KiB
PHP

<?php
require __DIR__.'/../vendor/autoload.php';
$app = require __DIR__.'/../bootstrap/app.php';
$app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();
\App\Shared\Testing\TestingDatabaseGuard::assertSafe();
$db = \Illuminate\Support\Facades\DB::class;
$kinds = $db::table('doc_records')->selectRaw('kind,count(*) AS count')->groupBy('kind')->orderBy('kind')->get()->all();
$schemas = ['1' => 0, '2' => 0];
foreach ($db::table('b_internal_confirmations')->pluck('snapshot') as $encoded) { $snapshot = json_decode($encoded, true, 64, JSON_THROW_ON_ERROR); $schemas[(string) ($snapshot['schema_version'] ?? 1)]++; }
$privateValues = $db::table('doc_records')->where('kind', 'payment')->pluck('data')->map(fn ($value) => json_decode($value, true, 32, JSON_THROW_ON_ERROR)['account_number'] ?? null)->filter()->all();
$audit = $db::table('identity_audit')->pluck('details')->implode(''); $log = is_file(storage_path('logs/laravel.log')) ? file_get_contents(storage_path('logs/laravel.log')) : '';
foreach ($privateValues as $value) { if (str_contains($audit, $value) || str_contains($log, $value)) { throw new RuntimeException('Instruction value detected in audit or technical log; no value displayed.'); } }
$report = ['database' => 'sgf_tempo_test', 'preparation_records_by_kind' => $kinds, 'preparation_history_versions' => $db::table('doc_history')->count(), 'confirmation_snapshot_schemas' => $schemas, 'instruction_values_in_audit_or_technical_log' => false, 'instruction_values' => 'omitted', 'receipt_table_present' => \Illuminate\Support\Facades\Schema::hasTable('receipts'), 'journal_table_present' => \Illuminate\Support\Facades\Schema::hasTable('journal_entries')];
file_put_contents(base_path('docs/proofs/document-capture.json'), json_encode($report, JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));
echo "Document capture metrics recorded with no instruction values; v1/v2 schemas and audit/log confidentiality checked.\n";