commit13
This commit is contained in:
@@ -25,6 +25,12 @@ type Line = {
|
||||
quality_status: string;
|
||||
notes: string;
|
||||
stock_item_id: string;
|
||||
lots: {
|
||||
code: string;
|
||||
expires_on: string;
|
||||
no_expiry: boolean;
|
||||
quantity: string;
|
||||
}[];
|
||||
};
|
||||
type Props = {
|
||||
order: { id: number; number: string };
|
||||
@@ -34,6 +40,11 @@ type Props = {
|
||||
warehouses: Warehouse[];
|
||||
stockItems: StockItem[];
|
||||
canConfirm: boolean;
|
||||
lotScopes: {
|
||||
stock_item_id: number;
|
||||
warehouse_id: number;
|
||||
quarantine_on_receipt: boolean;
|
||||
}[];
|
||||
};
|
||||
export default function ReceiveOrder({
|
||||
order,
|
||||
@@ -43,6 +54,7 @@ export default function ReceiveOrder({
|
||||
warehouses,
|
||||
stockItems,
|
||||
canConfirm,
|
||||
lotScopes,
|
||||
}: Props) {
|
||||
const form = useForm({
|
||||
idempotency_key: crypto.randomUUID(),
|
||||
@@ -57,6 +69,7 @@ export default function ReceiveOrder({
|
||||
quality_status: 'compliant',
|
||||
notes: '',
|
||||
stock_item_id: line.stock_item_id ? String(line.stock_item_id) : '',
|
||||
lots: [] as Line['lots'],
|
||||
})),
|
||||
});
|
||||
const change = (index: number, updates: Partial<Line>) =>
|
||||
@@ -467,6 +480,248 @@ export default function ReceiveOrder({
|
||||
físicas.
|
||||
</p>
|
||||
)}
|
||||
{lotScopes.some(
|
||||
(scope) =>
|
||||
String(
|
||||
scope.stock_item_id,
|
||||
) ===
|
||||
form.data
|
||||
.items[
|
||||
index
|
||||
]
|
||||
.stock_item_id &&
|
||||
String(
|
||||
scope.warehouse_id,
|
||||
) ===
|
||||
form.data
|
||||
.warehouse_id,
|
||||
) && (
|
||||
<details className="rounded border p-3 md:col-span-2">
|
||||
<summary className="cursor-pointer text-sm">
|
||||
Identificação
|
||||
dos lotes
|
||||
recebidos
|
||||
</summary>
|
||||
<p className="my-3 text-sm text-muted-foreground">
|
||||
A regra
|
||||
aprovada
|
||||
deste
|
||||
artigo/local
|
||||
determina a
|
||||
quarentena.
|
||||
Só uma
|
||||
recepção
|
||||
conforme,
|
||||
identificada
|
||||
e com
|
||||
validade
|
||||
suficiente
|
||||
pode
|
||||
beneficiar
|
||||
de dispensa
|
||||
previamente
|
||||
aprovada. Um
|
||||
único lote
|
||||
reutiliza a
|
||||
quantidade
|
||||
aceite. Se
|
||||
não tiver a
|
||||
identificação,
|
||||
poderá
|
||||
registá-la
|
||||
posteriormente
|
||||
em Lotes,
|
||||
validade e
|
||||
quarentena.
|
||||
</p>
|
||||
{form.data.items[
|
||||
index
|
||||
].lots.map(
|
||||
(
|
||||
lot,
|
||||
lotIndex,
|
||||
) => (
|
||||
<fieldset
|
||||
key={
|
||||
lotIndex
|
||||
}
|
||||
className="mb-3 grid gap-3 md:grid-cols-2"
|
||||
>
|
||||
<legend>
|
||||
Lote{' '}
|
||||
{lotIndex +
|
||||
1}
|
||||
</legend>
|
||||
{(
|
||||
[
|
||||
'code',
|
||||
'expires_on',
|
||||
'quantity',
|
||||
] as const
|
||||
).map(
|
||||
(
|
||||
key,
|
||||
) => (
|
||||
<label
|
||||
key={
|
||||
key
|
||||
}
|
||||
className="grid gap-1 text-sm"
|
||||
>
|
||||
{
|
||||
{
|
||||
code: 'Código do lote',
|
||||
expires_on:
|
||||
'Validade',
|
||||
quantity:
|
||||
'Quantidade (apenas para vários lotes)',
|
||||
}[
|
||||
key
|
||||
]
|
||||
}
|
||||
<Input
|
||||
type={
|
||||
key ===
|
||||
'expires_on'
|
||||
? 'date'
|
||||
: 'text'
|
||||
}
|
||||
value={
|
||||
lot[
|
||||
key
|
||||
]
|
||||
}
|
||||
onChange={(
|
||||
e,
|
||||
) =>
|
||||
change(
|
||||
index,
|
||||
{
|
||||
lots: form.data.items[
|
||||
index
|
||||
].lots.map(
|
||||
(
|
||||
value,
|
||||
li,
|
||||
) =>
|
||||
li ===
|
||||
lotIndex
|
||||
? {
|
||||
...value,
|
||||
[key]: e
|
||||
.target
|
||||
.value,
|
||||
}
|
||||
: value,
|
||||
),
|
||||
},
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
),
|
||||
)}
|
||||
<label className="flex items-center gap-2 text-sm">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={
|
||||
lot.no_expiry
|
||||
}
|
||||
onChange={(
|
||||
e,
|
||||
) =>
|
||||
change(
|
||||
index,
|
||||
{
|
||||
lots: form.data.items[
|
||||
index
|
||||
].lots.map(
|
||||
(
|
||||
value,
|
||||
li,
|
||||
) =>
|
||||
li ===
|
||||
lotIndex
|
||||
? {
|
||||
...value,
|
||||
no_expiry:
|
||||
e
|
||||
.target
|
||||
.checked,
|
||||
}
|
||||
: value,
|
||||
),
|
||||
},
|
||||
)
|
||||
}
|
||||
/>
|
||||
Confirmo
|
||||
artigo
|
||||
sem
|
||||
prazo
|
||||
de
|
||||
validade
|
||||
</label>
|
||||
<Button
|
||||
variant="outline"
|
||||
type="button"
|
||||
onClick={() =>
|
||||
change(
|
||||
index,
|
||||
{
|
||||
lots: form.data.items[
|
||||
index
|
||||
].lots.filter(
|
||||
(
|
||||
_,
|
||||
li,
|
||||
) =>
|
||||
li !==
|
||||
lotIndex,
|
||||
),
|
||||
},
|
||||
)
|
||||
}
|
||||
>
|
||||
Remover
|
||||
repartição
|
||||
</Button>
|
||||
</fieldset>
|
||||
),
|
||||
)}
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={() =>
|
||||
change(
|
||||
index,
|
||||
{
|
||||
lots: [
|
||||
...form
|
||||
.data
|
||||
.items[
|
||||
index
|
||||
]
|
||||
.lots,
|
||||
{
|
||||
code: '',
|
||||
expires_on:
|
||||
'',
|
||||
no_expiry: false,
|
||||
quantity:
|
||||
'',
|
||||
},
|
||||
],
|
||||
},
|
||||
)
|
||||
}
|
||||
>
|
||||
Acrescentar
|
||||
identificação
|
||||
de lote
|
||||
</Button>
|
||||
</details>
|
||||
)}
|
||||
<div className="space-y-2 md:col-span-2">
|
||||
<Label
|
||||
htmlFor={`notes-${source.id}`}
|
||||
|
||||
@@ -8,9 +8,11 @@ import type { Receipt, StockMovement } from '@/types/inventory';
|
||||
export default function ReceiptShow({
|
||||
receipt,
|
||||
movements,
|
||||
correctedReceiptItems = {},
|
||||
}: {
|
||||
receipt: Receipt;
|
||||
movements: StockMovement[];
|
||||
correctedReceiptItems?: Record<number, string>;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
@@ -59,6 +61,15 @@ export default function ReceiptShow({
|
||||
{line.snapshot.order_item.description} ·{' '}
|
||||
{qualityStates[line.quality_status]}
|
||||
</h3>
|
||||
{correctedReceiptItems[line.id] && (
|
||||
<p className="mt-2 font-medium">
|
||||
Linha estornada integralmente por{' '}
|
||||
{correctedReceiptItems[line.id]}. As
|
||||
quantidades abaixo preservam o documento
|
||||
original; consulte a situação efectiva
|
||||
da ordem.
|
||||
</p>
|
||||
)}
|
||||
<p className="mt-2">
|
||||
Recebido: {quantity(line.received_milli)} ·
|
||||
Aceite: {quantity(line.accepted_milli)} ·
|
||||
|
||||
Reference in New Issue
Block a user