import { Column, Entity, JoinColumn, ManyToOne, OneToMany, PrimaryGeneratedColumn, } from "typeorm"; import { CategoryDate, Partner, RequestInvoiceCategory, ScheduleCategory, } from ".."; import { jsonTransformer } from "../transformers/jsonTransformer"; import { Local } from "./Local"; import { Product } from "./Product"; @Entity({ comment: "Lista de categorías que tiene un local en su menú: promos, de la semana, completo...\r\n\r\nEsas categorías será visibles a nivel app como un menu horizontal donde cada categoría tendrá sus productos.", }) export class Category { @PrimaryGeneratedColumn({ type: "int", comment: "Número de identificación (ID) único de cada registro.", }) id: number; @ManyToOne(() => Local, (local) => local.categories, { onDelete: "CASCADE", onUpdate: "NO ACTION", }) @JoinColumn({ name: "local" }) local: Local; @Column({ length: 30, type: "varchar", comment: "Nombre de la categoría." }) name: string; @Column({ type: "int", comment: "¿En qué posición se va a mostrar esta categoría?", }) position: number; @Column({ nullable: true, type: "int", width: 1, comment: "Campo para saber el tipo de horario que se va a mostrar en la aplicación:\n 1. Días. \n2. Fecha específica.", default: null, }) type_sales_hours: number | null; @Column({ nullable: true, type: "int", width: 1, comment: "Columna para saber el tipo de horario qué el usuario quiere para el elemento: \n1. Mostrar (Show). \n2. Ocultar (Hide)", default: null, }) show_or_hide_item: number | null; @ManyToOne(() => Partner, (partner) => partner.partners_category_created_by, { onDelete: "RESTRICT", onUpdate: "NO ACTION", }) @JoinColumn({ name: "created_by" }) created_by: Partner; @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(() => Partner, (partner) => partner.partners_category_update_by, { onDelete: "RESTRICT", onUpdate: "NO ACTION", nullable: true, }) @JoinColumn({ name: "updated_by" }) updated_by: Partner | null; @Column({ type: "mediumtext", nullable: true, default: null, transformer: jsonTransformer, comment: "Valores qué se van a mostrar mientras se aprueban los nuevos cambios.", }) current_values: any | null; @Column({ default: 1, type: "int", width: 1, comment: "Estado en el que está el elemento: \n0. Inactivo. \n1. Activo. \n2. Eliminado.", }) status: number; @Column({ default: 1, type: "int", width: 1, comment: "Estado en el que se encuentra la revisión de los cambios: \n1. En revisión. \n2. Rechazado.", }) status_review: number; @Column({ nullable: true, default: null, type: "varchar", length: 600, comment: "Comentario del revisor al rechazar una categoría (master).", }) review_comment: string | null; @OneToMany(() => Product, (product) => product.category) products: Product[]; @OneToMany( () => ScheduleCategory, (scheduleCategory) => scheduleCategory.category, ) category_schedules: ScheduleCategory[]; @OneToMany(() => CategoryDate, (categoryDate) => categoryDate.category) category_dates: CategoryDate[]; @OneToMany( () => RequestInvoiceCategory, (requestInvoiceCategory) => requestInvoiceCategory.category, ) request_invoice_categories: RequestInvoiceCategory[]; }