diff --git a/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx b/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx index ffa1fdbb2..eb882f046 100644 --- a/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx +++ b/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx @@ -257,7 +257,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 +340,17 @@ const OrderFulfillPage: React.FC = props => { ); } + const warehouseAllocation = line.allocations.find( + allocation => + allocation.warehouse.id === warehouse.id + ); + const allocatedQuantityForLine = + warehouseAllocation?.quantity || 0; + const availableQuantity = + warehouseStock.quantity - + warehouseStock.quantityAllocated + + allocatedQuantityForLine; + return ( = props => { ), max: ( line.variant.trackInventory && - warehouseStock.quantity + availableQuantity ).toString(), min: 0, style: { textAlign: "right" } @@ -384,7 +395,7 @@ const OrderFulfillPage: React.FC = props => { overfulfill || (line.variant.trackInventory && formsetStock.quantity > - warehouseStock.quantityAllocated) || + availableQuantity) || !!errors?.find( err => err.warehouse === warehouse.id && @@ -399,7 +410,7 @@ const OrderFulfillPage: React.FC = props => {
- / {warehouseStock.quantityAllocated} + / {availableQuantity}
) }} @@ -407,6 +418,7 @@ const OrderFulfillPage: React.FC = props => {
); })} + - / 2 + / 758