chore(core-flows,inventory,types,medusa): add fixes to inventory module + location levels api (#7629)

what:

- santizes inputs to prevent reserved_quantity from being updated directly
- inventory items create api can create location levels
- add validation to update quantity of reservation items
- general cleanup

RESOLVES CORE-2254
This commit is contained in:
Riqwan Thamir
2024-06-06 14:58:17 +02:00
committed by GitHub
parent 3fbb8aa671
commit 0507dbe027
13 changed files with 366 additions and 93 deletions

View File

@@ -351,18 +351,33 @@ medusaIntegrationTestRunner({
},
])
const inventoryItem = await inventoryModule.create({
sku: "inv-1234",
})
const inventoryItem = (
await api.post(
`/admin/inventory-items`,
{
sku: "inv-1234",
location_levels: [
{
location_id: location.id,
stocked_quantity: 2,
},
],
},
adminHeaders
)
).data.inventory_item
await inventoryModule.createInventoryLevels([
await api.post(
`/admin/reservations`,
{
line_item_id: "line-item-id-1",
inventory_item_id: inventoryItem.id,
location_id: location.id,
stocked_quantity: 2,
reserved_quantity: 2,
description: "test description",
quantity: 2,
},
])
adminHeaders
)
const region = await regionModuleService.create({
name: "US",