diff --git a/src/entity/pharmacy/item_master.ts b/src/entity/pharmacy/item_master.ts index 5bbe252..6f3ff57 100644 --- a/src/entity/pharmacy/item_master.ts +++ b/src/entity/pharmacy/item_master.ts @@ -58,13 +58,9 @@ export class ItemMaster { factory!: Factory; @ManyToOne(() => Unit, { nullable: false }) - @JoinColumn({ name: "large_unit_id" }) - large_unit!: Unit; - - @ManyToOne(() => Unit, { nullable: false }) - @JoinColumn({ name: "small_unit_id" }) - small_unit!: Unit; - + @JoinColumn({ name: "unit_id" }) + unit!: Unit; + @Column({ type: "int", nullable: true, diff --git a/src/entity/pharmacy/item_price.ts b/src/entity/pharmacy/item_price.ts new file mode 100644 index 0000000..861ab20 --- /dev/null +++ b/src/entity/pharmacy/item_price.ts @@ -0,0 +1,49 @@ +import { + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + UpdateDateColumn, + DeleteDateColumn, + OneToOne, + JoinColumn, +} from "typeorm"; + +import { ItemMaster } from "./item_master"; + +@Entity("pharmacy_item_price", { schema: "pharmacy" }) +export class ItemPrice { + @PrimaryGeneratedColumn("uuid") + id!: string; + + @OneToOne(() => ItemMaster, { nullable: false }) + @JoinColumn({ name: "item_master_id" }) + item_master!: ItemMaster; + + @Column({ type: "numeric", precision: 15, scale: 2, nullable: false }) + purchase_price!: number; + + @Column({ type: "numeric", precision: 15, scale: 2, nullable: false }) + selling_price!: number; + + @Column({ type: "date", nullable: true }) + expired_date?: Date; + + @CreateDateColumn() + created_at!: Date; + + @Column({ nullable: true, length: 256 }) + created_by?: string; + + @UpdateDateColumn({ nullable: true }) + updated_at?: Date; + + @Column({ nullable: true, length: 256 }) + updated_by?: string; + + @DeleteDateColumn({ nullable: true }) + deleted_at?: Date; + + @Column({ nullable: true, length: 256 }) + deleted_by?: string; +} \ No newline at end of file diff --git a/src/entity/pharmacy/pharmacy_info.ts b/src/entity/pharmacy/pharmacy_info.ts new file mode 100644 index 0000000..8f551c5 --- /dev/null +++ b/src/entity/pharmacy/pharmacy_info.ts @@ -0,0 +1,71 @@ +import { + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + UpdateDateColumn, + DeleteDateColumn, + ManyToOne, + JoinColumn, +} from "typeorm"; +import { Room } from "../room"; +import { Munisipo } from "../munisipo"; +import { Administrativu } from "../administrativu"; +import { Suco } from "../suco"; +import { Aldeia } from "../aldeia"; + +@Entity("pharmacy_info", { schema: "pharmacy" }) +export class PharmacyInfo { + @PrimaryGeneratedColumn("uuid") + id!: string; + + @Column({ type: "text", nullable: true }) + logo?: string; // store file path / url + + @Column({ type: "text", nullable: false }) + name!: string; + + @Column({ type: "text", nullable: false }) + address!: string; + + @ManyToOne(() => Munisipo, { nullable: true }) + @JoinColumn({ name: "munisipiu_id" }) + munisipiu?: Munisipo; + + @ManyToOne(() => Administrativu, { nullable: true }) + @JoinColumn({ name: "postu_admin_id" }) + postu_admin?: Administrativu; + + @ManyToOne(() => Suco, { nullable: true }) + @JoinColumn({ name: "suco_id" }) + suco?: Suco; + + @ManyToOne(() => Aldeia, { nullable: true }) + @JoinColumn({ name: "aldeia_id" }) + aldeia?: Aldeia; + + @Column({ type: "text", nullable: true }) + phone?: string; + + @ManyToOne(() => Room, { nullable: true }) + @JoinColumn({ name: "default_room_id" }) + default_room?: Room; + + @CreateDateColumn() + created_at!: Date; + + @Column({ nullable: true, length: 256 }) + created_by?: string; + + @UpdateDateColumn({ nullable: true }) + updated_at?: Date; + + @Column({ nullable: true, length: 256 }) + updated_by?: string; + + @DeleteDateColumn({ nullable: true }) + deleted_at?: Date; + + @Column({ nullable: true, length: 256 }) + deleted_by?: string; +} \ No newline at end of file diff --git a/src/entity/pharmacy/selling_price_percentage.ts b/src/entity/pharmacy/selling_price_percentage.ts new file mode 100644 index 0000000..4327829 --- /dev/null +++ b/src/entity/pharmacy/selling_price_percentage.ts @@ -0,0 +1,49 @@ +import { + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + UpdateDateColumn, + DeleteDateColumn, + ManyToOne, + JoinColumn, +} from "typeorm"; + +import { ItemMaster } from "./item_master"; +import { ItemOrigin } from "./item_origin"; + +@Entity("pharmacy_selling_price_percentage", { schema: "pharmacy" }) +export class SellingPricePercentage { + @PrimaryGeneratedColumn("uuid") + id!: string; + + @ManyToOne(() => ItemMaster, { nullable: false }) + @JoinColumn({ name: "item_master_id" }) + item_master!: ItemMaster; + + @ManyToOne(() => ItemOrigin, { nullable: false }) + @JoinColumn({ name: "item_origin_id" }) + item_origin!: ItemOrigin; + + @Column({ type: "numeric", precision: 5, scale: 2, nullable: false }) + percentage!: number; + // example: 15.50 (%) + + @CreateDateColumn() + created_at!: Date; + + @Column({ nullable: true, length: 256 }) + created_by?: string; + + @UpdateDateColumn({ nullable: true }) + updated_at?: Date; + + @Column({ nullable: true, length: 256 }) + updated_by?: string; + + @DeleteDateColumn({ nullable: true }) + deleted_at?: Date; + + @Column({ nullable: true, length: 256 }) + deleted_by?: string; +} \ No newline at end of file diff --git a/src/schema/pharmacy.ts b/src/schema/pharmacy.ts index 7db89c0..930983e 100644 --- a/src/schema/pharmacy.ts +++ b/src/schema/pharmacy.ts @@ -13,4 +13,7 @@ export * from "../entity/pharmacy/generic_name"; export * from "../entity/pharmacy/factory"; export * from "../entity/pharmacy/supplier"; export * from "../entity/pharmacy/factory_to_supplier"; -export * from "../entity/pharmacy/item_master"; \ No newline at end of file +export * from "../entity/pharmacy/item_master"; +export * from "../entity/pharmacy/pharmacy_info"; +export * from "../entity/pharmacy/item_price"; +export * from "../entity/pharmacy/selling_price_percentage";