diff --git a/CHANGELOG.md b/CHANGELOG.md index 82e2bea2a..6315fb66e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ All notable, unreleased changes to this project will be documented in this file. - Fix isPublished and isAvailable behaviour for products, collections and pages - #780 by @mmarkusik - Add metadata editor to page views - #782 by @dominik-zeglen - Add missing infinite scroll to searches - #793 by @dominik-zeglen +- Fix for fulfilling order when allocated quantity equals total quantity - #788 by @GrzegorzDerdak ## 2.10.1 diff --git a/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx b/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx index e8e157f5b..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,9 +340,16 @@ 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; + warehouseStock.quantityAllocated + + allocatedQuantityForLine; return ( = props => { ), max: ( line.variant.trackInventory && - warehouseStock.quantity + availableQuantity ).toString(), min: 0, style: { textAlign: "right" } @@ -411,6 +418,7 @@ const OrderFulfillPage: React.FC = props => { ); })} +