@@ -8,6 +8,8 @@ use App\Services\ImportBankSupport;
|
||||
use App\Services\ImportEstimates;
|
||||
use App\Services\ImportLegalEstimates;
|
||||
use App\Services\ImportLegalRules;
|
||||
use App\Services\RequisitionExpiry;
|
||||
use App\Services\RequisitionWorkflow;
|
||||
use App\Services\SupplyPlanning;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Cookie\CookieJar;
|
||||
@@ -29,6 +31,7 @@ $corpus = realpath($argv[3] ?? '');
|
||||
$candidateRelative = $argv[4] ?? '';
|
||||
$candidateHash = $argv[5] ?? '';
|
||||
$expiryReview = ($argv[2] ?? '') === 'expiry-review';
|
||||
$referenceHttp = ($argv[2] ?? '') === 'legal-reference-http';
|
||||
$reviewMode = ($argv[2] ?? '') === 'legal-review' || $expiryReview;
|
||||
if (! app()->environment('testing') || DB::getDriverName() !== 'pgsql' || DB::connection()->getDatabaseName() !== $database
|
||||
|| DB::connection()->getConfig('host') !== '127.0.0.1' || ! preg_match('/^compras_receipts_test_[a-f0-9]{12}$/D', $database)
|
||||
@@ -40,8 +43,9 @@ require_once __DIR__.'/../Support/ReceiptFixture.php';
|
||||
require_once __DIR__.'/../Support/SupplyFixture.php';
|
||||
require_once __DIR__.'/../Support/ImportLegalQaFixture.php';
|
||||
require_once __DIR__.'/../Support/ImportBankQaFixture.php';
|
||||
$files = glob(str_replace('\\', '/', $corpus).'/Legislacao/2022/12 Dezembro/series-i/br-series-i-29-12-2022-*.pdf');
|
||||
if ($files === false || count($files) !== 1 || filesize($files[0]) <= 2097152) {
|
||||
$files = $referenceHttp ? [$corpus.'/novas/BR_248_I_SERIE_SUPLEMENTO_2025.pdf']
|
||||
: glob(str_replace('\\', '/', $corpus).'/Legislacao/2022/12 Dezembro/series-i/br-series-i-29-12-2022-*.pdf');
|
||||
if ($files === false || count($files) !== 1 || ! is_file($files[0]) || filesize($files[0]) < 1 || (! $referenceHttp && filesize($files[0]) <= 2097152)) {
|
||||
throw new LogicException('Select the complete shared official journal, not a small extracted example.');
|
||||
}
|
||||
$path = $files[0];
|
||||
@@ -103,7 +107,7 @@ try {
|
||||
throw new RuntimeException('Native HTTP source requests must require CSRF: '.$negative->getStatusCode());
|
||||
}
|
||||
$input = ['operation_key' => (string) Str::uuid(), 'action' => 'source', 'version' => '0',
|
||||
'official_reference' => 'BR I Série 251 de 29/12/2022 — exemplar integral real partilhado',
|
||||
'official_reference' => $referenceHttp ? 'BR I Série 248, suplemento, 29/12/2025 — exemplar integral real partilhado' : 'BR I Série 251 de 29/12/2022 — exemplar integral real partilhado',
|
||||
'reason' => 'Ensaio HTTP estritamente QA com exemplar oficial real, empresa e conta sintéticas; sem publicar regras'];
|
||||
foreach ([1, 2] as $attempt) {
|
||||
$multipart = array_map(fn ($name) => ['name' => $name, 'contents' => $input[$name]], array_keys($input));
|
||||
@@ -124,6 +128,9 @@ try {
|
||||
}
|
||||
$props = json_decode((string) $page->getBody(), true, 64, JSON_THROW_ON_ERROR)['props'] ?? [];
|
||||
$source = SupplyRecord::query()->where('kind', 'import_legal_source')->sole();
|
||||
if (count($props['referenceDrafts'] ?? []) !== ($referenceHttp ? 48 : 0) || ($props['referenceDraftWarnings'] ?? []) !== []) {
|
||||
throw new RuntimeException('The native legal workspace did not preserve the edition-specific documentary draft scope.');
|
||||
}
|
||||
$download = $client->get($route.'/fontes/'.$source->id);
|
||||
$guest = new Client(['base_uri' => $url, 'http_errors' => false, 'allow_redirects' => false, 'timeout' => 10]);
|
||||
$anonymous = $guest->get($route.'/fontes/'.$source->id, ['headers' => ['Accept' => 'application/json']]);
|
||||
@@ -143,6 +150,7 @@ try {
|
||||
'original_sha256' => $originalHash, 'original_unchanged' => true, 'exact_native_download' => true, 'one_source_one_audit_after_replay' => true,
|
||||
'guest_status' => 401, 'revoked_status' => 403, 'rules_published' => 0, 'financial_stock_unchanged' => true,
|
||||
'private_upload_limit' => '64M', 'private_post_limit' => '70M', 'global_php_config_unchanged' => true];
|
||||
$result['documentary_reference_drafts'] = count($props['referenceDrafts'] ?? []);
|
||||
if ($reviewMode) {
|
||||
// Existing factory password is confined to guarded, disposable synthetic QA identities.
|
||||
$reviewer = $f['otherReceiver'];
|
||||
@@ -188,10 +196,10 @@ try {
|
||||
supplyGrant($reviewer, ['admin', 'procurement', 'requester', 'import_read', 'import_prepare', 'import_customs']);
|
||||
$head = User::factory()->create(['tenant_id' => $f['tenant']->id, 'department_id' => $f['department']->id, 'purchasing_role' => PurchasingRole::DepartmentHead]);
|
||||
supplyGrant($head, ['department_head']);
|
||||
app(\App\Services\RequisitionExpiry::class)->savePolicy($reviewer, ['operation_key' => (string) Str::uuid(), 'version' => 0, 'enabled' => true,
|
||||
app(RequisitionExpiry::class)->savePolicy($reviewer, ['operation_key' => (string) Str::uuid(), 'version' => 0, 'enabled' => true,
|
||||
'levels' => [['role' => 'department_head', 'expire_minutes' => 30, 'reminder_minutes' => 10, 'escalation_minutes' => null, 'profile_ids' => []]],
|
||||
'reason' => 'Política estritamente sintética para revisão visual do ciclo']);
|
||||
$workflow = app(\App\Services\RequisitionWorkflow::class);
|
||||
$workflow = app(RequisitionWorkflow::class);
|
||||
$expiryRequest = $workflow->save($reviewer, ['operation_key' => (string) Str::uuid(), 'cost_center_id' => $f['r']->cost_center_id, 'priority' => 'normal',
|
||||
'needed_by' => today()->addWeek()->toDateString(), 'justification' => 'Ensaio visual sintético da devolução e nova submissão',
|
||||
'items' => [['description' => 'Material sintético do ciclo', 'category' => 'Material', 'purchase_type' => 'consumable', 'quantity' => '1.000', 'unit' => 'un', 'unit_price' => '100.00', 'tax_rate' => '0.00']]]);
|
||||
|
||||
Reference in New Issue
Block a user