@@ -14,6 +14,11 @@ import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { money } from '@/types/procurement';
|
||||
import {
|
||||
ExchangeSummary,
|
||||
QuotationExchangePanel,
|
||||
} from '@/components/quotation-exchange-panel';
|
||||
import type { ExchangeBasis } from '@/components/quotation-exchange-panel';
|
||||
|
||||
type Item = {
|
||||
id: number;
|
||||
@@ -33,6 +38,13 @@ type Evaluation = {
|
||||
created_at: string;
|
||||
};
|
||||
type Quote = {
|
||||
currency: string;
|
||||
exchange_basis: ExchangeBasis | null;
|
||||
reference_amounts: {
|
||||
subtotal_minor: number;
|
||||
tax_minor: number;
|
||||
total_minor: number;
|
||||
} | null;
|
||||
canEvaluate: boolean;
|
||||
id: number;
|
||||
reference: string;
|
||||
@@ -62,6 +74,9 @@ export default function Comparison({
|
||||
ready,
|
||||
topIds,
|
||||
comparisonPolicy,
|
||||
exchangeRates = [],
|
||||
exchangeAvailable = false,
|
||||
canRecordExchange = false,
|
||||
}: {
|
||||
requisition: {
|
||||
id: number;
|
||||
@@ -78,10 +93,14 @@ export default function Comparison({
|
||||
ready: boolean;
|
||||
topIds: number[];
|
||||
comparisonPolicy: ComparisonPolicy;
|
||||
exchangeRates?: ExchangeBasis[];
|
||||
exchangeAvailable?: boolean;
|
||||
canRecordExchange?: boolean;
|
||||
}) {
|
||||
const [adding, setAdding] = useState(prepare && canCreate);
|
||||
const [selected, setSelected] = useState<number | null>(focusQuotationId);
|
||||
const form = useForm({
|
||||
currency: 'MZN',
|
||||
supplier_id: '',
|
||||
reference: '',
|
||||
delivery_days: '1',
|
||||
@@ -195,7 +214,7 @@ export default function Comparison({
|
||||
<div id="quotation-create">
|
||||
<Panel
|
||||
title="Nova proposta"
|
||||
description="MZN · Quantidades e IVA herdados da requisição. Desconto por unidade antes do IVA; preço líquido arredondado ao centavo antes de multiplicar pela quantidade. Preencha todas as linhas."
|
||||
description="Valores na moeda seleccionada, com duas casas decimais. Quantidades e IVA herdados da requisição. Desconto por unidade antes do IVA; preço líquido arredondado ao centavo antes de multiplicar pela quantidade. Preencha todas as linhas."
|
||||
>
|
||||
<form
|
||||
className="space-y-5"
|
||||
@@ -213,6 +232,31 @@ export default function Comparison({
|
||||
}}
|
||||
>
|
||||
<FormErrors errors={form.errors} />
|
||||
<Label htmlFor="quotation-currency">
|
||||
Moeda original da proposta
|
||||
</Label>
|
||||
<select
|
||||
id="quotation-currency"
|
||||
className={controlClass}
|
||||
value={form.data.currency}
|
||||
onChange={(event) =>
|
||||
form.setData(
|
||||
'currency',
|
||||
event.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="MZN">MZN</option>
|
||||
{exchangeRates.map((rate) => (
|
||||
<option
|
||||
key={rate.id}
|
||||
value={rate.currency}
|
||||
>
|
||||
{rate.currency} · taxa {rate.rate}{' '}
|
||||
MZN
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="supplier">
|
||||
@@ -304,7 +348,8 @@ export default function Comparison({
|
||||
htmlFor={`price-${i.id}`}
|
||||
>
|
||||
Preço unitário antes de
|
||||
desconto e IVA (MZN)
|
||||
desconto e IVA (
|
||||
{form.data.currency})
|
||||
</Label>
|
||||
<Input
|
||||
id={`price-${i.id}`}
|
||||
@@ -385,7 +430,8 @@ export default function Comparison({
|
||||
Percentagem (%)
|
||||
</option>
|
||||
<option value="amount">
|
||||
Valor por unidade (MZN)
|
||||
Valor por unidade (
|
||||
{form.data.currency})
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
@@ -393,7 +439,7 @@ export default function Comparison({
|
||||
{form.data.items[index]
|
||||
.discount_type === 'percent'
|
||||
? 'Percentagem (%)'
|
||||
: 'Valor unitário (MZN)'}
|
||||
: `Valor unitário (${form.data.currency})`}
|
||||
<Input
|
||||
type="number"
|
||||
min="0"
|
||||
@@ -459,6 +505,13 @@ export default function Comparison({
|
||||
</Panel>
|
||||
</div>
|
||||
)}
|
||||
{exchangeAvailable && (
|
||||
<QuotationExchangePanel
|
||||
requisitionId={requisition.id}
|
||||
rates={exchangeRates}
|
||||
canRecord={canRecordExchange}
|
||||
/>
|
||||
)}
|
||||
<Panel
|
||||
title="Matriz de comparação"
|
||||
description="Ponderações da regra deste processo. Preço e prazo calculados automaticamente entre propostas elegíveis."
|
||||
@@ -507,13 +560,28 @@ export default function Comparison({
|
||||
)}
|
||||
</td>
|
||||
<td className="pr-4 whitespace-nowrap">
|
||||
{money(q.subtotal_minor)}
|
||||
{money(
|
||||
q.subtotal_minor,
|
||||
q.currency,
|
||||
)}
|
||||
</td>
|
||||
<td className="pr-4 whitespace-nowrap">
|
||||
{money(q.tax_minor)}
|
||||
{money(q.tax_minor, q.currency)}
|
||||
</td>
|
||||
<td className="pr-4 whitespace-nowrap">
|
||||
{money(q.total_minor)}
|
||||
{money(q.total_minor, q.currency)}
|
||||
{q.exchange_basis &&
|
||||
q.reference_amounts && (
|
||||
<p className="text-xs">
|
||||
Referência:{' '}
|
||||
{money(
|
||||
q.reference_amounts
|
||||
.total_minor,
|
||||
)}{' '}
|
||||
· Taxa{' '}
|
||||
{q.exchange_basis.rate}
|
||||
</p>
|
||||
)}
|
||||
</td>
|
||||
<td className="pr-4">
|
||||
{q.delivery_days} dias
|
||||
@@ -571,13 +639,21 @@ export default function Comparison({
|
||||
)}
|
||||
<QuotationCommercialTerms
|
||||
terms={q.commercial_terms}
|
||||
currency={q.currency}
|
||||
/>
|
||||
{q.exchange_basis && (
|
||||
<ExchangeSummary basis={q.exchange_basis} />
|
||||
)}
|
||||
<div className="space-y-3">
|
||||
{q.items.map((i) => (
|
||||
<p className="text-sm" key={i.id}>
|
||||
{i.description} · {i.quantity} ×{' '}
|
||||
{money(i.unit_price_minor)} · total
|
||||
com IVA {money(i.total_minor)}
|
||||
{money(
|
||||
i.unit_price_minor,
|
||||
q.currency,
|
||||
)}{' '}
|
||||
· total com IVA{' '}
|
||||
{money(i.total_minor, q.currency)}
|
||||
</p>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user