feat(medusa): Stock location module (#2907)

* feat: stock location module
This commit is contained in:
Carlos R. L. Rodrigues
2023-01-04 13:11:59 -03:00
committed by GitHub
parent cc10c20f35
commit c07ffb6165
50 changed files with 2040 additions and 198 deletions
@@ -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")
}
}