fix(core-flows, dashboard, types): improve allocation flows on Admin (#12572)
**What** - handle single inventory items with `required_quantity > 1` correctly in the allocate UI flow - display correct availability amount in the create fulullment form for inventory kit items - fix check in the create fulfillment flow that would allow negative reservation because `required_quantity` wasn't included in the check - show the most recent reservations first in the reservations table - display an error in the allocation form if a reservation is not created for some inventory items - display inventory kit in the order summary if the product has multiple same inventory items --- CLOSES SUP-1655
This commit is contained in:
@@ -306,13 +306,6 @@ function prepareInventoryUpdate({
|
||||
const inputQuantity = inputItemsMap[item.id]?.quantity ?? item.quantity
|
||||
|
||||
reservations.forEach((reservation) => {
|
||||
if (MathBN.gt(inputQuantity, reservation.quantity)) {
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.INVALID_DATA,
|
||||
`Quantity to fulfill exceeds the reserved quantity for the item: ${item.id}`
|
||||
)
|
||||
}
|
||||
|
||||
const iItem = orderItem?.variant?.inventory_items.find(
|
||||
(ii) => ii.inventory.id === reservation.inventory_item_id
|
||||
)
|
||||
@@ -327,6 +320,13 @@ function prepareInventoryUpdate({
|
||||
adjustemntQuantity
|
||||
)
|
||||
|
||||
if (MathBN.lt(remainingReservationQuantity, 0)) {
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.INVALID_DATA,
|
||||
`Quantity to fulfill exceeds the reserved quantity for the item: ${item.id}`
|
||||
)
|
||||
}
|
||||
|
||||
inventoryAdjustment.push({
|
||||
inventory_item_id: reservation.inventory_item_id,
|
||||
location_id: input.location_id ?? reservation.location_id,
|
||||
|
||||
Reference in New Issue
Block a user