fix: complete InvesteMoz validation and error corrections
This commit is contained in:
@@ -1,9 +1,163 @@
|
||||
import type {FiscalClaimEvents} from '@/lib/fiscal-claim-events';
|
||||
export function FiscalClaimEventsFields({value:r,onChange}:{value:FiscalClaimEvents;onChange:(p:Partial<FiscalClaimEvents>)=>void}){return<>
|
||||
<label>Referência do pedido ou preparação<input value={r.requestReference} onChange={e=>onChange({requestReference:e.target.value})}/></label><label>Data do pedido ou prevista<input type="date" value={r.requestDate} onChange={e=>onChange({requestDate:e.target.value})}/></label>
|
||||
<label>Situação do pedido<select value={r.stage} onChange={e=>onChange({stage:e.target.value as FiscalClaimEvents['stage']})}><option value="preparation">Em preparação — sem submissão</option><option value="submitted">Apresentado fora doInvesteMoz — registo declarado</option></select></label>
|
||||
<label>Decisão recebida<select value={r.decision} onChange={e=>onChange({decision:e.target.value as FiscalClaimEvents['decision']})}><option value="pending">Ainda não identificada</option><option value="approved">Deferimento integral</option><option value="partial">Deferimento parcial</option><option value="rejected">Indeferimento</option></select></label>
|
||||
{r.decision!=='pending'&&<><label>Número ou referência da decisão<input value={r.decisionReference} onChange={e=>onChange({decisionReference:e.target.value})}/></label><label>Data da decisão<input type="date" value={r.decisionDate} onChange={e=>onChange({decisionDate:e.target.value})}/></label><label>Entidade emitente da decisão<input value={r.decisionIssuer} onChange={e=>onChange({decisionIssuer:e.target.value})}/></label><label>Montante reconhecido na decisão (MZN)<input value={r.approvedAmount} onChange={e=>onChange({approvedAmount:e.target.value})}/></label></>}
|
||||
{r.receipts.map(p=><fieldset key={p.id}><legend>Recebimento identificado</legend>{(['reference','date','amount']as const).map(k=><label key={k}>{k==='reference'?'Referência do recebimento':k==='date'?'Data do recebimento':'Montante recebido (MZN)'}<input type={k==='date'?'date':'text'} value={p[k]} onChange={e=>onChange({receipts:r.receipts.map(q=>q.id===p.id?{...q,[k]:e.target.value}:q)})}/></label>)}<button type="button" onClick={()=>onChange({receipts:r.receipts.filter(q=>q.id!==p.id)})}>Remover recebimento desta preparação</button></fieldset>)}
|
||||
<button type="button" onClick={()=>onChange({receipts:[...r.receipts,{id:crypto.randomUUID(),reference:'',date:'',amount:''}]})}>Registar recebimento identificado</button>
|
||||
</>;}
|
||||
import type { FiscalClaimEvents } from '@/lib/fiscal-claim-events';
|
||||
export function FiscalClaimEventsFields({
|
||||
value: r,
|
||||
onChange,
|
||||
}: {
|
||||
value: FiscalClaimEvents;
|
||||
onChange: (p: Partial<FiscalClaimEvents>) => void;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<label>
|
||||
Referência do pedido ou preparação
|
||||
<input
|
||||
value={r.requestReference}
|
||||
onChange={(e) =>
|
||||
onChange({ requestReference: e.target.value })
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Data do pedido ou prevista
|
||||
<input
|
||||
type="date"
|
||||
value={r.requestDate}
|
||||
onChange={(e) => onChange({ requestDate: e.target.value })}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Situação do pedido
|
||||
<select
|
||||
value={r.stage}
|
||||
onChange={(e) =>
|
||||
onChange({
|
||||
stage: e.target.value as FiscalClaimEvents['stage'],
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="preparation">
|
||||
Em preparação — sem submissão
|
||||
</option>
|
||||
<option value="submitted">
|
||||
Apresentado fora doInvesteMoz — registo declarado
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Decisão recebida
|
||||
<select
|
||||
value={r.decision}
|
||||
onChange={(e) =>
|
||||
onChange({
|
||||
decision: e.target
|
||||
.value as FiscalClaimEvents['decision'],
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="pending">Ainda não identificada</option>
|
||||
<option value="approved">Deferimento integral</option>
|
||||
<option value="partial">Deferimento parcial</option>
|
||||
<option value="rejected">Indeferimento</option>
|
||||
</select>
|
||||
</label>
|
||||
{r.decision !== 'pending' && (
|
||||
<>
|
||||
<label>
|
||||
Número ou referência da decisão
|
||||
<input
|
||||
value={r.decisionReference}
|
||||
onChange={(e) =>
|
||||
onChange({ decisionReference: e.target.value })
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Data da decisão
|
||||
<input
|
||||
type="date"
|
||||
value={r.decisionDate}
|
||||
onChange={(e) =>
|
||||
onChange({ decisionDate: e.target.value })
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Entidade emitente da decisão
|
||||
<input
|
||||
value={r.decisionIssuer}
|
||||
onChange={(e) =>
|
||||
onChange({ decisionIssuer: e.target.value })
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Montante reconhecido na decisão (MZN)
|
||||
<input
|
||||
value={r.approvedAmount}
|
||||
onChange={(e) =>
|
||||
onChange({ approvedAmount: e.target.value })
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
</>
|
||||
)}
|
||||
{r.receipts.map((p) => (
|
||||
<fieldset key={p.id}>
|
||||
<legend>Recebimento identificado</legend>
|
||||
{(['reference', 'date', 'amount'] as const).map((k) => (
|
||||
<label key={k}>
|
||||
{k === 'reference'
|
||||
? 'Referência do recebimento'
|
||||
: k === 'date'
|
||||
? 'Data do recebimento'
|
||||
: 'Montante recebido (MZN)'}
|
||||
<input
|
||||
type={k === 'date' ? 'date' : 'text'}
|
||||
value={p[k]}
|
||||
onChange={(e) =>
|
||||
onChange({
|
||||
receipts: r.receipts.map((q) =>
|
||||
q.id === p.id
|
||||
? { ...q, [k]: e.target.value }
|
||||
: q,
|
||||
),
|
||||
})
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
))}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
onChange({
|
||||
receipts: r.receipts.filter(
|
||||
(q) => q.id !== p.id,
|
||||
),
|
||||
})
|
||||
}
|
||||
>
|
||||
Remover recebimento desta preparação
|
||||
</button>
|
||||
</fieldset>
|
||||
))}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
onChange({
|
||||
receipts: [
|
||||
...r.receipts,
|
||||
{
|
||||
id: crypto.randomUUID(),
|
||||
reference: '',
|
||||
date: '',
|
||||
amount: '',
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
>
|
||||
Registar recebimento identificado
|
||||
</button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user