@@ -22,6 +22,13 @@ type Financial = {
|
||||
origin: number;
|
||||
award_id: number;
|
||||
requires_adoption: boolean;
|
||||
approved_reference?: { subtotal_minor: number; total_minor: number };
|
||||
adoption_lines?: {
|
||||
line_id: number;
|
||||
description: string;
|
||||
subtotal_minor: number;
|
||||
total_minor: number;
|
||||
}[];
|
||||
version?: number;
|
||||
plan_hash?: string;
|
||||
allocations: {
|
||||
@@ -47,6 +54,12 @@ type Preview = {
|
||||
requisition_number?: string | null;
|
||||
award_id: number;
|
||||
currency: string;
|
||||
reference_amounts?: { subtotal_minor: number; total_minor: number };
|
||||
exchange_basis?: {
|
||||
rate: string;
|
||||
quoted_on: string;
|
||||
source: string;
|
||||
} | null;
|
||||
items: {
|
||||
description: string;
|
||||
quotation_item_id: number;
|
||||
@@ -82,8 +95,28 @@ function useGuard(ref: RefObject<HTMLFormElement | null>, dirty: boolean) {
|
||||
}, [dirty, ref]);
|
||||
}
|
||||
|
||||
function Adoption({ award }: { award: number }) {
|
||||
const form = useForm({ operation_key: crypto.randomUUID() });
|
||||
function Adoption({
|
||||
source,
|
||||
currency,
|
||||
}: {
|
||||
source: Financial;
|
||||
currency: string;
|
||||
}) {
|
||||
const foreign = currency !== 'MZN';
|
||||
const form = useForm({
|
||||
operation_key: crypto.randomUUID(),
|
||||
...(foreign
|
||||
? {
|
||||
reference_lines: (source.adoption_lines ?? []).map(
|
||||
(line) => ({
|
||||
line_id: line.line_id,
|
||||
subtotal: '',
|
||||
total: '',
|
||||
}),
|
||||
),
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
return (
|
||||
<div className="grid gap-3 rounded-lg border p-4">
|
||||
<p>
|
||||
@@ -96,11 +129,73 @@ function Adoption({ award }: { award: number }) {
|
||||
da origem. A adopção não cria dotação nem saldo.
|
||||
</p>
|
||||
<FormErrors errors={form.errors} />
|
||||
{foreign && (
|
||||
<>
|
||||
<p>
|
||||
Confira a referência integral aprovada em MZN antes de
|
||||
transferir a reserva:{' '}
|
||||
{source.approved_reference
|
||||
? money(
|
||||
source.approved_reference.total_minor,
|
||||
'MZN',
|
||||
)
|
||||
: 'Referência por conferir'}
|
||||
. Indique todos os artigos da proposta, mesmo os que não
|
||||
serão emitidos nesta parcela.
|
||||
</p>
|
||||
{(source.adoption_lines ?? []).map((line, index) => (
|
||||
<div
|
||||
key={line.line_id}
|
||||
className="grid gap-3 rounded border p-3 sm:grid-cols-2"
|
||||
>
|
||||
<p className="sm:col-span-2">
|
||||
{line.description} ·{' '}
|
||||
{money(line.total_minor, currency)}
|
||||
</p>
|
||||
{(['subtotal', 'total'] as const).map((field) => (
|
||||
<label key={field} className="grid gap-1">
|
||||
{field === 'subtotal'
|
||||
? 'Sem IVA (MZN)'
|
||||
: 'Com IVA (MZN)'}
|
||||
<Input
|
||||
inputMode="decimal"
|
||||
value={
|
||||
form.data.reference_lines?.[index][
|
||||
field
|
||||
] ?? ''
|
||||
}
|
||||
onChange={(event) =>
|
||||
form.setData(
|
||||
'reference_lines',
|
||||
(
|
||||
form.data.reference_lines ??
|
||||
[]
|
||||
).map((row, i) =>
|
||||
i === index
|
||||
? {
|
||||
...row,
|
||||
[field]:
|
||||
event.target
|
||||
.value,
|
||||
}
|
||||
: row,
|
||||
),
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
<Button
|
||||
type="button"
|
||||
disabled={form.processing}
|
||||
onClick={() =>
|
||||
form.post(`/adjudicacoes/${award}/parcelas/adoptar`)
|
||||
form.post(
|
||||
`/adjudicacoes/${source.award_id}/parcelas/adoptar`,
|
||||
)
|
||||
}
|
||||
>
|
||||
Adoptar a reserva existente
|
||||
@@ -219,8 +314,28 @@ function Prepared({
|
||||
{money(line.total_minor, source.currency)}
|
||||
</p>
|
||||
))}
|
||||
{source.reference_amounts &&
|
||||
source.exchange_basis && (
|
||||
<p className="text-sm break-words">
|
||||
Referência desta origem:{' '}
|
||||
{money(
|
||||
source.reference_amounts
|
||||
.total_minor,
|
||||
'MZN',
|
||||
)}
|
||||
{' · '}Taxa:{' '}
|
||||
{source.exchange_basis.rate}
|
||||
{' · '}
|
||||
{source.exchange_basis.quoted_on}
|
||||
{' · '}
|
||||
{source.exchange_basis.source}
|
||||
</p>
|
||||
)}
|
||||
{preview.financial[index].requires_adoption ? (
|
||||
<Adoption award={source.award_id} />
|
||||
<Adoption
|
||||
source={preview.financial[index]}
|
||||
currency={source.currency}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
@@ -354,8 +469,7 @@ function Prepared({
|
||||
{!preview.can_issue && (
|
||||
<p role="status">
|
||||
Complete a distribuição de todas as origens antes de
|
||||
emitir. A emissão multimoeda por parcelas ainda não
|
||||
está disponível.
|
||||
emitir.
|
||||
</p>
|
||||
)}
|
||||
<p className="text-sm text-muted-foreground">
|
||||
|
||||
Reference in New Issue
Block a user