@@ -0,0 +1,97 @@
|
||||
import { controlClass } from '@/components/procurement';
|
||||
|
||||
export type BudgetDistributionInput = {
|
||||
allocation_key: string;
|
||||
line_id: number;
|
||||
centre_id: number;
|
||||
subtotal: string;
|
||||
total: string;
|
||||
};
|
||||
export type BudgetDistributionOption = BudgetDistributionInput & {
|
||||
line_label: string;
|
||||
centre_label: string;
|
||||
};
|
||||
|
||||
export default function BudgetDistributionFields({
|
||||
options,
|
||||
rows,
|
||||
onChange,
|
||||
reason,
|
||||
onReason,
|
||||
}: {
|
||||
options: BudgetDistributionOption[];
|
||||
rows: BudgetDistributionInput[];
|
||||
onChange: (rows: BudgetDistributionInput[]) => void;
|
||||
reason: string;
|
||||
onReason: (reason: string) => void;
|
||||
}) {
|
||||
return (
|
||||
<fieldset className="space-y-4 rounded border p-4">
|
||||
<legend>Distribuição explícita em MZN</legend>
|
||||
<p className="text-sm">
|
||||
Confira o valor sem IVA e o total de cada parcela com o
|
||||
documento actual. As parcelas conservam os artigos e centros
|
||||
aprovados. Nenhuma diferença será distribuída automaticamente.
|
||||
</p>
|
||||
{rows.map((row, index) => {
|
||||
const option = options.find(
|
||||
(item) => item.allocation_key === row.allocation_key,
|
||||
);
|
||||
return (
|
||||
<fieldset
|
||||
key={row.allocation_key}
|
||||
className="grid gap-3 sm:grid-cols-2"
|
||||
>
|
||||
<legend className="text-sm font-medium">
|
||||
{option?.line_label} · {option?.centre_label}
|
||||
</legend>
|
||||
{(['subtotal', 'total'] as const).map((field) => (
|
||||
<label key={field}>
|
||||
{field === 'subtotal'
|
||||
? 'Sem IVA (MZN)'
|
||||
: 'Total (MZN)'}
|
||||
<input
|
||||
required
|
||||
inputMode="decimal"
|
||||
pattern="[0-9]+([.][0-9]{1,2})?"
|
||||
className={controlClass}
|
||||
value={row[field]}
|
||||
onChange={(event) =>
|
||||
onChange(
|
||||
rows.map((item, i) =>
|
||||
i === index
|
||||
? {
|
||||
...item,
|
||||
[field]:
|
||||
event.target
|
||||
.value,
|
||||
}
|
||||
: item,
|
||||
),
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
))}
|
||||
</fieldset>
|
||||
);
|
||||
})}
|
||||
<label>
|
||||
Motivo da imputação
|
||||
<textarea
|
||||
required
|
||||
minLength={10}
|
||||
maxLength={4000}
|
||||
className={controlClass}
|
||||
value={reason}
|
||||
onChange={(event) => onReason(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<p className="text-sm">
|
||||
Use ponto para separar os centavos. Se a referência cambial ou a
|
||||
conferência tiver mudado, os valores terão de ser novamente
|
||||
conferidos.
|
||||
</p>
|
||||
</fieldset>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user