feat(medusa, inventory): Inventory Management module (#2956)
* feat: inventory module
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
export * from "./reservation-item"
|
||||
export * from "./inventory-item"
|
||||
export * from "./inventory-level"
|
||||
@@ -0,0 +1,44 @@
|
||||
import { Index, BeforeInsert, Column, Entity } from "typeorm"
|
||||
import { SoftDeletableEntity, generateEntityId } from "@medusajs/medusa"
|
||||
|
||||
@Entity()
|
||||
export class InventoryItem extends SoftDeletableEntity {
|
||||
@Index({ unique: true })
|
||||
@Column({ type: "text", nullable: true })
|
||||
sku: string | null
|
||||
|
||||
@Column({ type: "text", nullable: true })
|
||||
origin_country: string | null
|
||||
|
||||
@Column({ type: "text", nullable: true })
|
||||
hs_code: string | null
|
||||
|
||||
@Column({ type: "text", nullable: true })
|
||||
mid_code: string | null
|
||||
|
||||
@Column({ type: "text", nullable: true })
|
||||
material: string | null
|
||||
|
||||
@Column({ type: "int", nullable: true })
|
||||
weight: number | null
|
||||
|
||||
@Column({ type: "int", nullable: true })
|
||||
length: number | null
|
||||
|
||||
@Column({ type: "int", nullable: true })
|
||||
height: number | null
|
||||
|
||||
@Column({ type: "int", nullable: true })
|
||||
width: number | null
|
||||
|
||||
@Column({ default: true })
|
||||
requires_shipping: boolean
|
||||
|
||||
@Column({ type: "jsonb", nullable: true })
|
||||
metadata: Record<string, unknown> | null
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "iitem")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { Index, Unique, BeforeInsert, Column, Entity } from "typeorm"
|
||||
import { SoftDeletableEntity, generateEntityId } from "@medusajs/medusa"
|
||||
|
||||
@Entity()
|
||||
@Index(["inventory_item_id", "location_id"], { unique: true })
|
||||
export class InventoryLevel extends SoftDeletableEntity {
|
||||
@Index()
|
||||
@Column({ type: "text" })
|
||||
inventory_item_id: string
|
||||
|
||||
@Index()
|
||||
@Column({ type: "text" })
|
||||
location_id: string
|
||||
|
||||
@Column({ default: 0 })
|
||||
stocked_quantity: number
|
||||
|
||||
@Column({ default: 0 })
|
||||
reserved_quantity: number
|
||||
|
||||
@Column({ default: 0 })
|
||||
incoming_quantity: number
|
||||
|
||||
@Column({ type: "jsonb", nullable: true })
|
||||
metadata: Record<string, unknown> | null
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "ilev")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { Index, Unique, BeforeInsert, Column, Entity } from "typeorm"
|
||||
import { SoftDeletableEntity, generateEntityId } from "@medusajs/medusa"
|
||||
|
||||
@Entity()
|
||||
export class ReservationItem extends SoftDeletableEntity {
|
||||
@Index()
|
||||
@Column({ type: "text", nullable: true })
|
||||
line_item_id: string | null
|
||||
|
||||
@Index()
|
||||
@Column({ type: "text" })
|
||||
inventory_item_id: string
|
||||
|
||||
@Index()
|
||||
@Column({ type: "text" })
|
||||
location_id: string
|
||||
|
||||
@Column()
|
||||
quantity: number
|
||||
|
||||
@Column({ type: "jsonb", nullable: true })
|
||||
metadata: Record<string, unknown> | null
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "resitem")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user