@@ -0,0 +1,58 @@
|
||||
import { Panel } from '@/components/procurement';
|
||||
|
||||
export type FrozenImportTariff = {
|
||||
record_id: number;
|
||||
version: number;
|
||||
item: { description: string; quantity: string; unit: string };
|
||||
data: {
|
||||
proposed_code: string | null;
|
||||
confirmed_code: string;
|
||||
source_reference: string | null;
|
||||
confirmation_source: string;
|
||||
deviation: boolean;
|
||||
};
|
||||
confirmed_by: { name: string };
|
||||
reason: string;
|
||||
};
|
||||
export default function ImportTariffSummary({
|
||||
records,
|
||||
}: {
|
||||
records?: Record<number, FrozenImportTariff>;
|
||||
}) {
|
||||
if (!records || !Object.keys(records).length) return null;
|
||||
return (
|
||||
<Panel title="Classificação pautal preservada na emissão">
|
||||
<div className="grid gap-4">
|
||||
{Object.values(records).map((record) => (
|
||||
<dl
|
||||
key={record.record_id}
|
||||
className="rounded border p-3 text-sm"
|
||||
>
|
||||
<dt className="font-medium">
|
||||
{record.item.description}
|
||||
</dt>
|
||||
<dd>
|
||||
Código confirmado: {record.data.confirmed_code} ·
|
||||
versão {record.version} · {record.confirmed_by.name}
|
||||
</dd>
|
||||
<dt>Proposta e fonte</dt>
|
||||
<dd>
|
||||
{record.data.proposed_code ?? 'Não indicada'} ·{' '}
|
||||
{record.data.source_reference ?? 'Por completar'}
|
||||
</dd>
|
||||
<dt>Fonte da confirmação</dt>
|
||||
<dd>{record.data.confirmation_source}</dd>
|
||||
<dt>
|
||||
{record.data.deviation
|
||||
? 'Justificação do desvio'
|
||||
: 'Motivo'}
|
||||
</dt>
|
||||
<dd className="break-words whitespace-pre-wrap">
|
||||
{record.reason}
|
||||
</dd>
|
||||
</dl>
|
||||
))}
|
||||
</div>
|
||||
</Panel>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
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 (
|
||||
<Panel
|
||||
title={
|
||||
sources.length === 1
|
||||
? 'Origem da parcela emitida'
|
||||
: 'Origens preservadas na ordem'
|
||||
}
|
||||
>
|
||||
<p className="mb-4">
|
||||
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.
|
||||
</p>
|
||||
<div className="grid min-w-0 gap-4">
|
||||
{sources.map((source) => (
|
||||
<section
|
||||
key={source.requisition.id}
|
||||
className="grid min-w-0 gap-2 rounded-lg border p-4"
|
||||
>
|
||||
<h3 className="font-semibold">
|
||||
<Link
|
||||
href={`/requisicoes/${source.requisition.id}`}
|
||||
className="underline"
|
||||
>
|
||||
{source.requisition.number}
|
||||
</Link>
|
||||
</h3>
|
||||
<p className="break-words">
|
||||
{source.department.name} · {source.cost_center.code}{' '}
|
||||
· {source.cost_center.name}
|
||||
</p>
|
||||
<p className="break-words">
|
||||
Proposta {source.quotation.reference} · Pagamento:{' '}
|
||||
{source.quotation.payment_terms}
|
||||
</p>
|
||||
<p className="break-words">
|
||||
Entrega: {source.award.delivery_date} ·{' '}
|
||||
{source.award.delivery_location}
|
||||
</p>
|
||||
{source.native_preparation.approved_reference && (
|
||||
<p>
|
||||
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'}
|
||||
).
|
||||
</p>
|
||||
)}
|
||||
{source.award.justification && (
|
||||
<p className="break-words whitespace-pre-wrap">
|
||||
Fundamento: {source.award.justification}
|
||||
</p>
|
||||
)}
|
||||
<Link
|
||||
href={`/requisicoes/${source.requisition.id}/adjudicacao`}
|
||||
className="underline"
|
||||
>
|
||||
Consultar a adjudicação desta origem
|
||||
</Link>
|
||||
{(source.final_approvals ?? []).map((step) => (
|
||||
<p key={step.id} className="text-sm">
|
||||
{Object.entries(roleLabels).find(
|
||||
([role]) => role === step.role,
|
||||
)?.[1] ?? step.role}{' '}
|
||||
·{' '}
|
||||
{step.decision === 'approved'
|
||||
? 'Aprovado'
|
||||
: step.decision === 'rejected'
|
||||
? 'Rejeitado'
|
||||
: 'Pendente'}{' '}
|
||||
· Interveniente #{step.approver_id}
|
||||
</p>
|
||||
))}
|
||||
{source.native_preparation.items.map((line) => (
|
||||
<p
|
||||
key={line.quotation_item_id}
|
||||
className="break-words"
|
||||
>
|
||||
{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,
|
||||
)}
|
||||
</p>
|
||||
))}
|
||||
</section>
|
||||
))}
|
||||
</div>
|
||||
</Panel>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user