feat(medusa, inventory): Inventory Management module (#2956)

* feat: inventory module
This commit is contained in:
Carlos R. L. Rodrigues
2023-01-10 14:38:30 -03:00
committed by GitHub
parent a2df11fc10
commit 93ee248493
22 changed files with 1735 additions and 14 deletions
+3
View File
@@ -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")
}
}