From 5025efd6950d93fe38f8e72ae423289919270c0f Mon Sep 17 00:00:00 2001 From: Rayhan Ardiansyah Date: Mon, 2 Mar 2026 10:51:16 +0700 Subject: [PATCH 1/5] update entity phar item master --- src/entity/pharmacy/item_master.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) 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, From 62ebe4a7859caf3b4cc652188900aa2d324efe4b Mon Sep 17 00:00:00 2001 From: Rayhan Ardiansyah Date: Mon, 2 Mar 2026 11:29:06 +0700 Subject: [PATCH 2/5] add addt entity pharmacy --- src/entity/pharmacy/item_price.ts | 49 +++++++++++++++ src/entity/pharmacy/pharmacy_info.ts | 60 +++++++++++++++++++ .../pharmacy/selling_price_percentage.ts | 49 +++++++++++++++ 3 files changed, 158 insertions(+) create mode 100644 src/entity/pharmacy/item_price.ts create mode 100644 src/entity/pharmacy/pharmacy_info.ts create mode 100644 src/entity/pharmacy/selling_price_percentage.ts 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..3264024 --- /dev/null +++ b/src/entity/pharmacy/pharmacy_info.ts @@ -0,0 +1,60 @@ +import { + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + UpdateDateColumn, + DeleteDateColumn, +} from "typeorm"; + +@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; + + @Column({ type: "text", nullable: true }) + munisipiu?: string; + + @Column({ type: "text", nullable: true }) + postu_admin?: string; + + @Column({ type: "text", nullable: true }) + suco?: string; + + @Column({ type: "text", nullable: true }) + aldeia?: string; + + @Column({ type: "text", nullable: true }) + phone?: string; + + @Column({ type: "uuid", nullable: true }) + default_room_id?: string; + // FK ke room (where department = 'pharmacy') + + @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 From 7fb545392103e0f13050e512445651ed380f015a Mon Sep 17 00:00:00 2001 From: Rayhan Ardiansyah Date: Mon, 2 Mar 2026 11:35:12 +0700 Subject: [PATCH 3/5] update pharmacy --- src/schema/pharmacy.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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"; From c767a53e8af733c866cb6c3d9ef6fc6c2158fcc8 Mon Sep 17 00:00:00 2001 From: Rayhan Ardiansyah Date: Mon, 2 Mar 2026 11:46:04 +0700 Subject: [PATCH 4/5] update pharmacy info --- src/entity/pharmacy/pharmacy_info.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/entity/pharmacy/pharmacy_info.ts b/src/entity/pharmacy/pharmacy_info.ts index 3264024..5116b2b 100644 --- a/src/entity/pharmacy/pharmacy_info.ts +++ b/src/entity/pharmacy/pharmacy_info.ts @@ -5,7 +5,10 @@ import { CreateDateColumn, UpdateDateColumn, DeleteDateColumn, + ManyToOne, + JoinColumn, } from "typeorm"; +import { Room } from "../room"; @Entity("pharmacy_info", { schema: "pharmacy" }) export class PharmacyInfo { @@ -36,9 +39,9 @@ export class PharmacyInfo { @Column({ type: "text", nullable: true }) phone?: string; - @Column({ type: "uuid", nullable: true }) - default_room_id?: string; - // FK ke room (where department = 'pharmacy') + @ManyToOne(() => Room, { nullable: true }) + @JoinColumn({ name: "default_room_id" }) + default_room?: Room; @CreateDateColumn() created_at!: Date; From 5a4bb5a76d1d45ee81d16f7adb7562cf2b25f5a5 Mon Sep 17 00:00:00 2001 From: Rayhan Ardiansyah Date: Mon, 2 Mar 2026 11:59:35 +0700 Subject: [PATCH 5/5] update pharmacy info --- src/entity/pharmacy/pharmacy_info.ts | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/entity/pharmacy/pharmacy_info.ts b/src/entity/pharmacy/pharmacy_info.ts index 5116b2b..8f551c5 100644 --- a/src/entity/pharmacy/pharmacy_info.ts +++ b/src/entity/pharmacy/pharmacy_info.ts @@ -9,6 +9,10 @@ import { 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 { @@ -24,17 +28,21 @@ export class PharmacyInfo { @Column({ type: "text", nullable: false }) address!: string; - @Column({ type: "text", nullable: true }) - munisipiu?: string; + @ManyToOne(() => Munisipo, { nullable: true }) + @JoinColumn({ name: "munisipiu_id" }) + munisipiu?: Munisipo; - @Column({ type: "text", nullable: true }) - postu_admin?: string; + @ManyToOne(() => Administrativu, { nullable: true }) + @JoinColumn({ name: "postu_admin_id" }) + postu_admin?: Administrativu; - @Column({ type: "text", nullable: true }) - suco?: string; + @ManyToOne(() => Suco, { nullable: true }) + @JoinColumn({ name: "suco_id" }) + suco?: Suco; - @Column({ type: "text", nullable: true }) - aldeia?: string; + @ManyToOne(() => Aldeia, { nullable: true }) + @JoinColumn({ name: "aldeia_id" }) + aldeia?: Aldeia; @Column({ type: "text", nullable: true }) phone?: string;