@@ -36,7 +36,11 @@ type Invoice = {
|
||||
subtotal_minor: number;
|
||||
tax_minor: number;
|
||||
total_minor: number;
|
||||
snapshot: { supplier: { name: string }; order_number: string };
|
||||
snapshot: {
|
||||
supplier: { name: string };
|
||||
order_number: string;
|
||||
currency?: string;
|
||||
};
|
||||
items: {
|
||||
id: number;
|
||||
quantity_milli: number;
|
||||
@@ -57,7 +61,13 @@ export default function Invoices({
|
||||
focusOrderId = null,
|
||||
}: {
|
||||
invoices: Page<Invoice>;
|
||||
orders: { id: number; number: string; supplier: string; items: Source[] }[];
|
||||
orders: {
|
||||
id: number;
|
||||
number: string;
|
||||
currency?: string;
|
||||
supplier: string;
|
||||
items: Source[];
|
||||
}[];
|
||||
canManage: boolean;
|
||||
focusInvoiceId?: number | null;
|
||||
focusOrderId?: number | null;
|
||||
@@ -342,10 +352,9 @@ export default function Invoices({
|
||||
<label key={key}>
|
||||
{
|
||||
{
|
||||
subtotal:
|
||||
'Subtotal sem IVA (MZN)',
|
||||
tax: 'IVA (MZN)',
|
||||
total: 'Total (MZN)',
|
||||
subtotal: `Subtotal sem IVA (${order?.currency ?? 'MZN'})`,
|
||||
tax: `IVA (${order?.currency ?? 'MZN'})`,
|
||||
total: `Total (${order?.currency ?? 'MZN'})`,
|
||||
}[key]
|
||||
}
|
||||
<Input
|
||||
@@ -386,9 +395,21 @@ export default function Invoices({
|
||||
: 'Pendente de validação'}
|
||||
</p>
|
||||
<p>
|
||||
Subtotal {money(invoice.subtotal_minor)} · IVA{' '}
|
||||
{money(invoice.tax_minor)} · Total{' '}
|
||||
{money(invoice.total_minor)}
|
||||
Subtotal{' '}
|
||||
{money(
|
||||
invoice.subtotal_minor,
|
||||
invoice.snapshot.currency,
|
||||
)}{' '}
|
||||
· IVA{' '}
|
||||
{money(
|
||||
invoice.tax_minor,
|
||||
invoice.snapshot.currency,
|
||||
)}{' '}
|
||||
· Total{' '}
|
||||
{money(
|
||||
invoice.total_minor,
|
||||
invoice.snapshot.currency,
|
||||
)}
|
||||
</p>
|
||||
{payablesAvailable && (
|
||||
<p className="my-3">
|
||||
@@ -418,7 +439,10 @@ export default function Invoices({
|
||||
{l.snapshot.description} ·{' '}
|
||||
{l.quantity_milli / 1000}{' '}
|
||||
{l.snapshot.unit} ·{' '}
|
||||
{money(l.subtotal_minor + l.tax_minor)}
|
||||
{money(
|
||||
l.subtotal_minor + l.tax_minor,
|
||||
invoice.snapshot.currency,
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
@@ -13,6 +13,14 @@ import type { Page } from '@/types/inventory';
|
||||
import { money } from '@/types/procurement';
|
||||
|
||||
type Invoice = {
|
||||
banks?: {
|
||||
id: number;
|
||||
revision: number;
|
||||
label: string;
|
||||
currency: string;
|
||||
state: string;
|
||||
}[];
|
||||
currency?: string;
|
||||
id: number;
|
||||
number: string;
|
||||
supplier_id: number;
|
||||
@@ -135,9 +143,14 @@ export default function Payments({
|
||||
{i.number} · {i.supplier_name}
|
||||
</p>
|
||||
<p>
|
||||
Total {money(i.total_minor)} · Confirmado{' '}
|
||||
{money(i.total_minor - i.outstanding_minor)}{' '}
|
||||
· Pendente {money(i.outstanding_minor)}
|
||||
Total {money(i.total_minor, i.currency)} ·
|
||||
Confirmado{' '}
|
||||
{money(
|
||||
i.total_minor - i.outstanding_minor,
|
||||
i.currency,
|
||||
)}{' '}
|
||||
· Pendente{' '}
|
||||
{money(i.outstanding_minor, i.currency)}
|
||||
</p>
|
||||
<p>
|
||||
{i.outstanding_minor === 0
|
||||
@@ -214,20 +227,75 @@ export default function Payments({
|
||||
.map((i) => (
|
||||
<option key={i.id} value={i.id}>
|
||||
{i.number} · {i.supplier_name} ·{' '}
|
||||
{money(i.outstanding_minor)}
|
||||
{money(
|
||||
i.outstanding_minor,
|
||||
i.currency,
|
||||
)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
{selected?.banks && (
|
||||
<label>
|
||||
Conta bancária na moeda da factura
|
||||
<select
|
||||
className={controlClass}
|
||||
required
|
||||
value={
|
||||
form.data.supplier_bank_detail_id ||
|
||||
''
|
||||
}
|
||||
onChange={(event) =>
|
||||
form.setData(
|
||||
'supplier_bank_detail_id',
|
||||
Number(event.target.value),
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">
|
||||
Seleccione uma conta validada
|
||||
</option>
|
||||
{selected.banks.map((bank) => (
|
||||
<option
|
||||
key={bank.id}
|
||||
value={bank.id}
|
||||
disabled={
|
||||
bank.state !== 'approved'
|
||||
}
|
||||
>
|
||||
{bank.label} ·{' '}
|
||||
{bank.state === 'approved'
|
||||
? 'Validada'
|
||||
: 'Por concluir'}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
{selected.banks.length === 0 && (
|
||||
<p className="mt-2 text-sm">
|
||||
Não há conta disponível na moeda
|
||||
desta factura. Consulte os dados
|
||||
bancários do fornecedor.
|
||||
</p>
|
||||
)}
|
||||
</label>
|
||||
)}
|
||||
{selected && (
|
||||
<p className="text-sm">
|
||||
Versão bancária seleccionada:{' '}
|
||||
{selected.bank_revision}. Se os dados
|
||||
mudarem, a confirmação será bloqueada.
|
||||
{selected.banks?.find(
|
||||
(bank) =>
|
||||
bank.id ===
|
||||
form.data.supplier_bank_detail_id,
|
||||
)?.revision ??
|
||||
(selected.bank_revision ||
|
||||
'Por seleccionar')}
|
||||
. Se os dados mudarem, a confirmação será
|
||||
bloqueada.
|
||||
</p>
|
||||
)}
|
||||
<label>
|
||||
Montante do pagamento (MZN)
|
||||
Montante do pagamento (
|
||||
{selected?.currency ?? 'MZN'})
|
||||
<Input
|
||||
required
|
||||
inputMode="decimal"
|
||||
@@ -296,7 +364,8 @@ export default function Payments({
|
||||
title={`Registo externo #${p.id} · ${invoices.find((i) => i.id === p.invoice_id)?.number ?? `Factura #${p.invoice_id}`}`}
|
||||
>
|
||||
<p>
|
||||
{money(p.amount_minor)} · {p.paid_on} ·{' '}
|
||||
{money(p.amount_minor, p.currency)} ·{' '}
|
||||
{p.paid_on} ·{' '}
|
||||
{{
|
||||
pending: 'Pendente de conferência',
|
||||
confirmed: 'Confirmado',
|
||||
|
||||
@@ -114,7 +114,17 @@ export default function Award({
|
||||
)}
|
||||
</td>
|
||||
<td className="pr-4 whitespace-nowrap">
|
||||
{money(q.total_minor)}
|
||||
{money(q.total_minor, q.currency)}
|
||||
{q.reference_amounts &&
|
||||
q.exchange_basis && (
|
||||
<p className="text-xs">
|
||||
Referência para alçadas:{' '}
|
||||
{money(
|
||||
q.reference_amounts
|
||||
.total_minor,
|
||||
)}
|
||||
</p>
|
||||
)}
|
||||
</td>
|
||||
<td className="pr-4">
|
||||
{q.evaluation_count} /{' '}
|
||||
@@ -199,8 +209,11 @@ export default function Award({
|
||||
.map((q) => (
|
||||
<option key={q.id} value={q.id}>
|
||||
{q.supplier.name} ·{' '}
|
||||
{money(q.total_minor)} ·{' '}
|
||||
{q.score?.toFixed(2)} / 10
|
||||
{money(
|
||||
q.total_minor,
|
||||
q.currency,
|
||||
)}{' '}
|
||||
· {q.score?.toFixed(2)} / 10
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
|
||||
@@ -7,6 +7,8 @@ import type { AiPreparation } from '@/components/ai-preparation-preview';
|
||||
import { ComparisonPolicySummary } from '@/components/comparison-policy-summary';
|
||||
import type { ComparisonPolicy } from '@/components/comparison-policy-summary';
|
||||
import { QuotationCommercialTerms } from '@/components/quotation-commercial-terms';
|
||||
import { ExchangeSummary } from '@/components/quotation-exchange-panel';
|
||||
import type { ExchangeBasis } from '@/components/quotation-exchange-panel';
|
||||
import type { CommercialTerms } from '@/components/quotation-commercial-terms';
|
||||
import { PageTitle, Panel, Status } from '@/components/procurement';
|
||||
import { Button } from '@/components/ui/button';
|
||||
@@ -33,6 +35,12 @@ type Analysis = {
|
||||
answers: Answer[];
|
||||
};
|
||||
type ComparisonRow = {
|
||||
exchange_basis?: ExchangeBasis;
|
||||
reference_amounts?: {
|
||||
subtotal_minor: number;
|
||||
tax_minor: number;
|
||||
total_minor: number;
|
||||
} | null;
|
||||
commercial_terms?: CommercialTerms | null;
|
||||
id: number;
|
||||
reference: string;
|
||||
@@ -208,6 +216,11 @@ export default function ReviewReport({
|
||||
<Printer className="size-4" />
|
||||
Imprimir esta consulta
|
||||
</Button>
|
||||
<Button asChild variant="outline">
|
||||
<a href={`/requisicoes/${r.id}/relatorio.csv`}>
|
||||
Exportar conferência completa (CSV)
|
||||
</a>
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
@@ -399,7 +412,24 @@ export default function ReviewReport({
|
||||
</strong>
|
||||
<QuotationCommercialTerms
|
||||
terms={row.commercial_terms}
|
||||
currency={row.currency}
|
||||
/>
|
||||
{row.exchange_basis && (
|
||||
<ExchangeSummary
|
||||
basis={row.exchange_basis}
|
||||
/>
|
||||
)}
|
||||
{row.reference_amounts && (
|
||||
<p className="text-sm">
|
||||
Referência para comparação e
|
||||
alçadas:{' '}
|
||||
{money(
|
||||
row.reference_amounts
|
||||
.total_minor,
|
||||
'MZN',
|
||||
)}
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
))}
|
||||
{report.comparison.rows.map((row) => (
|
||||
|
||||
@@ -5,6 +5,7 @@ import { QuotationCommercialTerms } from '@/components/quotation-commercial-term
|
||||
import { PageTitle, Panel } from '@/components/procurement';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { date, money, roleLabels } from '@/types/procurement';
|
||||
import { ExchangeSummary } from '@/components/quotation-exchange-panel';
|
||||
import type { PurchaseOrder } from '@/types/purchase';
|
||||
import OrderCancellationRequest, {
|
||||
type OrderCancellationState,
|
||||
@@ -196,13 +197,19 @@ export default function OrderShow({
|
||||
{Number(item.quantity)} {item.unit}
|
||||
</td>
|
||||
<td className="pr-4 whitespace-nowrap">
|
||||
{money(item.unit_price_minor)}
|
||||
{money(
|
||||
item.unit_price_minor,
|
||||
order.currency,
|
||||
)}
|
||||
</td>
|
||||
<td className="pr-4">
|
||||
{Number(item.tax_rate)}%
|
||||
</td>
|
||||
<td className="whitespace-nowrap">
|
||||
{money(item.total_minor)}
|
||||
{money(
|
||||
item.total_minor,
|
||||
order.currency,
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
@@ -212,17 +219,28 @@ export default function OrderShow({
|
||||
<dl className="mt-5 ml-auto max-w-sm space-y-3 text-sm">
|
||||
<div className="flex justify-between gap-4">
|
||||
<dt>Subtotal sem IVA</dt>
|
||||
<dd>{money(order.subtotal_minor)}</dd>
|
||||
<dd>
|
||||
{money(order.subtotal_minor, order.currency)}
|
||||
</dd>
|
||||
</div>
|
||||
<div className="flex justify-between gap-4">
|
||||
<dt>IVA</dt>
|
||||
<dd>{money(order.tax_minor)}</dd>
|
||||
<dd>{money(order.tax_minor, order.currency)}</dd>
|
||||
</div>
|
||||
<div className="flex justify-between gap-4 border-t pt-3 font-semibold">
|
||||
<dt>Total com IVA</dt>
|
||||
<dd>{money(order.total_minor)}</dd>
|
||||
<dd>{money(order.total_minor, order.currency)}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
{snapshot.exchange_basis && (
|
||||
<ExchangeSummary basis={snapshot.exchange_basis} />
|
||||
)}
|
||||
{snapshot.reference_amounts && (
|
||||
<p className="mt-3 text-sm">
|
||||
Referência orçamental:{' '}
|
||||
{money(snapshot.reference_amounts.total_minor)}
|
||||
</p>
|
||||
)}
|
||||
</Panel>
|
||||
<Panel title="Fundamento e matriz congelada">
|
||||
{snapshot.comparison_policy && (
|
||||
@@ -246,11 +264,13 @@ export default function OrderShow({
|
||||
: `${row.score.toFixed(2)} / 10`}
|
||||
</p>
|
||||
<p className="mt-1 text-muted-foreground">
|
||||
{money(row.total_minor)} com IVA ·{' '}
|
||||
{row.evaluation_count} avaliações elegíveis
|
||||
{money(row.total_minor, row.currency)} com
|
||||
IVA · {row.evaluation_count} avaliações
|
||||
elegíveis
|
||||
</p>
|
||||
<QuotationCommercialTerms
|
||||
terms={row.commercial_terms}
|
||||
currency={row.currency}
|
||||
/>
|
||||
{row.evaluations.map((e) => (
|
||||
<p
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { Head, Link, useForm } from '@inertiajs/react';
|
||||
import { ReceiptConversionFields } from '@/components/receipt-conversion';
|
||||
import type { ReceiptConversion } from '@/components/receipt-conversion';
|
||||
import { InventoryNotice, ReceiptProgressTable } from '@/components/inventory';
|
||||
import {
|
||||
FormErrors,
|
||||
@@ -25,6 +27,7 @@ type Line = {
|
||||
quality_status: string;
|
||||
notes: string;
|
||||
stock_item_id: string;
|
||||
conversion: ReceiptConversion;
|
||||
lots: {
|
||||
code: string;
|
||||
expires_on: string;
|
||||
@@ -40,6 +43,7 @@ type Props = {
|
||||
warehouses: Warehouse[];
|
||||
stockItems: StockItem[];
|
||||
canConfirm: boolean;
|
||||
conversionQaEnabled?: boolean;
|
||||
lotScopes: {
|
||||
stock_item_id: number;
|
||||
warehouse_id: number;
|
||||
@@ -54,6 +58,7 @@ export default function ReceiveOrder({
|
||||
warehouses,
|
||||
stockItems,
|
||||
canConfirm,
|
||||
conversionQaEnabled = false,
|
||||
lotScopes,
|
||||
}: Props) {
|
||||
const form = useForm({
|
||||
@@ -69,6 +74,12 @@ export default function ReceiveOrder({
|
||||
quality_status: 'compliant',
|
||||
notes: '',
|
||||
stock_item_id: line.stock_item_id ? String(line.stock_item_id) : '',
|
||||
conversion: {
|
||||
numerator: '',
|
||||
denominator: '',
|
||||
source: '',
|
||||
version: '',
|
||||
},
|
||||
lots: [] as Line['lots'],
|
||||
})),
|
||||
});
|
||||
@@ -120,6 +131,25 @@ export default function ReceiveOrder({
|
||||
...line
|
||||
}) => ({
|
||||
...line,
|
||||
conversion:
|
||||
conversionQaEnabled &&
|
||||
stockItems.some(
|
||||
(item) =>
|
||||
String(item.id) ===
|
||||
line.stock_item_id &&
|
||||
item.unit.toLowerCase() !==
|
||||
progress.lines
|
||||
.find(
|
||||
(
|
||||
source,
|
||||
) =>
|
||||
source.id ===
|
||||
line.purchase_order_item_id,
|
||||
)
|
||||
?.unit.toLowerCase(),
|
||||
)
|
||||
? line.conversion
|
||||
: undefined,
|
||||
stock_item_id:
|
||||
line.stock_item_id || null,
|
||||
}),
|
||||
@@ -445,8 +475,9 @@ export default function ReceiveOrder({
|
||||
(
|
||||
item,
|
||||
) =>
|
||||
conversionQaEnabled ||
|
||||
item.unit.toLowerCase() ===
|
||||
source.unit.toLowerCase(),
|
||||
source.unit.toLowerCase(),
|
||||
)
|
||||
.map(
|
||||
(
|
||||
@@ -471,6 +502,65 @@ export default function ReceiveOrder({
|
||||
),
|
||||
)}
|
||||
</select>
|
||||
{conversionQaEnabled &&
|
||||
stockItems.some(
|
||||
(
|
||||
item,
|
||||
) =>
|
||||
String(
|
||||
item.id,
|
||||
) ===
|
||||
form
|
||||
.data
|
||||
.items[
|
||||
index
|
||||
]
|
||||
.stock_item_id &&
|
||||
item.unit.toLowerCase() !==
|
||||
source.unit.toLowerCase(),
|
||||
) && (
|
||||
<ReceiptConversionFields
|
||||
value={
|
||||
form
|
||||
.data
|
||||
.items[
|
||||
index
|
||||
]
|
||||
.conversion
|
||||
}
|
||||
onChange={(
|
||||
conversion,
|
||||
) =>
|
||||
change(
|
||||
index,
|
||||
{
|
||||
conversion,
|
||||
},
|
||||
)
|
||||
}
|
||||
documentUnit={
|
||||
source.unit
|
||||
}
|
||||
stockUnit={
|
||||
stockItems.find(
|
||||
(
|
||||
item,
|
||||
) =>
|
||||
String(
|
||||
item.id,
|
||||
) ===
|
||||
form
|
||||
.data
|
||||
.items[
|
||||
index
|
||||
]
|
||||
.stock_item_id,
|
||||
)
|
||||
?.unit ??
|
||||
''
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<p className="self-center text-sm text-muted-foreground">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Head, Link } from '@inertiajs/react';
|
||||
import { convertedQuantity } from '@/components/receipt-conversion';
|
||||
import { InventoryNotice } from '@/components/inventory';
|
||||
import { PageTitle, Panel } from '@/components/procurement';
|
||||
import { date } from '@/types/procurement';
|
||||
@@ -101,6 +102,39 @@ export default function ReceiptShow({
|
||||
Rejeitado: {quantity(line.rejected_milli)}{' '}
|
||||
{line.snapshot.order_item.unit}
|
||||
</p>
|
||||
{line.snapshot.quantity_conversion && (
|
||||
<p className="mt-2 text-sm">
|
||||
Entrada física:{' '}
|
||||
{convertedQuantity(
|
||||
line.snapshot.quantity_conversion
|
||||
.accepted_stock_milli,
|
||||
)}{' '}
|
||||
{
|
||||
line.snapshot.quantity_conversion
|
||||
.stock_unit
|
||||
}{' '}
|
||||
· factor{' '}
|
||||
{
|
||||
line.snapshot.quantity_conversion
|
||||
.numerator
|
||||
}
|
||||
/
|
||||
{
|
||||
line.snapshot.quantity_conversion
|
||||
.denominator
|
||||
}{' '}
|
||||
·
|
||||
{
|
||||
line.snapshot.quantity_conversion
|
||||
.source
|
||||
}{' '}
|
||||
· versão{' '}
|
||||
{
|
||||
line.snapshot.quantity_conversion
|
||||
.version
|
||||
}
|
||||
</p>
|
||||
)}
|
||||
<p className="mt-2 text-muted-foreground">
|
||||
{line.snapshot.stock_item
|
||||
? `${line.snapshot.stock_item.code} · ${line.snapshot.stock_item.name}`
|
||||
|
||||
@@ -78,6 +78,7 @@ type Props = {
|
||||
stock_item_id: number;
|
||||
warehouse_id: number;
|
||||
accepted_milli: number;
|
||||
physical_accepted_milli?: number;
|
||||
returned_milli: number;
|
||||
label: string;
|
||||
}[];
|
||||
@@ -216,7 +217,10 @@ function Prepare({ props, old }: { props: Props; old?: RecordEntry }) {
|
||||
{receipts.map((r) => (
|
||||
<option key={r.id} value={r.id}>
|
||||
{r.label} · Devolvível da origem:{' '}
|
||||
{quantity(r.accepted_milli - r.returned_milli)}
|
||||
{quantity(
|
||||
(r.physical_accepted_milli ??
|
||||
r.accepted_milli) - r.returned_milli,
|
||||
)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Head, Link, useForm } from '@inertiajs/react';
|
||||
import { useState } from 'react';
|
||||
import {
|
||||
FormErrors,
|
||||
Panel,
|
||||
@@ -20,6 +21,16 @@ type Detail = {
|
||||
reason: string;
|
||||
};
|
||||
type Props = {
|
||||
accountKey?: string | null;
|
||||
actorId?: number;
|
||||
multiAccountsAvailable?: boolean;
|
||||
accounts?: {
|
||||
id: number;
|
||||
key: string | null;
|
||||
revision: number;
|
||||
label: string;
|
||||
state: string;
|
||||
}[];
|
||||
supplier: { id: number; name: string };
|
||||
current: Detail | null;
|
||||
currentId: number;
|
||||
@@ -39,7 +50,16 @@ type Props = {
|
||||
canPropose: boolean;
|
||||
canReview: boolean;
|
||||
};
|
||||
export default function Bank({
|
||||
export default function BankPage(props: Props) {
|
||||
return (
|
||||
<Bank
|
||||
key={`${props.supplier.id}:${props.accountKey ?? 'legacy'}:${props.actorId ?? 0}:${props.canPropose}:${props.canReview}`}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function Bank({
|
||||
supplier,
|
||||
current,
|
||||
currentId,
|
||||
@@ -48,9 +68,14 @@ export default function Bank({
|
||||
reviews,
|
||||
canPropose,
|
||||
canReview,
|
||||
accountKey = null,
|
||||
accounts = [],
|
||||
multiAccountsAvailable = false,
|
||||
}: Props) {
|
||||
const [addingAccount, setAddingAccount] = useState(false);
|
||||
const form = useForm({
|
||||
previous_id: currentId,
|
||||
account_key: accountKey,
|
||||
bank_name: '',
|
||||
country: '',
|
||||
currency: '',
|
||||
@@ -93,9 +118,51 @@ export default function Bank({
|
||||
<Link href={`/fornecedores/${supplier.id}`}>
|
||||
← Ficha do fornecedor
|
||||
</Link>
|
||||
{multiAccountsAvailable && (
|
||||
<Panel
|
||||
title="Contas do fornecedor"
|
||||
description="Cada conta conserva as suas versões e duas validações independentes. Adicionar outra conta não substitui nem reactiva versões anteriores."
|
||||
>
|
||||
<div className="flex flex-wrap gap-3">
|
||||
{accounts.map((account) => (
|
||||
<Link
|
||||
key={account.id}
|
||||
className="rounded border p-3 text-sm"
|
||||
href={`/fornecedores/${supplier.id}/dados-bancarios${account.key === null ? '' : `?account=${encodeURIComponent(account.key)}`}`}
|
||||
>
|
||||
{account.label} ·{' '}
|
||||
{states[account.state] ?? account.state}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
{canPropose && (
|
||||
<Button
|
||||
className="mt-4"
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
const add = !addingAccount;
|
||||
setAddingAccount(add);
|
||||
form.reset();
|
||||
form.clearErrors();
|
||||
form.setData((data) => ({
|
||||
...data,
|
||||
previous_id: add ? 0 : currentId,
|
||||
account_key: add
|
||||
? crypto.randomUUID()
|
||||
: accountKey,
|
||||
}));
|
||||
}}
|
||||
>
|
||||
{addingAccount
|
||||
? 'Rever a conta seleccionada'
|
||||
: 'Adicionar conta independente'}
|
||||
</Button>
|
||||
)}
|
||||
</Panel>
|
||||
)}
|
||||
<Panel
|
||||
title={states[state] ?? state}
|
||||
description="A versão mais recente substitui a anterior para efeitos de disponibilidade. A aprovação não confirma a titularidade junto do banco nem valida formatos bancários nacionais."
|
||||
description="A versão mais recente desta conta substitui a sua anterior para efeitos de disponibilidade. A aprovação não confirma a titularidade junto do banco nem valida formatos bancários nacionais."
|
||||
>
|
||||
{current && (
|
||||
<dl className="grid gap-4 text-sm sm:grid-cols-2">
|
||||
@@ -181,7 +248,11 @@ export default function Bank({
|
||||
)}
|
||||
{canPropose && (
|
||||
<Panel
|
||||
title="Propor nova versão"
|
||||
title={
|
||||
addingAccount
|
||||
? 'Propor conta independente'
|
||||
: 'Propor nova versão da conta seleccionada'
|
||||
}
|
||||
description="Preencha integralmente os dados confirmados. A nova versão exige duas validações novas; a versão anterior permanece no histórico."
|
||||
>
|
||||
<form
|
||||
|
||||
Reference in New Issue
Block a user