Files
nala 63d20b10fc
tests / ci (push) Canceled after 0s
commit de armazens
2026-11-04 09:40:26 +02:00

67 lines
6.3 KiB
PHP

<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ $order->number }} · SGC</title>
<style>
@page { size: A4; margin: 17mm; }
* { box-sizing: border-box; }
body { color: #111; font: 12px/1.5 Arial, sans-serif; margin: 24px auto; max-width: 900px; }
h1 { font-size: 25px; margin-bottom: 2px; } h2 { font-size: 16px; margin-top: 24px; }
.notice { border: 1px solid #aaa; padding: 12px; margin: 18px 0; }
.columns { display: flex; gap: 30px; } .columns > div { flex: 1; }
table { border-collapse: collapse; width: 100%; margin: 14px 0; }
th, td { border: 1px solid #ddd; text-align: left; padding: 8px; vertical-align: top; }
th { background: #eee; } thead { display: table-header-group; } tr { break-inside: avoid; }
.totals { margin-left: auto; width: 330px; } .pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.small { font-size: 10px; color: #444; } button { padding: 10px 18px; cursor: pointer; }
@media print { body { margin: 0; max-width: none; } .no-print { display: none; } }
</style>
</head>
<body>
@php($money = fn ($minor) => number_format($minor / 100, 2, ',', '.') . ' MZN')
<button type="button" class="no-print" onclick="window.print()">Imprimir ou guardar como PDF</button>
<h1>Ordem de compra {{ $order->number }}</h1>
@if(($operationalState ?? 'issued') !== 'issued')
<p class="notice"><strong>{{ $operationalState === 'cancelled' ? 'Ordem cancelada' : 'Cancelamento pendente — execução suspensa' }}.</strong> Reprodução do documento original, preservado no histórico.</p>
@endif
<p>{{ $snapshot['company']['name'] }} · {{ $snapshot['requisition']['number'] }}</p>
<div class="notice"><strong>Documento de desenvolvimento. Não autoriza compras reais.</strong><br>Orçamento não verificado. @if($snapshot['approval_rules']['rules_provisional']) Regras de aprovação provisórias. @endif</div>
<div class="columns">
<div><h2>Fornecedor</h2><strong>{{ $snapshot['supplier']['name'] }}</strong><br>NUIT {{ $snapshot['supplier']['nuit'] }}<br><span class="pre">{{ $snapshot['supplier']['address'] }}</span><br>{{ $snapshot['supplier']['contact'] }}<br>{{ $snapshot['supplier']['phone'] }} · {{ $snapshot['supplier']['email'] }}</div>
<div><h2>Condições</h2>Entrega: {{ $snapshot['award']['delivery_date'] }}<br><span class="pre">{{ $snapshot['award']['delivery_location'] }}</span><br>Pagamento: {{ $snapshot['quotation']['payment_terms'] }}<br>Proposta: {{ $snapshot['quotation']['reference'] }}<br>{{ $snapshot['department']['name'] }} · {{ $snapshot['cost_center']['code'] }}<br>Emitente: {{ $snapshot['issuer']['name'] }}<br>Emissão: {{ $order->issued_at->format('Y-m-d H:i:s') }}</div>
</div>
<h2>Artigos e valores</h2>
@if(!empty($snapshot['investment_rules']))
<h2>Regra de investimento congelada</h2>
<p>Versão {{ $snapshot['investment_rules']['revision'] }} · Tecto {{ $money($snapshot['investment_rules']['ceiling_minor']) }} · {{ $snapshot['investment_rules']['includes_tax'] ? 'com IVA' : 'sem IVA' }} · Vigência {{ $snapshot['investment_rules']['valid_from'] }} a {{ $snapshot['investment_rules']['valid_until'] }}.</p>
@foreach($snapshot['equipment_requests'] ?? [] as $context)<p class="pre">{{ $context['description'] }} · Área: {{ $context['production_area'] }}</p>@endforeach
@endif
<table><thead><tr><th>Descrição</th><th>Quantidade</th><th>Preço sem IVA</th><th>IVA</th><th>Total com IVA</th></tr></thead><tbody>
@foreach($order->items as $item)
<tr><td class="pre">{{ $item->description }}</td><td>{{ $item->quantity }} {{ $item->unit }}</td><td>{{ $money($item->unit_price_minor) }}</td><td>{{ $item->tax_rate }}%</td><td>{{ $money($item->total_minor) }}</td></tr>
@endforeach
</tbody></table>
@foreach($snapshot['decision_matrix'] as $row)
@if(!empty($row['commercial_terms']))
<h3>{{ $row['supplier']['name'] }} · {{ $row['reference'] }}</h3>
@include('purchases.commercial-terms', ['terms' => $row['commercial_terms']])
@endif
@endforeach
<table class="totals"><tr><td>Subtotal sem IVA</td><td>{{ $money($order->subtotal_minor) }}</td></tr><tr><td>IVA</td><td>{{ $money($order->tax_minor) }}</td></tr><tr><th>Total com IVA</th><th>{{ $money($order->total_minor) }}</th></tr></table>
<h2>Justificação da adjudicação</h2><p class="pre">{{ $snapshot['award']['justification'] }}</p>
<h2>Matriz de avaliação congelada</h2>
@if(!empty($snapshot['comparison_policy']))
<p class="small">Regra de comparação preservada: revisão {{ $snapshot['comparison_policy']['revision'] }} · mínimo de {{ $snapshot['comparison_policy']['minimum_proposals'] }} fornecedores com propostas elegíveis e {{ $snapshot['comparison_policy']['minimum_evaluators'] }} avaliações independentes por proposta.</p>
@endif
<table><thead><tr><th>Fornecedor / proposta</th><th>Total com IVA</th><th>Avaliações elegíveis</th><th>Pontuação</th></tr></thead><tbody>
@foreach($snapshot['decision_matrix'] as $row)
<tr><td>{{ $row['supplier']['name'] }} · {{ $row['reference'] }}<br>@foreach($row['evaluations'] as $evaluation)<span class="small">Avaliador #{{ $evaluation['evaluator_id'] }}: qualidade {{ $evaluation['quality'] }}, histórico {{ $evaluation['history'] }}, pagamento {{ $evaluation['payment'] }}. {{ $evaluation['comment'] }}</span><br>@endforeach</td><td>{{ $money($row['total_minor']) }}</td><td>{{ $row['evaluation_count'] }}</td><td>{{ $row['score'] === null ? 'Não elegível / incompleta' : number_format($row['score'], 2, ',', '.') . ' / 10' }}</td></tr>
@endforeach
</tbody></table>
<h2>Aprovações do valor final</h2><ul>@foreach($snapshot['final_approvals'] as $approval)<li>{{ \App\Enums\PurchasingRole::from($approval['role'])->label() }} · Utilizador #{{ $approval['approver_id'] }} · {{ $approval['decided_at'] }} · {{ $approval['comment'] }}</li>@endforeach</ul>
<p class="small">Base dos escalões: {{ $snapshot['approval_rules']['approval_includes_tax'] ? 'com IVA' : 'sem IVA' }}. Dados congelados na emissão; alterações posteriores às fichas não reescrevem este documento. Não foi enviado por email.</p>
</body>
</html>