import type { GeographyDescription } from '@/components/administrative-location'; import { Head, Link } from '@inertiajs/react'; import { PageTitle, Panel } from '@/components/procurement'; import { quantity, warehouseStateLabels } from '@/types/inventory'; import { statusLabels } from '@/types/procurement'; type Page = { data: T[]; total: number; current_page: number; last_page: number; prev_page_url: string | null; next_page_url: string | null; }; type Purchase = { id: number; number: string; status: string; needed_by: string; items: { id: number; description: string; quantity: string; unit: string; }[]; }; type Movement = { id: number; kind: string; reference: string; recorded_at: string; quantity_milli: number; item: { code: string; name: string; unit: string } | null; warehouse: { code: string; name: string } | null; }; function Pages({ page, label }: { page: Page; label: string }) { return ( ); } export default function EquipmentShow({ equipment, geography = null, purchases, movements, warehouseRequests = null, }: { geography?: GeographyDescription; equipment: { id: number; code: string; description: string; area: string; status: string; }; purchases: Page; movements: Page; warehouseRequests?: Page<{ id: number; state: string; version: number; reservation_ready: boolean; lines: { line: number; item: { code: string; name: string; unit: string }; destination: string; requested_milli: number; reserved_milli: number; delivered_milli: number; remaining_milli: number; cancelled_milli: number; }[]; }> | null; }) { return ( <>
Voltar a Equipamentos e peças {geography && (

{geography.path .map((node) => node.name) .join(' / ')}

Referência actual do cadastro. Os documentos e movimentos anteriores conservam os seus dados de origem.

)}

Estas quantidades representam pedidos de compra. Não comprovam recepção, entrega ao equipamento ou consumo. Cada processo conserva as suas aprovações.

{purchases.data.map((purchase) => (
{purchase.number}

Estado do processo:{' '} {statusLabels[purchase.status] ?? purchase.status}{' '} · Necessário até {purchase.needed_by}

{purchase.items.map((item) => (

{item.description} · Pedido: {item.quantity}{' '} {item.unit}

))}
))} {!purchases.data.length && (

Sem requisições associadas que possa consultar.

)}

Pedidos e reservas para este equipamento, conforme os seus acessos ao armazém. As entregas acumuladas não descontam devoluções ou correcções posteriores.

{warehouseRequests === null ? (

Consulta indisponível para o seu acesso ou nesta instalação.

) : ( <> {warehouseRequests.data.map((record) => (
RA-{record.id}

{warehouseStateLabels[record.state] ?? record.state}{' '} · Versão {record.version}

{record.lines.map((line) => (

{line.item.code} ·{' '} {line.item.name} ·{' '} {line.destination}

Pedida:{' '} {quantity(line.requested_milli)}{' '} {line.item.unit} · Reservada agora:{' '} {record.reservation_ready ? quantity( line.reserved_milli, ) : 'Indisponível'}{' '} · Entregue acumulada:{' '} {quantity(line.delivered_milli)}{' '} · Por entregar:{' '} {quantity(line.remaining_milli)}{' '} · Cancelada:{' '} {quantity(line.cancelled_milli)}

))}
))} {!warehouseRequests.data.length && (

Sem requisições internas visíveis para este equipamento.

)} )}

Documentos originais ligados ao equipamento, pela ordem de registo. Um estorno tem documento próprio; estas quantidades não são um saldo nem comprovam consumo técnico.

{movements.data.map((movement) => (

{movement.reference} ·{' '} {movement.kind === 'issue' ? 'Saída' : movement.kind === 'reversal' ? 'Estorno' : movement.kind}

{movement.recorded_at} ·{' '} {movement.warehouse?.code}{' '} {movement.warehouse?.name}

{movement.item?.code} · {movement.item?.name} · Quantidade do documento:{' '} {quantity(movement.quantity_milli)}{' '} {movement.item?.unit}

))} {!movements.data.length && (

Sem movimentos físicos registados para este equipamento.

)}
); } EquipmentShow.layout = { breadcrumbs: [ { title: 'Equipamentos', href: '/equipamentos' }, { title: 'Acompanhamento', href: '#' }, ], };