feat(types,medusa): add inventory quantity to products endpoint (#7541)

what:

- when inventory_quantity is requested through the API, we calculate the inventory based on sales channels + stock locations and return the total available inventory.

A variant can have multiple inventory items. As an example:

Table: (variant)
  - 4 (required_quantity via link) x legs (inventory item)
  - 2 x table top

Only if all individual inventory items of a variant are available, do we mark the variant as available as a single unit. 

RESOLVES CORE-2187
This commit is contained in:
Riqwan Thamir
2024-05-30 13:20:06 +00:00
committed by GitHub
parent 4e20588522
commit 15e9787465
8 changed files with 409 additions and 5 deletions
@@ -88,6 +88,7 @@ export type InventoryItemDTO = {
created_at: string | Date
updated_at: string | Date
deleted_at: string | Date | null
location_levels?: InventoryLevelDTO[]
}
/**
@@ -195,6 +196,7 @@ export type InventoryLevelDTO = {
location_id: string
stocked_quantity: number
reserved_quantity: number
available_quantity: number
incoming_quantity: number
metadata: Record<string, unknown> | null
created_at: string | Date