106 lines
12 KiB
PHP
106 lines
12 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, $currency = null) => number_format($minor / 100, 2, ',', '.') . ' ' . ($currency ?? $order->currency))
|
|
<button type="button" class="no-print" onclick="window.print()">Imprimir ou guardar como PDF</button>
|
|
<h1>Ordem de compra {{ $order->number }}</h1>
|
|
@if(!empty($snapshot['exchange_basis']))
|
|
<p>Taxa congelada: 1 {{ $snapshot['exchange_basis']['currency'] }} = {{ $snapshot['exchange_basis']['rate'] }} MZN · {{ $snapshot['exchange_basis']['quoted_on'] }} · Fonte: {{ $snapshot['exchange_basis']['source'] }}. Referência orçamental: {{ $money($snapshot['reference_amounts']['total_minor'], 'MZN') }}. Os valores da ordem estão na moeda original.</p>
|
|
@endif
|
|
@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
|
|
@if(!$snapshotComplete)
|
|
<div class="notice"><strong>Documento original incompleto.</strong> Esta consulta apresenta apenas dados preservados na emissão. Não reconstrói condições ou aprovações a partir dos cadastros actuais e não substitui um comprovativo completo.</div>
|
|
<p>Fornecedor preservado: {{ $snapshot['supplier']['name'] ?? 'Não registado no original' }}<br>Emissão: {{ $order->issued_at->format('Y-m-d H:i:s') }}</p>
|
|
<table><thead><tr><th>Descrição</th><th>Quantidade</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->total_minor) }}</td></tr>@endforeach
|
|
</tbody></table>
|
|
<p>Subtotal sem IVA: {{ $money($order->subtotal_minor) }}<br>IVA: {{ $money($order->tax_minor) }}<br>Total com IVA: {{ $money($order->total_minor) }}</p>
|
|
@else
|
|
<p>{{ $snapshot['company']['name'] }} · {{ $snapshot['requisition']['number'] }}</p>
|
|
<div class="notice"><strong>Documento de desenvolvimento. Não autoriza compras reais.</strong><br>@if(($snapshot['budget_checked'] ?? false) === true) Controlo orçamental confirmado para as parcelas emitidas. @else Orçamento não verificado. @endif @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>
|
|
@if(!empty($snapshot['order_parts']['frames']))
|
|
<h2>Origens desta ordem</h2>
|
|
<p>Cada origem conserva as condições e aprovações registadas. Os valores das parcelas usam o arredondamento cumulativo da origem.</p>
|
|
@foreach($snapshot['order_parts']['frames'] as $frame)
|
|
<section><h3>{{ $frame['requisition']['number'] }}</h3><p>{{ $frame['department']['name'] }} · {{ $frame['cost_center']['code'] }} · {{ $frame['cost_center']['name'] }}<br>Proposta {{ $frame['quotation']['reference'] }} · Pagamento: {{ $frame['quotation']['payment_terms'] }}<br>Entrega: {{ $frame['award']['delivery_date'] }} · <span class="pre">{{ $frame['award']['delivery_location'] }}</span></p></section>
|
|
@endforeach
|
|
@endif
|
|
<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'], 'MZN') }} · {{ $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>@if(!empty($snapshot['order_parts']['frames']))<th>Origem</th>@endif<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>@if(!empty($snapshot['order_parts']['frames']))@php($originFrame = collect($snapshot['order_parts']['frames'])->first(fn ($frame) => in_array($item->requisition_item_id, array_column($frame['native_preparation']['items'], 'requisition_item_id'), true)))<td>{{ $originFrame['requisition']['number'] ?? 'Origem indisponível' }}</td>@endif<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'], 'currency' => $row['currency'], 'money' => fn ($minor) => number_format($minor / 100, 2, ',', '.') . ' ' . $row['currency']])
|
|
@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>
|
|
@if(!empty($snapshot['agreement_bindings']))
|
|
<h2>Acordos e limites preservados por ordem</h2>
|
|
@foreach(collect($snapshot['agreement_bindings'])->pluck('contract')->filter()->unique('id') as $contract)
|
|
<p>Contrato global: {{ $contract['reference'] }} · versão {{ $contract['version'] }} · Total com impostos dos artigos ligados: {{ $money($contract['checked_order_value_minor'], $contract['currency']) }};
|
|
limite global por ordem: {{ $contract['max_order_value_minor'] === null ? 'Não definido' : $money($contract['max_order_value_minor'], $contract['currency']) }}.</p>
|
|
@endforeach
|
|
<p>Cada ordem pode utilizar o limite completo. Conferência apenas das linhas ligadas ao mesmo acordo; sem acumular outras ordens.</p>
|
|
@foreach(collect($snapshot['agreement_bindings'])->unique('agreement_id') as $binding)
|
|
<p>{{ $binding['reference'] }} · versão {{ $binding['version'] }} · Total com impostos conferido: {{ $money($binding['checked_order_value_minor'], $binding['currency']) }};
|
|
limite por ordem: {{ $binding['max_order_value_minor'] === null ? 'Não definido' : $money($binding['max_order_value_minor'], $binding['currency']) }}.<br>
|
|
Quantidade conferida: {{ str_replace('.', ',', (string)\Brick\Math\BigDecimal::of($binding['checked_order_quantity_milli'])->dividedBy(1000, 3)) }} {{ $binding['unit'] }};
|
|
limite por ordem: {{ $binding['max_order_quantity_milli'] === null ? 'Não definido' : str_replace('.', ',', (string)\Brick\Math\BigDecimal::of($binding['max_order_quantity_milli'])->dividedBy(1000, 3)) . ' ' . $binding['unit'] }}.</p>
|
|
@endforeach
|
|
@endif
|
|
@if(!empty($snapshot['import_tariffs']))
|
|
<h2>Classificação pautal preservada na emissão</h2>
|
|
@foreach($snapshot['import_tariffs'] as $classification)
|
|
<p class="pre"><strong>{{ $classification['item']['description'] }}</strong><br>Código confirmado: {{ $classification['data']['confirmed_code'] }} · versão {{ $classification['version'] }} · {{ $classification['confirmed_by']['name'] }}<br>Proposta: {{ $classification['data']['proposed_code'] ?? 'Não indicada' }} · Fonte: {{ $classification['data']['source_reference'] ?? 'Por completar' }}<br>Fonte da confirmação: {{ $classification['data']['confirmation_source'] }}<br>{{ $classification['data']['deviation'] ? 'Justificação do desvio' : 'Motivo' }}: {{ $classification['reason'] }}</p>
|
|
@endforeach
|
|
@endif
|
|
<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'], $row['currency']) }}</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>
|
|
@endif
|
|
</body>
|
|
</html>
|