diff --git a/src/entity/procurement/procurement_work_order_copies.ts b/src/entity/procurement/procurement_work_order_copies.ts new file mode 100644 index 0000000..424f8c3 --- /dev/null +++ b/src/entity/procurement/procurement_work_order_copies.ts @@ -0,0 +1,51 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, ManyToOne, JoinColumn } from "typeorm"; +import { ProcurementWorkOrder } from "./procurement_work_orders"; + +@Entity("procurement_work_order_copies", { schema: "procurement" }) +export class ProcurementWorkOrderCopy { + @PrimaryGeneratedColumn("uuid") + id: string; + + // ========================= + // REFERENCE + // ========================= + + @ManyToOne(() => ProcurementWorkOrder, (wo) => wo.copies, { onDelete: "CASCADE", nullable: false }) + @JoinColumn() + work_order: ProcurementWorkOrder; + + // ========================= + // COPY INFORMATION + // ========================= + + @Column({ length: 32 }) + label: string; // COPIA 1, COPIA 2, COPIA 3 + + @Column({ length: 256 }) + recipient: string; // Exe. Presidente do C.A. da ANATL, E.P. + + @Column({ type: "int" }) + order: number; // 1, 2, 3 - untuk urutan display + + // ========================= + // AUDIT + // ========================= + + @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; +} diff --git a/src/entity/procurement/procurement_work_orders.ts b/src/entity/procurement/procurement_work_orders.ts new file mode 100644 index 0000000..c75b577 --- /dev/null +++ b/src/entity/procurement/procurement_work_orders.ts @@ -0,0 +1,106 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, ManyToOne, JoinColumn, OneToMany } from "typeorm"; +import { ProcurementTender } from "./procurement_tender"; +import { ProcurementWorkOrderStatus } from "../../types/procurement"; +import { ProcurementWorkOrderCopy } from "./procurement_work_order_copies"; + +@Entity("procurement_work_orders", { schema: "procurement" }) +export class ProcurementWorkOrder { + @PrimaryGeneratedColumn("uuid") + id: string; + + // ========================= + // REFERENCE + // ========================= + + @ManyToOne(() => ProcurementTender, { onDelete: "NO ACTION", nullable: false }) + @JoinColumn() + tender: ProcurementTender; + + @Column({ length: 64 }) + reference_number: string; // 142/ANATL,E.P./U-APROV./VII/2025 + + // ========================= + // RECIPIENT INFORMATION + // ========================= + + @Column({ length: 256 }) + recipient_name: string; // SR. JUSCELINO DE JESUS PEREIRA + + @Column({ type: "text" }) + subject: string; // ORDEM DO SERVISU MANUTENSAUN EDIFISIU... + + // ========================= + // CONTENT + // ========================= + + @Column({ type: "text" }) + content: string; // Full work order content/body + + // ========================= + // SIGNATURE + // ========================= + + @Column({ length: 256, nullable: true }) + signer_name: string; // ENG. JOSÉ ANTÓNÍO SANCHES + + @Column({ length: 256, nullable: true }) + signer_position: string; // DIRECTOR U-APROVISIONAMENTO ANATL, E.P. + + @Column({ type: "date", nullable: true }) + signed_date: Date; + + // ========================= + // STATUS & METADATA + // ========================= + + @Column({ length: 32, default: "draft" }) + status: ProcurementWorkOrderStatus; // draft, issued, completed, cancelled + + @Column({ type: "date", nullable: true }) + issue_date: Date; // When the work order was officially issued + + @Column({ type: "date", nullable: true }) + start_date: Date; // Expected start date of work + + @Column({ type: "date", nullable: true }) + completion_date: Date; // Expected completion date + + // ========================= + // DOCUMENT + // ========================= + + @Column({ length: 256, nullable: true }) + document_file_url: string; // URL to generated PDF + + @Column({ type: "date", nullable: true }) + document_generated_at: Date; + + // ========================= + // COPIES + // ========================= + + @OneToMany(() => ProcurementWorkOrderCopy, (copy) => copy.work_order, { cascade: true }) + copies: ProcurementWorkOrderCopy[]; + + // ========================= + // AUDIT + // ========================= + + @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; +} diff --git a/src/schema/procurement.ts b/src/schema/procurement.ts index 7347adc..3d61c0a 100644 --- a/src/schema/procurement.ts +++ b/src/schema/procurement.ts @@ -9,5 +9,7 @@ export * from "../entity/procurement/procurement_checklist_payment_approval"; export * from "../entity/procurement/procurement_purchase_order"; export * from "../entity/procurement/procurement_purchase_order_item"; export * from "../entity/procurement/procurement_payment_request"; +export * from "../entity/procurement/procurement_work_orders"; +export * from "../entity/procurement/procurement_work_order_copies"; export * from "../types/procurement"; diff --git a/src/types/procurement.ts b/src/types/procurement.ts index ef75323..16c163a 100644 --- a/src/types/procurement.ts +++ b/src/types/procurement.ts @@ -75,4 +75,16 @@ export enum ProcurementPRCStatus { APPROVED = "APPROVED", REJECTED = "REJECTED", RECEIVED = "RECEIVED", -} \ No newline at end of file +} + +// File: src/types/procurement.ts + +export enum ProcurementWorkOrderStatus { + DRAFT = "DRAFT", + PENDING_APPROVAL = "PENDING_APPROVAL", + APPROVED = "APPROVED", + ISSUED = "ISSUED", + IN_PROGRESS = "IN_PROGRESS", + COMPLETED = "COMPLETED", + CANCELLED = "CANCELLED", +}