feat(medusa): Stock location module (#2907)
* feat: stock location module
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
export * from "./stock-location"
|
||||
export * from "./stock-location-address"
|
||||
@@ -0,0 +1,35 @@
|
||||
import { BeforeInsert, Column, Entity, Index } from "typeorm"
|
||||
import { SoftDeletableEntity, generateEntityId } from "@medusajs/medusa"
|
||||
|
||||
@Entity()
|
||||
export class StockLocationAddress extends SoftDeletableEntity {
|
||||
@Column({ type: "text" })
|
||||
address_1: string
|
||||
|
||||
@Column({ type: "text", nullable: true })
|
||||
address_2: string | null
|
||||
|
||||
@Column({ type: "text", nullable: true })
|
||||
city: string | null
|
||||
|
||||
@Index()
|
||||
@Column({ type: "text" })
|
||||
country_code: string
|
||||
|
||||
@Column({ type: "text", nullable: true })
|
||||
phone: string | null
|
||||
|
||||
@Column({ type: "text", nullable: true })
|
||||
province: string | null
|
||||
|
||||
@Column({ type: "text", nullable: true })
|
||||
postal_code: string | null
|
||||
|
||||
@Column({ type: "jsonb", nullable: true })
|
||||
metadata: Record<string, unknown> | null
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "laddr")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import {
|
||||
BeforeInsert,
|
||||
Column,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
} from "typeorm"
|
||||
import { SoftDeletableEntity, generateEntityId } from "@medusajs/medusa"
|
||||
|
||||
import { StockLocationAddress } from "."
|
||||
|
||||
@Entity()
|
||||
export class StockLocation extends SoftDeletableEntity {
|
||||
@Column({ type: "text" })
|
||||
name: string
|
||||
|
||||
@Index()
|
||||
@Column({ type: "text" })
|
||||
address_id: string
|
||||
|
||||
@ManyToOne(() => StockLocationAddress)
|
||||
@JoinColumn({ name: "address_id" })
|
||||
address: StockLocationAddress | null
|
||||
|
||||
@Column({ type: "jsonb", nullable: true })
|
||||
metadata: Record<string, unknown> | null
|
||||
|
||||
@BeforeInsert()
|
||||
private beforeInsert(): void {
|
||||
this.id = generateEntityId(this.id, "sloc")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user