import { Link } from '@inertiajs/react'; import { Panel } from '@/components/procurement'; import { money, roleLabels } from '@/types/procurement'; export type OrderPartFrame = { requisition: { id: number; number: string }; department: { name: string }; cost_center: { code: string; name: string }; quotation: { reference: string; currency: string; payment_terms: string }; award: { delivery_date: string; delivery_location: string; justification?: string; }; native_preparation: { approved_reference?: { subtotal_minor: number; total_minor: number }; items: { quotation_item_id: number; description: string; quantity_milli: number; approved_quantity_milli?: number; total_minor: number; }[]; }; approval_rules?: { approval_includes_tax: boolean }; final_approvals?: { id: number; role: string; approver_id: number | null; decision: string; }[]; }; export function OrderPartsSummary({ sources }: { sources: OrderPartFrame[] }) { if (sources.length === 0) return null; return (

Cada linha conserva a adjudicação original. Quantidades e IVA usam os arredondamentos cumulativos da origem; o documento mostra apenas as parcelas emitidas nesta ordem.

{sources.map((source) => (

{source.requisition.number}

{source.department.name} · {source.cost_center.code}{' '} · {source.cost_center.name}

Proposta {source.quotation.reference} · Pagamento:{' '} {source.quotation.payment_terms}

Entrega: {source.award.delivery_date} ·{' '} {source.award.delivery_location}

{source.native_preparation.approved_reference && (

Base aprovada da origem:{' '} {money( source.approval_rules ?.approval_includes_tax === false ? source.native_preparation .approved_reference.subtotal_minor : source.native_preparation .approved_reference.total_minor, 'MZN', )}{' '} ( {source.approval_rules ?.approval_includes_tax === false ? 'sem IVA' : 'com IVA'} ).

)} {source.award.justification && (

Fundamento: {source.award.justification}

)} Consultar a adjudicação desta origem {(source.final_approvals ?? []).map((step) => (

{Object.entries(roleLabels).find( ([role]) => role === step.role, )?.[1] ?? step.role}{' '} ·{' '} {step.decision === 'approved' ? 'Aprovado' : step.decision === 'rejected' ? 'Rejeitado' : 'Pendente'}{' '} · Interveniente #{step.approver_id}

))} {source.native_preparation.items.map((line) => (

{line.description}: emitido{' '} {line.quantity_milli / 1000} {line.approved_quantity_milli === undefined ? '' : ` de ${line.approved_quantity_milli / 1000} aprovado(s)`}{' '} ·{' '} {money( line.total_minor, source.quotation.currency, )}

))}
))}
); }