import { Column, Entity, Index, JoinColumn, ManyToOne, OneToMany, PrimaryGeneratedColumn, } from "typeorm"; import { Transaction } from "./Transaction"; import { Product } from "./Product"; import { Promocode } from "./Promocode"; import { UserTariffPlan } from "./UserTariffPlan"; @Index("IX_user_subscription_currency_id", ["currencyId"], {}) @Index("PK_user_subscription", ["id"], { unique: true }) @Index("IX_user_subscription_product_id", ["productId"], {}) @Index("IX_user_subscription_promocode_id", ["promocodeId"], {}) @Index("IX_user_subscription_user_id", ["userId"], {}) @Index("uq_user_subscription_usid", ["usid"], { unique: true }) @Entity("user_subscription", { schema: "core" }) export class UserSubscription { @PrimaryGeneratedColumn({ type: "integer", name: "id" }) id: number; @Column("timestamp without time zone", { name: "created_date" }) createdDate: Date; @Column("integer", { name: "created_by" }) createdBy: number; @Column("timestamp without time zone", { name: "modified_date" }) modifiedDate: Date; @Column("integer", { name: "modified_by" }) modifiedBy: number; @Column("smallint", { name: "state" }) state: number; @Column("timestamp without time zone", { name: "start_date" }) startDate: Date; @Column("timestamp without time zone", { name: "end_date" }) endDate: Date; @Column("integer", { name: "user_id" }) userId: number; @Column("integer", { name: "product_id" }) productId: number; @Column("integer", { name: "promocode_id", nullable: true }) promocodeId: number | null; @Column("boolean", { name: "is_trial_period", default: () => "false" }) isTrialPeriod: boolean; @Column("boolean", { name: "is_auto_renew_status", default: () => "false" }) isAutoRenewStatus: boolean; @Column("integer", { name: "currency_id", nullable: true }) currencyId: number | null; @Column("numeric", { name: "intro_price", precision: 16, scale: 4, default: () => "0.0", }) introPrice: string; @Column("numeric", { name: "main_price", precision: 16, scale: 4, default: () => "0.0", }) mainPrice: string; @Column("boolean", { name: "is_grace_period", default: () => "false" }) isGracePeriod: boolean; @Column("timestamp without time zone", { name: "grace_period_date_end", nullable: true, }) gracePeriodDateEnd: Date | null; @Column("character varying", { name: "usid", nullable: true, length: 128 }) usid: string | null; @Column("boolean", { name: "is_intro_period", default: () => "false" }) isIntroPeriod: boolean; @Column("boolean", { name: "is_family_shared", default: () => "false" }) isFamilyShared: boolean; @Column("character varying", { name: "rebill_id", nullable: true, length: 128, }) rebillId: string | null; @OneToMany(() => Transaction, (transaction) => transaction.userSubscription) transactions: Transaction[]; @ManyToOne(() => Product, (product) => product.userSubscriptions, { onDelete: "RESTRICT", }) @JoinColumn([{ name: "product_id", referencedColumnName: "id" }]) product: Product; @ManyToOne(() => Promocode, (promocode) => promocode.userSubscriptions, { onDelete: "RESTRICT", }) @JoinColumn([{ name: "promocode_id", referencedColumnName: "id" }]) promocode: Promocode; @OneToMany( () => UserTariffPlan, (userTariffPlan) => userTariffPlan.shareSubscription ) userTariffPlans: UserTariffPlan[]; @OneToMany( () => UserTariffPlan, (userTariffPlan) => userTariffPlan.userSubscription ) userTariffPlans2: UserTariffPlan[]; }