diff --git a/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx b/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx index fe3977e45..a0c30050d 100644 --- a/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx +++ b/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx @@ -232,7 +232,7 @@ const OrderFulfillPage: React.FC = ({ lineIndex ].value.reduce( (quantityToFulfill, lineInput) => - quantityToFulfill + lineInput.quantity, + quantityToFulfill + (lineInput.quantity || 0), 0 ); const overfulfill = remainingQuantity < quantityToFulfill; @@ -281,6 +281,10 @@ const OrderFulfillPage: React.FC = ({ ); } + const availableQuantity = + warehouseStock.quantity - + warehouseStock.quantityAllocated; + return (
@@ -312,12 +316,11 @@ const OrderFulfillPage: React.FC = ({ } error={ overfulfill || - formsetStock.quantity > - warehouseStock.quantity + formsetStock.quantity > availableQuantity } />
- / {warehouseStock.quantity} + / {availableQuantity}
diff --git a/src/orders/components/OrderFulfillPage/fixtures.ts b/src/orders/components/OrderFulfillPage/fixtures.ts index 1e72213aa..fdb2857bc 100644 --- a/src/orders/components/OrderFulfillPage/fixtures.ts +++ b/src/orders/components/OrderFulfillPage/fixtures.ts @@ -37,25 +37,29 @@ export const orderToFulfill: OrderFulfillData_order = { __typename: "Stock", id: "U3RvY2s6NTIy", warehouse: warehouseList[0], - quantity: 1217 + quantity: 1217, + quantityAllocated: 10 }, { __typename: "Stock", id: "U3RvY2s6NTIx", warehouse: warehouseList[1], - quantity: 1217 + quantity: 1217, + quantityAllocated: 20 }, { __typename: "Stock", id: "U3RvY2s6NTIz", warehouse: warehouseList[2], - quantity: 1217 + quantity: 1217, + quantityAllocated: 4 }, { __typename: "Stock", id: "U3RvY2s6NTI0", warehouse: warehouseList[3], - quantity: 1220 + quantity: 1220, + quantityAllocated: 7 } ] }, @@ -93,19 +97,22 @@ export const orderToFulfill: OrderFulfillData_order = { __typename: "Stock", id: "U3RvY2s6NTI=", warehouse: warehouseList[1], - quantity: 760 + quantity: 760, + quantityAllocated: 2 }, { __typename: "Stock", id: "U3RvY2s6NTE=", warehouse: warehouseList[2], - quantity: 760 + quantity: 760, + quantityAllocated: 33 }, { __typename: "Stock", id: "U3RvY2s6NTM=", warehouse: warehouseList[3], - quantity: 760 + quantity: 760, + quantityAllocated: 4 } ] }, @@ -143,13 +150,15 @@ export const orderToFulfill: OrderFulfillData_order = { __typename: "Stock", id: "U3RvY2s6NTc=", warehouse: warehouseList[0], - quantity: 587 + quantity: 587, + quantityAllocated: 0 }, { __typename: "Stock", id: "U3RvY2s6NTY=", warehouse: warehouseList[2], - quantity: 587 + quantity: 587, + quantityAllocated: 1 } ] }, diff --git a/src/orders/queries.ts b/src/orders/queries.ts index 4089d9ded..8ecb5ff8d 100644 --- a/src/orders/queries.ts +++ b/src/orders/queries.ts @@ -365,6 +365,7 @@ const orderFulfillData = gql` id } quantity + quantityAllocated } } thumbnail(size: 64) { diff --git a/src/orders/types/OrderFulfillData.ts b/src/orders/types/OrderFulfillData.ts index b9fbf9bf4..1bc8412b8 100644 --- a/src/orders/types/OrderFulfillData.ts +++ b/src/orders/types/OrderFulfillData.ts @@ -27,6 +27,7 @@ export interface OrderFulfillData_order_lines_variant_stocks { id: string; warehouse: OrderFulfillData_order_lines_variant_stocks_warehouse; quantity: number; + quantityAllocated: number; } export interface OrderFulfillData_order_lines_variant { diff --git a/src/storybook/__snapshots__/Stories.test.ts.snap b/src/storybook/__snapshots__/Stories.test.ts.snap index 8377e828e..5f068e403 100644 --- a/src/storybook/__snapshots__/Stories.test.ts.snap +++ b/src/storybook/__snapshots__/Stories.test.ts.snap @@ -64486,7 +64486,7 @@ exports[`Storyshots Views / Orders / Fulfill order default 1`] = `
- / 1217 + / 1207
@@ -64530,7 +64530,7 @@ exports[`Storyshots Views / Orders / Fulfill order default 1`] = `
- / 1217 + / 1197
@@ -64574,7 +64574,7 @@ exports[`Storyshots Views / Orders / Fulfill order default 1`] = `
- / 1217 + / 1213
@@ -64618,7 +64618,7 @@ exports[`Storyshots Views / Orders / Fulfill order default 1`] = `
- / 1220 + / 1213
@@ -64712,7 +64712,7 @@ exports[`Storyshots Views / Orders / Fulfill order default 1`] = `
- / 760 + / 758
@@ -64756,7 +64756,7 @@ exports[`Storyshots Views / Orders / Fulfill order default 1`] = `
- / 760 + / 727
@@ -64800,7 +64800,7 @@ exports[`Storyshots Views / Orders / Fulfill order default 1`] = `
- / 760 + / 756
@@ -64889,7 +64889,7 @@ exports[`Storyshots Views / Orders / Fulfill order default 1`] = `
- / 587 + / 586