import { Column, Entity, JoinColumn, ManyToOne, OneToMany, PrimaryGeneratedColumn, Unique, } from "typeorm"; import { jsonTransformer } from "../transformers/jsonTransformer"; import { Master } from "./Master"; // import { ServiceDiscountsPlan } from "./ServiceDiscountsPlan"; @Entity("service_plan") @Unique(["code"]) export class ServicePlan { @PrimaryGeneratedColumn({ name: "id_service_plan" }) id_service_plan: number; @Column({ type: "varchar", length: 100 }) name: string; @Column({ type: "varchar", length: 100 }) code: string; @Column({ type: "varchar", length: 450, nullable: true }) description: string | null; @Column({ type: "float", nullable: true }) price: number | null; @Column({ type: "varchar", length: 10, nullable: true }) currency: string | null; @Column({ type: "int", default: 1 }) status: number; @Column({ type: "int" }) type: number; @Column({ type: "text", nullable: true }) time_periods: any | null; @Column({ type: "float", nullable: true }) assigned_discount: number | null; @Column({ type: "longtext", nullable: true, transformer: jsonTransformer }) information_general: any | null; @Column({ type: "datetime", default: () => "CURRENT_TIMESTAMP", comment: "Fecha de creación del registro.", }) created: Date; @Column({ type: "datetime", nullable: true, default: null, onUpdate: "CURRENT_TIMESTAMP", comment: "Fecha de actualización del registro.", }) updated: Date | null; @ManyToOne(() => Master, (master) => master.id, { onDelete: "SET NULL", onUpdate: "CASCADE", nullable: true, }) @JoinColumn({ name: "updated_by" }) updated_by: Master | null; // @OneToMany( // () => ServiceDiscountsPlan, // (serviceDiscountsPlan) => serviceDiscountsPlan.servicePlan, // ) // service_discounts_plan: ServiceDiscountsPlan[]; }