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