commit compras2 2811
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-28 15:45:52 +02:00
parent eb32c74c56
commit 060c119ba1
92 changed files with 4936 additions and 43 deletions
+19 -2
View File
@@ -44,10 +44,27 @@ final class ImportLegalRules
$rules = app(SupplyPlanning::class)->latest('import_legal_rule')->latest('id')
->paginate(15, ['id', 'record_key', 'version', 'state', 'data', 'snapshot', 'reason'], 'rules_page')->withQueryString();
$rules->through(fn ($rule) => [...$rule->toArray(), 'source_url' => '/requisicoes/'.$request->id.'/base-legal/fontes/'.$rule->snapshot['source_id']]);
$sources = SupplyRecord::query()->where('kind', 'import_legal_source')->latest('id')
->paginate(15, ['id', 'tenant_id', 'record_key', 'version', 'kind', 'data', 'snapshot', 'created_at'], 'legal_sources_page')->withQueryString();
$referenceDrafts = [];
$referenceDraftWarnings = [];
if ($actor->hasFunctions(['import_customs'])) {
foreach ($sources as $source) {
try {
array_push($referenceDrafts, ...app(ImportLegalReferenceDrafts::class)->forSource($source));
} catch (HttpExceptionInterface $error) {
if ($error->getStatusCode() !== 409) {
throw $error;
}
$referenceDraftWarnings[] = ['source_id' => $source->id, 'message' => 'O original da fonte não pôde ser conferido; as suas propostas documentais estão indisponíveis.'];
}
}
}
// The UI receives source metadata and drafts, never native private paths.
$sources->through(fn ($source) => $source->only(['id', 'data', 'created_at']));
return ['requisition' => $request->only(['id', 'number']), 'rules' => $rules,
'sources' => SupplyRecord::query()->where('kind', 'import_legal_source')->latest('id')
->paginate(15, ['id', 'data', 'created_at'], 'legal_sources_page')->withQueryString(),
'sources' => $sources, 'referenceDrafts' => $referenceDrafts, 'referenceDraftWarnings' => $referenceDraftWarnings,
'items' => $request->items()->orderBy('id')->get(['id', 'description']),
'classifications' => app(SupplyPlanning::class)->latest('import_tariff')->where('data->requisition_id', $request->id)->get(['version', 'data']),
'canPropose' => $actor->hasFunctions([PurchasingRole::Procurement]),