commit melhorias compras4
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-11-22 16:28:03 +02:00
parent efd97e265b
commit 36dcfdf00c
118 changed files with 6042 additions and 92 deletions
@@ -0,0 +1,56 @@
<?php
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Support\Facades\DB;
$root = dirname(__DIR__);
$proof = json_decode(file_get_contents($root.'/storage/framework/testing/distribution-visual-running.json'), true, 32, JSON_THROW_ON_ERROR);
$expected = 'C:/laragon/data/sgf-tempo/qa/distribution-visual-'.$proof['database'];
if (! preg_match('/^compras_receipts_test_[a-f0-9]{12}$/D', $proof['database']) || str_replace('\\', '/', dirname($proof['stop_file'])) !== $expected) {
throw new LogicException('Invalid private visual QA identity.');
}
$settings = json_decode(file_get_contents($expected.'/settings.json'), true, 32, JSON_THROW_ON_ERROR);
if ($settings['DB_DATABASE'] !== $proof['database'] || $settings['APP_ENV'] !== 'testing' || $settings['DB_HOST'] !== '127.0.0.1') {
throw new LogicException('Private QA settings do not match the review.');
}
foreach ($settings as $key => $value) {
putenv($key.'='.$value);
$_ENV[$key] = $_SERVER[$key] = $value;
}
require $root.'/vendor/autoload.php';
$app = require $root.'/bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
if (DB::getDriverName() !== 'pgsql' || DB::connection()->getDatabaseName() !== $proof['database']) {
throw new LogicException('Review verification database mismatch.');
}
$request = DB::table('requisitions')->where('id', $proof['synthetic_fixture']['draft'])->first();
$plan = json_decode($request->budget_distribution_preparation, true, 32, JSON_THROW_ON_ERROR);
if ((int) $request->process_version !== 3 || $request->status !== 'draft' || count($plan['allocations']) !== 2
|| array_column($plan['allocations'], 'subtotal_minor') !== [5000, 5000] || array_column($plan['allocations'], 'total_minor') !== [5000, 5000]
|| DB::table('budget_distributions')->where('requisition_id', $request->id)->exists()
|| DB::table('audit_logs')->where('requisition_id', $request->id)->where('action', 'requisition.allocations_prepared')->count() !== 2) {
throw new RuntimeException('Browser correction did not preserve the draft, exact values and absence of financial effects.');
}
echo json_encode(['native_browser_draft_saved' => true, 'version' => 3, 'failed_attempt_no_effects' => true,
'two_explicit_allocations' => true, 'no_reservation_on_prepare' => true], JSON_THROW_ON_ERROR).PHP_EOL;
if (in_array('--amended', $argv, true)) {
$order = DB::table('purchase_orders')->where('id', $proof['synthetic_fixture']['foreign_order'])->first();
$source = DB::table('budget_distributions')->where('requisition_id', $order->requisition_id)->first();
$current = json_decode($source->snapshot, true, 32, JSON_THROW_ON_ERROR);
$original = json_decode(DB::table('budget_distribution_events')->where('distribution_id', $source->id)->where('kind', 'commit')->value('snapshot'), true, 32, JSON_THROW_ON_ERROR);
$document = json_decode($order->snapshot, true, 32, JSON_THROW_ON_ERROR);
$values = array_column($current['allocations'], 'total_minor');
sort($values);
if ($current['amendment_version'] !== 1 || $values !== [4999, 5001] || array_column($original['allocations'], 'total_minor') !== [5000, 5000]
|| array_sum(array_column($current['allocations'], 'subtotal_minor')) !== 10000 || $document['budget_control']['plan_hash'] !== $original['plan_hash']
|| $document['exchange_basis']['rate'] !== '1.0000000000' || $order->currency !== 'USD' || (int) $order->total_minor !== 10000
|| DB::table('budget_distribution_events')->where('distribution_id', $source->id)->count() !== 4
|| DB::table('audit_logs')->where('requisition_id', $order->requisition_id)->where('action', 'budget.distribution_amended')->count() !== 1) {
throw new RuntimeException('Native browser amendment did not preserve the original document, exact total, version and history.');
}
if (DB::table('invoices')->count() !== 0 || DB::table('purchase_awards')->where('requisition_id', $proof['synthetic_fixture']['award'])->exists()) {
throw new RuntimeException('Read-only invoice/adjudication review unexpectedly registered a business document.');
}
echo json_encode(['native_browser_finance_amendment' => true, 'version' => 1, 'original_commitment_and_rate_preserved' => true,
'one_amendment_and_audit' => true], JSON_THROW_ON_ERROR).PHP_EOL;
}