import { inputText } from '../lib/input-text.ts'; import { useState } from 'react'; import { objectiveImportBook, objectiveImportCurrent, objectiveImportReportRows, objectiveImportSource, objectiveImportSources, objectiveImportTreatments, newObjectiveImport, reuseObjectiveImport, recordObjectiveImports, saveObjectiveImportBook, type ObjectiveImportBook, type ObjectiveImportRow, } from '@/lib/iva-objective-imports'; import { annexIEntries } from '@/lib/iva-annex-i'; import { pharmaAnnexEntries } from '@/lib/iva-pharma-annex'; export function SimulationObjectiveImports({ draft, onChange, }: { draft: Record; onChange: (field: string, value: string) => void; }) { const [error, setError] = useState(''); let book: ObjectiveImportBook; try { book = objectiveImportBook(draft); } catch (e) { return

{String(e)}

; } const save = (next: ObjectiveImportBook) => { try { onChange('modelo_a_snapshot', saveObjectiveImportBook(draft, next)); setError(''); } catch (e) { setError(String(e)); } }; const change = (id: string, patch: Partial) => save({ ...book, rows: book.rows.map((r) => (r.id === id ? { ...r, ...patch } : r)), }); let sources: ReturnType = []; try { sources = objectiveImportSources(draft); } catch { /* Preserve unrecoverable source; direct entry remains independent. */ } return (
Importações definitivas — isenção objectiva interna (P046)

Analise a transmissão interna hipotética dos mesmos bens. Não é necessário criar uma venda interna. A enumeração legal é exemplificativa; este percurso cobre as correspondências expressas implementadas. Outros fundamentos permanecem por enquadrar.

{objectiveImportSource}

{error &&

{error}

} {book.rows.map((row) => { const rule = objectiveImportTreatments.find( (t) => t.id === row.reference.treatment, ); return (
{row.description || 'Importação por preparar'} —{' '} {row.period || 'período por indicar'} {!!sources.length && ( )} {( [ 'description', 'period', 'importer', 'documentRef', 'documentDate', 'scope', 'evidence', ] as const ).map((field, i) => ( ))} {( [ 'definitive', 'goods', 'sameGoods', 'internalApplicable', ] as const ).map((field, i) => ( ))} {rule && ( <>

{rule.article}. As condições seguintes referem-se à hipótese de transmissão no território nacional dos bens identificados; não ao fornecedor estrangeiro. Trocar correspondência conserva anexos em rascunho e limpa confirmações.

{rule.conditions.map((condition, i) => ( ))} )} {row.reference.treatment === 'annexI_goods' && ( <> )} {row.reference.treatment === 'pharma_manufacturing_inputs' && ( )}
); })} {!!book.rows.length && ( )} {book.result && ( <>

{objectiveImportCurrent(draft, book) ? 'Resultado corresponde às entradas guardadas.' : 'Entradas alteradas;resultado histórico conservado.'}{' '} {book.history?.length ?? 0} versões anteriores. Sem dedução ou soma aos livros internos.

{objectiveImportReportRows(draft).map( ([, label, value, origin], i) => (
{label}
{value} {origin}
), )}
)}
); }