diff --git a/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx b/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx index ffa1fdbb2af..4b4a1e5b04e 100644 --- a/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx +++ b/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx @@ -25,6 +25,7 @@ import { renderCollection } from "@saleor/misc"; import { FulfillOrder_orderFulfill_errors } from "@saleor/orders/types/FulfillOrder"; import { OrderFulfillData_order, + OrderFulfillData_order_allocation, OrderFulfillData_order_lines } from "@saleor/orders/types/OrderFulfillData"; import { @@ -257,7 +258,7 @@ const OrderFulfillPage: React.FC = props => { {renderCollection( order?.lines.filter(line => getRemainingQuantity(line) > 0), - (line, lineIndex) => { + (line: OrderFulfillData_order_lines, lineIndex) => { if (!line) { return ( @@ -340,6 +341,18 @@ const OrderFulfillPage: React.FC = props => { ); } + const allocation: OrderFulfillData_order_allocation = line.allocations.find( + allocation => + allocation.warehouse.id === warehouse.id + ); + + const availableQuantity = allocation + ? warehouseStock.quantity - + allocation.quantity + + line.quantity + : warehouseStock.quantity - + warehouseStock.quantityAllocated; + return ( = props => { ), max: ( line.variant.trackInventory && - warehouseStock.quantity + availableQuantity ).toString(), min: 0, style: { textAlign: "right" } @@ -384,7 +397,7 @@ const OrderFulfillPage: React.FC = props => { overfulfill || (line.variant.trackInventory && formsetStock.quantity > - warehouseStock.quantityAllocated) || + availableQuantity) || !!errors?.find( err => err.warehouse === warehouse.id && @@ -399,7 +412,7 @@ const OrderFulfillPage: React.FC = props => {
- / {warehouseStock.quantityAllocated} + / {availableQuantity}
) }} @@ -407,6 +420,7 @@ const OrderFulfillPage: React.FC = props => {
); })} + - / 2 + / 758