@@ -1,4 +1,7 @@
|
||||
import { Head, Link, useForm } from '@inertiajs/react';
|
||||
import { Head, Link, useForm, usePage } from '@inertiajs/react';
|
||||
import BudgetDistributionFields, {
|
||||
type BudgetDistributionOption,
|
||||
} from '@/components/budget-distribution-fields';
|
||||
import AgreementOrderBindings, {
|
||||
type OrderAgreementBinding,
|
||||
type OrderAgreementOption,
|
||||
@@ -19,11 +22,12 @@ import { money, roleLabels, date } from '@/types/procurement';
|
||||
import type { MatrixRow, PurchaseAward } from '@/types/purchase';
|
||||
|
||||
type Props = {
|
||||
budgetDistributionOptions?: BudgetDistributionOption[] | null;
|
||||
agreementOrderLimitsReady?: boolean;
|
||||
agreementOptions?: OrderAgreementOption[];
|
||||
agreementLines?: OrderAgreementLine[];
|
||||
agreementSearch?: string;
|
||||
requisition: { id: number; number: string };
|
||||
requisition: { id: number; number: string; process_version?: number };
|
||||
comparison: {
|
||||
rows: MatrixRow[];
|
||||
ready: boolean;
|
||||
@@ -50,17 +54,51 @@ export default function Award({
|
||||
agreementOptions = [],
|
||||
agreementLines = [],
|
||||
agreementSearch = '',
|
||||
budgetDistributionOptions = null,
|
||||
}: Props) {
|
||||
const selection = useForm({
|
||||
quotation_id: '',
|
||||
justification: '',
|
||||
delivery_date: '',
|
||||
delivery_location: '',
|
||||
});
|
||||
const actor = usePage().props.auth?.user;
|
||||
const selection = useForm(
|
||||
`award-selection:${actor?.tenant_id}:${actor?.id}:${requisition.id}:${requisition.process_version ?? 0}`,
|
||||
{
|
||||
quotation_id: '',
|
||||
justification: '',
|
||||
delivery_date: '',
|
||||
delivery_location: '',
|
||||
...(budgetDistributionOptions === null
|
||||
? {}
|
||||
: {
|
||||
budget_distribution_preparation:
|
||||
budgetDistributionOptions.map(
|
||||
({
|
||||
allocation_key,
|
||||
line_id,
|
||||
centre_id,
|
||||
subtotal,
|
||||
total,
|
||||
}) => ({
|
||||
allocation_key,
|
||||
line_id,
|
||||
centre_id,
|
||||
subtotal,
|
||||
total,
|
||||
}),
|
||||
),
|
||||
reason: '',
|
||||
}),
|
||||
},
|
||||
);
|
||||
const decision = useForm({ decision: 'approved', comment: '' });
|
||||
const issue = useForm({
|
||||
agreement_bindings: [] as OrderAgreementBinding[],
|
||||
});
|
||||
const selectedQuote = comparison.rows.find(
|
||||
(row) => String(row.id) === selection.data.quotation_id,
|
||||
);
|
||||
const selectedReference =
|
||||
selectedQuote?.reference_amounts ??
|
||||
(selectedQuote && (selectedQuote.currency ?? 'MZN') === 'MZN'
|
||||
? selectedQuote
|
||||
: null);
|
||||
return (
|
||||
<>
|
||||
<Head title={`Adjudicação · ${requisition.number}`} />
|
||||
@@ -81,9 +119,12 @@ export default function Award({
|
||||
/>
|
||||
<div className="rounded-xl border border-amber-200 bg-amber-50 p-5 text-sm text-amber-900 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-100">
|
||||
Ambiente de desenvolvimento: os documentos não autorizam
|
||||
compras reais. O orçamento ainda não é verificado. Excepções
|
||||
à regra preservada neste processo ou à maior pontuação
|
||||
exigem um circuito próprio de revisão.
|
||||
compras reais.{' '}
|
||||
{budgetDistributionOptions === null
|
||||
? 'O orçamento ainda não é verificado.'
|
||||
: 'O saldo de cada parcela é conferido no controlo orçamental.'}{' '}
|
||||
Excepções à regra preservada neste processo ou à maior
|
||||
pontuação exigem um circuito próprio de revisão.
|
||||
</div>
|
||||
<Panel
|
||||
title="Comparação actual"
|
||||
@@ -201,12 +242,14 @@ export default function Award({
|
||||
className={controlClass}
|
||||
required
|
||||
value={selection.data.quotation_id}
|
||||
onChange={(e) =>
|
||||
onChange={(e) => {
|
||||
selection.setData(
|
||||
'quotation_id',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
);
|
||||
if (budgetDistributionOptions !== null)
|
||||
selection.setData('reason', '');
|
||||
}}
|
||||
>
|
||||
<option value="">
|
||||
Seleccione uma proposta no topo
|
||||
@@ -233,6 +276,37 @@ export default function Award({
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
{budgetDistributionOptions !== null &&
|
||||
selection.data.quotation_id !== '' && (
|
||||
<div className="space-y-3">
|
||||
<p>
|
||||
{selectedReference
|
||||
? `Referência da proposta em MZN: sem IVA ${money(selectedReference.subtotal_minor, 'MZN')} · total ${money(selectedReference.total_minor, 'MZN')}. Confira as parcelas abaixo.`
|
||||
: 'Referência em MZN indisponível. Confira a proposta e a taxa congelada.'}
|
||||
</p>
|
||||
<BudgetDistributionFields
|
||||
options={budgetDistributionOptions}
|
||||
rows={
|
||||
selection.data
|
||||
.budget_distribution_preparation ??
|
||||
[]
|
||||
}
|
||||
onChange={(rows) =>
|
||||
selection.setData(
|
||||
'budget_distribution_preparation',
|
||||
rows,
|
||||
)
|
||||
}
|
||||
reason={selection.data.reason ?? ''}
|
||||
onReason={(value) =>
|
||||
selection.setData(
|
||||
'reason',
|
||||
value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="award-justification">
|
||||
Justificação da adjudicação
|
||||
@@ -297,7 +371,11 @@ export default function Award({
|
||||
</p>
|
||||
<Button
|
||||
disabled={
|
||||
selection.processing || !comparison.ready
|
||||
selection.processing ||
|
||||
!comparison.ready ||
|
||||
(budgetDistributionOptions !== null &&
|
||||
selectedQuote !== undefined &&
|
||||
selectedReference === null)
|
||||
}
|
||||
>
|
||||
Registar adjudicação para aprovação
|
||||
|
||||
Reference in New Issue
Block a user