@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user