import { useState } from 'react'; import type { CurrencyEventRow } from '@/lib/iva-currency-events'; import { emptyFxSelection, selectFx, fxTempoSource, type FxSelection, } from '@/lib/iva-fx-selection'; const columnLabels: Record = { buy: 'Compra', sell: 'Venda', mean: 'Média de referência BM', exception: 'Excepção fiscal identificada', }; const directionLabels: Record = { mzn_per_unit: 'MZN por unidade da moeda original', units_per_mzn: 'unidades da moeda original por MZN', }; export function SimulationFxSelection({ row, onChange, }: { row: CurrencyEventRow; onChange: (patch: Partial) => void; }) { const [error, setError] = useState(''), [preview, setPreview] = useState | null>( null, ); const s = row.fxSelection ?? { ...emptyFxSelection(), sourceCurrency: row.sourceCurrency, direction: row.fxDirection, }; const edit = (patch: Partial) => { setPreview(null); onChange({ fxSelection: { ...s, ...patch } }); }; const text = ( key: | 'submissionDate' | 'bulletinDate' | 'bulletinRef' | 'source' | 'sourceCurrency' | 'bulletinPerspective' | 'buy' | 'sell' | 'mean' | 'exceptionRef' | 'exceptionScope' | 'exceptionDate' | 'exceptionRate', label: string, ) => ( ); return (
P104 — selecção da taxa segundo orientação da Tempo

{fxTempoSource}

{text('submissionDate', 'Data de submissão indicada')} {text('sourceCurrency', 'Moeda original já declarada')} {text('bulletinRef', 'Boletim,edição e série de referência')} {text( 'source', 'Fonte do boletim;URL do Banco de Moçambique para operações comerciais', )} {text('bulletinDate', 'Data do boletim')} {s.mode === 'exception' ? ( <> {text( 'exceptionRef', 'Disposição fiscal que impõe outra data/taxa', )} {text('exceptionScope', 'Âmbito da excepção')} {text('exceptionDate', 'Data imposta pela disposição')} {text( 'exceptionRate', 'Taxa da excepção,com fonte no boletim indicado', )} ) : s.nature === 'commercial' ? ( text( 'mean', 'Coluna Média da série de referênciaBM;sem calcular média própria', ) ) : ( <> {text( 'bulletinPerspective', 'Perspectiva de compra/venda indicada no boletim', )} {text('buy', 'Taxa da coluna Compra do boletim')} {text('sell', 'Taxa da coluna Venda do boletim')} )} {error &&

{error}

} {preview && (

Coluna:{columnLabels[preview.column]};taxa: {preview.rate};data:{preview.date};sentido: {directionLabels[s.direction]}. Confirmação substitui os campos cambiais desta linha:{row.fxRate || 'taxa vazia'}{' '} → {preview.rate};{row.fxDate || 'data vazia'} →{' '} {preview.date};{row.sourceCurrency || 'moeda vazia'} →{' '} {s.sourceCurrency}. O resultado e os históricos permanecem até usar «Conferir moeda/eventos e guardar versão».

)}

Não usar taxa de apresentação nem a mais recente como substituto de boletim ausente. Compra/venda são interpretadas pela perspectiva indicada;relação desconhecida fica por esclarecer. Alterações não recalculam versões anteriores.

); }