@@ -74,6 +74,10 @@ export default function Show({
|
||||
href: string | null;
|
||||
destination: string;
|
||||
equipment: { code: string; description: string } | null;
|
||||
production?: {
|
||||
reference: string | null;
|
||||
verification: 'user_supplied';
|
||||
};
|
||||
remaining_milli: number;
|
||||
}[];
|
||||
} | null;
|
||||
@@ -169,6 +173,8 @@ export default function Show({
|
||||
</>
|
||||
)}{' '}
|
||||
· Utilização: {o.destination}
|
||||
{o.production &&
|
||||
` · Insumos para produção${o.production.reference ? ` · Referência declarada: ${o.production.reference}` : ''}`}
|
||||
{o.equipment
|
||||
? ` · Equipamento ${o.equipment.code} · ${o.equipment.description}`
|
||||
: ''}{' '}
|
||||
@@ -209,87 +215,89 @@ export default function Show({
|
||||
<Panel title="Regra de comparação deste processo">
|
||||
<ComparisonPolicySummary policy={comparisonPolicy} />
|
||||
</Panel>
|
||||
{r.items.some((i) => i.purchase_type === 'equipment') && (
|
||||
<Panel title="Validação técnica do equipamento">
|
||||
<p className="mb-4 text-sm">
|
||||
Responsável da área, distinto do solicitante.
|
||||
Finanças é obrigatória para qualquer valor. A
|
||||
adjudicação e a emissão exigem regra de investimento
|
||||
vigente, com duas aprovações administrativas, e
|
||||
reserva em dotação de investimento. Sem estas
|
||||
condições permanecem bloqueadas. O orçamento ainda
|
||||
não é validado; documentos de desenvolvimento não
|
||||
autorizam compras reais.
|
||||
</p>
|
||||
{technical?.reviews.map((t) => (
|
||||
<p
|
||||
key={t.id}
|
||||
className="mb-3 rounded-lg border p-3 text-sm"
|
||||
>
|
||||
{t.decision === 'approved'
|
||||
? 'Validado'
|
||||
: 'Rejeitado'}{' '}
|
||||
por {t.snapshot.reviewer.name} ·{' '}
|
||||
{t.basis_hash === technical.basis_hash
|
||||
? 'Versão actual'
|
||||
: 'Versão anterior, decisão preservada'}{' '}
|
||||
· {t.reason}
|
||||
{!r.draft_input?.incomplete &&
|
||||
r.items.some((i) => i.purchase_type === 'equipment') && (
|
||||
<Panel title="Validação técnica do equipamento">
|
||||
<p className="mb-4 text-sm">
|
||||
Responsável da área, distinto do solicitante.
|
||||
Finanças é obrigatória para qualquer valor. A
|
||||
adjudicação e a emissão exigem regra de
|
||||
investimento vigente, com duas aprovações
|
||||
administrativas, e reserva em dotação de
|
||||
investimento. Sem estas condições permanecem
|
||||
bloqueadas. O orçamento ainda não é validado;
|
||||
documentos de desenvolvimento não autorizam
|
||||
compras reais.
|
||||
</p>
|
||||
))}
|
||||
{technical?.canReview && (
|
||||
<form
|
||||
className="grid gap-3"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
review.transform((d) => ({
|
||||
...d,
|
||||
basis_hash: technical.basis_hash,
|
||||
}));
|
||||
review.post(
|
||||
`/requisicoes/${r.id}/validacao-tecnica`,
|
||||
);
|
||||
}}
|
||||
>
|
||||
<select
|
||||
aria-label="Decisão técnica"
|
||||
className={controlClass}
|
||||
value={review.data.decision}
|
||||
onChange={(e) =>
|
||||
review.setData(
|
||||
'decision',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
{technical?.reviews.map((t) => (
|
||||
<p
|
||||
key={t.id}
|
||||
className="mb-3 rounded-lg border p-3 text-sm"
|
||||
>
|
||||
<option value="approved">
|
||||
Validar tecnicamente
|
||||
</option>
|
||||
<option value="rejected">
|
||||
Rejeitar tecnicamente
|
||||
</option>
|
||||
</select>
|
||||
<label className="grid gap-2 text-sm">
|
||||
Fundamento técnico
|
||||
<textarea
|
||||
required
|
||||
{t.decision === 'approved'
|
||||
? 'Validado'
|
||||
: 'Rejeitado'}{' '}
|
||||
por {t.snapshot.reviewer.name} ·{' '}
|
||||
{t.basis_hash === technical.basis_hash
|
||||
? 'Versão actual'
|
||||
: 'Versão anterior, decisão preservada'}{' '}
|
||||
· {t.reason}
|
||||
</p>
|
||||
))}
|
||||
{technical?.canReview && (
|
||||
<form
|
||||
className="grid gap-3"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
review.transform((d) => ({
|
||||
...d,
|
||||
basis_hash: technical.basis_hash,
|
||||
}));
|
||||
review.post(
|
||||
`/requisicoes/${r.id}/validacao-tecnica`,
|
||||
);
|
||||
}}
|
||||
>
|
||||
<select
|
||||
aria-label="Decisão técnica"
|
||||
className={controlClass}
|
||||
value={review.data.reason}
|
||||
value={review.data.decision}
|
||||
onChange={(e) =>
|
||||
review.setData(
|
||||
'reason',
|
||||
'decision',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<FormErrors errors={review.errors} />
|
||||
<Button disabled={review.processing}>
|
||||
Registar decisão técnica
|
||||
</Button>
|
||||
</form>
|
||||
)}
|
||||
</Panel>
|
||||
)}
|
||||
>
|
||||
<option value="approved">
|
||||
Validar tecnicamente
|
||||
</option>
|
||||
<option value="rejected">
|
||||
Rejeitar tecnicamente
|
||||
</option>
|
||||
</select>
|
||||
<label className="grid gap-2 text-sm">
|
||||
Fundamento técnico
|
||||
<textarea
|
||||
required
|
||||
className={controlClass}
|
||||
value={review.data.reason}
|
||||
onChange={(e) =>
|
||||
review.setData(
|
||||
'reason',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<FormErrors errors={review.errors} />
|
||||
<Button disabled={review.processing}>
|
||||
Registar decisão técnica
|
||||
</Button>
|
||||
</form>
|
||||
)}
|
||||
</Panel>
|
||||
)}
|
||||
{conflictBlocked && (
|
||||
<div className="rounded-lg border border-amber-200 bg-amber-50 p-4 text-sm text-amber-900 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-100">
|
||||
Existe um conflito de interesses activo que impede a
|
||||
@@ -302,32 +310,49 @@ export default function Show({
|
||||
.
|
||||
</div>
|
||||
)}
|
||||
{canEdit && (
|
||||
<div className="flex flex-wrap items-center justify-between gap-4 rounded-xl border bg-muted/30 p-5">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Confira o pedido antes de o enviar para aprovação.
|
||||
</p>
|
||||
<div className="flex gap-2">
|
||||
<Button asChild variant="outline">
|
||||
<Link href={`/requisicoes/${r.id}/editar`}>
|
||||
<Pencil className="size-4" />
|
||||
Editar
|
||||
</Link>
|
||||
</Button>
|
||||
<Button
|
||||
disabled={submission.processing}
|
||||
onClick={() =>
|
||||
submission.post(
|
||||
`/requisicoes/${r.id}/submeter`,
|
||||
)
|
||||
}
|
||||
{canEdit &&
|
||||
(r.draft_input?.incomplete ? (
|
||||
<div role="status" className="rounded-xl border p-5">
|
||||
<p>
|
||||
Rascunho incompleto guardado. Os montantes estão
|
||||
por completar; não há submissão nem reserva
|
||||
orçamental. As linhas anteriormente completas
|
||||
não representam esta preparação.
|
||||
</p>
|
||||
<Link
|
||||
className="mt-3 inline-block underline"
|
||||
href={`/requisicoes/${r.id}/editar`}
|
||||
>
|
||||
<Send className="size-4" />
|
||||
Submeter para aprovação
|
||||
</Button>
|
||||
Continuar a preparação
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
) : (
|
||||
<div className="flex flex-wrap items-center justify-between gap-4 rounded-xl border bg-muted/30 p-5">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Confira o pedido antes de o enviar para
|
||||
aprovação.
|
||||
</p>
|
||||
<div className="flex gap-2">
|
||||
<Button asChild variant="outline">
|
||||
<Link href={`/requisicoes/${r.id}/editar`}>
|
||||
<Pencil className="size-4" />
|
||||
Editar
|
||||
</Link>
|
||||
</Button>
|
||||
<Button
|
||||
disabled={submission.processing}
|
||||
onClick={() =>
|
||||
submission.post(
|
||||
`/requisicoes/${r.id}/submeter`,
|
||||
)
|
||||
}
|
||||
>
|
||||
<Send className="size-4" />
|
||||
Submeter para aprovação
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
<div className="grid gap-6 lg:grid-cols-3">
|
||||
<div className="space-y-6 lg:col-span-2">
|
||||
<Panel title="Detalhes do pedido">
|
||||
@@ -337,8 +362,9 @@ export default function Show({
|
||||
Centro de custo
|
||||
</dt>
|
||||
<dd className="mt-1 font-medium">
|
||||
{r.cost_center?.code} ·{' '}
|
||||
{r.cost_center?.name}
|
||||
{r.cost_center
|
||||
? `${r.cost_center.code} · ${r.cost_center.name}`
|
||||
: 'Por completar'}
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
@@ -367,85 +393,106 @@ export default function Show({
|
||||
</div>
|
||||
</dl>
|
||||
</Panel>
|
||||
<Panel
|
||||
title="Artigos e valores"
|
||||
description="Moeda: MZN · Montantes estimados"
|
||||
>
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-left text-sm">
|
||||
<thead className="border-b text-xs text-muted-foreground">
|
||||
<tr>
|
||||
<th className="pb-3">Artigo</th>
|
||||
<th className="pr-3">Qtd.</th>
|
||||
<th className="pr-3">
|
||||
Preço s/ IVA
|
||||
</th>
|
||||
<th className="pr-3">IVA</th>
|
||||
<th className="text-right">
|
||||
Total c/ IVA
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{r.items.map((i) => (
|
||||
<tr key={i.id} className="border-b">
|
||||
<td className="py-4 pr-4">
|
||||
<p className="font-medium">
|
||||
{i.description}
|
||||
</p>
|
||||
<p className="mt-1 text-xs text-muted-foreground">
|
||||
{i.category}
|
||||
</p>
|
||||
{i.equipment_id && (
|
||||
<p className="mt-1 text-xs">
|
||||
Equipamento #
|
||||
{i.equipment_id} ·
|
||||
Peça #
|
||||
{i.spare_part_id}
|
||||
{i.downtime_started_at &&
|
||||
` · Paragem: ${i.downtime_started_at} UTC`}
|
||||
</p>
|
||||
)}
|
||||
{i.production_area && (
|
||||
<p className="mt-1 text-xs">
|
||||
Área de destino:{' '}
|
||||
{i.production_area}
|
||||
</p>
|
||||
)}
|
||||
</td>
|
||||
<td className="pr-3 whitespace-nowrap">
|
||||
{Number(i.quantity)}{' '}
|
||||
{i.unit}
|
||||
</td>
|
||||
<td className="pr-3 whitespace-nowrap">
|
||||
{money(i.unit_price_minor)}
|
||||
</td>
|
||||
<td className="pr-3">
|
||||
{Number(i.tax_rate)}%
|
||||
</td>
|
||||
<td className="text-right whitespace-nowrap">
|
||||
{money(i.total_minor)}
|
||||
</td>
|
||||
{r.draft_input?.incomplete ? (
|
||||
<Panel title="Linhas em preparação">
|
||||
<p>
|
||||
Os valores ainda não estão completos. Abra
|
||||
«Continuar a preparação» para recuperar as
|
||||
linhas guardadas. Não são apresentados
|
||||
totais estimados nem linhas antigas como
|
||||
valores desta preparação.
|
||||
</p>
|
||||
</Panel>
|
||||
) : (
|
||||
<Panel
|
||||
title="Artigos e valores"
|
||||
description="Moeda: MZN · Montantes estimados"
|
||||
>
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-left text-sm">
|
||||
<thead className="border-b text-xs text-muted-foreground">
|
||||
<tr>
|
||||
<th className="pb-3">Artigo</th>
|
||||
<th className="pr-3">Qtd.</th>
|
||||
<th className="pr-3">
|
||||
Preço s/ IVA
|
||||
</th>
|
||||
<th className="pr-3">IVA</th>
|
||||
<th className="text-right">
|
||||
Total c/ IVA
|
||||
</th>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<dl className="mt-5 ml-auto max-w-xs space-y-3 text-sm">
|
||||
<div className="flex justify-between">
|
||||
<dt>Subtotal sem IVA</dt>
|
||||
<dd>{money(r.subtotal_minor)}</dd>
|
||||
</thead>
|
||||
<tbody>
|
||||
{r.items.map((i) => (
|
||||
<tr
|
||||
key={i.id}
|
||||
className="border-b"
|
||||
>
|
||||
<td className="py-4 pr-4">
|
||||
<p className="font-medium">
|
||||
{i.description}
|
||||
</p>
|
||||
<p className="mt-1 text-xs text-muted-foreground">
|
||||
{i.category}
|
||||
</p>
|
||||
{i.equipment_id && (
|
||||
<p className="mt-1 text-xs">
|
||||
Equipamento #
|
||||
{i.equipment_id}{' '}
|
||||
· Peça #
|
||||
{
|
||||
i.spare_part_id
|
||||
}
|
||||
{i.downtime_started_at &&
|
||||
` · Paragem: ${i.downtime_started_at} UTC`}
|
||||
</p>
|
||||
)}
|
||||
{i.production_area && (
|
||||
<p className="mt-1 text-xs">
|
||||
Área de destino:{' '}
|
||||
{
|
||||
i.production_area
|
||||
}
|
||||
</p>
|
||||
)}
|
||||
</td>
|
||||
<td className="pr-3 whitespace-nowrap">
|
||||
{Number(i.quantity)}{' '}
|
||||
{i.unit}
|
||||
</td>
|
||||
<td className="pr-3 whitespace-nowrap">
|
||||
{money(
|
||||
i.unit_price_minor,
|
||||
)}
|
||||
</td>
|
||||
<td className="pr-3">
|
||||
{Number(i.tax_rate)}%
|
||||
</td>
|
||||
<td className="text-right whitespace-nowrap">
|
||||
{money(i.total_minor)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<dt>IVA</dt>
|
||||
<dd>{money(r.tax_minor)}</dd>
|
||||
</div>
|
||||
<div className="flex justify-between border-t pt-3 text-base font-semibold">
|
||||
<dt>Total com IVA</dt>
|
||||
<dd>{money(r.total_minor)}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</Panel>
|
||||
<dl className="mt-5 ml-auto max-w-xs space-y-3 text-sm">
|
||||
<div className="flex justify-between">
|
||||
<dt>Subtotal sem IVA</dt>
|
||||
<dd>{money(r.subtotal_minor)}</dd>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<dt>IVA</dt>
|
||||
<dd>{money(r.tax_minor)}</dd>
|
||||
</div>
|
||||
<div className="flex justify-between border-t pt-3 text-base font-semibold">
|
||||
<dt>Total com IVA</dt>
|
||||
<dd>{money(r.total_minor)}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</Panel>
|
||||
)}
|
||||
{canDecide && (
|
||||
<Panel
|
||||
title="Registar decisão"
|
||||
|
||||
Reference in New Issue
Block a user